babylon.module.d.ts 5.3 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198
  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 current color in rgb space to HSV values
  466. * @returns a new color3 representing the HSV values
  467. */
  468. toHSV(): Color3;
  469. /**
  470. * Converts current color in rgb space to HSV values
  471. * @param result defines the Color3 where to store the HSV values
  472. */
  473. toHSVToRef(result: Color3): void;
  474. /**
  475. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  476. * @param convertedColor defines the Color3 object where to store the linear space version
  477. * @returns the unmodified Color3
  478. */
  479. toLinearSpaceToRef(convertedColor: Color3): Color3;
  480. /**
  481. * Computes a new Color3 converted from the current one to gamma space
  482. * @returns a new Color3 object
  483. */
  484. toGammaSpace(): Color3;
  485. /**
  486. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  487. * @param convertedColor defines the Color3 object where to store the gamma space version
  488. * @returns the unmodified Color3
  489. */
  490. toGammaSpaceToRef(convertedColor: Color3): Color3;
  491. private static _BlackReadOnly;
  492. /**
  493. * Convert Hue, saturation and value to a Color3 (RGB)
  494. * @param hue defines the hue
  495. * @param saturation defines the saturation
  496. * @param value defines the value
  497. * @param result defines the Color3 where to store the RGB values
  498. */
  499. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  500. /**
  501. * Creates a new Color3 from the string containing valid hexadecimal values
  502. * @param hex defines a string containing valid hexadecimal values
  503. * @returns a new Color3 object
  504. */
  505. static FromHexString(hex: string): Color3;
  506. /**
  507. * Creates a new Color3 from the starting index of the given array
  508. * @param array defines the source array
  509. * @param offset defines an offset in the source array
  510. * @returns a new Color3 object
  511. */
  512. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  513. /**
  514. * Creates a new Color3 from integer values (< 256)
  515. * @param r defines the red component to read from (value between 0 and 255)
  516. * @param g defines the green component to read from (value between 0 and 255)
  517. * @param b defines the blue component to read from (value between 0 and 255)
  518. * @returns a new Color3 object
  519. */
  520. static FromInts(r: number, g: number, b: number): Color3;
  521. /**
  522. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  523. * @param start defines the start Color3 value
  524. * @param end defines the end Color3 value
  525. * @param amount defines the gradient value between start and end
  526. * @returns a new Color3 object
  527. */
  528. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  529. /**
  530. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  531. * @param left defines the start value
  532. * @param right defines the end value
  533. * @param amount defines the gradient factor
  534. * @param result defines the Color3 object where to store the result
  535. */
  536. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  537. /**
  538. * Returns a Color3 value containing a red color
  539. * @returns a new Color3 object
  540. */
  541. static Red(): Color3;
  542. /**
  543. * Returns a Color3 value containing a green color
  544. * @returns a new Color3 object
  545. */
  546. static Green(): Color3;
  547. /**
  548. * Returns a Color3 value containing a blue color
  549. * @returns a new Color3 object
  550. */
  551. static Blue(): Color3;
  552. /**
  553. * Returns a Color3 value containing a black color
  554. * @returns a new Color3 object
  555. */
  556. static Black(): Color3;
  557. /**
  558. * Gets a Color3 value containing a black color that must not be updated
  559. */
  560. static readonly BlackReadOnly: DeepImmutable<Color3>;
  561. /**
  562. * Returns a Color3 value containing a white color
  563. * @returns a new Color3 object
  564. */
  565. static White(): Color3;
  566. /**
  567. * Returns a Color3 value containing a purple color
  568. * @returns a new Color3 object
  569. */
  570. static Purple(): Color3;
  571. /**
  572. * Returns a Color3 value containing a magenta color
  573. * @returns a new Color3 object
  574. */
  575. static Magenta(): Color3;
  576. /**
  577. * Returns a Color3 value containing a yellow color
  578. * @returns a new Color3 object
  579. */
  580. static Yellow(): Color3;
  581. /**
  582. * Returns a Color3 value containing a gray color
  583. * @returns a new Color3 object
  584. */
  585. static Gray(): Color3;
  586. /**
  587. * Returns a Color3 value containing a teal color
  588. * @returns a new Color3 object
  589. */
  590. static Teal(): Color3;
  591. /**
  592. * Returns a Color3 value containing a random color
  593. * @returns a new Color3 object
  594. */
  595. static Random(): Color3;
  596. }
  597. /**
  598. * Class used to hold a RBGA color
  599. */
  600. export class Color4 {
  601. /**
  602. * Defines the red component (between 0 and 1, default is 0)
  603. */
  604. r: number;
  605. /**
  606. * Defines the green component (between 0 and 1, default is 0)
  607. */
  608. g: number;
  609. /**
  610. * Defines the blue component (between 0 and 1, default is 0)
  611. */
  612. b: number;
  613. /**
  614. * Defines the alpha component (between 0 and 1, default is 1)
  615. */
  616. a: number;
  617. /**
  618. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  619. * @param r defines the red component (between 0 and 1, default is 0)
  620. * @param g defines the green component (between 0 and 1, default is 0)
  621. * @param b defines the blue component (between 0 and 1, default is 0)
  622. * @param a defines the alpha component (between 0 and 1, default is 1)
  623. */
  624. constructor(
  625. /**
  626. * Defines the red component (between 0 and 1, default is 0)
  627. */
  628. r?: number,
  629. /**
  630. * Defines the green component (between 0 and 1, default is 0)
  631. */
  632. g?: number,
  633. /**
  634. * Defines the blue component (between 0 and 1, default is 0)
  635. */
  636. b?: number,
  637. /**
  638. * Defines the alpha component (between 0 and 1, default is 1)
  639. */
  640. a?: number);
  641. /**
  642. * Adds in place the given Color4 values to the current Color4 object
  643. * @param right defines the second operand
  644. * @returns the current updated Color4 object
  645. */
  646. addInPlace(right: DeepImmutable<Color4>): Color4;
  647. /**
  648. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  649. * @returns the new array
  650. */
  651. asArray(): number[];
  652. /**
  653. * Stores from the starting index in the given array the Color4 successive values
  654. * @param array defines the array where to store the r,g,b components
  655. * @param index defines an optional index in the target array to define where to start storing values
  656. * @returns the current Color4 object
  657. */
  658. toArray(array: number[], index?: number): Color4;
  659. /**
  660. * Determines equality between Color4 objects
  661. * @param otherColor defines the second operand
  662. * @returns true if the rgba values are equal to the given ones
  663. */
  664. equals(otherColor: DeepImmutable<Color4>): boolean;
  665. /**
  666. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  667. * @param right defines the second operand
  668. * @returns a new Color4 object
  669. */
  670. add(right: DeepImmutable<Color4>): Color4;
  671. /**
  672. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  673. * @param right defines the second operand
  674. * @returns a new Color4 object
  675. */
  676. subtract(right: DeepImmutable<Color4>): Color4;
  677. /**
  678. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  679. * @param right defines the second operand
  680. * @param result defines the Color4 object where to store the result
  681. * @returns the current Color4 object
  682. */
  683. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  684. /**
  685. * Creates a new Color4 with the current Color4 values multiplied by scale
  686. * @param scale defines the scaling factor to apply
  687. * @returns a new Color4 object
  688. */
  689. scale(scale: number): Color4;
  690. /**
  691. * Multiplies the current Color4 values by scale and stores the result in "result"
  692. * @param scale defines the scaling factor to apply
  693. * @param result defines the Color4 object where to store the result
  694. * @returns the current unmodified Color4
  695. */
  696. scaleToRef(scale: number, result: Color4): Color4;
  697. /**
  698. * Scale the current Color4 values by a factor and add the result to a given Color4
  699. * @param scale defines the scale factor
  700. * @param result defines the Color4 object where to store the result
  701. * @returns the unmodified current Color4
  702. */
  703. scaleAndAddToRef(scale: number, result: Color4): Color4;
  704. /**
  705. * Clamps the rgb values by the min and max values and stores the result into "result"
  706. * @param min defines minimum clamping value (default is 0)
  707. * @param max defines maximum clamping value (default is 1)
  708. * @param result defines color to store the result into.
  709. * @returns the cuurent Color4
  710. */
  711. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  712. /**
  713. * Multipy an Color4 value by another and return a new Color4 object
  714. * @param color defines the Color4 value to multiply by
  715. * @returns a new Color4 object
  716. */
  717. multiply(color: Color4): Color4;
  718. /**
  719. * Multipy a Color4 value by another and push the result in a reference value
  720. * @param color defines the Color4 value to multiply by
  721. * @param result defines the Color4 to fill the result in
  722. * @returns the result Color4
  723. */
  724. multiplyToRef(color: Color4, result: Color4): Color4;
  725. /**
  726. * Creates a string with the Color4 current values
  727. * @returns the string representation of the Color4 object
  728. */
  729. toString(): string;
  730. /**
  731. * Returns the string "Color4"
  732. * @returns "Color4"
  733. */
  734. getClassName(): string;
  735. /**
  736. * Compute the Color4 hash code
  737. * @returns an unique number that can be used to hash Color4 objects
  738. */
  739. getHashCode(): number;
  740. /**
  741. * Creates a new Color4 copied from the current one
  742. * @returns a new Color4 object
  743. */
  744. clone(): Color4;
  745. /**
  746. * Copies the given Color4 values into the current one
  747. * @param source defines the source Color4 object
  748. * @returns the current updated Color4 object
  749. */
  750. copyFrom(source: Color4): Color4;
  751. /**
  752. * Copies the given float values into the current one
  753. * @param r defines the red component to read from
  754. * @param g defines the green component to read from
  755. * @param b defines the blue component to read from
  756. * @param a defines the alpha component to read from
  757. * @returns the current updated Color4 object
  758. */
  759. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  760. /**
  761. * Copies the given float values into the current one
  762. * @param r defines the red component to read from
  763. * @param g defines the green component to read from
  764. * @param b defines the blue component to read from
  765. * @param a defines the alpha component to read from
  766. * @returns the current updated Color4 object
  767. */
  768. set(r: number, g: number, b: number, a: number): Color4;
  769. /**
  770. * Compute the Color4 hexadecimal code as a string
  771. * @returns a string containing the hexadecimal representation of the Color4 object
  772. */
  773. toHexString(): string;
  774. /**
  775. * Computes a new Color4 converted from the current one to linear space
  776. * @returns a new Color4 object
  777. */
  778. toLinearSpace(): Color4;
  779. /**
  780. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  781. * @param convertedColor defines the Color4 object where to store the linear space version
  782. * @returns the unmodified Color4
  783. */
  784. toLinearSpaceToRef(convertedColor: Color4): Color4;
  785. /**
  786. * Computes a new Color4 converted from the current one to gamma space
  787. * @returns a new Color4 object
  788. */
  789. toGammaSpace(): Color4;
  790. /**
  791. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  792. * @param convertedColor defines the Color4 object where to store the gamma space version
  793. * @returns the unmodified Color4
  794. */
  795. toGammaSpaceToRef(convertedColor: Color4): Color4;
  796. /**
  797. * Creates a new Color4 from the string containing valid hexadecimal values
  798. * @param hex defines a string containing valid hexadecimal values
  799. * @returns a new Color4 object
  800. */
  801. static FromHexString(hex: string): Color4;
  802. /**
  803. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  804. * @param left defines the start value
  805. * @param right defines the end value
  806. * @param amount defines the gradient factor
  807. * @returns a new Color4 object
  808. */
  809. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  810. /**
  811. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  812. * @param left defines the start value
  813. * @param right defines the end value
  814. * @param amount defines the gradient factor
  815. * @param result defines the Color4 object where to store data
  816. */
  817. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  818. /**
  819. * Creates a new Color4 from a Color3 and an alpha value
  820. * @param color3 defines the source Color3 to read from
  821. * @param alpha defines the alpha component (1.0 by default)
  822. * @returns a new Color4 object
  823. */
  824. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  825. /**
  826. * Creates a new Color4 from the starting index element of the given array
  827. * @param array defines the source array to read from
  828. * @param offset defines the offset in the source array
  829. * @returns a new Color4 object
  830. */
  831. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  832. /**
  833. * Creates a new Color3 from integer values (< 256)
  834. * @param r defines the red component to read from (value between 0 and 255)
  835. * @param g defines the green component to read from (value between 0 and 255)
  836. * @param b defines the blue component to read from (value between 0 and 255)
  837. * @param a defines the alpha component to read from (value between 0 and 255)
  838. * @returns a new Color3 object
  839. */
  840. static FromInts(r: number, g: number, b: number, a: number): Color4;
  841. /**
  842. * Check the content of a given array and convert it to an array containing RGBA data
  843. * If the original array was already containing count * 4 values then it is returned directly
  844. * @param colors defines the array to check
  845. * @param count defines the number of RGBA data to expect
  846. * @returns an array containing count * 4 values (RGBA)
  847. */
  848. static CheckColors4(colors: number[], count: number): number[];
  849. }
  850. /**
  851. * Class representing a vector containing 2 coordinates
  852. */
  853. export class Vector2 {
  854. /** defines the first coordinate */
  855. x: number;
  856. /** defines the second coordinate */
  857. y: number;
  858. /**
  859. * Creates a new Vector2 from the given x and y coordinates
  860. * @param x defines the first coordinate
  861. * @param y defines the second coordinate
  862. */
  863. constructor(
  864. /** defines the first coordinate */
  865. x?: number,
  866. /** defines the second coordinate */
  867. y?: number);
  868. /**
  869. * Gets a string with the Vector2 coordinates
  870. * @returns a string with the Vector2 coordinates
  871. */
  872. toString(): string;
  873. /**
  874. * Gets class name
  875. * @returns the string "Vector2"
  876. */
  877. getClassName(): string;
  878. /**
  879. * Gets current vector hash code
  880. * @returns the Vector2 hash code as a number
  881. */
  882. getHashCode(): number;
  883. /**
  884. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  885. * @param array defines the source array
  886. * @param index defines the offset in source array
  887. * @returns the current Vector2
  888. */
  889. toArray(array: FloatArray, index?: number): Vector2;
  890. /**
  891. * Copy the current vector to an array
  892. * @returns a new array with 2 elements: the Vector2 coordinates.
  893. */
  894. asArray(): number[];
  895. /**
  896. * Sets the Vector2 coordinates with the given Vector2 coordinates
  897. * @param source defines the source Vector2
  898. * @returns the current updated Vector2
  899. */
  900. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  901. /**
  902. * Sets the Vector2 coordinates with the given floats
  903. * @param x defines the first coordinate
  904. * @param y defines the second coordinate
  905. * @returns the current updated Vector2
  906. */
  907. copyFromFloats(x: number, y: number): Vector2;
  908. /**
  909. * Sets the Vector2 coordinates with the given floats
  910. * @param x defines the first coordinate
  911. * @param y defines the second coordinate
  912. * @returns the current updated Vector2
  913. */
  914. set(x: number, y: number): Vector2;
  915. /**
  916. * Add another vector with the current one
  917. * @param otherVector defines the other vector
  918. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  919. */
  920. add(otherVector: DeepImmutable<Vector2>): Vector2;
  921. /**
  922. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  923. * @param otherVector defines the other vector
  924. * @param result defines the target vector
  925. * @returns the unmodified current Vector2
  926. */
  927. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  928. /**
  929. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  930. * @param otherVector defines the other vector
  931. * @returns the current updated Vector2
  932. */
  933. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  934. /**
  935. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  936. * @param otherVector defines the other vector
  937. * @returns a new Vector2
  938. */
  939. addVector3(otherVector: Vector3): Vector2;
  940. /**
  941. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  942. * @param otherVector defines the other vector
  943. * @returns a new Vector2
  944. */
  945. subtract(otherVector: Vector2): Vector2;
  946. /**
  947. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  948. * @param otherVector defines the other vector
  949. * @param result defines the target vector
  950. * @returns the unmodified current Vector2
  951. */
  952. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  953. /**
  954. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  955. * @param otherVector defines the other vector
  956. * @returns the current updated Vector2
  957. */
  958. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  959. /**
  960. * Multiplies in place the current Vector2 coordinates by the given ones
  961. * @param otherVector defines the other vector
  962. * @returns the current updated Vector2
  963. */
  964. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  965. /**
  966. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  967. * @param otherVector defines the other vector
  968. * @returns a new Vector2
  969. */
  970. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  971. /**
  972. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  973. * @param otherVector defines the other vector
  974. * @param result defines the target vector
  975. * @returns the unmodified current Vector2
  976. */
  977. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  978. /**
  979. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  980. * @param x defines the first coordinate
  981. * @param y defines the second coordinate
  982. * @returns a new Vector2
  983. */
  984. multiplyByFloats(x: number, y: number): Vector2;
  985. /**
  986. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  987. * @param otherVector defines the other vector
  988. * @returns a new Vector2
  989. */
  990. divide(otherVector: Vector2): Vector2;
  991. /**
  992. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  993. * @param otherVector defines the other vector
  994. * @param result defines the target vector
  995. * @returns the unmodified current Vector2
  996. */
  997. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  998. /**
  999. * Divides the current Vector2 coordinates by the given ones
  1000. * @param otherVector defines the other vector
  1001. * @returns the current updated Vector2
  1002. */
  1003. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1004. /**
  1005. * Gets a new Vector2 with current Vector2 negated coordinates
  1006. * @returns a new Vector2
  1007. */
  1008. negate(): Vector2;
  1009. /**
  1010. * Multiply the Vector2 coordinates by scale
  1011. * @param scale defines the scaling factor
  1012. * @returns the current updated Vector2
  1013. */
  1014. scaleInPlace(scale: number): Vector2;
  1015. /**
  1016. * Returns a new Vector2 scaled by "scale" from the current Vector2
  1017. * @param scale defines the scaling factor
  1018. * @returns a new Vector2
  1019. */
  1020. scale(scale: number): Vector2;
  1021. /**
  1022. * Scale the current Vector2 values by a factor to a given Vector2
  1023. * @param scale defines the scale factor
  1024. * @param result defines the Vector2 object where to store the result
  1025. * @returns the unmodified current Vector2
  1026. */
  1027. scaleToRef(scale: number, result: Vector2): Vector2;
  1028. /**
  1029. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1030. * @param scale defines the scale factor
  1031. * @param result defines the Vector2 object where to store the result
  1032. * @returns the unmodified current Vector2
  1033. */
  1034. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1035. /**
  1036. * Gets a boolean if two vectors are equals
  1037. * @param otherVector defines the other vector
  1038. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1039. */
  1040. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1041. /**
  1042. * Gets a boolean if two vectors are equals (using an epsilon value)
  1043. * @param otherVector defines the other vector
  1044. * @param epsilon defines the minimal distance to consider equality
  1045. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1046. */
  1047. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1048. /**
  1049. * Gets a new Vector2 from current Vector2 floored values
  1050. * @returns a new Vector2
  1051. */
  1052. floor(): Vector2;
  1053. /**
  1054. * Gets a new Vector2 from current Vector2 floored values
  1055. * @returns a new Vector2
  1056. */
  1057. fract(): Vector2;
  1058. /**
  1059. * Gets the length of the vector
  1060. * @returns the vector length (float)
  1061. */
  1062. length(): number;
  1063. /**
  1064. * Gets the vector squared length
  1065. * @returns the vector squared length (float)
  1066. */
  1067. lengthSquared(): number;
  1068. /**
  1069. * Normalize the vector
  1070. * @returns the current updated Vector2
  1071. */
  1072. normalize(): Vector2;
  1073. /**
  1074. * Gets a new Vector2 copied from the Vector2
  1075. * @returns a new Vector2
  1076. */
  1077. clone(): Vector2;
  1078. /**
  1079. * Gets a new Vector2(0, 0)
  1080. * @returns a new Vector2
  1081. */
  1082. static Zero(): Vector2;
  1083. /**
  1084. * Gets a new Vector2(1, 1)
  1085. * @returns a new Vector2
  1086. */
  1087. static One(): Vector2;
  1088. /**
  1089. * Gets a new Vector2 set from the given index element of the given array
  1090. * @param array defines the data source
  1091. * @param offset defines the offset in the data source
  1092. * @returns a new Vector2
  1093. */
  1094. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1095. /**
  1096. * Sets "result" from the given index element of the given array
  1097. * @param array defines the data source
  1098. * @param offset defines the offset in the data source
  1099. * @param result defines the target vector
  1100. */
  1101. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1102. /**
  1103. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1104. * @param value1 defines 1st point of control
  1105. * @param value2 defines 2nd point of control
  1106. * @param value3 defines 3rd point of control
  1107. * @param value4 defines 4th point of control
  1108. * @param amount defines the interpolation factor
  1109. * @returns a new Vector2
  1110. */
  1111. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1112. /**
  1113. * 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".
  1114. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1115. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1116. * @param value defines the value to clamp
  1117. * @param min defines the lower limit
  1118. * @param max defines the upper limit
  1119. * @returns a new Vector2
  1120. */
  1121. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1122. /**
  1123. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1124. * @param value1 defines the 1st control point
  1125. * @param tangent1 defines the outgoing tangent
  1126. * @param value2 defines the 2nd control point
  1127. * @param tangent2 defines the incoming tangent
  1128. * @param amount defines the interpolation factor
  1129. * @returns a new Vector2
  1130. */
  1131. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1132. /**
  1133. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1134. * @param start defines the start vector
  1135. * @param end defines the end vector
  1136. * @param amount defines the interpolation factor
  1137. * @returns a new Vector2
  1138. */
  1139. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1140. /**
  1141. * Gets the dot product of the vector "left" and the vector "right"
  1142. * @param left defines first vector
  1143. * @param right defines second vector
  1144. * @returns the dot product (float)
  1145. */
  1146. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1147. /**
  1148. * Returns a new Vector2 equal to the normalized given vector
  1149. * @param vector defines the vector to normalize
  1150. * @returns a new Vector2
  1151. */
  1152. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1153. /**
  1154. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1155. * @param left defines 1st vector
  1156. * @param right defines 2nd vector
  1157. * @returns a new Vector2
  1158. */
  1159. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1160. /**
  1161. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1162. * @param left defines 1st vector
  1163. * @param right defines 2nd vector
  1164. * @returns a new Vector2
  1165. */
  1166. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1167. /**
  1168. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1169. * @param vector defines the vector to transform
  1170. * @param transformation defines the matrix to apply
  1171. * @returns a new Vector2
  1172. */
  1173. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1174. /**
  1175. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1176. * @param vector defines the vector to transform
  1177. * @param transformation defines the matrix to apply
  1178. * @param result defines the target vector
  1179. */
  1180. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1181. /**
  1182. * Determines if a given vector is included in a triangle
  1183. * @param p defines the vector to test
  1184. * @param p0 defines 1st triangle point
  1185. * @param p1 defines 2nd triangle point
  1186. * @param p2 defines 3rd triangle point
  1187. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1188. */
  1189. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1190. /**
  1191. * Gets the distance between the vectors "value1" and "value2"
  1192. * @param value1 defines first vector
  1193. * @param value2 defines second vector
  1194. * @returns the distance between vectors
  1195. */
  1196. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1197. /**
  1198. * Returns the squared distance between the vectors "value1" and "value2"
  1199. * @param value1 defines first vector
  1200. * @param value2 defines second vector
  1201. * @returns the squared distance between vectors
  1202. */
  1203. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1204. /**
  1205. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1206. * @param value1 defines first vector
  1207. * @param value2 defines second vector
  1208. * @returns a new Vector2
  1209. */
  1210. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1211. /**
  1212. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1213. * @param p defines the middle point
  1214. * @param segA defines one point of the segment
  1215. * @param segB defines the other point of the segment
  1216. * @returns the shortest distance
  1217. */
  1218. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1219. }
  1220. /**
  1221. * Classed used to store (x,y,z) vector representation
  1222. * A Vector3 is the main object used in 3D geometry
  1223. * It can represent etiher the coordinates of a point the space, either a direction
  1224. * Reminder: js uses a left handed forward facing system
  1225. */
  1226. export class Vector3 {
  1227. /**
  1228. * Defines the first coordinates (on X axis)
  1229. */
  1230. x: number;
  1231. /**
  1232. * Defines the second coordinates (on Y axis)
  1233. */
  1234. y: number;
  1235. /**
  1236. * Defines the third coordinates (on Z axis)
  1237. */
  1238. z: number;
  1239. private static _UpReadOnly;
  1240. private static _ZeroReadOnly;
  1241. /**
  1242. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1243. * @param x defines the first coordinates (on X axis)
  1244. * @param y defines the second coordinates (on Y axis)
  1245. * @param z defines the third coordinates (on Z axis)
  1246. */
  1247. constructor(
  1248. /**
  1249. * Defines the first coordinates (on X axis)
  1250. */
  1251. x?: number,
  1252. /**
  1253. * Defines the second coordinates (on Y axis)
  1254. */
  1255. y?: number,
  1256. /**
  1257. * Defines the third coordinates (on Z axis)
  1258. */
  1259. z?: number);
  1260. /**
  1261. * Creates a string representation of the Vector3
  1262. * @returns a string with the Vector3 coordinates.
  1263. */
  1264. toString(): string;
  1265. /**
  1266. * Gets the class name
  1267. * @returns the string "Vector3"
  1268. */
  1269. getClassName(): string;
  1270. /**
  1271. * Creates the Vector3 hash code
  1272. * @returns a number which tends to be unique between Vector3 instances
  1273. */
  1274. getHashCode(): number;
  1275. /**
  1276. * Creates an array containing three elements : the coordinates of the Vector3
  1277. * @returns a new array of numbers
  1278. */
  1279. asArray(): number[];
  1280. /**
  1281. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1282. * @param array defines the destination array
  1283. * @param index defines the offset in the destination array
  1284. * @returns the current Vector3
  1285. */
  1286. toArray(array: FloatArray, index?: number): Vector3;
  1287. /**
  1288. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1289. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1290. */
  1291. toQuaternion(): Quaternion;
  1292. /**
  1293. * Adds the given vector to the current Vector3
  1294. * @param otherVector defines the second operand
  1295. * @returns the current updated Vector3
  1296. */
  1297. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1298. /**
  1299. * Adds the given coordinates to the current Vector3
  1300. * @param x defines the x coordinate of the operand
  1301. * @param y defines the y coordinate of the operand
  1302. * @param z defines the z coordinate of the operand
  1303. * @returns the current updated Vector3
  1304. */
  1305. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1306. /**
  1307. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1308. * @param otherVector defines the second operand
  1309. * @returns the resulting Vector3
  1310. */
  1311. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1312. /**
  1313. * Adds the current Vector3 to the given one 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. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1319. /**
  1320. * Subtract the given vector from the current Vector3
  1321. * @param otherVector defines the second operand
  1322. * @returns the current updated Vector3
  1323. */
  1324. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1325. /**
  1326. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1327. * @param otherVector defines the second operand
  1328. * @returns the resulting Vector3
  1329. */
  1330. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1331. /**
  1332. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1333. * @param otherVector defines the second operand
  1334. * @param result defines the Vector3 object where to store the result
  1335. * @returns the current Vector3
  1336. */
  1337. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1338. /**
  1339. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1340. * @param x defines the x coordinate of the operand
  1341. * @param y defines the y coordinate of the operand
  1342. * @param z defines the z coordinate of the operand
  1343. * @returns the resulting Vector3
  1344. */
  1345. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1346. /**
  1347. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1348. * @param x defines the x coordinate of the operand
  1349. * @param y defines the y coordinate of the operand
  1350. * @param z defines the z coordinate of the operand
  1351. * @param result defines the Vector3 object where to store the result
  1352. * @returns the current Vector3
  1353. */
  1354. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1355. /**
  1356. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1357. * @returns a new Vector3
  1358. */
  1359. negate(): Vector3;
  1360. /**
  1361. * Multiplies the Vector3 coordinates by the float "scale"
  1362. * @param scale defines the multiplier factor
  1363. * @returns the current updated Vector3
  1364. */
  1365. scaleInPlace(scale: number): Vector3;
  1366. /**
  1367. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1368. * @param scale defines the multiplier factor
  1369. * @returns a new Vector3
  1370. */
  1371. scale(scale: number): Vector3;
  1372. /**
  1373. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1374. * @param scale defines the multiplier factor
  1375. * @param result defines the Vector3 object where to store the result
  1376. * @returns the current Vector3
  1377. */
  1378. scaleToRef(scale: number, result: Vector3): Vector3;
  1379. /**
  1380. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1381. * @param scale defines the scale factor
  1382. * @param result defines the Vector3 object where to store the result
  1383. * @returns the unmodified current Vector3
  1384. */
  1385. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1386. /**
  1387. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1388. * @param otherVector defines the second operand
  1389. * @returns true if both vectors are equals
  1390. */
  1391. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1392. /**
  1393. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1394. * @param otherVector defines the second operand
  1395. * @param epsilon defines the minimal distance to define values as equals
  1396. * @returns true if both vectors are distant less than epsilon
  1397. */
  1398. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1399. /**
  1400. * Returns true if the current Vector3 coordinates equals the given floats
  1401. * @param x defines the x coordinate of the operand
  1402. * @param y defines the y coordinate of the operand
  1403. * @param z defines the z coordinate of the operand
  1404. * @returns true if both vectors are equals
  1405. */
  1406. equalsToFloats(x: number, y: number, z: number): boolean;
  1407. /**
  1408. * Multiplies the current Vector3 coordinates by the given ones
  1409. * @param otherVector defines the second operand
  1410. * @returns the current updated Vector3
  1411. */
  1412. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1413. /**
  1414. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1415. * @param otherVector defines the second operand
  1416. * @returns the new Vector3
  1417. */
  1418. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1419. /**
  1420. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1421. * @param otherVector defines the second operand
  1422. * @param result defines the Vector3 object where to store the result
  1423. * @returns the current Vector3
  1424. */
  1425. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1426. /**
  1427. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1428. * @param x defines the x coordinate of the operand
  1429. * @param y defines the y coordinate of the operand
  1430. * @param z defines the z coordinate of the operand
  1431. * @returns the new Vector3
  1432. */
  1433. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1434. /**
  1435. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1436. * @param otherVector defines the second operand
  1437. * @returns the new Vector3
  1438. */
  1439. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1440. /**
  1441. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1442. * @param otherVector defines the second operand
  1443. * @param result defines the Vector3 object where to store the result
  1444. * @returns the current Vector3
  1445. */
  1446. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1447. /**
  1448. * Divides the current Vector3 coordinates by the given ones.
  1449. * @param otherVector defines the second operand
  1450. * @returns the current updated Vector3
  1451. */
  1452. divideInPlace(otherVector: Vector3): Vector3;
  1453. /**
  1454. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1455. * @param other defines the second operand
  1456. * @returns the current updated Vector3
  1457. */
  1458. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1459. /**
  1460. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1461. * @param other defines the second operand
  1462. * @returns the current updated Vector3
  1463. */
  1464. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1465. /**
  1466. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1467. * @param x defines the x coordinate of the operand
  1468. * @param y defines the y coordinate of the operand
  1469. * @param z defines the z coordinate of the operand
  1470. * @returns the current updated Vector3
  1471. */
  1472. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1473. /**
  1474. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1475. * @param x defines the x coordinate of the operand
  1476. * @param y defines the y coordinate of the operand
  1477. * @param z defines the z coordinate of the operand
  1478. * @returns the current updated Vector3
  1479. */
  1480. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1481. /**
  1482. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1483. * Check if is non uniform within a certain amount of decimal places to account for this
  1484. * @param epsilon the amount the values can differ
  1485. * @returns if the the vector is non uniform to a certain number of decimal places
  1486. */
  1487. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1488. /**
  1489. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1490. */
  1491. readonly isNonUniform: boolean;
  1492. /**
  1493. * Gets a new Vector3 from current Vector3 floored values
  1494. * @returns a new Vector3
  1495. */
  1496. floor(): Vector3;
  1497. /**
  1498. * Gets a new Vector3 from current Vector3 floored values
  1499. * @returns a new Vector3
  1500. */
  1501. fract(): Vector3;
  1502. /**
  1503. * Gets the length of the Vector3
  1504. * @returns the length of the Vector3
  1505. */
  1506. length(): number;
  1507. /**
  1508. * Gets the squared length of the Vector3
  1509. * @returns squared length of the Vector3
  1510. */
  1511. lengthSquared(): number;
  1512. /**
  1513. * Normalize the current Vector3.
  1514. * Please note that this is an in place operation.
  1515. * @returns the current updated Vector3
  1516. */
  1517. normalize(): Vector3;
  1518. /**
  1519. * Reorders the x y z properties of the vector in place
  1520. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1521. * @returns the current updated vector
  1522. */
  1523. reorderInPlace(order: string): this;
  1524. /**
  1525. * Rotates the vector around 0,0,0 by a quaternion
  1526. * @param quaternion the rotation quaternion
  1527. * @param result vector to store the result
  1528. * @returns the resulting vector
  1529. */
  1530. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1531. /**
  1532. * Rotates a vector around a given point
  1533. * @param quaternion the rotation quaternion
  1534. * @param point the point to rotate around
  1535. * @param result vector to store the result
  1536. * @returns the resulting vector
  1537. */
  1538. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1539. /**
  1540. * Normalize the current Vector3 with the given input length.
  1541. * Please note that this is an in place operation.
  1542. * @param len the length of the vector
  1543. * @returns the current updated Vector3
  1544. */
  1545. normalizeFromLength(len: number): Vector3;
  1546. /**
  1547. * Normalize the current Vector3 to a new vector
  1548. * @returns the new Vector3
  1549. */
  1550. normalizeToNew(): Vector3;
  1551. /**
  1552. * Normalize the current Vector3 to the reference
  1553. * @param reference define the Vector3 to update
  1554. * @returns the updated Vector3
  1555. */
  1556. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1557. /**
  1558. * Creates a new Vector3 copied from the current Vector3
  1559. * @returns the new Vector3
  1560. */
  1561. clone(): Vector3;
  1562. /**
  1563. * Copies the given vector coordinates to the current Vector3 ones
  1564. * @param source defines the source Vector3
  1565. * @returns the current updated Vector3
  1566. */
  1567. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1568. /**
  1569. * Copies the given floats to the current Vector3 coordinates
  1570. * @param x defines the x coordinate of the operand
  1571. * @param y defines the y coordinate of the operand
  1572. * @param z defines the z coordinate of the operand
  1573. * @returns the current updated Vector3
  1574. */
  1575. copyFromFloats(x: number, y: number, z: number): Vector3;
  1576. /**
  1577. * Copies the given floats to the current Vector3 coordinates
  1578. * @param x defines the x coordinate of the operand
  1579. * @param y defines the y coordinate of the operand
  1580. * @param z defines the z coordinate of the operand
  1581. * @returns the current updated Vector3
  1582. */
  1583. set(x: number, y: number, z: number): Vector3;
  1584. /**
  1585. * Copies the given float to the current Vector3 coordinates
  1586. * @param v defines the x, y and z coordinates of the operand
  1587. * @returns the current updated Vector3
  1588. */
  1589. setAll(v: number): Vector3;
  1590. /**
  1591. * Get the clip factor between two vectors
  1592. * @param vector0 defines the first operand
  1593. * @param vector1 defines the second operand
  1594. * @param axis defines the axis to use
  1595. * @param size defines the size along the axis
  1596. * @returns the clip factor
  1597. */
  1598. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1599. /**
  1600. * Get angle between two vectors
  1601. * @param vector0 angle between vector0 and vector1
  1602. * @param vector1 angle between vector0 and vector1
  1603. * @param normal direction of the normal
  1604. * @return the angle between vector0 and vector1
  1605. */
  1606. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1607. /**
  1608. * Returns a new Vector3 set from the index "offset" of the given array
  1609. * @param array defines the source array
  1610. * @param offset defines the offset in the source array
  1611. * @returns the new Vector3
  1612. */
  1613. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1614. /**
  1615. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1616. * This function is deprecated. Use FromArray instead
  1617. * @param array defines the source array
  1618. * @param offset defines the offset in the source array
  1619. * @returns the new Vector3
  1620. */
  1621. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1622. /**
  1623. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1624. * @param array defines the source array
  1625. * @param offset defines the offset in the source array
  1626. * @param result defines the Vector3 where to store the result
  1627. */
  1628. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1629. /**
  1630. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1631. * This function is deprecated. Use FromArrayToRef instead.
  1632. * @param array defines the source array
  1633. * @param offset defines the offset in the source array
  1634. * @param result defines the Vector3 where to store the result
  1635. */
  1636. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1637. /**
  1638. * Sets the given vector "result" with the given floats.
  1639. * @param x defines the x coordinate of the source
  1640. * @param y defines the y coordinate of the source
  1641. * @param z defines the z coordinate of the source
  1642. * @param result defines the Vector3 where to store the result
  1643. */
  1644. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1645. /**
  1646. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1647. * @returns a new empty Vector3
  1648. */
  1649. static Zero(): Vector3;
  1650. /**
  1651. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1652. * @returns a new unit Vector3
  1653. */
  1654. static One(): Vector3;
  1655. /**
  1656. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1657. * @returns a new up Vector3
  1658. */
  1659. static Up(): Vector3;
  1660. /**
  1661. * Gets a up Vector3 that must not be updated
  1662. */
  1663. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1664. /**
  1665. * Gets a zero Vector3 that must not be updated
  1666. */
  1667. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  1668. /**
  1669. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1670. * @returns a new down Vector3
  1671. */
  1672. static Down(): Vector3;
  1673. /**
  1674. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1675. * @returns a new forward Vector3
  1676. */
  1677. static Forward(): Vector3;
  1678. /**
  1679. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1680. * @returns a new forward Vector3
  1681. */
  1682. static Backward(): Vector3;
  1683. /**
  1684. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1685. * @returns a new right Vector3
  1686. */
  1687. static Right(): Vector3;
  1688. /**
  1689. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1690. * @returns a new left Vector3
  1691. */
  1692. static Left(): Vector3;
  1693. /**
  1694. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1695. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1696. * @param vector defines the Vector3 to transform
  1697. * @param transformation defines the transformation matrix
  1698. * @returns the transformed Vector3
  1699. */
  1700. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1701. /**
  1702. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1703. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1704. * @param vector defines the Vector3 to transform
  1705. * @param transformation defines the transformation matrix
  1706. * @param result defines the Vector3 where to store the result
  1707. */
  1708. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1709. /**
  1710. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1711. * This method computes tranformed coordinates only, not transformed direction vectors
  1712. * @param x define the x coordinate of the source vector
  1713. * @param y define the y coordinate of the source vector
  1714. * @param z define the z coordinate of the source vector
  1715. * @param transformation defines the transformation matrix
  1716. * @param result defines the Vector3 where to store the result
  1717. */
  1718. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1719. /**
  1720. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1721. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1722. * @param vector defines the Vector3 to transform
  1723. * @param transformation defines the transformation matrix
  1724. * @returns the new Vector3
  1725. */
  1726. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1727. /**
  1728. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1729. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1730. * @param vector defines the Vector3 to transform
  1731. * @param transformation defines the transformation matrix
  1732. * @param result defines the Vector3 where to store the result
  1733. */
  1734. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1735. /**
  1736. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1737. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1738. * @param x define the x coordinate of the source vector
  1739. * @param y define the y coordinate of the source vector
  1740. * @param z define the z coordinate of the source vector
  1741. * @param transformation defines the transformation matrix
  1742. * @param result defines the Vector3 where to store the result
  1743. */
  1744. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1745. /**
  1746. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1747. * @param value1 defines the first control point
  1748. * @param value2 defines the second control point
  1749. * @param value3 defines the third control point
  1750. * @param value4 defines the fourth control point
  1751. * @param amount defines the amount on the spline to use
  1752. * @returns the new Vector3
  1753. */
  1754. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1755. /**
  1756. * 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"
  1757. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1758. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1759. * @param value defines the current value
  1760. * @param min defines the lower range value
  1761. * @param max defines the upper range value
  1762. * @returns the new Vector3
  1763. */
  1764. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1765. /**
  1766. * 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"
  1767. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1768. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1769. * @param value defines the current value
  1770. * @param min defines the lower range value
  1771. * @param max defines the upper range value
  1772. * @param result defines the Vector3 where to store the result
  1773. */
  1774. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1775. /**
  1776. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1777. * @param value1 defines the first control point
  1778. * @param tangent1 defines the first tangent vector
  1779. * @param value2 defines the second control point
  1780. * @param tangent2 defines the second tangent vector
  1781. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1782. * @returns the new Vector3
  1783. */
  1784. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1785. /**
  1786. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1787. * @param start defines the start value
  1788. * @param end defines the end value
  1789. * @param amount max defines amount between both (between 0 and 1)
  1790. * @returns the new Vector3
  1791. */
  1792. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1793. /**
  1794. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1795. * @param start defines the start value
  1796. * @param end defines the end value
  1797. * @param amount max defines amount between both (between 0 and 1)
  1798. * @param result defines the Vector3 where to store the result
  1799. */
  1800. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1801. /**
  1802. * Returns the dot product (float) between the vectors "left" and "right"
  1803. * @param left defines the left operand
  1804. * @param right defines the right operand
  1805. * @returns the dot product
  1806. */
  1807. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1808. /**
  1809. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1810. * The cross product is then orthogonal to both "left" and "right"
  1811. * @param left defines the left operand
  1812. * @param right defines the right operand
  1813. * @returns the cross product
  1814. */
  1815. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1816. /**
  1817. * Sets the given vector "result" with the cross product of "left" and "right"
  1818. * The cross product is then orthogonal to both "left" and "right"
  1819. * @param left defines the left operand
  1820. * @param right defines the right operand
  1821. * @param result defines the Vector3 where to store the result
  1822. */
  1823. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1824. /**
  1825. * Returns a new Vector3 as the normalization of the given vector
  1826. * @param vector defines the Vector3 to normalize
  1827. * @returns the new Vector3
  1828. */
  1829. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1830. /**
  1831. * Sets the given vector "result" with the normalization of the given first vector
  1832. * @param vector defines the Vector3 to normalize
  1833. * @param result defines the Vector3 where to store the result
  1834. */
  1835. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1836. /**
  1837. * Project a Vector3 onto screen space
  1838. * @param vector defines the Vector3 to project
  1839. * @param world defines the world matrix to use
  1840. * @param transform defines the transform (view x projection) matrix to use
  1841. * @param viewport defines the screen viewport to use
  1842. * @returns the new Vector3
  1843. */
  1844. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1845. /** @hidden */
  1846. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1847. /**
  1848. * Unproject from screen space to object space
  1849. * @param source defines the screen space Vector3 to use
  1850. * @param viewportWidth defines the current width of the viewport
  1851. * @param viewportHeight defines the current height of the viewport
  1852. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1853. * @param transform defines the transform (view x projection) matrix to use
  1854. * @returns the new Vector3
  1855. */
  1856. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1857. /**
  1858. * Unproject from screen space to object space
  1859. * @param source defines the screen space Vector3 to use
  1860. * @param viewportWidth defines the current width of the viewport
  1861. * @param viewportHeight defines the current height of the viewport
  1862. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1863. * @param view defines the view matrix to use
  1864. * @param projection defines the projection matrix to use
  1865. * @returns the new Vector3
  1866. */
  1867. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1868. /**
  1869. * Unproject from screen space to object space
  1870. * @param source defines the screen space Vector3 to use
  1871. * @param viewportWidth defines the current width of the viewport
  1872. * @param viewportHeight defines the current height of the viewport
  1873. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1874. * @param view defines the view matrix to use
  1875. * @param projection defines the projection matrix to use
  1876. * @param result defines the Vector3 where to store the result
  1877. */
  1878. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1879. /**
  1880. * Unproject from screen space to object space
  1881. * @param sourceX defines the screen space x coordinate to use
  1882. * @param sourceY defines the screen space y coordinate to use
  1883. * @param sourceZ defines the screen space z coordinate to use
  1884. * @param viewportWidth defines the current width of the viewport
  1885. * @param viewportHeight defines the current height of the viewport
  1886. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1887. * @param view defines the view matrix to use
  1888. * @param projection defines the projection matrix to use
  1889. * @param result defines the Vector3 where to store the result
  1890. */
  1891. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1892. /**
  1893. * Gets the minimal coordinate values between two Vector3
  1894. * @param left defines the first operand
  1895. * @param right defines the second operand
  1896. * @returns the new Vector3
  1897. */
  1898. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1899. /**
  1900. * Gets the maximal coordinate values between two Vector3
  1901. * @param left defines the first operand
  1902. * @param right defines the second operand
  1903. * @returns the new Vector3
  1904. */
  1905. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1906. /**
  1907. * Returns the distance between the vectors "value1" and "value2"
  1908. * @param value1 defines the first operand
  1909. * @param value2 defines the second operand
  1910. * @returns the distance
  1911. */
  1912. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1913. /**
  1914. * Returns the squared distance between the vectors "value1" and "value2"
  1915. * @param value1 defines the first operand
  1916. * @param value2 defines the second operand
  1917. * @returns the squared distance
  1918. */
  1919. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1920. /**
  1921. * Returns a new Vector3 located at the center between "value1" and "value2"
  1922. * @param value1 defines the first operand
  1923. * @param value2 defines the second operand
  1924. * @returns the new Vector3
  1925. */
  1926. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1927. /**
  1928. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1929. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1930. * to something in order to rotate it from its local system to the given target system
  1931. * Note: axis1, axis2 and axis3 are normalized during this operation
  1932. * @param axis1 defines the first axis
  1933. * @param axis2 defines the second axis
  1934. * @param axis3 defines the third axis
  1935. * @returns a new Vector3
  1936. */
  1937. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1938. /**
  1939. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1940. * @param axis1 defines the first axis
  1941. * @param axis2 defines the second axis
  1942. * @param axis3 defines the third axis
  1943. * @param ref defines the Vector3 where to store the result
  1944. */
  1945. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1946. }
  1947. /**
  1948. * Vector4 class created for EulerAngle class conversion to Quaternion
  1949. */
  1950. export class Vector4 {
  1951. /** x value of the vector */
  1952. x: number;
  1953. /** y value of the vector */
  1954. y: number;
  1955. /** z value of the vector */
  1956. z: number;
  1957. /** w value of the vector */
  1958. w: number;
  1959. /**
  1960. * Creates a Vector4 object from the given floats.
  1961. * @param x x value of the vector
  1962. * @param y y value of the vector
  1963. * @param z z value of the vector
  1964. * @param w w value of the vector
  1965. */
  1966. constructor(
  1967. /** x value of the vector */
  1968. x: number,
  1969. /** y value of the vector */
  1970. y: number,
  1971. /** z value of the vector */
  1972. z: number,
  1973. /** w value of the vector */
  1974. w: number);
  1975. /**
  1976. * Returns the string with the Vector4 coordinates.
  1977. * @returns a string containing all the vector values
  1978. */
  1979. toString(): string;
  1980. /**
  1981. * Returns the string "Vector4".
  1982. * @returns "Vector4"
  1983. */
  1984. getClassName(): string;
  1985. /**
  1986. * Returns the Vector4 hash code.
  1987. * @returns a unique hash code
  1988. */
  1989. getHashCode(): number;
  1990. /**
  1991. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1992. * @returns the resulting array
  1993. */
  1994. asArray(): number[];
  1995. /**
  1996. * Populates the given array from the given index with the Vector4 coordinates.
  1997. * @param array array to populate
  1998. * @param index index of the array to start at (default: 0)
  1999. * @returns the Vector4.
  2000. */
  2001. toArray(array: FloatArray, index?: number): Vector4;
  2002. /**
  2003. * Adds the given vector to the current Vector4.
  2004. * @param otherVector the vector to add
  2005. * @returns the updated Vector4.
  2006. */
  2007. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2008. /**
  2009. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2010. * @param otherVector the vector to add
  2011. * @returns the resulting vector
  2012. */
  2013. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2014. /**
  2015. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2016. * @param otherVector the vector to add
  2017. * @param result the vector to store the result
  2018. * @returns the current Vector4.
  2019. */
  2020. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2021. /**
  2022. * Subtract in place the given vector from the current Vector4.
  2023. * @param otherVector the vector to subtract
  2024. * @returns the updated Vector4.
  2025. */
  2026. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2027. /**
  2028. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2029. * @param otherVector the vector to add
  2030. * @returns the new vector with the result
  2031. */
  2032. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2033. /**
  2034. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2035. * @param otherVector the vector to subtract
  2036. * @param result the vector to store the result
  2037. * @returns the current Vector4.
  2038. */
  2039. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2040. /**
  2041. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2042. */
  2043. /**
  2044. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2045. * @param x value to subtract
  2046. * @param y value to subtract
  2047. * @param z value to subtract
  2048. * @param w value to subtract
  2049. * @returns new vector containing the result
  2050. */
  2051. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2052. /**
  2053. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2054. * @param x value to subtract
  2055. * @param y value to subtract
  2056. * @param z value to subtract
  2057. * @param w value to subtract
  2058. * @param result the vector to store the result in
  2059. * @returns the current Vector4.
  2060. */
  2061. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2062. /**
  2063. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2064. * @returns a new vector with the negated values
  2065. */
  2066. negate(): Vector4;
  2067. /**
  2068. * Multiplies the current Vector4 coordinates by scale (float).
  2069. * @param scale the number to scale with
  2070. * @returns the updated Vector4.
  2071. */
  2072. scaleInPlace(scale: number): Vector4;
  2073. /**
  2074. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2075. * @param scale the number to scale with
  2076. * @returns a new vector with the result
  2077. */
  2078. scale(scale: number): Vector4;
  2079. /**
  2080. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2081. * @param scale the number to scale with
  2082. * @param result a vector to store the result in
  2083. * @returns the current Vector4.
  2084. */
  2085. scaleToRef(scale: number, result: Vector4): Vector4;
  2086. /**
  2087. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2088. * @param scale defines the scale factor
  2089. * @param result defines the Vector4 object where to store the result
  2090. * @returns the unmodified current Vector4
  2091. */
  2092. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2093. /**
  2094. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2095. * @param otherVector the vector to compare against
  2096. * @returns true if they are equal
  2097. */
  2098. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2099. /**
  2100. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2101. * @param otherVector vector to compare against
  2102. * @param epsilon (Default: very small number)
  2103. * @returns true if they are equal
  2104. */
  2105. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2106. /**
  2107. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2108. * @param x x value to compare against
  2109. * @param y y value to compare against
  2110. * @param z z value to compare against
  2111. * @param w w value to compare against
  2112. * @returns true if equal
  2113. */
  2114. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2115. /**
  2116. * Multiplies in place the current Vector4 by the given one.
  2117. * @param otherVector vector to multiple with
  2118. * @returns the updated Vector4.
  2119. */
  2120. multiplyInPlace(otherVector: Vector4): Vector4;
  2121. /**
  2122. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2123. * @param otherVector vector to multiple with
  2124. * @returns resulting new vector
  2125. */
  2126. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2127. /**
  2128. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2129. * @param otherVector vector to multiple with
  2130. * @param result vector to store the result
  2131. * @returns the current Vector4.
  2132. */
  2133. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2134. /**
  2135. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2136. * @param x x value multiply with
  2137. * @param y y value multiply with
  2138. * @param z z value multiply with
  2139. * @param w w value multiply with
  2140. * @returns resulting new vector
  2141. */
  2142. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2143. /**
  2144. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2145. * @param otherVector vector to devide with
  2146. * @returns resulting new vector
  2147. */
  2148. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2149. /**
  2150. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2151. * @param otherVector vector to devide with
  2152. * @param result vector to store the result
  2153. * @returns the current Vector4.
  2154. */
  2155. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2156. /**
  2157. * Divides the current Vector3 coordinates by the given ones.
  2158. * @param otherVector vector to devide with
  2159. * @returns the updated Vector3.
  2160. */
  2161. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2162. /**
  2163. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2164. * @param other defines the second operand
  2165. * @returns the current updated Vector4
  2166. */
  2167. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2168. /**
  2169. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2170. * @param other defines the second operand
  2171. * @returns the current updated Vector4
  2172. */
  2173. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2174. /**
  2175. * Gets a new Vector4 from current Vector4 floored values
  2176. * @returns a new Vector4
  2177. */
  2178. floor(): Vector4;
  2179. /**
  2180. * Gets a new Vector4 from current Vector3 floored values
  2181. * @returns a new Vector4
  2182. */
  2183. fract(): Vector4;
  2184. /**
  2185. * Returns the Vector4 length (float).
  2186. * @returns the length
  2187. */
  2188. length(): number;
  2189. /**
  2190. * Returns the Vector4 squared length (float).
  2191. * @returns the length squared
  2192. */
  2193. lengthSquared(): number;
  2194. /**
  2195. * Normalizes in place the Vector4.
  2196. * @returns the updated Vector4.
  2197. */
  2198. normalize(): Vector4;
  2199. /**
  2200. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2201. * @returns this converted to a new vector3
  2202. */
  2203. toVector3(): Vector3;
  2204. /**
  2205. * Returns a new Vector4 copied from the current one.
  2206. * @returns the new cloned vector
  2207. */
  2208. clone(): Vector4;
  2209. /**
  2210. * Updates the current Vector4 with the given one coordinates.
  2211. * @param source the source vector to copy from
  2212. * @returns the updated Vector4.
  2213. */
  2214. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2215. /**
  2216. * Updates the current Vector4 coordinates with the given floats.
  2217. * @param x float to copy from
  2218. * @param y float to copy from
  2219. * @param z float to copy from
  2220. * @param w float to copy from
  2221. * @returns the updated Vector4.
  2222. */
  2223. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2224. /**
  2225. * Updates the current Vector4 coordinates with the given floats.
  2226. * @param x float to set from
  2227. * @param y float to set from
  2228. * @param z float to set from
  2229. * @param w float to set from
  2230. * @returns the updated Vector4.
  2231. */
  2232. set(x: number, y: number, z: number, w: number): Vector4;
  2233. /**
  2234. * Copies the given float to the current Vector3 coordinates
  2235. * @param v defines the x, y, z and w coordinates of the operand
  2236. * @returns the current updated Vector3
  2237. */
  2238. setAll(v: number): Vector4;
  2239. /**
  2240. * Returns a new Vector4 set from the starting index of the given array.
  2241. * @param array the array to pull values from
  2242. * @param offset the offset into the array to start at
  2243. * @returns the new vector
  2244. */
  2245. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2246. /**
  2247. * Updates the given vector "result" from the starting index of the given array.
  2248. * @param array the array to pull values from
  2249. * @param offset the offset into the array to start at
  2250. * @param result the vector to store the result in
  2251. */
  2252. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2253. /**
  2254. * Updates the given vector "result" from the starting index of the given Float32Array.
  2255. * @param array the array to pull values from
  2256. * @param offset the offset into the array to start at
  2257. * @param result the vector to store the result in
  2258. */
  2259. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2260. /**
  2261. * Updates the given vector "result" coordinates from the given floats.
  2262. * @param x float to set from
  2263. * @param y float to set from
  2264. * @param z float to set from
  2265. * @param w float to set from
  2266. * @param result the vector to the floats in
  2267. */
  2268. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2269. /**
  2270. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2271. * @returns the new vector
  2272. */
  2273. static Zero(): Vector4;
  2274. /**
  2275. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2276. * @returns the new vector
  2277. */
  2278. static One(): Vector4;
  2279. /**
  2280. * Returns a new normalized Vector4 from the given one.
  2281. * @param vector the vector to normalize
  2282. * @returns the vector
  2283. */
  2284. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2285. /**
  2286. * Updates the given vector "result" from the normalization of the given one.
  2287. * @param vector the vector to normalize
  2288. * @param result the vector to store the result in
  2289. */
  2290. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2291. /**
  2292. * Returns a vector with the minimum values from the left and right vectors
  2293. * @param left left vector to minimize
  2294. * @param right right vector to minimize
  2295. * @returns a new vector with the minimum of the left and right vector values
  2296. */
  2297. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2298. /**
  2299. * Returns a vector with the maximum values from the left and right vectors
  2300. * @param left left vector to maximize
  2301. * @param right right vector to maximize
  2302. * @returns a new vector with the maximum of the left and right vector values
  2303. */
  2304. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2305. /**
  2306. * Returns the distance (float) between the vectors "value1" and "value2".
  2307. * @param value1 value to calulate the distance between
  2308. * @param value2 value to calulate the distance between
  2309. * @return the distance between the two vectors
  2310. */
  2311. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2312. /**
  2313. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2314. * @param value1 value to calulate the distance between
  2315. * @param value2 value to calulate the distance between
  2316. * @return the distance between the two vectors squared
  2317. */
  2318. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2319. /**
  2320. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2321. * @param value1 value to calulate the center between
  2322. * @param value2 value to calulate the center between
  2323. * @return the center between the two vectors
  2324. */
  2325. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2326. /**
  2327. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2328. * This methods computes transformed normalized direction vectors only.
  2329. * @param vector the vector to transform
  2330. * @param transformation the transformation matrix to apply
  2331. * @returns the new vector
  2332. */
  2333. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2334. /**
  2335. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2336. * This methods computes transformed normalized direction vectors only.
  2337. * @param vector the vector to transform
  2338. * @param transformation the transformation matrix to apply
  2339. * @param result the vector to store the result in
  2340. */
  2341. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2342. /**
  2343. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2344. * This methods computes transformed normalized direction vectors only.
  2345. * @param x value to transform
  2346. * @param y value to transform
  2347. * @param z value to transform
  2348. * @param w value to transform
  2349. * @param transformation the transformation matrix to apply
  2350. * @param result the vector to store the results in
  2351. */
  2352. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2353. /**
  2354. * Creates a new Vector4 from a Vector3
  2355. * @param source defines the source data
  2356. * @param w defines the 4th component (default is 0)
  2357. * @returns a new Vector4
  2358. */
  2359. static FromVector3(source: Vector3, w?: number): Vector4;
  2360. }
  2361. /**
  2362. * Interface for the size containing width and height
  2363. */
  2364. export interface ISize {
  2365. /**
  2366. * Width
  2367. */
  2368. width: number;
  2369. /**
  2370. * Heighht
  2371. */
  2372. height: number;
  2373. }
  2374. /**
  2375. * Size containing widht and height
  2376. */
  2377. export class Size implements ISize {
  2378. /**
  2379. * Width
  2380. */
  2381. width: number;
  2382. /**
  2383. * Height
  2384. */
  2385. height: number;
  2386. /**
  2387. * Creates a Size object from the given width and height (floats).
  2388. * @param width width of the new size
  2389. * @param height height of the new size
  2390. */
  2391. constructor(width: number, height: number);
  2392. /**
  2393. * Returns a string with the Size width and height
  2394. * @returns a string with the Size width and height
  2395. */
  2396. toString(): string;
  2397. /**
  2398. * "Size"
  2399. * @returns the string "Size"
  2400. */
  2401. getClassName(): string;
  2402. /**
  2403. * Returns the Size hash code.
  2404. * @returns a hash code for a unique width and height
  2405. */
  2406. getHashCode(): number;
  2407. /**
  2408. * Updates the current size from the given one.
  2409. * @param src the given size
  2410. */
  2411. copyFrom(src: Size): void;
  2412. /**
  2413. * Updates in place the current Size from the given floats.
  2414. * @param width width of the new size
  2415. * @param height height of the new size
  2416. * @returns the updated Size.
  2417. */
  2418. copyFromFloats(width: number, height: number): Size;
  2419. /**
  2420. * Updates in place the current Size from the given floats.
  2421. * @param width width to set
  2422. * @param height height to set
  2423. * @returns the updated Size.
  2424. */
  2425. set(width: number, height: number): Size;
  2426. /**
  2427. * Multiplies the width and height by numbers
  2428. * @param w factor to multiple the width by
  2429. * @param h factor to multiple the height by
  2430. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  2431. */
  2432. multiplyByFloats(w: number, h: number): Size;
  2433. /**
  2434. * Clones the size
  2435. * @returns a new Size copied from the given one.
  2436. */
  2437. clone(): Size;
  2438. /**
  2439. * True if the current Size and the given one width and height are strictly equal.
  2440. * @param other the other size to compare against
  2441. * @returns True if the current Size and the given one width and height are strictly equal.
  2442. */
  2443. equals(other: Size): boolean;
  2444. /**
  2445. * The surface of the Size : width * height (float).
  2446. */
  2447. readonly surface: number;
  2448. /**
  2449. * Create a new size of zero
  2450. * @returns a new Size set to (0.0, 0.0)
  2451. */
  2452. static Zero(): Size;
  2453. /**
  2454. * Sums the width and height of two sizes
  2455. * @param otherSize size to add to this size
  2456. * @returns a new Size set as the addition result of the current Size and the given one.
  2457. */
  2458. add(otherSize: Size): Size;
  2459. /**
  2460. * Subtracts the width and height of two
  2461. * @param otherSize size to subtract to this size
  2462. * @returns a new Size set as the subtraction result of the given one from the current Size.
  2463. */
  2464. subtract(otherSize: Size): Size;
  2465. /**
  2466. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  2467. * @param start starting size to lerp between
  2468. * @param end end size to lerp between
  2469. * @param amount amount to lerp between the start and end values
  2470. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  2471. */
  2472. static Lerp(start: Size, end: Size, amount: number): Size;
  2473. }
  2474. /**
  2475. * Class used to store quaternion data
  2476. * @see https://en.wikipedia.org/wiki/Quaternion
  2477. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2478. */
  2479. export class Quaternion {
  2480. /** defines the first component (0 by default) */
  2481. x: number;
  2482. /** defines the second component (0 by default) */
  2483. y: number;
  2484. /** defines the third component (0 by default) */
  2485. z: number;
  2486. /** defines the fourth component (1.0 by default) */
  2487. w: number;
  2488. /**
  2489. * Creates a new Quaternion from the given floats
  2490. * @param x defines the first component (0 by default)
  2491. * @param y defines the second component (0 by default)
  2492. * @param z defines the third component (0 by default)
  2493. * @param w defines the fourth component (1.0 by default)
  2494. */
  2495. constructor(
  2496. /** defines the first component (0 by default) */
  2497. x?: number,
  2498. /** defines the second component (0 by default) */
  2499. y?: number,
  2500. /** defines the third component (0 by default) */
  2501. z?: number,
  2502. /** defines the fourth component (1.0 by default) */
  2503. w?: number);
  2504. /**
  2505. * Gets a string representation for the current quaternion
  2506. * @returns a string with the Quaternion coordinates
  2507. */
  2508. toString(): string;
  2509. /**
  2510. * Gets the class name of the quaternion
  2511. * @returns the string "Quaternion"
  2512. */
  2513. getClassName(): string;
  2514. /**
  2515. * Gets a hash code for this quaternion
  2516. * @returns the quaternion hash code
  2517. */
  2518. getHashCode(): number;
  2519. /**
  2520. * Copy the quaternion to an array
  2521. * @returns a new array populated with 4 elements from the quaternion coordinates
  2522. */
  2523. asArray(): number[];
  2524. /**
  2525. * Check if two quaternions are equals
  2526. * @param otherQuaternion defines the second operand
  2527. * @return true if the current quaternion and the given one coordinates are strictly equals
  2528. */
  2529. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2530. /**
  2531. * Clone the current quaternion
  2532. * @returns a new quaternion copied from the current one
  2533. */
  2534. clone(): Quaternion;
  2535. /**
  2536. * Copy a quaternion to the current one
  2537. * @param other defines the other quaternion
  2538. * @returns the updated current quaternion
  2539. */
  2540. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2541. /**
  2542. * Updates the current quaternion with the given float coordinates
  2543. * @param x defines the x coordinate
  2544. * @param y defines the y coordinate
  2545. * @param z defines the z coordinate
  2546. * @param w defines the w coordinate
  2547. * @returns the updated current quaternion
  2548. */
  2549. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2550. /**
  2551. * Updates the current quaternion from the given float coordinates
  2552. * @param x defines the x coordinate
  2553. * @param y defines the y coordinate
  2554. * @param z defines the z coordinate
  2555. * @param w defines the w coordinate
  2556. * @returns the updated current quaternion
  2557. */
  2558. set(x: number, y: number, z: number, w: number): Quaternion;
  2559. /**
  2560. * Adds two quaternions
  2561. * @param other defines the second operand
  2562. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2563. */
  2564. add(other: DeepImmutable<Quaternion>): Quaternion;
  2565. /**
  2566. * Add a quaternion to the current one
  2567. * @param other defines the quaternion to add
  2568. * @returns the current quaternion
  2569. */
  2570. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2571. /**
  2572. * Subtract two quaternions
  2573. * @param other defines the second operand
  2574. * @returns a new quaternion as the subtraction result of the given one from the current one
  2575. */
  2576. subtract(other: Quaternion): Quaternion;
  2577. /**
  2578. * Multiplies the current quaternion by a scale factor
  2579. * @param value defines the scale factor
  2580. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2581. */
  2582. scale(value: number): Quaternion;
  2583. /**
  2584. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2585. * @param scale defines the scale factor
  2586. * @param result defines the Quaternion object where to store the result
  2587. * @returns the unmodified current quaternion
  2588. */
  2589. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2590. /**
  2591. * Multiplies in place the current quaternion by a scale factor
  2592. * @param value defines the scale factor
  2593. * @returns the current modified quaternion
  2594. */
  2595. scaleInPlace(value: number): Quaternion;
  2596. /**
  2597. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2598. * @param scale defines the scale factor
  2599. * @param result defines the Quaternion object where to store the result
  2600. * @returns the unmodified current quaternion
  2601. */
  2602. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2603. /**
  2604. * Multiplies two quaternions
  2605. * @param q1 defines the second operand
  2606. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2607. */
  2608. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2609. /**
  2610. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2611. * @param q1 defines the second operand
  2612. * @param result defines the target quaternion
  2613. * @returns the current quaternion
  2614. */
  2615. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2616. /**
  2617. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2618. * @param q1 defines the second operand
  2619. * @returns the currentupdated quaternion
  2620. */
  2621. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2622. /**
  2623. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2624. * @param ref defines the target quaternion
  2625. * @returns the current quaternion
  2626. */
  2627. conjugateToRef(ref: Quaternion): Quaternion;
  2628. /**
  2629. * Conjugates in place (1-q) the current quaternion
  2630. * @returns the current updated quaternion
  2631. */
  2632. conjugateInPlace(): Quaternion;
  2633. /**
  2634. * Conjugates in place (1-q) the current quaternion
  2635. * @returns a new quaternion
  2636. */
  2637. conjugate(): Quaternion;
  2638. /**
  2639. * Gets length of current quaternion
  2640. * @returns the quaternion length (float)
  2641. */
  2642. length(): number;
  2643. /**
  2644. * Normalize in place the current quaternion
  2645. * @returns the current updated quaternion
  2646. */
  2647. normalize(): Quaternion;
  2648. /**
  2649. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2650. * @param order is a reserved parameter and is ignore for now
  2651. * @returns a new Vector3 containing the Euler angles
  2652. */
  2653. toEulerAngles(order?: string): Vector3;
  2654. /**
  2655. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2656. * @param result defines the vector which will be filled with the Euler angles
  2657. * @param order is a reserved parameter and is ignore for now
  2658. * @returns the current unchanged quaternion
  2659. */
  2660. toEulerAnglesToRef(result: Vector3): Quaternion;
  2661. /**
  2662. * Updates the given rotation matrix with the current quaternion values
  2663. * @param result defines the target matrix
  2664. * @returns the current unchanged quaternion
  2665. */
  2666. toRotationMatrix(result: Matrix): Quaternion;
  2667. /**
  2668. * Updates the current quaternion from the given rotation matrix values
  2669. * @param matrix defines the source matrix
  2670. * @returns the current updated quaternion
  2671. */
  2672. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2673. /**
  2674. * Creates a new quaternion from a rotation matrix
  2675. * @param matrix defines the source matrix
  2676. * @returns a new quaternion created from the given rotation matrix values
  2677. */
  2678. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2679. /**
  2680. * Updates the given quaternion with the given rotation matrix values
  2681. * @param matrix defines the source matrix
  2682. * @param result defines the target quaternion
  2683. */
  2684. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2685. /**
  2686. * Returns the dot product (float) between the quaternions "left" and "right"
  2687. * @param left defines the left operand
  2688. * @param right defines the right operand
  2689. * @returns the dot product
  2690. */
  2691. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2692. /**
  2693. * Checks if the two quaternions are close to each other
  2694. * @param quat0 defines the first quaternion to check
  2695. * @param quat1 defines the second quaternion to check
  2696. * @returns true if the two quaternions are close to each other
  2697. */
  2698. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2699. /**
  2700. * Creates an empty quaternion
  2701. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2702. */
  2703. static Zero(): Quaternion;
  2704. /**
  2705. * Inverse a given quaternion
  2706. * @param q defines the source quaternion
  2707. * @returns a new quaternion as the inverted current quaternion
  2708. */
  2709. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2710. /**
  2711. * Inverse a given quaternion
  2712. * @param q defines the source quaternion
  2713. * @param result the quaternion the result will be stored in
  2714. * @returns the result quaternion
  2715. */
  2716. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2717. /**
  2718. * Creates an identity quaternion
  2719. * @returns the identity quaternion
  2720. */
  2721. static Identity(): Quaternion;
  2722. /**
  2723. * Gets a boolean indicating if the given quaternion is identity
  2724. * @param quaternion defines the quaternion to check
  2725. * @returns true if the quaternion is identity
  2726. */
  2727. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2728. /**
  2729. * Creates a quaternion from a rotation around an axis
  2730. * @param axis defines the axis to use
  2731. * @param angle defines the angle to use
  2732. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2733. */
  2734. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2735. /**
  2736. * Creates a rotation around an axis and stores it into the given quaternion
  2737. * @param axis defines the axis to use
  2738. * @param angle defines the angle to use
  2739. * @param result defines the target quaternion
  2740. * @returns the target quaternion
  2741. */
  2742. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2743. /**
  2744. * Creates a new quaternion from data stored into an array
  2745. * @param array defines the data source
  2746. * @param offset defines the offset in the source array where the data starts
  2747. * @returns a new quaternion
  2748. */
  2749. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2750. /**
  2751. * Create a quaternion from Euler rotation angles
  2752. * @param x Pitch
  2753. * @param y Yaw
  2754. * @param z Roll
  2755. * @returns the new Quaternion
  2756. */
  2757. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2758. /**
  2759. * Updates a quaternion from Euler rotation angles
  2760. * @param x Pitch
  2761. * @param y Yaw
  2762. * @param z Roll
  2763. * @param result the quaternion to store the result
  2764. * @returns the updated quaternion
  2765. */
  2766. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2767. /**
  2768. * Create a quaternion from Euler rotation vector
  2769. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2770. * @returns the new Quaternion
  2771. */
  2772. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2773. /**
  2774. * Updates a quaternion from Euler rotation vector
  2775. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2776. * @param result the quaternion to store the result
  2777. * @returns the updated quaternion
  2778. */
  2779. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2780. /**
  2781. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2782. * @param yaw defines the rotation around Y axis
  2783. * @param pitch defines the rotation around X axis
  2784. * @param roll defines the rotation around Z axis
  2785. * @returns the new quaternion
  2786. */
  2787. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2788. /**
  2789. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2790. * @param yaw defines the rotation around Y axis
  2791. * @param pitch defines the rotation around X axis
  2792. * @param roll defines the rotation around Z axis
  2793. * @param result defines the target quaternion
  2794. */
  2795. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2796. /**
  2797. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2798. * @param alpha defines the rotation around first axis
  2799. * @param beta defines the rotation around second axis
  2800. * @param gamma defines the rotation around third axis
  2801. * @returns the new quaternion
  2802. */
  2803. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2804. /**
  2805. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2806. * @param alpha defines the rotation around first axis
  2807. * @param beta defines the rotation around second axis
  2808. * @param gamma defines the rotation around third axis
  2809. * @param result defines the target quaternion
  2810. */
  2811. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2812. /**
  2813. * 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)
  2814. * @param axis1 defines the first axis
  2815. * @param axis2 defines the second axis
  2816. * @param axis3 defines the third axis
  2817. * @returns the new quaternion
  2818. */
  2819. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2820. /**
  2821. * 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
  2822. * @param axis1 defines the first axis
  2823. * @param axis2 defines the second axis
  2824. * @param axis3 defines the third axis
  2825. * @param ref defines the target quaternion
  2826. */
  2827. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2828. /**
  2829. * Interpolates between two quaternions
  2830. * @param left defines first quaternion
  2831. * @param right defines second quaternion
  2832. * @param amount defines the gradient to use
  2833. * @returns the new interpolated quaternion
  2834. */
  2835. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2836. /**
  2837. * Interpolates between two quaternions and stores it into a target quaternion
  2838. * @param left defines first quaternion
  2839. * @param right defines second quaternion
  2840. * @param amount defines the gradient to use
  2841. * @param result defines the target quaternion
  2842. */
  2843. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2844. /**
  2845. * Interpolate between two quaternions using Hermite interpolation
  2846. * @param value1 defines first quaternion
  2847. * @param tangent1 defines the incoming tangent
  2848. * @param value2 defines second quaternion
  2849. * @param tangent2 defines the outgoing tangent
  2850. * @param amount defines the target quaternion
  2851. * @returns the new interpolated quaternion
  2852. */
  2853. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2854. }
  2855. /**
  2856. * Class used to store matrix data (4x4)
  2857. */
  2858. export class Matrix {
  2859. private static _updateFlagSeed;
  2860. private static _identityReadOnly;
  2861. private _isIdentity;
  2862. private _isIdentityDirty;
  2863. private _isIdentity3x2;
  2864. private _isIdentity3x2Dirty;
  2865. /**
  2866. * Gets the update flag of the matrix which is an unique number for the matrix.
  2867. * It will be incremented every time the matrix data change.
  2868. * You can use it to speed the comparison between two versions of the same matrix.
  2869. */
  2870. updateFlag: number;
  2871. private readonly _m;
  2872. /**
  2873. * Gets the internal data of the matrix
  2874. */
  2875. readonly m: DeepImmutable<Float32Array>;
  2876. /** @hidden */
  2877. _markAsUpdated(): void;
  2878. /** @hidden */
  2879. private _updateIdentityStatus;
  2880. /**
  2881. * Creates an empty matrix (filled with zeros)
  2882. */
  2883. constructor();
  2884. /**
  2885. * Check if the current matrix is identity
  2886. * @returns true is the matrix is the identity matrix
  2887. */
  2888. isIdentity(): boolean;
  2889. /**
  2890. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2891. * @returns true is the matrix is the identity matrix
  2892. */
  2893. isIdentityAs3x2(): boolean;
  2894. /**
  2895. * Gets the determinant of the matrix
  2896. * @returns the matrix determinant
  2897. */
  2898. determinant(): number;
  2899. /**
  2900. * Returns the matrix as a Float32Array
  2901. * @returns the matrix underlying array
  2902. */
  2903. toArray(): DeepImmutable<Float32Array>;
  2904. /**
  2905. * Returns the matrix as a Float32Array
  2906. * @returns the matrix underlying array.
  2907. */
  2908. asArray(): DeepImmutable<Float32Array>;
  2909. /**
  2910. * Inverts the current matrix in place
  2911. * @returns the current inverted matrix
  2912. */
  2913. invert(): Matrix;
  2914. /**
  2915. * Sets all the matrix elements to zero
  2916. * @returns the current matrix
  2917. */
  2918. reset(): Matrix;
  2919. /**
  2920. * Adds the current matrix with a second one
  2921. * @param other defines the matrix to add
  2922. * @returns a new matrix as the addition of the current matrix and the given one
  2923. */
  2924. add(other: DeepImmutable<Matrix>): Matrix;
  2925. /**
  2926. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2927. * @param other defines the matrix to add
  2928. * @param result defines the target matrix
  2929. * @returns the current matrix
  2930. */
  2931. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2932. /**
  2933. * Adds in place the given matrix to the current matrix
  2934. * @param other defines the second operand
  2935. * @returns the current updated matrix
  2936. */
  2937. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2938. /**
  2939. * Sets the given matrix to the current inverted Matrix
  2940. * @param other defines the target matrix
  2941. * @returns the unmodified current matrix
  2942. */
  2943. invertToRef(other: Matrix): Matrix;
  2944. /**
  2945. * add a value at the specified position in the current Matrix
  2946. * @param index the index of the value within the matrix. between 0 and 15.
  2947. * @param value the value to be added
  2948. * @returns the current updated matrix
  2949. */
  2950. addAtIndex(index: number, value: number): Matrix;
  2951. /**
  2952. * mutiply the specified position in the current Matrix by a value
  2953. * @param index the index of the value within the matrix. between 0 and 15.
  2954. * @param value the value to be added
  2955. * @returns the current updated matrix
  2956. */
  2957. multiplyAtIndex(index: number, value: number): Matrix;
  2958. /**
  2959. * Inserts the translation vector (using 3 floats) in the current matrix
  2960. * @param x defines the 1st component of the translation
  2961. * @param y defines the 2nd component of the translation
  2962. * @param z defines the 3rd component of the translation
  2963. * @returns the current updated matrix
  2964. */
  2965. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2966. /**
  2967. * Adds the translation vector (using 3 floats) in the current matrix
  2968. * @param x defines the 1st component of the translation
  2969. * @param y defines the 2nd component of the translation
  2970. * @param z defines the 3rd component of the translation
  2971. * @returns the current updated matrix
  2972. */
  2973. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2974. /**
  2975. * Inserts the translation vector in the current matrix
  2976. * @param vector3 defines the translation to insert
  2977. * @returns the current updated matrix
  2978. */
  2979. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2980. /**
  2981. * Gets the translation value of the current matrix
  2982. * @returns a new Vector3 as the extracted translation from the matrix
  2983. */
  2984. getTranslation(): Vector3;
  2985. /**
  2986. * Fill a Vector3 with the extracted translation from the matrix
  2987. * @param result defines the Vector3 where to store the translation
  2988. * @returns the current matrix
  2989. */
  2990. getTranslationToRef(result: Vector3): Matrix;
  2991. /**
  2992. * Remove rotation and scaling part from the matrix
  2993. * @returns the updated matrix
  2994. */
  2995. removeRotationAndScaling(): Matrix;
  2996. /**
  2997. * Multiply two matrices
  2998. * @param other defines the second operand
  2999. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3000. */
  3001. multiply(other: DeepImmutable<Matrix>): Matrix;
  3002. /**
  3003. * Copy the current matrix from the given one
  3004. * @param other defines the source matrix
  3005. * @returns the current updated matrix
  3006. */
  3007. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3008. /**
  3009. * Populates the given array from the starting index with the current matrix values
  3010. * @param array defines the target array
  3011. * @param offset defines the offset in the target array where to start storing values
  3012. * @returns the current matrix
  3013. */
  3014. copyToArray(array: Float32Array, offset?: number): Matrix;
  3015. /**
  3016. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3017. * @param other defines the second operand
  3018. * @param result defines the matrix where to store the multiplication
  3019. * @returns the current matrix
  3020. */
  3021. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3022. /**
  3023. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3024. * @param other defines the second operand
  3025. * @param result defines the array where to store the multiplication
  3026. * @param offset defines the offset in the target array where to start storing values
  3027. * @returns the current matrix
  3028. */
  3029. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3030. /**
  3031. * Check equality between this matrix and a second one
  3032. * @param value defines the second matrix to compare
  3033. * @returns true is the current matrix and the given one values are strictly equal
  3034. */
  3035. equals(value: DeepImmutable<Matrix>): boolean;
  3036. /**
  3037. * Clone the current matrix
  3038. * @returns a new matrix from the current matrix
  3039. */
  3040. clone(): Matrix;
  3041. /**
  3042. * Returns the name of the current matrix class
  3043. * @returns the string "Matrix"
  3044. */
  3045. getClassName(): string;
  3046. /**
  3047. * Gets the hash code of the current matrix
  3048. * @returns the hash code
  3049. */
  3050. getHashCode(): number;
  3051. /**
  3052. * Decomposes the current Matrix into a translation, rotation and scaling components
  3053. * @param scale defines the scale vector3 given as a reference to update
  3054. * @param rotation defines the rotation quaternion given as a reference to update
  3055. * @param translation defines the translation vector3 given as a reference to update
  3056. * @returns true if operation was successful
  3057. */
  3058. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3059. /**
  3060. * Gets specific row of the matrix
  3061. * @param index defines the number of the row to get
  3062. * @returns the index-th row of the current matrix as a new Vector4
  3063. */
  3064. getRow(index: number): Nullable<Vector4>;
  3065. /**
  3066. * Sets the index-th row of the current matrix to the vector4 values
  3067. * @param index defines the number of the row to set
  3068. * @param row defines the target vector4
  3069. * @returns the updated current matrix
  3070. */
  3071. setRow(index: number, row: Vector4): Matrix;
  3072. /**
  3073. * Compute the transpose of the matrix
  3074. * @returns the new transposed matrix
  3075. */
  3076. transpose(): Matrix;
  3077. /**
  3078. * Compute the transpose of the matrix and store it in a given matrix
  3079. * @param result defines the target matrix
  3080. * @returns the current matrix
  3081. */
  3082. transposeToRef(result: Matrix): Matrix;
  3083. /**
  3084. * Sets the index-th row of the current matrix with the given 4 x float values
  3085. * @param index defines the row index
  3086. * @param x defines the x component to set
  3087. * @param y defines the y component to set
  3088. * @param z defines the z component to set
  3089. * @param w defines the w component to set
  3090. * @returns the updated current matrix
  3091. */
  3092. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3093. /**
  3094. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3095. * @param scale defines the scale factor
  3096. * @returns a new matrix
  3097. */
  3098. scale(scale: number): Matrix;
  3099. /**
  3100. * Scale the current matrix values by a factor to a given result matrix
  3101. * @param scale defines the scale factor
  3102. * @param result defines the matrix to store the result
  3103. * @returns the current matrix
  3104. */
  3105. scaleToRef(scale: number, result: Matrix): Matrix;
  3106. /**
  3107. * Scale the current matrix values by a factor and add the result to a given matrix
  3108. * @param scale defines the scale factor
  3109. * @param result defines the Matrix to store the result
  3110. * @returns the current matrix
  3111. */
  3112. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3113. /**
  3114. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3115. * @param ref matrix to store the result
  3116. */
  3117. toNormalMatrix(ref: Matrix): void;
  3118. /**
  3119. * Gets only rotation part of the current matrix
  3120. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3121. */
  3122. getRotationMatrix(): Matrix;
  3123. /**
  3124. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3125. * @param result defines the target matrix to store data to
  3126. * @returns the current matrix
  3127. */
  3128. getRotationMatrixToRef(result: Matrix): Matrix;
  3129. /**
  3130. * Toggles model matrix from being right handed to left handed in place and vice versa
  3131. */
  3132. toggleModelMatrixHandInPlace(): void;
  3133. /**
  3134. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3135. */
  3136. toggleProjectionMatrixHandInPlace(): void;
  3137. /**
  3138. * Creates a matrix from an array
  3139. * @param array defines the source array
  3140. * @param offset defines an offset in the source array
  3141. * @returns a new Matrix set from the starting index of the given array
  3142. */
  3143. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3144. /**
  3145. * Copy the content of an array into a given matrix
  3146. * @param array defines the source array
  3147. * @param offset defines an offset in the source array
  3148. * @param result defines the target matrix
  3149. */
  3150. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3151. /**
  3152. * Stores an array into a matrix after having multiplied each component by a given factor
  3153. * @param array defines the source array
  3154. * @param offset defines the offset in the source array
  3155. * @param scale defines the scaling factor
  3156. * @param result defines the target matrix
  3157. */
  3158. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3159. /**
  3160. * Gets an identity matrix that must not be updated
  3161. */
  3162. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3163. /**
  3164. * Stores a list of values (16) inside a given matrix
  3165. * @param initialM11 defines 1st value of 1st row
  3166. * @param initialM12 defines 2nd value of 1st row
  3167. * @param initialM13 defines 3rd value of 1st row
  3168. * @param initialM14 defines 4th value of 1st row
  3169. * @param initialM21 defines 1st value of 2nd row
  3170. * @param initialM22 defines 2nd value of 2nd row
  3171. * @param initialM23 defines 3rd value of 2nd row
  3172. * @param initialM24 defines 4th value of 2nd row
  3173. * @param initialM31 defines 1st value of 3rd row
  3174. * @param initialM32 defines 2nd value of 3rd row
  3175. * @param initialM33 defines 3rd value of 3rd row
  3176. * @param initialM34 defines 4th value of 3rd row
  3177. * @param initialM41 defines 1st value of 4th row
  3178. * @param initialM42 defines 2nd value of 4th row
  3179. * @param initialM43 defines 3rd value of 4th row
  3180. * @param initialM44 defines 4th value of 4th row
  3181. * @param result defines the target matrix
  3182. */
  3183. 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;
  3184. /**
  3185. * Creates new matrix from a list of values (16)
  3186. * @param initialM11 defines 1st value of 1st row
  3187. * @param initialM12 defines 2nd value of 1st row
  3188. * @param initialM13 defines 3rd value of 1st row
  3189. * @param initialM14 defines 4th value of 1st row
  3190. * @param initialM21 defines 1st value of 2nd row
  3191. * @param initialM22 defines 2nd value of 2nd row
  3192. * @param initialM23 defines 3rd value of 2nd row
  3193. * @param initialM24 defines 4th value of 2nd row
  3194. * @param initialM31 defines 1st value of 3rd row
  3195. * @param initialM32 defines 2nd value of 3rd row
  3196. * @param initialM33 defines 3rd value of 3rd row
  3197. * @param initialM34 defines 4th value of 3rd row
  3198. * @param initialM41 defines 1st value of 4th row
  3199. * @param initialM42 defines 2nd value of 4th row
  3200. * @param initialM43 defines 3rd value of 4th row
  3201. * @param initialM44 defines 4th value of 4th row
  3202. * @returns the new matrix
  3203. */
  3204. 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;
  3205. /**
  3206. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3207. * @param scale defines the scale vector3
  3208. * @param rotation defines the rotation quaternion
  3209. * @param translation defines the translation vector3
  3210. * @returns a new matrix
  3211. */
  3212. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3213. /**
  3214. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3215. * @param scale defines the scale vector3
  3216. * @param rotation defines the rotation quaternion
  3217. * @param translation defines the translation vector3
  3218. * @param result defines the target matrix
  3219. */
  3220. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3221. /**
  3222. * Creates a new identity matrix
  3223. * @returns a new identity matrix
  3224. */
  3225. static Identity(): Matrix;
  3226. /**
  3227. * Creates a new identity matrix and stores the result in a given matrix
  3228. * @param result defines the target matrix
  3229. */
  3230. static IdentityToRef(result: Matrix): void;
  3231. /**
  3232. * Creates a new zero matrix
  3233. * @returns a new zero matrix
  3234. */
  3235. static Zero(): Matrix;
  3236. /**
  3237. * Creates a new rotation matrix for "angle" radians around the X axis
  3238. * @param angle defines the angle (in radians) to use
  3239. * @return the new matrix
  3240. */
  3241. static RotationX(angle: number): Matrix;
  3242. /**
  3243. * Creates a new matrix as the invert of a given matrix
  3244. * @param source defines the source matrix
  3245. * @returns the new matrix
  3246. */
  3247. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3248. /**
  3249. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3250. * @param angle defines the angle (in radians) to use
  3251. * @param result defines the target matrix
  3252. */
  3253. static RotationXToRef(angle: number, result: Matrix): void;
  3254. /**
  3255. * Creates a new rotation matrix for "angle" radians around the Y axis
  3256. * @param angle defines the angle (in radians) to use
  3257. * @return the new matrix
  3258. */
  3259. static RotationY(angle: number): Matrix;
  3260. /**
  3261. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3262. * @param angle defines the angle (in radians) to use
  3263. * @param result defines the target matrix
  3264. */
  3265. static RotationYToRef(angle: number, result: Matrix): void;
  3266. /**
  3267. * Creates a new rotation matrix for "angle" radians around the Z axis
  3268. * @param angle defines the angle (in radians) to use
  3269. * @return the new matrix
  3270. */
  3271. static RotationZ(angle: number): Matrix;
  3272. /**
  3273. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3274. * @param angle defines the angle (in radians) to use
  3275. * @param result defines the target matrix
  3276. */
  3277. static RotationZToRef(angle: number, result: Matrix): void;
  3278. /**
  3279. * Creates a new rotation matrix for "angle" radians around the given axis
  3280. * @param axis defines the axis to use
  3281. * @param angle defines the angle (in radians) to use
  3282. * @return the new matrix
  3283. */
  3284. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3285. /**
  3286. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3287. * @param axis defines the axis to use
  3288. * @param angle defines the angle (in radians) to use
  3289. * @param result defines the target matrix
  3290. */
  3291. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3292. /**
  3293. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3294. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3295. * @param from defines the vector to align
  3296. * @param to defines the vector to align to
  3297. * @param result defines the target matrix
  3298. */
  3299. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3300. /**
  3301. * Creates a rotation matrix
  3302. * @param yaw defines the yaw angle in radians (Y axis)
  3303. * @param pitch defines the pitch angle in radians (X axis)
  3304. * @param roll defines the roll angle in radians (X axis)
  3305. * @returns the new rotation matrix
  3306. */
  3307. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3308. /**
  3309. * Creates a rotation matrix and stores it in a given matrix
  3310. * @param yaw defines the yaw angle in radians (Y axis)
  3311. * @param pitch defines the pitch angle in radians (X axis)
  3312. * @param roll defines the roll angle in radians (X axis)
  3313. * @param result defines the target matrix
  3314. */
  3315. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3316. /**
  3317. * Creates a scaling matrix
  3318. * @param x defines the scale factor on X axis
  3319. * @param y defines the scale factor on Y axis
  3320. * @param z defines the scale factor on Z axis
  3321. * @returns the new matrix
  3322. */
  3323. static Scaling(x: number, y: number, z: number): Matrix;
  3324. /**
  3325. * Creates a scaling matrix and stores it in a given matrix
  3326. * @param x defines the scale factor on X axis
  3327. * @param y defines the scale factor on Y axis
  3328. * @param z defines the scale factor on Z axis
  3329. * @param result defines the target matrix
  3330. */
  3331. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3332. /**
  3333. * Creates a translation matrix
  3334. * @param x defines the translation on X axis
  3335. * @param y defines the translation on Y axis
  3336. * @param z defines the translationon Z axis
  3337. * @returns the new matrix
  3338. */
  3339. static Translation(x: number, y: number, z: number): Matrix;
  3340. /**
  3341. * Creates a translation matrix and stores it in a given matrix
  3342. * @param x defines the translation on X axis
  3343. * @param y defines the translation on Y axis
  3344. * @param z defines the translationon Z axis
  3345. * @param result defines the target matrix
  3346. */
  3347. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3348. /**
  3349. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3350. * @param startValue defines the start value
  3351. * @param endValue defines the end value
  3352. * @param gradient defines the gradient factor
  3353. * @returns the new matrix
  3354. */
  3355. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3356. /**
  3357. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3358. * @param startValue defines the start value
  3359. * @param endValue defines the end value
  3360. * @param gradient defines the gradient factor
  3361. * @param result defines the Matrix object where to store data
  3362. */
  3363. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3364. /**
  3365. * Builds a new matrix whose values are computed by:
  3366. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3367. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3368. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3369. * @param startValue defines the first matrix
  3370. * @param endValue defines the second matrix
  3371. * @param gradient defines the gradient between the two matrices
  3372. * @returns the new matrix
  3373. */
  3374. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3375. /**
  3376. * Update a matrix to values which are computed by:
  3377. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3378. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3379. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3380. * @param startValue defines the first matrix
  3381. * @param endValue defines the second matrix
  3382. * @param gradient defines the gradient between the two matrices
  3383. * @param result defines the target matrix
  3384. */
  3385. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3386. /**
  3387. * 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"
  3388. * This function works in left handed mode
  3389. * @param eye defines the final position of the entity
  3390. * @param target defines where the entity should look at
  3391. * @param up defines the up vector for the entity
  3392. * @returns the new matrix
  3393. */
  3394. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3395. /**
  3396. * 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".
  3397. * This function works in left handed mode
  3398. * @param eye defines the final position of the entity
  3399. * @param target defines where the entity should look at
  3400. * @param up defines the up vector for the entity
  3401. * @param result defines the target matrix
  3402. */
  3403. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3404. /**
  3405. * 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"
  3406. * This function works in right handed mode
  3407. * @param eye defines the final position of the entity
  3408. * @param target defines where the entity should look at
  3409. * @param up defines the up vector for the entity
  3410. * @returns the new matrix
  3411. */
  3412. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3413. /**
  3414. * 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".
  3415. * This function works in right handed mode
  3416. * @param eye defines the final position of the entity
  3417. * @param target defines where the entity should look at
  3418. * @param up defines the up vector for the entity
  3419. * @param result defines the target matrix
  3420. */
  3421. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3422. /**
  3423. * Create a left-handed orthographic projection matrix
  3424. * @param width defines the viewport width
  3425. * @param height defines the viewport height
  3426. * @param znear defines the near clip plane
  3427. * @param zfar defines the far clip plane
  3428. * @returns a new matrix as a left-handed orthographic projection matrix
  3429. */
  3430. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3431. /**
  3432. * Store a left-handed orthographic projection to a given matrix
  3433. * @param width defines the viewport width
  3434. * @param height defines the viewport height
  3435. * @param znear defines the near clip plane
  3436. * @param zfar defines the far clip plane
  3437. * @param result defines the target matrix
  3438. */
  3439. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3440. /**
  3441. * Create a left-handed orthographic projection matrix
  3442. * @param left defines the viewport left coordinate
  3443. * @param right defines the viewport right coordinate
  3444. * @param bottom defines the viewport bottom coordinate
  3445. * @param top defines the viewport top coordinate
  3446. * @param znear defines the near clip plane
  3447. * @param zfar defines the far clip plane
  3448. * @returns a new matrix as a left-handed orthographic projection matrix
  3449. */
  3450. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3451. /**
  3452. * Stores a left-handed orthographic projection into a given matrix
  3453. * @param left defines the viewport left coordinate
  3454. * @param right defines the viewport right coordinate
  3455. * @param bottom defines the viewport bottom coordinate
  3456. * @param top defines the viewport top coordinate
  3457. * @param znear defines the near clip plane
  3458. * @param zfar defines the far clip plane
  3459. * @param result defines the target matrix
  3460. */
  3461. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3462. /**
  3463. * Creates a right-handed orthographic projection matrix
  3464. * @param left defines the viewport left coordinate
  3465. * @param right defines the viewport right coordinate
  3466. * @param bottom defines the viewport bottom coordinate
  3467. * @param top defines the viewport top coordinate
  3468. * @param znear defines the near clip plane
  3469. * @param zfar defines the far clip plane
  3470. * @returns a new matrix as a right-handed orthographic projection matrix
  3471. */
  3472. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3473. /**
  3474. * Stores a right-handed orthographic projection into a given matrix
  3475. * @param left defines the viewport left coordinate
  3476. * @param right defines the viewport right coordinate
  3477. * @param bottom defines the viewport bottom coordinate
  3478. * @param top defines the viewport top coordinate
  3479. * @param znear defines the near clip plane
  3480. * @param zfar defines the far clip plane
  3481. * @param result defines the target matrix
  3482. */
  3483. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3484. /**
  3485. * Creates a left-handed perspective projection matrix
  3486. * @param width defines the viewport width
  3487. * @param height defines the viewport height
  3488. * @param znear defines the near clip plane
  3489. * @param zfar defines the far clip plane
  3490. * @returns a new matrix as a left-handed perspective projection matrix
  3491. */
  3492. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3493. /**
  3494. * Creates a left-handed perspective projection matrix
  3495. * @param fov defines the horizontal field of view
  3496. * @param aspect defines the aspect ratio
  3497. * @param znear defines the near clip plane
  3498. * @param zfar defines the far clip plane
  3499. * @returns a new matrix as a left-handed perspective projection matrix
  3500. */
  3501. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3502. /**
  3503. * Stores a left-handed perspective projection into a given matrix
  3504. * @param fov defines the horizontal field of view
  3505. * @param aspect defines the aspect ratio
  3506. * @param znear defines the near clip plane
  3507. * @param zfar defines the far clip plane
  3508. * @param result defines the target matrix
  3509. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3510. */
  3511. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3512. /**
  3513. * Creates a right-handed perspective projection matrix
  3514. * @param fov defines the horizontal field of view
  3515. * @param aspect defines the aspect ratio
  3516. * @param znear defines the near clip plane
  3517. * @param zfar defines the far clip plane
  3518. * @returns a new matrix as a right-handed perspective projection matrix
  3519. */
  3520. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3521. /**
  3522. * Stores a right-handed perspective projection into a given matrix
  3523. * @param fov defines the horizontal field of view
  3524. * @param aspect defines the aspect ratio
  3525. * @param znear defines the near clip plane
  3526. * @param zfar defines the far clip plane
  3527. * @param result defines the target matrix
  3528. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3529. */
  3530. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3531. /**
  3532. * Stores a perspective projection for WebVR info a given matrix
  3533. * @param fov defines the field of view
  3534. * @param znear defines the near clip plane
  3535. * @param zfar defines the far clip plane
  3536. * @param result defines the target matrix
  3537. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3538. */
  3539. static PerspectiveFovWebVRToRef(fov: {
  3540. upDegrees: number;
  3541. downDegrees: number;
  3542. leftDegrees: number;
  3543. rightDegrees: number;
  3544. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3545. /**
  3546. * Computes a complete transformation matrix
  3547. * @param viewport defines the viewport to use
  3548. * @param world defines the world matrix
  3549. * @param view defines the view matrix
  3550. * @param projection defines the projection matrix
  3551. * @param zmin defines the near clip plane
  3552. * @param zmax defines the far clip plane
  3553. * @returns the transformation matrix
  3554. */
  3555. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3556. /**
  3557. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3558. * @param matrix defines the matrix to use
  3559. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3560. */
  3561. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3562. /**
  3563. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3564. * @param matrix defines the matrix to use
  3565. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3566. */
  3567. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3568. /**
  3569. * Compute the transpose of a given matrix
  3570. * @param matrix defines the matrix to transpose
  3571. * @returns the new matrix
  3572. */
  3573. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3574. /**
  3575. * Compute the transpose of a matrix and store it in a target matrix
  3576. * @param matrix defines the matrix to transpose
  3577. * @param result defines the target matrix
  3578. */
  3579. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3580. /**
  3581. * Computes a reflection matrix from a plane
  3582. * @param plane defines the reflection plane
  3583. * @returns a new matrix
  3584. */
  3585. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  3586. /**
  3587. * Computes a reflection matrix from a plane
  3588. * @param plane defines the reflection plane
  3589. * @param result defines the target matrix
  3590. */
  3591. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  3592. /**
  3593. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3594. * @param xaxis defines the value of the 1st axis
  3595. * @param yaxis defines the value of the 2nd axis
  3596. * @param zaxis defines the value of the 3rd axis
  3597. * @param result defines the target matrix
  3598. */
  3599. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3600. /**
  3601. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3602. * @param quat defines the quaternion to use
  3603. * @param result defines the target matrix
  3604. */
  3605. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3606. }
  3607. /**
  3608. * Represens a plane by the equation ax + by + cz + d = 0
  3609. */
  3610. export class Plane {
  3611. /**
  3612. * Normal of the plane (a,b,c)
  3613. */
  3614. normal: Vector3;
  3615. /**
  3616. * d component of the plane
  3617. */
  3618. d: number;
  3619. /**
  3620. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  3621. * @param a a component of the plane
  3622. * @param b b component of the plane
  3623. * @param c c component of the plane
  3624. * @param d d component of the plane
  3625. */
  3626. constructor(a: number, b: number, c: number, d: number);
  3627. /**
  3628. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  3629. */
  3630. asArray(): number[];
  3631. /**
  3632. * @returns a new plane copied from the current Plane.
  3633. */
  3634. clone(): Plane;
  3635. /**
  3636. * @returns the string "Plane".
  3637. */
  3638. getClassName(): string;
  3639. /**
  3640. * @returns the Plane hash code.
  3641. */
  3642. getHashCode(): number;
  3643. /**
  3644. * Normalize the current Plane in place.
  3645. * @returns the updated Plane.
  3646. */
  3647. normalize(): Plane;
  3648. /**
  3649. * Applies a transformation the plane and returns the result
  3650. * @param transformation the transformation matrix to be applied to the plane
  3651. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  3652. */
  3653. transform(transformation: DeepImmutable<Matrix>): Plane;
  3654. /**
  3655. * Calcualtte the dot product between the point and the plane normal
  3656. * @param point point to calculate the dot product with
  3657. * @returns the dot product (float) of the point coordinates and the plane normal.
  3658. */
  3659. dotCoordinate(point: DeepImmutable<Vector3>): number;
  3660. /**
  3661. * Updates the current Plane from the plane defined by the three given points.
  3662. * @param point1 one of the points used to contruct the plane
  3663. * @param point2 one of the points used to contruct the plane
  3664. * @param point3 one of the points used to contruct the plane
  3665. * @returns the updated Plane.
  3666. */
  3667. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3668. /**
  3669. * Checks if the plane is facing a given direction
  3670. * @param direction the direction to check if the plane is facing
  3671. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  3672. * @returns True is the vector "direction" is the same side than the plane normal.
  3673. */
  3674. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  3675. /**
  3676. * Calculates the distance to a point
  3677. * @param point point to calculate distance to
  3678. * @returns the signed distance (float) from the given point to the Plane.
  3679. */
  3680. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  3681. /**
  3682. * Creates a plane from an array
  3683. * @param array the array to create a plane from
  3684. * @returns a new Plane from the given array.
  3685. */
  3686. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  3687. /**
  3688. * Creates a plane from three points
  3689. * @param point1 point used to create the plane
  3690. * @param point2 point used to create the plane
  3691. * @param point3 point used to create the plane
  3692. * @returns a new Plane defined by the three given points.
  3693. */
  3694. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3695. /**
  3696. * Creates a plane from an origin point and a normal
  3697. * @param origin origin of the plane to be constructed
  3698. * @param normal normal of the plane to be constructed
  3699. * @returns a new Plane the normal vector to this plane at the given origin point.
  3700. * Note : the vector "normal" is updated because normalized.
  3701. */
  3702. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  3703. /**
  3704. * Calculates the distance from a plane and a point
  3705. * @param origin origin of the plane to be constructed
  3706. * @param normal normal of the plane to be constructed
  3707. * @param point point to calculate distance to
  3708. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  3709. */
  3710. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  3711. }
  3712. /**
  3713. * Class used to represent a viewport on screen
  3714. */
  3715. export class Viewport {
  3716. /** viewport left coordinate */
  3717. x: number;
  3718. /** viewport top coordinate */
  3719. y: number;
  3720. /**viewport width */
  3721. width: number;
  3722. /** viewport height */
  3723. height: number;
  3724. /**
  3725. * Creates a Viewport object located at (x, y) and sized (width, height)
  3726. * @param x defines viewport left coordinate
  3727. * @param y defines viewport top coordinate
  3728. * @param width defines the viewport width
  3729. * @param height defines the viewport height
  3730. */
  3731. constructor(
  3732. /** viewport left coordinate */
  3733. x: number,
  3734. /** viewport top coordinate */
  3735. y: number,
  3736. /**viewport width */
  3737. width: number,
  3738. /** viewport height */
  3739. height: number);
  3740. /**
  3741. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  3742. * @param renderWidth defines the rendering width
  3743. * @param renderHeight defines the rendering height
  3744. * @returns a new Viewport
  3745. */
  3746. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  3747. /**
  3748. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  3749. * @param renderWidth defines the rendering width
  3750. * @param renderHeight defines the rendering height
  3751. * @param ref defines the target viewport
  3752. * @returns the current viewport
  3753. */
  3754. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  3755. /**
  3756. * Returns a new Viewport copied from the current one
  3757. * @returns a new Viewport
  3758. */
  3759. clone(): Viewport;
  3760. }
  3761. /**
  3762. * Reprasents a camera frustum
  3763. */
  3764. export class Frustum {
  3765. /**
  3766. * Gets the planes representing the frustum
  3767. * @param transform matrix to be applied to the returned planes
  3768. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  3769. */
  3770. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  3771. /**
  3772. * Gets the near frustum plane transformed by the transform matrix
  3773. * @param transform transformation matrix to be applied to the resulting frustum plane
  3774. * @param frustumPlane the resuling frustum plane
  3775. */
  3776. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3777. /**
  3778. * Gets the far frustum plane transformed by the transform matrix
  3779. * @param transform transformation matrix to be applied to the resulting frustum plane
  3780. * @param frustumPlane the resuling frustum plane
  3781. */
  3782. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3783. /**
  3784. * Gets the left frustum plane transformed by the transform matrix
  3785. * @param transform transformation matrix to be applied to the resulting frustum plane
  3786. * @param frustumPlane the resuling frustum plane
  3787. */
  3788. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3789. /**
  3790. * Gets the right frustum plane transformed by the transform matrix
  3791. * @param transform transformation matrix to be applied to the resulting frustum plane
  3792. * @param frustumPlane the resuling frustum plane
  3793. */
  3794. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3795. /**
  3796. * Gets the top frustum plane transformed by the transform matrix
  3797. * @param transform transformation matrix to be applied to the resulting frustum plane
  3798. * @param frustumPlane the resuling frustum plane
  3799. */
  3800. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3801. /**
  3802. * Gets the bottom frustum plane transformed by the transform matrix
  3803. * @param transform transformation matrix to be applied to the resulting frustum plane
  3804. * @param frustumPlane the resuling frustum plane
  3805. */
  3806. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3807. /**
  3808. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  3809. * @param transform transformation matrix to be applied to the resulting frustum planes
  3810. * @param frustumPlanes the resuling frustum planes
  3811. */
  3812. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  3813. }
  3814. /** Defines supported spaces */
  3815. export enum Space {
  3816. /** Local (object) space */
  3817. LOCAL = 0,
  3818. /** World space */
  3819. WORLD = 1,
  3820. /** Bone space */
  3821. BONE = 2
  3822. }
  3823. /** Defines the 3 main axes */
  3824. export class Axis {
  3825. /** X axis */
  3826. static X: Vector3;
  3827. /** Y axis */
  3828. static Y: Vector3;
  3829. /** Z axis */
  3830. static Z: Vector3;
  3831. }
  3832. /** Class used to represent a Bezier curve */
  3833. export class BezierCurve {
  3834. /**
  3835. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  3836. * @param t defines the time
  3837. * @param x1 defines the left coordinate on X axis
  3838. * @param y1 defines the left coordinate on Y axis
  3839. * @param x2 defines the right coordinate on X axis
  3840. * @param y2 defines the right coordinate on Y axis
  3841. * @returns the interpolated value
  3842. */
  3843. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  3844. }
  3845. /**
  3846. * Defines potential orientation for back face culling
  3847. */
  3848. export enum Orientation {
  3849. /**
  3850. * Clockwise
  3851. */
  3852. CW = 0,
  3853. /** Counter clockwise */
  3854. CCW = 1
  3855. }
  3856. /**
  3857. * Defines angle representation
  3858. */
  3859. export class Angle {
  3860. private _radians;
  3861. /**
  3862. * Creates an Angle object of "radians" radians (float).
  3863. * @param radians the angle in radians
  3864. */
  3865. constructor(radians: number);
  3866. /**
  3867. * Get value in degrees
  3868. * @returns the Angle value in degrees (float)
  3869. */
  3870. degrees(): number;
  3871. /**
  3872. * Get value in radians
  3873. * @returns the Angle value in radians (float)
  3874. */
  3875. radians(): number;
  3876. /**
  3877. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  3878. * @param a defines first vector
  3879. * @param b defines second vector
  3880. * @returns a new Angle
  3881. */
  3882. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  3883. /**
  3884. * Gets a new Angle object from the given float in radians
  3885. * @param radians defines the angle value in radians
  3886. * @returns a new Angle
  3887. */
  3888. static FromRadians(radians: number): Angle;
  3889. /**
  3890. * Gets a new Angle object from the given float in degrees
  3891. * @param degrees defines the angle value in degrees
  3892. * @returns a new Angle
  3893. */
  3894. static FromDegrees(degrees: number): Angle;
  3895. }
  3896. /**
  3897. * This represents an arc in a 2d space.
  3898. */
  3899. export class Arc2 {
  3900. /** Defines the start point of the arc */
  3901. startPoint: Vector2;
  3902. /** Defines the mid point of the arc */
  3903. midPoint: Vector2;
  3904. /** Defines the end point of the arc */
  3905. endPoint: Vector2;
  3906. /**
  3907. * Defines the center point of the arc.
  3908. */
  3909. centerPoint: Vector2;
  3910. /**
  3911. * Defines the radius of the arc.
  3912. */
  3913. radius: number;
  3914. /**
  3915. * Defines the angle of the arc (from mid point to end point).
  3916. */
  3917. angle: Angle;
  3918. /**
  3919. * Defines the start angle of the arc (from start point to middle point).
  3920. */
  3921. startAngle: Angle;
  3922. /**
  3923. * Defines the orientation of the arc (clock wise/counter clock wise).
  3924. */
  3925. orientation: Orientation;
  3926. /**
  3927. * Creates an Arc object from the three given points : start, middle and end.
  3928. * @param startPoint Defines the start point of the arc
  3929. * @param midPoint Defines the midlle point of the arc
  3930. * @param endPoint Defines the end point of the arc
  3931. */
  3932. constructor(
  3933. /** Defines the start point of the arc */
  3934. startPoint: Vector2,
  3935. /** Defines the mid point of the arc */
  3936. midPoint: Vector2,
  3937. /** Defines the end point of the arc */
  3938. endPoint: Vector2);
  3939. }
  3940. /**
  3941. * Represents a 2D path made up of multiple 2D points
  3942. */
  3943. export class Path2 {
  3944. private _points;
  3945. private _length;
  3946. /**
  3947. * If the path start and end point are the same
  3948. */
  3949. closed: boolean;
  3950. /**
  3951. * Creates a Path2 object from the starting 2D coordinates x and y.
  3952. * @param x the starting points x value
  3953. * @param y the starting points y value
  3954. */
  3955. constructor(x: number, y: number);
  3956. /**
  3957. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  3958. * @param x the added points x value
  3959. * @param y the added points y value
  3960. * @returns the updated Path2.
  3961. */
  3962. addLineTo(x: number, y: number): Path2;
  3963. /**
  3964. * 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.
  3965. * @param midX middle point x value
  3966. * @param midY middle point y value
  3967. * @param endX end point x value
  3968. * @param endY end point y value
  3969. * @param numberOfSegments (default: 36)
  3970. * @returns the updated Path2.
  3971. */
  3972. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  3973. /**
  3974. * Closes the Path2.
  3975. * @returns the Path2.
  3976. */
  3977. close(): Path2;
  3978. /**
  3979. * Gets the sum of the distance between each sequential point in the path
  3980. * @returns the Path2 total length (float).
  3981. */
  3982. length(): number;
  3983. /**
  3984. * Gets the points which construct the path
  3985. * @returns the Path2 internal array of points.
  3986. */
  3987. getPoints(): Vector2[];
  3988. /**
  3989. * Retreives the point at the distance aways from the starting point
  3990. * @param normalizedLengthPosition the length along the path to retreive the point from
  3991. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  3992. */
  3993. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  3994. /**
  3995. * Creates a new path starting from an x and y position
  3996. * @param x starting x value
  3997. * @param y starting y value
  3998. * @returns a new Path2 starting at the coordinates (x, y).
  3999. */
  4000. static StartingAt(x: number, y: number): Path2;
  4001. }
  4002. /**
  4003. * Represents a 3D path made up of multiple 3D points
  4004. */
  4005. export class Path3D {
  4006. /**
  4007. * an array of Vector3, the curve axis of the Path3D
  4008. */
  4009. path: Vector3[];
  4010. private _curve;
  4011. private _distances;
  4012. private _tangents;
  4013. private _normals;
  4014. private _binormals;
  4015. private _raw;
  4016. /**
  4017. * new Path3D(path, normal, raw)
  4018. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4019. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4020. * @param path an array of Vector3, the curve axis of the Path3D
  4021. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4022. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4023. */
  4024. constructor(
  4025. /**
  4026. * an array of Vector3, the curve axis of the Path3D
  4027. */
  4028. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  4029. /**
  4030. * Returns the Path3D array of successive Vector3 designing its curve.
  4031. * @returns the Path3D array of successive Vector3 designing its curve.
  4032. */
  4033. getCurve(): Vector3[];
  4034. /**
  4035. * Returns an array populated with tangent vectors on each Path3D curve point.
  4036. * @returns an array populated with tangent vectors on each Path3D curve point.
  4037. */
  4038. getTangents(): Vector3[];
  4039. /**
  4040. * Returns an array populated with normal vectors on each Path3D curve point.
  4041. * @returns an array populated with normal vectors on each Path3D curve point.
  4042. */
  4043. getNormals(): Vector3[];
  4044. /**
  4045. * Returns an array populated with binormal vectors on each Path3D curve point.
  4046. * @returns an array populated with binormal vectors on each Path3D curve point.
  4047. */
  4048. getBinormals(): Vector3[];
  4049. /**
  4050. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4051. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4052. */
  4053. getDistances(): number[];
  4054. /**
  4055. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4056. * @param path path which all values are copied into the curves points
  4057. * @param firstNormal which should be projected onto the curve
  4058. * @returns the same object updated.
  4059. */
  4060. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4061. private _compute;
  4062. private _getFirstNonNullVector;
  4063. private _getLastNonNullVector;
  4064. private _normalVector;
  4065. }
  4066. /**
  4067. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4068. * A Curve3 is designed from a series of successive Vector3.
  4069. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4070. */
  4071. export class Curve3 {
  4072. private _points;
  4073. private _length;
  4074. /**
  4075. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4076. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4077. * @param v1 (Vector3) the control point
  4078. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4079. * @param nbPoints (integer) the wanted number of points in the curve
  4080. * @returns the created Curve3
  4081. */
  4082. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4083. /**
  4084. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4085. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4086. * @param v1 (Vector3) the first control point
  4087. * @param v2 (Vector3) the second control point
  4088. * @param v3 (Vector3) the end point of the Cubic Bezier
  4089. * @param nbPoints (integer) the wanted number of points in the curve
  4090. * @returns the created Curve3
  4091. */
  4092. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4093. /**
  4094. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4095. * @param p1 (Vector3) the origin point of the Hermite Spline
  4096. * @param t1 (Vector3) the tangent vector at the origin point
  4097. * @param p2 (Vector3) the end point of the Hermite Spline
  4098. * @param t2 (Vector3) the tangent vector at the end point
  4099. * @param nbPoints (integer) the wanted number of points in the curve
  4100. * @returns the created Curve3
  4101. */
  4102. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4103. /**
  4104. * Returns a Curve3 object along a CatmullRom Spline curve :
  4105. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4106. * @param nbPoints (integer) the wanted number of points between each curve control points
  4107. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4108. * @returns the created Curve3
  4109. */
  4110. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4111. /**
  4112. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4113. * A Curve3 is designed from a series of successive Vector3.
  4114. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4115. * @param points points which make up the curve
  4116. */
  4117. constructor(points: Vector3[]);
  4118. /**
  4119. * @returns the Curve3 stored array of successive Vector3
  4120. */
  4121. getPoints(): Vector3[];
  4122. /**
  4123. * @returns the computed length (float) of the curve.
  4124. */
  4125. length(): number;
  4126. /**
  4127. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4128. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4129. * curveA and curveB keep unchanged.
  4130. * @param curve the curve to continue from this curve
  4131. * @returns the newly constructed curve
  4132. */
  4133. continue(curve: DeepImmutable<Curve3>): Curve3;
  4134. private _computeLength;
  4135. }
  4136. /**
  4137. * Contains position and normal vectors for a vertex
  4138. */
  4139. export class PositionNormalVertex {
  4140. /** the position of the vertex (defaut: 0,0,0) */
  4141. position: Vector3;
  4142. /** the normal of the vertex (defaut: 0,1,0) */
  4143. normal: Vector3;
  4144. /**
  4145. * Creates a PositionNormalVertex
  4146. * @param position the position of the vertex (defaut: 0,0,0)
  4147. * @param normal the normal of the vertex (defaut: 0,1,0)
  4148. */
  4149. constructor(
  4150. /** the position of the vertex (defaut: 0,0,0) */
  4151. position?: Vector3,
  4152. /** the normal of the vertex (defaut: 0,1,0) */
  4153. normal?: Vector3);
  4154. /**
  4155. * Clones the PositionNormalVertex
  4156. * @returns the cloned PositionNormalVertex
  4157. */
  4158. clone(): PositionNormalVertex;
  4159. }
  4160. /**
  4161. * Contains position, normal and uv vectors for a vertex
  4162. */
  4163. export class PositionNormalTextureVertex {
  4164. /** the position of the vertex (defaut: 0,0,0) */
  4165. position: Vector3;
  4166. /** the normal of the vertex (defaut: 0,1,0) */
  4167. normal: Vector3;
  4168. /** the uv of the vertex (default: 0,0) */
  4169. uv: Vector2;
  4170. /**
  4171. * Creates a PositionNormalTextureVertex
  4172. * @param position the position of the vertex (defaut: 0,0,0)
  4173. * @param normal the normal of the vertex (defaut: 0,1,0)
  4174. * @param uv the uv of the vertex (default: 0,0)
  4175. */
  4176. constructor(
  4177. /** the position of the vertex (defaut: 0,0,0) */
  4178. position?: Vector3,
  4179. /** the normal of the vertex (defaut: 0,1,0) */
  4180. normal?: Vector3,
  4181. /** the uv of the vertex (default: 0,0) */
  4182. uv?: Vector2);
  4183. /**
  4184. * Clones the PositionNormalTextureVertex
  4185. * @returns the cloned PositionNormalTextureVertex
  4186. */
  4187. clone(): PositionNormalTextureVertex;
  4188. }
  4189. /**
  4190. * @hidden
  4191. */
  4192. export class Tmp {
  4193. static Color3: Color3[];
  4194. static Color4: Color4[];
  4195. static Vector2: Vector2[];
  4196. static Vector3: Vector3[];
  4197. static Vector4: Vector4[];
  4198. static Quaternion: Quaternion[];
  4199. static Matrix: Matrix[];
  4200. }
  4201. }
  4202. declare module "babylonjs/Offline/IOfflineProvider" {
  4203. /**
  4204. * Class used to enable access to offline support
  4205. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4206. */
  4207. export interface IOfflineProvider {
  4208. /**
  4209. * Gets a boolean indicating if scene must be saved in the database
  4210. */
  4211. enableSceneOffline: boolean;
  4212. /**
  4213. * Gets a boolean indicating if textures must be saved in the database
  4214. */
  4215. enableTexturesOffline: boolean;
  4216. /**
  4217. * Open the offline support and make it available
  4218. * @param successCallback defines the callback to call on success
  4219. * @param errorCallback defines the callback to call on error
  4220. */
  4221. open(successCallback: () => void, errorCallback: () => void): void;
  4222. /**
  4223. * Loads an image from the offline support
  4224. * @param url defines the url to load from
  4225. * @param image defines the target DOM image
  4226. */
  4227. loadImage(url: string, image: HTMLImageElement): void;
  4228. /**
  4229. * Loads a file from offline support
  4230. * @param url defines the URL to load from
  4231. * @param sceneLoaded defines a callback to call on success
  4232. * @param progressCallBack defines a callback to call when progress changed
  4233. * @param errorCallback defines a callback to call on error
  4234. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4235. */
  4236. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4237. }
  4238. }
  4239. declare module "babylonjs/Misc/observable" {
  4240. import { Nullable } from "babylonjs/types";
  4241. /**
  4242. * A class serves as a medium between the observable and its observers
  4243. */
  4244. export class EventState {
  4245. /**
  4246. * Create a new EventState
  4247. * @param mask defines the mask associated with this state
  4248. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4249. * @param target defines the original target of the state
  4250. * @param currentTarget defines the current target of the state
  4251. */
  4252. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  4253. /**
  4254. * Initialize the current event state
  4255. * @param mask defines the mask associated with this state
  4256. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4257. * @param target defines the original target of the state
  4258. * @param currentTarget defines the current target of the state
  4259. * @returns the current event state
  4260. */
  4261. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  4262. /**
  4263. * An Observer can set this property to true to prevent subsequent observers of being notified
  4264. */
  4265. skipNextObservers: boolean;
  4266. /**
  4267. * Get the mask value that were used to trigger the event corresponding to this EventState object
  4268. */
  4269. mask: number;
  4270. /**
  4271. * The object that originally notified the event
  4272. */
  4273. target?: any;
  4274. /**
  4275. * The current object in the bubbling phase
  4276. */
  4277. currentTarget?: any;
  4278. /**
  4279. * This will be populated with the return value of the last function that was executed.
  4280. * If it is the first function in the callback chain it will be the event data.
  4281. */
  4282. lastReturnValue?: any;
  4283. }
  4284. /**
  4285. * Represent an Observer registered to a given Observable object.
  4286. */
  4287. export class Observer<T> {
  4288. /**
  4289. * Defines the callback to call when the observer is notified
  4290. */
  4291. callback: (eventData: T, eventState: EventState) => void;
  4292. /**
  4293. * Defines the mask of the observer (used to filter notifications)
  4294. */
  4295. mask: number;
  4296. /**
  4297. * Defines the current scope used to restore the JS context
  4298. */
  4299. scope: any;
  4300. /** @hidden */
  4301. _willBeUnregistered: boolean;
  4302. /**
  4303. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  4304. */
  4305. unregisterOnNextCall: boolean;
  4306. /**
  4307. * Creates a new observer
  4308. * @param callback defines the callback to call when the observer is notified
  4309. * @param mask defines the mask of the observer (used to filter notifications)
  4310. * @param scope defines the current scope used to restore the JS context
  4311. */
  4312. constructor(
  4313. /**
  4314. * Defines the callback to call when the observer is notified
  4315. */
  4316. callback: (eventData: T, eventState: EventState) => void,
  4317. /**
  4318. * Defines the mask of the observer (used to filter notifications)
  4319. */
  4320. mask: number,
  4321. /**
  4322. * Defines the current scope used to restore the JS context
  4323. */
  4324. scope?: any);
  4325. }
  4326. /**
  4327. * Represent a list of observers registered to multiple Observables object.
  4328. */
  4329. export class MultiObserver<T> {
  4330. private _observers;
  4331. private _observables;
  4332. /**
  4333. * Release associated resources
  4334. */
  4335. dispose(): void;
  4336. /**
  4337. * Raise a callback when one of the observable will notify
  4338. * @param observables defines a list of observables to watch
  4339. * @param callback defines the callback to call on notification
  4340. * @param mask defines the mask used to filter notifications
  4341. * @param scope defines the current scope used to restore the JS context
  4342. * @returns the new MultiObserver
  4343. */
  4344. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  4345. }
  4346. /**
  4347. * The Observable class is a simple implementation of the Observable pattern.
  4348. *
  4349. * 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.
  4350. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  4351. * 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).
  4352. * 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.
  4353. */
  4354. export class Observable<T> {
  4355. private _observers;
  4356. private _eventState;
  4357. private _onObserverAdded;
  4358. /**
  4359. * Creates a new observable
  4360. * @param onObserverAdded defines a callback to call when a new observer is added
  4361. */
  4362. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4363. /**
  4364. * Create a new Observer with the specified callback
  4365. * @param callback the callback that will be executed for that Observer
  4366. * @param mask the mask used to filter observers
  4367. * @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.
  4368. * @param scope optional scope for the callback to be called from
  4369. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4370. * @returns the new observer created for the callback
  4371. */
  4372. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4373. /**
  4374. * Create a new Observer with the specified callback and unregisters after the next notification
  4375. * @param callback the callback that will be executed for that Observer
  4376. * @returns the new observer created for the callback
  4377. */
  4378. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4379. /**
  4380. * Remove an Observer from the Observable object
  4381. * @param observer the instance of the Observer to remove
  4382. * @returns false if it doesn't belong to this Observable
  4383. */
  4384. remove(observer: Nullable<Observer<T>>): boolean;
  4385. /**
  4386. * Remove a callback from the Observable object
  4387. * @param callback the callback to remove
  4388. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4389. * @returns false if it doesn't belong to this Observable
  4390. */
  4391. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4392. private _deferUnregister;
  4393. private _remove;
  4394. /**
  4395. * Moves the observable to the top of the observer list making it get called first when notified
  4396. * @param observer the observer to move
  4397. */
  4398. makeObserverTopPriority(observer: Observer<T>): void;
  4399. /**
  4400. * Moves the observable to the bottom of the observer list making it get called last when notified
  4401. * @param observer the observer to move
  4402. */
  4403. makeObserverBottomPriority(observer: Observer<T>): void;
  4404. /**
  4405. * Notify all Observers by calling their respective callback with the given data
  4406. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4407. * @param eventData defines the data to send to all observers
  4408. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4409. * @param target defines the original target of the state
  4410. * @param currentTarget defines the current target of the state
  4411. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4412. */
  4413. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4414. /**
  4415. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4416. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4417. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4418. * and it is crucial that all callbacks will be executed.
  4419. * The order of the callbacks is kept, callbacks are not executed parallel.
  4420. *
  4421. * @param eventData The data to be sent to each callback
  4422. * @param mask is used to filter observers defaults to -1
  4423. * @param target defines the callback target (see EventState)
  4424. * @param currentTarget defines he current object in the bubbling phase
  4425. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4426. */
  4427. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4428. /**
  4429. * Notify a specific observer
  4430. * @param observer defines the observer to notify
  4431. * @param eventData defines the data to be sent to each callback
  4432. * @param mask is used to filter observers defaults to -1
  4433. */
  4434. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4435. /**
  4436. * Gets a boolean indicating if the observable has at least one observer
  4437. * @returns true is the Observable has at least one Observer registered
  4438. */
  4439. hasObservers(): boolean;
  4440. /**
  4441. * Clear the list of observers
  4442. */
  4443. clear(): void;
  4444. /**
  4445. * Clone the current observable
  4446. * @returns a new observable
  4447. */
  4448. clone(): Observable<T>;
  4449. /**
  4450. * Does this observable handles observer registered with a given mask
  4451. * @param mask defines the mask to be tested
  4452. * @return whether or not one observer registered with the given mask is handeled
  4453. **/
  4454. hasSpecificMask(mask?: number): boolean;
  4455. }
  4456. }
  4457. declare module "babylonjs/Misc/filesInputStore" {
  4458. /**
  4459. * Class used to help managing file picking and drag'n'drop
  4460. * File Storage
  4461. */
  4462. export class FilesInputStore {
  4463. /**
  4464. * List of files ready to be loaded
  4465. */
  4466. static FilesToLoad: {
  4467. [key: string]: File;
  4468. };
  4469. }
  4470. }
  4471. declare module "babylonjs/Engines/constants" {
  4472. /** Defines the cross module used constants to avoid circular dependncies */
  4473. export class Constants {
  4474. /** Defines that alpha blending is disabled */
  4475. static readonly ALPHA_DISABLE: number;
  4476. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4477. static readonly ALPHA_ADD: number;
  4478. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4479. static readonly ALPHA_COMBINE: number;
  4480. /** Defines that alpha blending to DEST - SRC * DEST */
  4481. static readonly ALPHA_SUBTRACT: number;
  4482. /** Defines that alpha blending to SRC * DEST */
  4483. static readonly ALPHA_MULTIPLY: number;
  4484. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4485. static readonly ALPHA_MAXIMIZED: number;
  4486. /** Defines that alpha blending to SRC + DEST */
  4487. static readonly ALPHA_ONEONE: number;
  4488. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4489. static readonly ALPHA_PREMULTIPLIED: number;
  4490. /**
  4491. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4492. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4493. */
  4494. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4495. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4496. static readonly ALPHA_INTERPOLATE: number;
  4497. /**
  4498. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4499. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4500. */
  4501. static readonly ALPHA_SCREENMODE: number;
  4502. /** Defines that the ressource is not delayed*/
  4503. static readonly DELAYLOADSTATE_NONE: number;
  4504. /** Defines that the ressource was successfully delay loaded */
  4505. static readonly DELAYLOADSTATE_LOADED: number;
  4506. /** Defines that the ressource is currently delay loading */
  4507. static readonly DELAYLOADSTATE_LOADING: number;
  4508. /** Defines that the ressource is delayed and has not started loading */
  4509. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4510. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4511. static readonly NEVER: number;
  4512. /** 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 */
  4513. static readonly ALWAYS: number;
  4514. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4515. static readonly LESS: number;
  4516. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4517. static readonly EQUAL: number;
  4518. /** 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 */
  4519. static readonly LEQUAL: number;
  4520. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4521. static readonly GREATER: number;
  4522. /** 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 */
  4523. static readonly GEQUAL: number;
  4524. /** 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 */
  4525. static readonly NOTEQUAL: number;
  4526. /** Passed to stencilOperation to specify that stencil value must be kept */
  4527. static readonly KEEP: number;
  4528. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4529. static readonly REPLACE: number;
  4530. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4531. static readonly INCR: number;
  4532. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4533. static readonly DECR: number;
  4534. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4535. static readonly INVERT: number;
  4536. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4537. static readonly INCR_WRAP: number;
  4538. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4539. static readonly DECR_WRAP: number;
  4540. /** Texture is not repeating outside of 0..1 UVs */
  4541. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4542. /** Texture is repeating outside of 0..1 UVs */
  4543. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4544. /** Texture is repeating and mirrored */
  4545. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4546. /** ALPHA */
  4547. static readonly TEXTUREFORMAT_ALPHA: number;
  4548. /** LUMINANCE */
  4549. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4550. /** LUMINANCE_ALPHA */
  4551. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4552. /** RGB */
  4553. static readonly TEXTUREFORMAT_RGB: number;
  4554. /** RGBA */
  4555. static readonly TEXTUREFORMAT_RGBA: number;
  4556. /** RED */
  4557. static readonly TEXTUREFORMAT_RED: number;
  4558. /** RED (2nd reference) */
  4559. static readonly TEXTUREFORMAT_R: number;
  4560. /** RG */
  4561. static readonly TEXTUREFORMAT_RG: number;
  4562. /** RED_INTEGER */
  4563. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4564. /** RED_INTEGER (2nd reference) */
  4565. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4566. /** RG_INTEGER */
  4567. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4568. /** RGB_INTEGER */
  4569. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4570. /** RGBA_INTEGER */
  4571. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4572. /** UNSIGNED_BYTE */
  4573. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4574. /** UNSIGNED_BYTE (2nd reference) */
  4575. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4576. /** FLOAT */
  4577. static readonly TEXTURETYPE_FLOAT: number;
  4578. /** HALF_FLOAT */
  4579. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4580. /** BYTE */
  4581. static readonly TEXTURETYPE_BYTE: number;
  4582. /** SHORT */
  4583. static readonly TEXTURETYPE_SHORT: number;
  4584. /** UNSIGNED_SHORT */
  4585. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4586. /** INT */
  4587. static readonly TEXTURETYPE_INT: number;
  4588. /** UNSIGNED_INT */
  4589. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4590. /** UNSIGNED_SHORT_4_4_4_4 */
  4591. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4592. /** UNSIGNED_SHORT_5_5_5_1 */
  4593. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4594. /** UNSIGNED_SHORT_5_6_5 */
  4595. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4596. /** UNSIGNED_INT_2_10_10_10_REV */
  4597. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4598. /** UNSIGNED_INT_24_8 */
  4599. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4600. /** UNSIGNED_INT_10F_11F_11F_REV */
  4601. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4602. /** UNSIGNED_INT_5_9_9_9_REV */
  4603. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4604. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4605. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4606. /** nearest is mag = nearest and min = nearest and mip = linear */
  4607. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4608. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4609. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4610. /** Trilinear is mag = linear and min = linear and mip = linear */
  4611. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4612. /** nearest is mag = nearest and min = nearest and mip = linear */
  4613. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4614. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4615. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4616. /** Trilinear is mag = linear and min = linear and mip = linear */
  4617. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4618. /** mag = nearest and min = nearest and mip = nearest */
  4619. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4620. /** mag = nearest and min = linear and mip = nearest */
  4621. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4622. /** mag = nearest and min = linear and mip = linear */
  4623. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4624. /** mag = nearest and min = linear and mip = none */
  4625. static readonly TEXTURE_NEAREST_LINEAR: number;
  4626. /** mag = nearest and min = nearest and mip = none */
  4627. static readonly TEXTURE_NEAREST_NEAREST: number;
  4628. /** mag = linear and min = nearest and mip = nearest */
  4629. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4630. /** mag = linear and min = nearest and mip = linear */
  4631. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4632. /** mag = linear and min = linear and mip = none */
  4633. static readonly TEXTURE_LINEAR_LINEAR: number;
  4634. /** mag = linear and min = nearest and mip = none */
  4635. static readonly TEXTURE_LINEAR_NEAREST: number;
  4636. /** Explicit coordinates mode */
  4637. static readonly TEXTURE_EXPLICIT_MODE: number;
  4638. /** Spherical coordinates mode */
  4639. static readonly TEXTURE_SPHERICAL_MODE: number;
  4640. /** Planar coordinates mode */
  4641. static readonly TEXTURE_PLANAR_MODE: number;
  4642. /** Cubic coordinates mode */
  4643. static readonly TEXTURE_CUBIC_MODE: number;
  4644. /** Projection coordinates mode */
  4645. static readonly TEXTURE_PROJECTION_MODE: number;
  4646. /** Skybox coordinates mode */
  4647. static readonly TEXTURE_SKYBOX_MODE: number;
  4648. /** Inverse Cubic coordinates mode */
  4649. static readonly TEXTURE_INVCUBIC_MODE: number;
  4650. /** Equirectangular coordinates mode */
  4651. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4652. /** Equirectangular Fixed coordinates mode */
  4653. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4654. /** Equirectangular Fixed Mirrored coordinates mode */
  4655. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4656. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4657. static readonly SCALEMODE_FLOOR: number;
  4658. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4659. static readonly SCALEMODE_NEAREST: number;
  4660. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4661. static readonly SCALEMODE_CEILING: number;
  4662. /**
  4663. * The dirty texture flag value
  4664. */
  4665. static readonly MATERIAL_TextureDirtyFlag: number;
  4666. /**
  4667. * The dirty light flag value
  4668. */
  4669. static readonly MATERIAL_LightDirtyFlag: number;
  4670. /**
  4671. * The dirty fresnel flag value
  4672. */
  4673. static readonly MATERIAL_FresnelDirtyFlag: number;
  4674. /**
  4675. * The dirty attribute flag value
  4676. */
  4677. static readonly MATERIAL_AttributesDirtyFlag: number;
  4678. /**
  4679. * The dirty misc flag value
  4680. */
  4681. static readonly MATERIAL_MiscDirtyFlag: number;
  4682. /**
  4683. * The all dirty flag value
  4684. */
  4685. static readonly MATERIAL_AllDirtyFlag: number;
  4686. /**
  4687. * Returns the triangle fill mode
  4688. */
  4689. static readonly MATERIAL_TriangleFillMode: number;
  4690. /**
  4691. * Returns the wireframe mode
  4692. */
  4693. static readonly MATERIAL_WireFrameFillMode: number;
  4694. /**
  4695. * Returns the point fill mode
  4696. */
  4697. static readonly MATERIAL_PointFillMode: number;
  4698. /**
  4699. * Returns the point list draw mode
  4700. */
  4701. static readonly MATERIAL_PointListDrawMode: number;
  4702. /**
  4703. * Returns the line list draw mode
  4704. */
  4705. static readonly MATERIAL_LineListDrawMode: number;
  4706. /**
  4707. * Returns the line loop draw mode
  4708. */
  4709. static readonly MATERIAL_LineLoopDrawMode: number;
  4710. /**
  4711. * Returns the line strip draw mode
  4712. */
  4713. static readonly MATERIAL_LineStripDrawMode: number;
  4714. /**
  4715. * Returns the triangle strip draw mode
  4716. */
  4717. static readonly MATERIAL_TriangleStripDrawMode: number;
  4718. /**
  4719. * Returns the triangle fan draw mode
  4720. */
  4721. static readonly MATERIAL_TriangleFanDrawMode: number;
  4722. /**
  4723. * Stores the clock-wise side orientation
  4724. */
  4725. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4726. /**
  4727. * Stores the counter clock-wise side orientation
  4728. */
  4729. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4730. /**
  4731. * Nothing
  4732. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4733. */
  4734. static readonly ACTION_NothingTrigger: number;
  4735. /**
  4736. * On pick
  4737. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4738. */
  4739. static readonly ACTION_OnPickTrigger: number;
  4740. /**
  4741. * On left pick
  4742. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4743. */
  4744. static readonly ACTION_OnLeftPickTrigger: number;
  4745. /**
  4746. * On right pick
  4747. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4748. */
  4749. static readonly ACTION_OnRightPickTrigger: number;
  4750. /**
  4751. * On center pick
  4752. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4753. */
  4754. static readonly ACTION_OnCenterPickTrigger: number;
  4755. /**
  4756. * On pick down
  4757. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4758. */
  4759. static readonly ACTION_OnPickDownTrigger: number;
  4760. /**
  4761. * On double pick
  4762. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4763. */
  4764. static readonly ACTION_OnDoublePickTrigger: number;
  4765. /**
  4766. * On pick up
  4767. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4768. */
  4769. static readonly ACTION_OnPickUpTrigger: number;
  4770. /**
  4771. * On pick out.
  4772. * This trigger will only be raised if you also declared a OnPickDown
  4773. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4774. */
  4775. static readonly ACTION_OnPickOutTrigger: number;
  4776. /**
  4777. * On long press
  4778. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4779. */
  4780. static readonly ACTION_OnLongPressTrigger: number;
  4781. /**
  4782. * On pointer over
  4783. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4784. */
  4785. static readonly ACTION_OnPointerOverTrigger: number;
  4786. /**
  4787. * On pointer out
  4788. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4789. */
  4790. static readonly ACTION_OnPointerOutTrigger: number;
  4791. /**
  4792. * On every frame
  4793. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4794. */
  4795. static readonly ACTION_OnEveryFrameTrigger: number;
  4796. /**
  4797. * On intersection enter
  4798. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4799. */
  4800. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4801. /**
  4802. * On intersection exit
  4803. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4804. */
  4805. static readonly ACTION_OnIntersectionExitTrigger: number;
  4806. /**
  4807. * On key down
  4808. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4809. */
  4810. static readonly ACTION_OnKeyDownTrigger: number;
  4811. /**
  4812. * On key up
  4813. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4814. */
  4815. static readonly ACTION_OnKeyUpTrigger: number;
  4816. /**
  4817. * Billboard mode will only apply to Y axis
  4818. */
  4819. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4820. /**
  4821. * Billboard mode will apply to all axes
  4822. */
  4823. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4824. /**
  4825. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4826. */
  4827. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4828. /**
  4829. * Gets or sets base Assets URL
  4830. */
  4831. static PARTICLES_BaseAssetsUrl: string;
  4832. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4833. * Test order :
  4834. * Is the bounding sphere outside the frustum ?
  4835. * If not, are the bounding box vertices outside the frustum ?
  4836. * It not, then the cullable object is in the frustum.
  4837. */
  4838. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4839. /** Culling strategy : Bounding Sphere Only.
  4840. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4841. * It's also less accurate than the standard because some not visible objects can still be selected.
  4842. * Test : is the bounding sphere outside the frustum ?
  4843. * If not, then the cullable object is in the frustum.
  4844. */
  4845. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4846. /** Culling strategy : Optimistic Inclusion.
  4847. * This in an inclusion test first, then the standard exclusion test.
  4848. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4849. * 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.
  4850. * Anyway, it's as accurate as the standard strategy.
  4851. * Test :
  4852. * Is the cullable object bounding sphere center in the frustum ?
  4853. * If not, apply the default culling strategy.
  4854. */
  4855. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4856. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4857. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4858. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4859. * 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.
  4860. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4861. * Test :
  4862. * Is the cullable object bounding sphere center in the frustum ?
  4863. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4864. */
  4865. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4866. /**
  4867. * No logging while loading
  4868. */
  4869. static readonly SCENELOADER_NO_LOGGING: number;
  4870. /**
  4871. * Minimal logging while loading
  4872. */
  4873. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4874. /**
  4875. * Summary logging while loading
  4876. */
  4877. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4878. /**
  4879. * Detailled logging while loading
  4880. */
  4881. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4882. }
  4883. }
  4884. declare module "babylonjs/Misc/domManagement" {
  4885. /**
  4886. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4887. * Babylon.js
  4888. */
  4889. export class DomManagement {
  4890. /**
  4891. * Checks if the window object exists
  4892. * @returns true if the window object exists
  4893. */
  4894. static IsWindowObjectExist(): boolean;
  4895. /**
  4896. * Extracts text content from a DOM element hierarchy
  4897. * @param element defines the root element
  4898. * @returns a string
  4899. */
  4900. static GetDOMTextContent(element: HTMLElement): string;
  4901. }
  4902. }
  4903. declare module "babylonjs/Misc/logger" {
  4904. /**
  4905. * Logger used througouht the application to allow configuration of
  4906. * the log level required for the messages.
  4907. */
  4908. export class Logger {
  4909. /**
  4910. * No log
  4911. */
  4912. static readonly NoneLogLevel: number;
  4913. /**
  4914. * Only message logs
  4915. */
  4916. static readonly MessageLogLevel: number;
  4917. /**
  4918. * Only warning logs
  4919. */
  4920. static readonly WarningLogLevel: number;
  4921. /**
  4922. * Only error logs
  4923. */
  4924. static readonly ErrorLogLevel: number;
  4925. /**
  4926. * All logs
  4927. */
  4928. static readonly AllLogLevel: number;
  4929. private static _LogCache;
  4930. /**
  4931. * Gets a value indicating the number of loading errors
  4932. * @ignorenaming
  4933. */
  4934. static errorsCount: number;
  4935. /**
  4936. * Callback called when a new log is added
  4937. */
  4938. static OnNewCacheEntry: (entry: string) => void;
  4939. private static _AddLogEntry;
  4940. private static _FormatMessage;
  4941. private static _LogDisabled;
  4942. private static _LogEnabled;
  4943. private static _WarnDisabled;
  4944. private static _WarnEnabled;
  4945. private static _ErrorDisabled;
  4946. private static _ErrorEnabled;
  4947. /**
  4948. * Log a message to the console
  4949. */
  4950. static Log: (message: string) => void;
  4951. /**
  4952. * Write a warning message to the console
  4953. */
  4954. static Warn: (message: string) => void;
  4955. /**
  4956. * Write an error message to the console
  4957. */
  4958. static Error: (message: string) => void;
  4959. /**
  4960. * Gets current log cache (list of logs)
  4961. */
  4962. static readonly LogCache: string;
  4963. /**
  4964. * Clears the log cache
  4965. */
  4966. static ClearLogCache(): void;
  4967. /**
  4968. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4969. */
  4970. static LogLevels: number;
  4971. }
  4972. }
  4973. declare module "babylonjs/Misc/typeStore" {
  4974. /** @hidden */
  4975. export class _TypeStore {
  4976. /** @hidden */
  4977. static RegisteredTypes: {
  4978. [key: string]: Object;
  4979. };
  4980. /** @hidden */
  4981. static GetClass(fqdn: string): any;
  4982. }
  4983. }
  4984. declare module "babylonjs/Misc/deepCopier" {
  4985. /**
  4986. * Class containing a set of static utilities functions for deep copy.
  4987. */
  4988. export class DeepCopier {
  4989. /**
  4990. * Tries to copy an object by duplicating every property
  4991. * @param source defines the source object
  4992. * @param destination defines the target object
  4993. * @param doNotCopyList defines a list of properties to avoid
  4994. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4995. */
  4996. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4997. }
  4998. }
  4999. declare module "babylonjs/Misc/precisionDate" {
  5000. /**
  5001. * Class containing a set of static utilities functions for precision date
  5002. */
  5003. export class PrecisionDate {
  5004. /**
  5005. * Gets either window.performance.now() if supported or Date.now() else
  5006. */
  5007. static readonly Now: number;
  5008. }
  5009. }
  5010. declare module "babylonjs/Misc/devTools" {
  5011. /** @hidden */
  5012. export class _DevTools {
  5013. static WarnImport(name: string): string;
  5014. }
  5015. }
  5016. declare module "babylonjs/Misc/webRequest" {
  5017. /**
  5018. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  5019. */
  5020. export class WebRequest {
  5021. private _xhr;
  5022. /**
  5023. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  5024. * i.e. when loading files, where the server/service expects an Authorization header
  5025. */
  5026. static CustomRequestHeaders: {
  5027. [key: string]: string;
  5028. };
  5029. /**
  5030. * Add callback functions in this array to update all the requests before they get sent to the network
  5031. */
  5032. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  5033. private _injectCustomRequestHeaders;
  5034. /**
  5035. * Gets or sets a function to be called when loading progress changes
  5036. */
  5037. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  5038. /**
  5039. * Returns client's state
  5040. */
  5041. readonly readyState: number;
  5042. /**
  5043. * Returns client's status
  5044. */
  5045. readonly status: number;
  5046. /**
  5047. * Returns client's status as a text
  5048. */
  5049. readonly statusText: string;
  5050. /**
  5051. * Returns client's response
  5052. */
  5053. readonly response: any;
  5054. /**
  5055. * Returns client's response url
  5056. */
  5057. readonly responseURL: string;
  5058. /**
  5059. * Returns client's response as text
  5060. */
  5061. readonly responseText: string;
  5062. /**
  5063. * Gets or sets the expected response type
  5064. */
  5065. responseType: XMLHttpRequestResponseType;
  5066. /** @hidden */
  5067. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  5068. /** @hidden */
  5069. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  5070. /**
  5071. * Cancels any network activity
  5072. */
  5073. abort(): void;
  5074. /**
  5075. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  5076. * @param body defines an optional request body
  5077. */
  5078. send(body?: Document | BodyInit | null): void;
  5079. /**
  5080. * Sets the request method, request URL
  5081. * @param method defines the method to use (GET, POST, etc..)
  5082. * @param url defines the url to connect with
  5083. */
  5084. open(method: string, url: string): void;
  5085. }
  5086. }
  5087. declare module "babylonjs/Misc/andOrNotEvaluator" {
  5088. /**
  5089. * Class used to evalaute queries containing `and` and `or` operators
  5090. */
  5091. export class AndOrNotEvaluator {
  5092. /**
  5093. * Evaluate a query
  5094. * @param query defines the query to evaluate
  5095. * @param evaluateCallback defines the callback used to filter result
  5096. * @returns true if the query matches
  5097. */
  5098. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5099. private static _HandleParenthesisContent;
  5100. private static _SimplifyNegation;
  5101. }
  5102. }
  5103. declare module "babylonjs/Misc/tags" {
  5104. /**
  5105. * Class used to store custom tags
  5106. */
  5107. export class Tags {
  5108. /**
  5109. * Adds support for tags on the given object
  5110. * @param obj defines the object to use
  5111. */
  5112. static EnableFor(obj: any): void;
  5113. /**
  5114. * Removes tags support
  5115. * @param obj defines the object to use
  5116. */
  5117. static DisableFor(obj: any): void;
  5118. /**
  5119. * Gets a boolean indicating if the given object has tags
  5120. * @param obj defines the object to use
  5121. * @returns a boolean
  5122. */
  5123. static HasTags(obj: any): boolean;
  5124. /**
  5125. * Gets the tags available on a given object
  5126. * @param obj defines the object to use
  5127. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5128. * @returns the tags
  5129. */
  5130. static GetTags(obj: any, asString?: boolean): any;
  5131. /**
  5132. * Adds tags to an object
  5133. * @param obj defines the object to use
  5134. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5135. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5136. */
  5137. static AddTagsTo(obj: any, tagsString: string): void;
  5138. /**
  5139. * @hidden
  5140. */
  5141. static _AddTagTo(obj: any, tag: string): void;
  5142. /**
  5143. * Removes specific tags from a specific object
  5144. * @param obj defines the object to use
  5145. * @param tagsString defines the tags to remove
  5146. */
  5147. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5148. /**
  5149. * @hidden
  5150. */
  5151. static _RemoveTagFrom(obj: any, tag: string): void;
  5152. /**
  5153. * Defines if tags hosted on an object match a given query
  5154. * @param obj defines the object to use
  5155. * @param tagsQuery defines the tag query
  5156. * @returns a boolean
  5157. */
  5158. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5159. }
  5160. }
  5161. declare module "babylonjs/Materials/materialDefines" {
  5162. /**
  5163. * Manages the defines for the Material
  5164. */
  5165. export class MaterialDefines {
  5166. /** @hidden */
  5167. protected _keys: string[];
  5168. private _isDirty;
  5169. /** @hidden */
  5170. _renderId: number;
  5171. /** @hidden */
  5172. _areLightsDirty: boolean;
  5173. /** @hidden */
  5174. _areAttributesDirty: boolean;
  5175. /** @hidden */
  5176. _areTexturesDirty: boolean;
  5177. /** @hidden */
  5178. _areFresnelDirty: boolean;
  5179. /** @hidden */
  5180. _areMiscDirty: boolean;
  5181. /** @hidden */
  5182. _areImageProcessingDirty: boolean;
  5183. /** @hidden */
  5184. _normals: boolean;
  5185. /** @hidden */
  5186. _uvs: boolean;
  5187. /** @hidden */
  5188. _needNormals: boolean;
  5189. /** @hidden */
  5190. _needUVs: boolean;
  5191. [id: string]: any;
  5192. /**
  5193. * Specifies if the material needs to be re-calculated
  5194. */
  5195. readonly isDirty: boolean;
  5196. /**
  5197. * Marks the material to indicate that it has been re-calculated
  5198. */
  5199. markAsProcessed(): void;
  5200. /**
  5201. * Marks the material to indicate that it needs to be re-calculated
  5202. */
  5203. markAsUnprocessed(): void;
  5204. /**
  5205. * Marks the material to indicate all of its defines need to be re-calculated
  5206. */
  5207. markAllAsDirty(): void;
  5208. /**
  5209. * Marks the material to indicate that image processing needs to be re-calculated
  5210. */
  5211. markAsImageProcessingDirty(): void;
  5212. /**
  5213. * Marks the material to indicate the lights need to be re-calculated
  5214. */
  5215. markAsLightDirty(): void;
  5216. /**
  5217. * Marks the attribute state as changed
  5218. */
  5219. markAsAttributesDirty(): void;
  5220. /**
  5221. * Marks the texture state as changed
  5222. */
  5223. markAsTexturesDirty(): void;
  5224. /**
  5225. * Marks the fresnel state as changed
  5226. */
  5227. markAsFresnelDirty(): void;
  5228. /**
  5229. * Marks the misc state as changed
  5230. */
  5231. markAsMiscDirty(): void;
  5232. /**
  5233. * Rebuilds the material defines
  5234. */
  5235. rebuild(): void;
  5236. /**
  5237. * Specifies if two material defines are equal
  5238. * @param other - A material define instance to compare to
  5239. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5240. */
  5241. isEqual(other: MaterialDefines): boolean;
  5242. /**
  5243. * Clones this instance's defines to another instance
  5244. * @param other - material defines to clone values to
  5245. */
  5246. cloneTo(other: MaterialDefines): void;
  5247. /**
  5248. * Resets the material define values
  5249. */
  5250. reset(): void;
  5251. /**
  5252. * Converts the material define values to a string
  5253. * @returns - String of material define information
  5254. */
  5255. toString(): string;
  5256. }
  5257. }
  5258. declare module "babylonjs/Engines/IPipelineContext" {
  5259. /**
  5260. * Class used to store and describe the pipeline context associated with an effect
  5261. */
  5262. export interface IPipelineContext {
  5263. /**
  5264. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  5265. */
  5266. isAsync: boolean;
  5267. /**
  5268. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  5269. */
  5270. isReady: boolean;
  5271. /** @hidden */
  5272. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  5273. }
  5274. }
  5275. declare module "babylonjs/Meshes/dataBuffer" {
  5276. /**
  5277. * Class used to store gfx data (like WebGLBuffer)
  5278. */
  5279. export class DataBuffer {
  5280. /**
  5281. * Gets or sets the number of objects referencing this buffer
  5282. */
  5283. references: number;
  5284. /** Gets or sets the size of the underlying buffer */
  5285. capacity: number;
  5286. /**
  5287. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  5288. */
  5289. is32Bits: boolean;
  5290. /**
  5291. * Gets the underlying buffer
  5292. */
  5293. readonly underlyingResource: any;
  5294. }
  5295. }
  5296. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  5297. /** @hidden */
  5298. export interface IShaderProcessor {
  5299. attributeProcessor?: (attribute: string) => string;
  5300. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  5301. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  5302. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  5303. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  5304. lineProcessor?: (line: string, isFragment: boolean) => string;
  5305. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  5306. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  5307. }
  5308. }
  5309. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  5310. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  5311. /** @hidden */
  5312. export interface ProcessingOptions {
  5313. defines: string[];
  5314. indexParameters: any;
  5315. isFragment: boolean;
  5316. shouldUseHighPrecisionShader: boolean;
  5317. supportsUniformBuffers: boolean;
  5318. shadersRepository: string;
  5319. includesShadersStore: {
  5320. [key: string]: string;
  5321. };
  5322. processor?: IShaderProcessor;
  5323. version: string;
  5324. platformName: string;
  5325. lookForClosingBracketForUniformBuffer?: boolean;
  5326. }
  5327. }
  5328. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  5329. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  5330. /** @hidden */
  5331. export class ShaderCodeNode {
  5332. line: string;
  5333. children: ShaderCodeNode[];
  5334. additionalDefineKey?: string;
  5335. additionalDefineValue?: string;
  5336. isValid(preprocessors: {
  5337. [key: string]: string;
  5338. }): boolean;
  5339. process(preprocessors: {
  5340. [key: string]: string;
  5341. }, options: ProcessingOptions): string;
  5342. }
  5343. }
  5344. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  5345. /** @hidden */
  5346. export class ShaderCodeCursor {
  5347. private _lines;
  5348. lineIndex: number;
  5349. readonly currentLine: string;
  5350. readonly canRead: boolean;
  5351. lines: string[];
  5352. }
  5353. }
  5354. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  5355. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  5356. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  5357. /** @hidden */
  5358. export class ShaderCodeConditionNode extends ShaderCodeNode {
  5359. process(preprocessors: {
  5360. [key: string]: string;
  5361. }, options: ProcessingOptions): string;
  5362. }
  5363. }
  5364. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  5365. /** @hidden */
  5366. export class ShaderDefineExpression {
  5367. isTrue(preprocessors: {
  5368. [key: string]: string;
  5369. }): boolean;
  5370. }
  5371. }
  5372. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  5373. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  5374. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  5375. /** @hidden */
  5376. export class ShaderCodeTestNode extends ShaderCodeNode {
  5377. testExpression: ShaderDefineExpression;
  5378. isValid(preprocessors: {
  5379. [key: string]: string;
  5380. }): boolean;
  5381. }
  5382. }
  5383. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  5384. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  5385. /** @hidden */
  5386. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  5387. define: string;
  5388. not: boolean;
  5389. constructor(define: string, not?: boolean);
  5390. isTrue(preprocessors: {
  5391. [key: string]: string;
  5392. }): boolean;
  5393. }
  5394. }
  5395. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  5396. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  5397. /** @hidden */
  5398. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  5399. leftOperand: ShaderDefineExpression;
  5400. rightOperand: ShaderDefineExpression;
  5401. isTrue(preprocessors: {
  5402. [key: string]: string;
  5403. }): boolean;
  5404. }
  5405. }
  5406. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  5407. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  5408. /** @hidden */
  5409. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  5410. leftOperand: ShaderDefineExpression;
  5411. rightOperand: ShaderDefineExpression;
  5412. isTrue(preprocessors: {
  5413. [key: string]: string;
  5414. }): boolean;
  5415. }
  5416. }
  5417. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  5418. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  5419. /** @hidden */
  5420. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  5421. define: string;
  5422. operand: string;
  5423. testValue: string;
  5424. constructor(define: string, operand: string, testValue: string);
  5425. isTrue(preprocessors: {
  5426. [key: string]: string;
  5427. }): boolean;
  5428. }
  5429. }
  5430. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  5431. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  5432. /** @hidden */
  5433. export class ShaderProcessor {
  5434. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  5435. private static _ProcessPrecision;
  5436. private static _ExtractOperation;
  5437. private static _BuildSubExpression;
  5438. private static _BuildExpression;
  5439. private static _MoveCursorWithinIf;
  5440. private static _MoveCursor;
  5441. private static _EvaluatePreProcessors;
  5442. private static _PreparePreProcessors;
  5443. private static _ProcessShaderConversion;
  5444. private static _ProcessIncludes;
  5445. }
  5446. }
  5447. declare module "babylonjs/Misc/performanceMonitor" {
  5448. /**
  5449. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5450. */
  5451. export class PerformanceMonitor {
  5452. private _enabled;
  5453. private _rollingFrameTime;
  5454. private _lastFrameTimeMs;
  5455. /**
  5456. * constructor
  5457. * @param frameSampleSize The number of samples required to saturate the sliding window
  5458. */
  5459. constructor(frameSampleSize?: number);
  5460. /**
  5461. * Samples current frame
  5462. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5463. */
  5464. sampleFrame(timeMs?: number): void;
  5465. /**
  5466. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5467. */
  5468. readonly averageFrameTime: number;
  5469. /**
  5470. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5471. */
  5472. readonly averageFrameTimeVariance: number;
  5473. /**
  5474. * Returns the frame time of the most recent frame
  5475. */
  5476. readonly instantaneousFrameTime: number;
  5477. /**
  5478. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5479. */
  5480. readonly averageFPS: number;
  5481. /**
  5482. * Returns the average framerate in frames per second using the most recent frame time
  5483. */
  5484. readonly instantaneousFPS: number;
  5485. /**
  5486. * Returns true if enough samples have been taken to completely fill the sliding window
  5487. */
  5488. readonly isSaturated: boolean;
  5489. /**
  5490. * Enables contributions to the sliding window sample set
  5491. */
  5492. enable(): void;
  5493. /**
  5494. * Disables contributions to the sliding window sample set
  5495. * Samples will not be interpolated over the disabled period
  5496. */
  5497. disable(): void;
  5498. /**
  5499. * Returns true if sampling is enabled
  5500. */
  5501. readonly isEnabled: boolean;
  5502. /**
  5503. * Resets performance monitor
  5504. */
  5505. reset(): void;
  5506. }
  5507. /**
  5508. * RollingAverage
  5509. *
  5510. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5511. */
  5512. export class RollingAverage {
  5513. /**
  5514. * Current average
  5515. */
  5516. average: number;
  5517. /**
  5518. * Current variance
  5519. */
  5520. variance: number;
  5521. protected _samples: Array<number>;
  5522. protected _sampleCount: number;
  5523. protected _pos: number;
  5524. protected _m2: number;
  5525. /**
  5526. * constructor
  5527. * @param length The number of samples required to saturate the sliding window
  5528. */
  5529. constructor(length: number);
  5530. /**
  5531. * Adds a sample to the sample set
  5532. * @param v The sample value
  5533. */
  5534. add(v: number): void;
  5535. /**
  5536. * Returns previously added values or null if outside of history or outside the sliding window domain
  5537. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5538. * @return Value previously recorded with add() or null if outside of range
  5539. */
  5540. history(i: number): number;
  5541. /**
  5542. * Returns true if enough samples have been taken to completely fill the sliding window
  5543. * @return true if sample-set saturated
  5544. */
  5545. isSaturated(): boolean;
  5546. /**
  5547. * Resets the rolling average (equivalent to 0 samples taken so far)
  5548. */
  5549. reset(): void;
  5550. /**
  5551. * Wraps a value around the sample range boundaries
  5552. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5553. * @return Wrapped position in sample range
  5554. */
  5555. protected _wrapPosition(i: number): number;
  5556. }
  5557. }
  5558. declare module "babylonjs/Misc/stringDictionary" {
  5559. import { Nullable } from "babylonjs/types";
  5560. /**
  5561. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5562. * The underlying implementation relies on an associative array to ensure the best performances.
  5563. * The value can be anything including 'null' but except 'undefined'
  5564. */
  5565. export class StringDictionary<T> {
  5566. /**
  5567. * This will clear this dictionary and copy the content from the 'source' one.
  5568. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5569. * @param source the dictionary to take the content from and copy to this dictionary
  5570. */
  5571. copyFrom(source: StringDictionary<T>): void;
  5572. /**
  5573. * Get a value based from its key
  5574. * @param key the given key to get the matching value from
  5575. * @return the value if found, otherwise undefined is returned
  5576. */
  5577. get(key: string): T | undefined;
  5578. /**
  5579. * Get a value from its key or add it if it doesn't exist.
  5580. * This method will ensure you that a given key/data will be present in the dictionary.
  5581. * @param key the given key to get the matching value from
  5582. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5583. * The factory will only be invoked if there's no data for the given key.
  5584. * @return the value corresponding to the key.
  5585. */
  5586. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5587. /**
  5588. * Get a value from its key if present in the dictionary otherwise add it
  5589. * @param key the key to get the value from
  5590. * @param val if there's no such key/value pair in the dictionary add it with this value
  5591. * @return the value corresponding to the key
  5592. */
  5593. getOrAdd(key: string, val: T): T;
  5594. /**
  5595. * Check if there's a given key in the dictionary
  5596. * @param key the key to check for
  5597. * @return true if the key is present, false otherwise
  5598. */
  5599. contains(key: string): boolean;
  5600. /**
  5601. * Add a new key and its corresponding value
  5602. * @param key the key to add
  5603. * @param value the value corresponding to the key
  5604. * @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
  5605. */
  5606. add(key: string, value: T): boolean;
  5607. /**
  5608. * Update a specific value associated to a key
  5609. * @param key defines the key to use
  5610. * @param value defines the value to store
  5611. * @returns true if the value was updated (or false if the key was not found)
  5612. */
  5613. set(key: string, value: T): boolean;
  5614. /**
  5615. * Get the element of the given key and remove it from the dictionary
  5616. * @param key defines the key to search
  5617. * @returns the value associated with the key or null if not found
  5618. */
  5619. getAndRemove(key: string): Nullable<T>;
  5620. /**
  5621. * Remove a key/value from the dictionary.
  5622. * @param key the key to remove
  5623. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5624. */
  5625. remove(key: string): boolean;
  5626. /**
  5627. * Clear the whole content of the dictionary
  5628. */
  5629. clear(): void;
  5630. /**
  5631. * Gets the current count
  5632. */
  5633. readonly count: number;
  5634. /**
  5635. * Execute a callback on each key/val of the dictionary.
  5636. * Note that you can remove any element in this dictionary in the callback implementation
  5637. * @param callback the callback to execute on a given key/value pair
  5638. */
  5639. forEach(callback: (key: string, val: T) => void): void;
  5640. /**
  5641. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5642. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5643. * Note that you can remove any element in this dictionary in the callback implementation
  5644. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5645. * @returns the first item
  5646. */
  5647. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5648. private _count;
  5649. private _data;
  5650. }
  5651. }
  5652. declare module "babylonjs/Misc/promise" {
  5653. /**
  5654. * Helper class that provides a small promise polyfill
  5655. */
  5656. export class PromisePolyfill {
  5657. /**
  5658. * Static function used to check if the polyfill is required
  5659. * If this is the case then the function will inject the polyfill to window.Promise
  5660. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5661. */
  5662. static Apply(force?: boolean): void;
  5663. }
  5664. }
  5665. declare module "babylonjs/Meshes/buffer" {
  5666. import { Nullable, DataArray } from "babylonjs/types";
  5667. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  5668. /**
  5669. * Class used to store data that will be store in GPU memory
  5670. */
  5671. export class Buffer {
  5672. private _engine;
  5673. private _buffer;
  5674. /** @hidden */
  5675. _data: Nullable<DataArray>;
  5676. private _updatable;
  5677. private _instanced;
  5678. /**
  5679. * Gets the byte stride.
  5680. */
  5681. readonly byteStride: number;
  5682. /**
  5683. * Constructor
  5684. * @param engine the engine
  5685. * @param data the data to use for this buffer
  5686. * @param updatable whether the data is updatable
  5687. * @param stride the stride (optional)
  5688. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5689. * @param instanced whether the buffer is instanced (optional)
  5690. * @param useBytes set to true if the stride in in bytes (optional)
  5691. */
  5692. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5693. /**
  5694. * Create a new VertexBuffer based on the current buffer
  5695. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5696. * @param offset defines offset in the buffer (0 by default)
  5697. * @param size defines the size in floats of attributes (position is 3 for instance)
  5698. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5699. * @param instanced defines if the vertex buffer contains indexed data
  5700. * @param useBytes defines if the offset and stride are in bytes
  5701. * @returns the new vertex buffer
  5702. */
  5703. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5704. /**
  5705. * Gets a boolean indicating if the Buffer is updatable?
  5706. * @returns true if the buffer is updatable
  5707. */
  5708. isUpdatable(): boolean;
  5709. /**
  5710. * Gets current buffer's data
  5711. * @returns a DataArray or null
  5712. */
  5713. getData(): Nullable<DataArray>;
  5714. /**
  5715. * Gets underlying native buffer
  5716. * @returns underlying native buffer
  5717. */
  5718. getBuffer(): Nullable<DataBuffer>;
  5719. /**
  5720. * Gets the stride in float32 units (i.e. byte stride / 4).
  5721. * May not be an integer if the byte stride is not divisible by 4.
  5722. * DEPRECATED. Use byteStride instead.
  5723. * @returns the stride in float32 units
  5724. */
  5725. getStrideSize(): number;
  5726. /**
  5727. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5728. * @param data defines the data to store
  5729. */
  5730. create(data?: Nullable<DataArray>): void;
  5731. /** @hidden */
  5732. _rebuild(): void;
  5733. /**
  5734. * Update current buffer data
  5735. * @param data defines the data to store
  5736. */
  5737. update(data: DataArray): void;
  5738. /**
  5739. * Updates the data directly.
  5740. * @param data the new data
  5741. * @param offset the new offset
  5742. * @param vertexCount the vertex count (optional)
  5743. * @param useBytes set to true if the offset is in bytes
  5744. */
  5745. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5746. /**
  5747. * Release all resources
  5748. */
  5749. dispose(): void;
  5750. }
  5751. /**
  5752. * Specialized buffer used to store vertex data
  5753. */
  5754. export class VertexBuffer {
  5755. /** @hidden */
  5756. _buffer: Buffer;
  5757. private _kind;
  5758. private _size;
  5759. private _ownsBuffer;
  5760. private _instanced;
  5761. private _instanceDivisor;
  5762. /**
  5763. * The byte type.
  5764. */
  5765. static readonly BYTE: number;
  5766. /**
  5767. * The unsigned byte type.
  5768. */
  5769. static readonly UNSIGNED_BYTE: number;
  5770. /**
  5771. * The short type.
  5772. */
  5773. static readonly SHORT: number;
  5774. /**
  5775. * The unsigned short type.
  5776. */
  5777. static readonly UNSIGNED_SHORT: number;
  5778. /**
  5779. * The integer type.
  5780. */
  5781. static readonly INT: number;
  5782. /**
  5783. * The unsigned integer type.
  5784. */
  5785. static readonly UNSIGNED_INT: number;
  5786. /**
  5787. * The float type.
  5788. */
  5789. static readonly FLOAT: number;
  5790. /**
  5791. * Gets or sets the instance divisor when in instanced mode
  5792. */
  5793. instanceDivisor: number;
  5794. /**
  5795. * Gets the byte stride.
  5796. */
  5797. readonly byteStride: number;
  5798. /**
  5799. * Gets the byte offset.
  5800. */
  5801. readonly byteOffset: number;
  5802. /**
  5803. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5804. */
  5805. readonly normalized: boolean;
  5806. /**
  5807. * Gets the data type of each component in the array.
  5808. */
  5809. readonly type: number;
  5810. /**
  5811. * Constructor
  5812. * @param engine the engine
  5813. * @param data the data to use for this vertex buffer
  5814. * @param kind the vertex buffer kind
  5815. * @param updatable whether the data is updatable
  5816. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5817. * @param stride the stride (optional)
  5818. * @param instanced whether the buffer is instanced (optional)
  5819. * @param offset the offset of the data (optional)
  5820. * @param size the number of components (optional)
  5821. * @param type the type of the component (optional)
  5822. * @param normalized whether the data contains normalized data (optional)
  5823. * @param useBytes set to true if stride and offset are in bytes (optional)
  5824. */
  5825. 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);
  5826. /** @hidden */
  5827. _rebuild(): void;
  5828. /**
  5829. * Returns the kind of the VertexBuffer (string)
  5830. * @returns a string
  5831. */
  5832. getKind(): string;
  5833. /**
  5834. * Gets a boolean indicating if the VertexBuffer is updatable?
  5835. * @returns true if the buffer is updatable
  5836. */
  5837. isUpdatable(): boolean;
  5838. /**
  5839. * Gets current buffer's data
  5840. * @returns a DataArray or null
  5841. */
  5842. getData(): Nullable<DataArray>;
  5843. /**
  5844. * Gets underlying native buffer
  5845. * @returns underlying native buffer
  5846. */
  5847. getBuffer(): Nullable<DataBuffer>;
  5848. /**
  5849. * Gets the stride in float32 units (i.e. byte stride / 4).
  5850. * May not be an integer if the byte stride is not divisible by 4.
  5851. * DEPRECATED. Use byteStride instead.
  5852. * @returns the stride in float32 units
  5853. */
  5854. getStrideSize(): number;
  5855. /**
  5856. * Returns the offset as a multiple of the type byte length.
  5857. * DEPRECATED. Use byteOffset instead.
  5858. * @returns the offset in bytes
  5859. */
  5860. getOffset(): number;
  5861. /**
  5862. * Returns the number of components per vertex attribute (integer)
  5863. * @returns the size in float
  5864. */
  5865. getSize(): number;
  5866. /**
  5867. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5868. * @returns true if this buffer is instanced
  5869. */
  5870. getIsInstanced(): boolean;
  5871. /**
  5872. * Returns the instancing divisor, zero for non-instanced (integer).
  5873. * @returns a number
  5874. */
  5875. getInstanceDivisor(): number;
  5876. /**
  5877. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5878. * @param data defines the data to store
  5879. */
  5880. create(data?: DataArray): void;
  5881. /**
  5882. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5883. * This function will create a new buffer if the current one is not updatable
  5884. * @param data defines the data to store
  5885. */
  5886. update(data: DataArray): void;
  5887. /**
  5888. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5889. * Returns the directly updated WebGLBuffer.
  5890. * @param data the new data
  5891. * @param offset the new offset
  5892. * @param useBytes set to true if the offset is in bytes
  5893. */
  5894. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5895. /**
  5896. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5897. */
  5898. dispose(): void;
  5899. /**
  5900. * Enumerates each value of this vertex buffer as numbers.
  5901. * @param count the number of values to enumerate
  5902. * @param callback the callback function called for each value
  5903. */
  5904. forEach(count: number, callback: (value: number, index: number) => void): void;
  5905. /**
  5906. * Positions
  5907. */
  5908. static readonly PositionKind: string;
  5909. /**
  5910. * Normals
  5911. */
  5912. static readonly NormalKind: string;
  5913. /**
  5914. * Tangents
  5915. */
  5916. static readonly TangentKind: string;
  5917. /**
  5918. * Texture coordinates
  5919. */
  5920. static readonly UVKind: string;
  5921. /**
  5922. * Texture coordinates 2
  5923. */
  5924. static readonly UV2Kind: string;
  5925. /**
  5926. * Texture coordinates 3
  5927. */
  5928. static readonly UV3Kind: string;
  5929. /**
  5930. * Texture coordinates 4
  5931. */
  5932. static readonly UV4Kind: string;
  5933. /**
  5934. * Texture coordinates 5
  5935. */
  5936. static readonly UV5Kind: string;
  5937. /**
  5938. * Texture coordinates 6
  5939. */
  5940. static readonly UV6Kind: string;
  5941. /**
  5942. * Colors
  5943. */
  5944. static readonly ColorKind: string;
  5945. /**
  5946. * Matrix indices (for bones)
  5947. */
  5948. static readonly MatricesIndicesKind: string;
  5949. /**
  5950. * Matrix weights (for bones)
  5951. */
  5952. static readonly MatricesWeightsKind: string;
  5953. /**
  5954. * Additional matrix indices (for bones)
  5955. */
  5956. static readonly MatricesIndicesExtraKind: string;
  5957. /**
  5958. * Additional matrix weights (for bones)
  5959. */
  5960. static readonly MatricesWeightsExtraKind: string;
  5961. /**
  5962. * Deduces the stride given a kind.
  5963. * @param kind The kind string to deduce
  5964. * @returns The deduced stride
  5965. */
  5966. static DeduceStride(kind: string): number;
  5967. /**
  5968. * Gets the byte length of the given type.
  5969. * @param type the type
  5970. * @returns the number of bytes
  5971. */
  5972. static GetTypeByteLength(type: number): number;
  5973. /**
  5974. * Enumerates each value of the given parameters as numbers.
  5975. * @param data the data to enumerate
  5976. * @param byteOffset the byte offset of the data
  5977. * @param byteStride the byte stride of the data
  5978. * @param componentCount the number of components per element
  5979. * @param componentType the type of the component
  5980. * @param count the number of values to enumerate
  5981. * @param normalized whether the data is normalized
  5982. * @param callback the callback function called for each value
  5983. */
  5984. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5985. private static _GetFloatValue;
  5986. }
  5987. }
  5988. declare module "babylonjs/Maths/sphericalPolynomial" {
  5989. import { Vector3, Color3 } from "babylonjs/Maths/math";
  5990. /**
  5991. * Class representing spherical harmonics coefficients to the 3rd degree
  5992. */
  5993. export class SphericalHarmonics {
  5994. /**
  5995. * Defines whether or not the harmonics have been prescaled for rendering.
  5996. */
  5997. preScaled: boolean;
  5998. /**
  5999. * The l0,0 coefficients of the spherical harmonics
  6000. */
  6001. l00: Vector3;
  6002. /**
  6003. * The l1,-1 coefficients of the spherical harmonics
  6004. */
  6005. l1_1: Vector3;
  6006. /**
  6007. * The l1,0 coefficients of the spherical harmonics
  6008. */
  6009. l10: Vector3;
  6010. /**
  6011. * The l1,1 coefficients of the spherical harmonics
  6012. */
  6013. l11: Vector3;
  6014. /**
  6015. * The l2,-2 coefficients of the spherical harmonics
  6016. */
  6017. l2_2: Vector3;
  6018. /**
  6019. * The l2,-1 coefficients of the spherical harmonics
  6020. */
  6021. l2_1: Vector3;
  6022. /**
  6023. * The l2,0 coefficients of the spherical harmonics
  6024. */
  6025. l20: Vector3;
  6026. /**
  6027. * The l2,1 coefficients of the spherical harmonics
  6028. */
  6029. l21: Vector3;
  6030. /**
  6031. * The l2,2 coefficients of the spherical harmonics
  6032. */
  6033. l22: Vector3;
  6034. /**
  6035. * Adds a light to the spherical harmonics
  6036. * @param direction the direction of the light
  6037. * @param color the color of the light
  6038. * @param deltaSolidAngle the delta solid angle of the light
  6039. */
  6040. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  6041. /**
  6042. * Scales the spherical harmonics by the given amount
  6043. * @param scale the amount to scale
  6044. */
  6045. scaleInPlace(scale: number): void;
  6046. /**
  6047. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  6048. *
  6049. * ```
  6050. * E_lm = A_l * L_lm
  6051. * ```
  6052. *
  6053. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  6054. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  6055. * the scaling factors are given in equation 9.
  6056. */
  6057. convertIncidentRadianceToIrradiance(): void;
  6058. /**
  6059. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  6060. *
  6061. * ```
  6062. * L = (1/pi) * E * rho
  6063. * ```
  6064. *
  6065. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  6066. */
  6067. convertIrradianceToLambertianRadiance(): void;
  6068. /**
  6069. * Integrates the reconstruction coefficients directly in to the SH preventing further
  6070. * required operations at run time.
  6071. *
  6072. * This is simply done by scaling back the SH with Ylm constants parameter.
  6073. * The trigonometric part being applied by the shader at run time.
  6074. */
  6075. preScaleForRendering(): void;
  6076. /**
  6077. * Constructs a spherical harmonics from an array.
  6078. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  6079. * @returns the spherical harmonics
  6080. */
  6081. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  6082. /**
  6083. * Gets the spherical harmonics from polynomial
  6084. * @param polynomial the spherical polynomial
  6085. * @returns the spherical harmonics
  6086. */
  6087. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  6088. }
  6089. /**
  6090. * Class representing spherical polynomial coefficients to the 3rd degree
  6091. */
  6092. export class SphericalPolynomial {
  6093. private _harmonics;
  6094. /**
  6095. * The spherical harmonics used to create the polynomials.
  6096. */
  6097. readonly preScaledHarmonics: SphericalHarmonics;
  6098. /**
  6099. * The x coefficients of the spherical polynomial
  6100. */
  6101. x: Vector3;
  6102. /**
  6103. * The y coefficients of the spherical polynomial
  6104. */
  6105. y: Vector3;
  6106. /**
  6107. * The z coefficients of the spherical polynomial
  6108. */
  6109. z: Vector3;
  6110. /**
  6111. * The xx coefficients of the spherical polynomial
  6112. */
  6113. xx: Vector3;
  6114. /**
  6115. * The yy coefficients of the spherical polynomial
  6116. */
  6117. yy: Vector3;
  6118. /**
  6119. * The zz coefficients of the spherical polynomial
  6120. */
  6121. zz: Vector3;
  6122. /**
  6123. * The xy coefficients of the spherical polynomial
  6124. */
  6125. xy: Vector3;
  6126. /**
  6127. * The yz coefficients of the spherical polynomial
  6128. */
  6129. yz: Vector3;
  6130. /**
  6131. * The zx coefficients of the spherical polynomial
  6132. */
  6133. zx: Vector3;
  6134. /**
  6135. * Adds an ambient color to the spherical polynomial
  6136. * @param color the color to add
  6137. */
  6138. addAmbient(color: Color3): void;
  6139. /**
  6140. * Scales the spherical polynomial by the given amount
  6141. * @param scale the amount to scale
  6142. */
  6143. scaleInPlace(scale: number): void;
  6144. /**
  6145. * Gets the spherical polynomial from harmonics
  6146. * @param harmonics the spherical harmonics
  6147. * @returns the spherical polynomial
  6148. */
  6149. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  6150. /**
  6151. * Constructs a spherical polynomial from an array.
  6152. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  6153. * @returns the spherical polynomial
  6154. */
  6155. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  6156. }
  6157. }
  6158. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  6159. import { Nullable } from "babylonjs/types";
  6160. /**
  6161. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  6162. */
  6163. export interface CubeMapInfo {
  6164. /**
  6165. * The pixel array for the front face.
  6166. * This is stored in format, left to right, up to down format.
  6167. */
  6168. front: Nullable<ArrayBufferView>;
  6169. /**
  6170. * The pixel array for the back face.
  6171. * This is stored in format, left to right, up to down format.
  6172. */
  6173. back: Nullable<ArrayBufferView>;
  6174. /**
  6175. * The pixel array for the left face.
  6176. * This is stored in format, left to right, up to down format.
  6177. */
  6178. left: Nullable<ArrayBufferView>;
  6179. /**
  6180. * The pixel array for the right face.
  6181. * This is stored in format, left to right, up to down format.
  6182. */
  6183. right: Nullable<ArrayBufferView>;
  6184. /**
  6185. * The pixel array for the up face.
  6186. * This is stored in format, left to right, up to down format.
  6187. */
  6188. up: Nullable<ArrayBufferView>;
  6189. /**
  6190. * The pixel array for the down face.
  6191. * This is stored in format, left to right, up to down format.
  6192. */
  6193. down: Nullable<ArrayBufferView>;
  6194. /**
  6195. * The size of the cubemap stored.
  6196. *
  6197. * Each faces will be size * size pixels.
  6198. */
  6199. size: number;
  6200. /**
  6201. * The format of the texture.
  6202. *
  6203. * RGBA, RGB.
  6204. */
  6205. format: number;
  6206. /**
  6207. * The type of the texture data.
  6208. *
  6209. * UNSIGNED_INT, FLOAT.
  6210. */
  6211. type: number;
  6212. /**
  6213. * Specifies whether the texture is in gamma space.
  6214. */
  6215. gammaSpace: boolean;
  6216. }
  6217. /**
  6218. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  6219. */
  6220. export class PanoramaToCubeMapTools {
  6221. private static FACE_FRONT;
  6222. private static FACE_BACK;
  6223. private static FACE_RIGHT;
  6224. private static FACE_LEFT;
  6225. private static FACE_DOWN;
  6226. private static FACE_UP;
  6227. /**
  6228. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  6229. *
  6230. * @param float32Array The source data.
  6231. * @param inputWidth The width of the input panorama.
  6232. * @param inputHeight The height of the input panorama.
  6233. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  6234. * @return The cubemap data
  6235. */
  6236. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  6237. private static CreateCubemapTexture;
  6238. private static CalcProjectionSpherical;
  6239. }
  6240. }
  6241. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  6242. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6243. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6244. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  6245. /**
  6246. * Helper class dealing with the extraction of spherical polynomial dataArray
  6247. * from a cube map.
  6248. */
  6249. export class CubeMapToSphericalPolynomialTools {
  6250. private static FileFaces;
  6251. /**
  6252. * Converts a texture to the according Spherical Polynomial data.
  6253. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6254. *
  6255. * @param texture The texture to extract the information from.
  6256. * @return The Spherical Polynomial data.
  6257. */
  6258. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  6259. /**
  6260. * Converts a cubemap to the according Spherical Polynomial data.
  6261. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6262. *
  6263. * @param cubeInfo The Cube map to extract the information from.
  6264. * @return The Spherical Polynomial data.
  6265. */
  6266. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  6267. }
  6268. }
  6269. declare module "babylonjs/Engines/engineStore" {
  6270. import { Nullable } from "babylonjs/types";
  6271. import { Engine } from "babylonjs/Engines/engine";
  6272. import { Scene } from "babylonjs/scene";
  6273. /**
  6274. * The engine store class is responsible to hold all the instances of Engine and Scene created
  6275. * during the life time of the application.
  6276. */
  6277. export class EngineStore {
  6278. /** Gets the list of created engines */
  6279. static Instances: import("babylonjs/Engines/engine").Engine[];
  6280. /** @hidden */
  6281. static _LastCreatedScene: Nullable<Scene>;
  6282. /**
  6283. * Gets the latest created engine
  6284. */
  6285. static readonly LastCreatedEngine: Nullable<Engine>;
  6286. /**
  6287. * Gets the latest created scene
  6288. */
  6289. static readonly LastCreatedScene: Nullable<Scene>;
  6290. }
  6291. }
  6292. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  6293. /**
  6294. * Define options used to create a render target texture
  6295. */
  6296. export class RenderTargetCreationOptions {
  6297. /**
  6298. * Specifies is mipmaps must be generated
  6299. */
  6300. generateMipMaps?: boolean;
  6301. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6302. generateDepthBuffer?: boolean;
  6303. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6304. generateStencilBuffer?: boolean;
  6305. /** Defines texture type (int by default) */
  6306. type?: number;
  6307. /** Defines sampling mode (trilinear by default) */
  6308. samplingMode?: number;
  6309. /** Defines format (RGBA by default) */
  6310. format?: number;
  6311. }
  6312. }
  6313. declare module "babylonjs/States/alphaCullingState" {
  6314. /**
  6315. * @hidden
  6316. **/
  6317. export class _AlphaState {
  6318. private _isAlphaBlendDirty;
  6319. private _isBlendFunctionParametersDirty;
  6320. private _isBlendEquationParametersDirty;
  6321. private _isBlendConstantsDirty;
  6322. private _alphaBlend;
  6323. private _blendFunctionParameters;
  6324. private _blendEquationParameters;
  6325. private _blendConstants;
  6326. /**
  6327. * Initializes the state.
  6328. */
  6329. constructor();
  6330. readonly isDirty: boolean;
  6331. alphaBlend: boolean;
  6332. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6333. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6334. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6335. reset(): void;
  6336. apply(gl: WebGLRenderingContext): void;
  6337. }
  6338. }
  6339. declare module "babylonjs/States/depthCullingState" {
  6340. import { Nullable } from "babylonjs/types";
  6341. /**
  6342. * @hidden
  6343. **/
  6344. export class _DepthCullingState {
  6345. private _isDepthTestDirty;
  6346. private _isDepthMaskDirty;
  6347. private _isDepthFuncDirty;
  6348. private _isCullFaceDirty;
  6349. private _isCullDirty;
  6350. private _isZOffsetDirty;
  6351. private _isFrontFaceDirty;
  6352. private _depthTest;
  6353. private _depthMask;
  6354. private _depthFunc;
  6355. private _cull;
  6356. private _cullFace;
  6357. private _zOffset;
  6358. private _frontFace;
  6359. /**
  6360. * Initializes the state.
  6361. */
  6362. constructor();
  6363. readonly isDirty: boolean;
  6364. zOffset: number;
  6365. cullFace: Nullable<number>;
  6366. cull: Nullable<boolean>;
  6367. depthFunc: Nullable<number>;
  6368. depthMask: boolean;
  6369. depthTest: boolean;
  6370. frontFace: Nullable<number>;
  6371. reset(): void;
  6372. apply(gl: WebGLRenderingContext): void;
  6373. }
  6374. }
  6375. declare module "babylonjs/States/stencilState" {
  6376. /**
  6377. * @hidden
  6378. **/
  6379. export class _StencilState {
  6380. /** 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 */
  6381. static readonly ALWAYS: number;
  6382. /** Passed to stencilOperation to specify that stencil value must be kept */
  6383. static readonly KEEP: number;
  6384. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6385. static readonly REPLACE: number;
  6386. private _isStencilTestDirty;
  6387. private _isStencilMaskDirty;
  6388. private _isStencilFuncDirty;
  6389. private _isStencilOpDirty;
  6390. private _stencilTest;
  6391. private _stencilMask;
  6392. private _stencilFunc;
  6393. private _stencilFuncRef;
  6394. private _stencilFuncMask;
  6395. private _stencilOpStencilFail;
  6396. private _stencilOpDepthFail;
  6397. private _stencilOpStencilDepthPass;
  6398. readonly isDirty: boolean;
  6399. stencilFunc: number;
  6400. stencilFuncRef: number;
  6401. stencilFuncMask: number;
  6402. stencilOpStencilFail: number;
  6403. stencilOpDepthFail: number;
  6404. stencilOpStencilDepthPass: number;
  6405. stencilMask: number;
  6406. stencilTest: boolean;
  6407. constructor();
  6408. reset(): void;
  6409. apply(gl: WebGLRenderingContext): void;
  6410. }
  6411. }
  6412. declare module "babylonjs/States/index" {
  6413. export * from "babylonjs/States/alphaCullingState";
  6414. export * from "babylonjs/States/depthCullingState";
  6415. export * from "babylonjs/States/stencilState";
  6416. }
  6417. declare module "babylonjs/Instrumentation/timeToken" {
  6418. import { Nullable } from "babylonjs/types";
  6419. /**
  6420. * @hidden
  6421. **/
  6422. export class _TimeToken {
  6423. _startTimeQuery: Nullable<WebGLQuery>;
  6424. _endTimeQuery: Nullable<WebGLQuery>;
  6425. _timeElapsedQuery: Nullable<WebGLQuery>;
  6426. _timeElapsedQueryEnded: boolean;
  6427. }
  6428. }
  6429. declare module "babylonjs/Materials/Textures/internalTexture" {
  6430. import { Observable } from "babylonjs/Misc/observable";
  6431. import { Nullable, int } from "babylonjs/types";
  6432. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6433. import { Engine } from "babylonjs/Engines/engine";
  6434. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6435. /**
  6436. * Class used to store data associated with WebGL texture data for the engine
  6437. * This class should not be used directly
  6438. */
  6439. export class InternalTexture {
  6440. /** @hidden */
  6441. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6442. /**
  6443. * The source of the texture data is unknown
  6444. */
  6445. static DATASOURCE_UNKNOWN: number;
  6446. /**
  6447. * Texture data comes from an URL
  6448. */
  6449. static DATASOURCE_URL: number;
  6450. /**
  6451. * Texture data is only used for temporary storage
  6452. */
  6453. static DATASOURCE_TEMP: number;
  6454. /**
  6455. * Texture data comes from raw data (ArrayBuffer)
  6456. */
  6457. static DATASOURCE_RAW: number;
  6458. /**
  6459. * Texture content is dynamic (video or dynamic texture)
  6460. */
  6461. static DATASOURCE_DYNAMIC: number;
  6462. /**
  6463. * Texture content is generated by rendering to it
  6464. */
  6465. static DATASOURCE_RENDERTARGET: number;
  6466. /**
  6467. * Texture content is part of a multi render target process
  6468. */
  6469. static DATASOURCE_MULTIRENDERTARGET: number;
  6470. /**
  6471. * Texture data comes from a cube data file
  6472. */
  6473. static DATASOURCE_CUBE: number;
  6474. /**
  6475. * Texture data comes from a raw cube data
  6476. */
  6477. static DATASOURCE_CUBERAW: number;
  6478. /**
  6479. * Texture data come from a prefiltered cube data file
  6480. */
  6481. static DATASOURCE_CUBEPREFILTERED: number;
  6482. /**
  6483. * Texture content is raw 3D data
  6484. */
  6485. static DATASOURCE_RAW3D: number;
  6486. /**
  6487. * Texture content is a depth texture
  6488. */
  6489. static DATASOURCE_DEPTHTEXTURE: number;
  6490. /**
  6491. * Texture data comes from a raw cube data encoded with RGBD
  6492. */
  6493. static DATASOURCE_CUBERAW_RGBD: number;
  6494. /**
  6495. * Defines if the texture is ready
  6496. */
  6497. isReady: boolean;
  6498. /**
  6499. * Defines if the texture is a cube texture
  6500. */
  6501. isCube: boolean;
  6502. /**
  6503. * Defines if the texture contains 3D data
  6504. */
  6505. is3D: boolean;
  6506. /**
  6507. * Defines if the texture contains multiview data
  6508. */
  6509. isMultiview: boolean;
  6510. /**
  6511. * Gets the URL used to load this texture
  6512. */
  6513. url: string;
  6514. /**
  6515. * Gets the sampling mode of the texture
  6516. */
  6517. samplingMode: number;
  6518. /**
  6519. * Gets a boolean indicating if the texture needs mipmaps generation
  6520. */
  6521. generateMipMaps: boolean;
  6522. /**
  6523. * Gets the number of samples used by the texture (WebGL2+ only)
  6524. */
  6525. samples: number;
  6526. /**
  6527. * Gets the type of the texture (int, float...)
  6528. */
  6529. type: number;
  6530. /**
  6531. * Gets the format of the texture (RGB, RGBA...)
  6532. */
  6533. format: number;
  6534. /**
  6535. * Observable called when the texture is loaded
  6536. */
  6537. onLoadedObservable: Observable<InternalTexture>;
  6538. /**
  6539. * Gets the width of the texture
  6540. */
  6541. width: number;
  6542. /**
  6543. * Gets the height of the texture
  6544. */
  6545. height: number;
  6546. /**
  6547. * Gets the depth of the texture
  6548. */
  6549. depth: number;
  6550. /**
  6551. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6552. */
  6553. baseWidth: number;
  6554. /**
  6555. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6556. */
  6557. baseHeight: number;
  6558. /**
  6559. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6560. */
  6561. baseDepth: number;
  6562. /**
  6563. * Gets a boolean indicating if the texture is inverted on Y axis
  6564. */
  6565. invertY: boolean;
  6566. /** @hidden */
  6567. _invertVScale: boolean;
  6568. /** @hidden */
  6569. _associatedChannel: number;
  6570. /** @hidden */
  6571. _dataSource: number;
  6572. /** @hidden */
  6573. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6574. /** @hidden */
  6575. _bufferView: Nullable<ArrayBufferView>;
  6576. /** @hidden */
  6577. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6578. /** @hidden */
  6579. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6580. /** @hidden */
  6581. _size: number;
  6582. /** @hidden */
  6583. _extension: string;
  6584. /** @hidden */
  6585. _files: Nullable<string[]>;
  6586. /** @hidden */
  6587. _workingCanvas: Nullable<HTMLCanvasElement>;
  6588. /** @hidden */
  6589. _workingContext: Nullable<CanvasRenderingContext2D>;
  6590. /** @hidden */
  6591. _framebuffer: Nullable<WebGLFramebuffer>;
  6592. /** @hidden */
  6593. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6594. /** @hidden */
  6595. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6596. /** @hidden */
  6597. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6598. /** @hidden */
  6599. _attachments: Nullable<number[]>;
  6600. /** @hidden */
  6601. _cachedCoordinatesMode: Nullable<number>;
  6602. /** @hidden */
  6603. _cachedWrapU: Nullable<number>;
  6604. /** @hidden */
  6605. _cachedWrapV: Nullable<number>;
  6606. /** @hidden */
  6607. _cachedWrapR: Nullable<number>;
  6608. /** @hidden */
  6609. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6610. /** @hidden */
  6611. _isDisabled: boolean;
  6612. /** @hidden */
  6613. _compression: Nullable<string>;
  6614. /** @hidden */
  6615. _generateStencilBuffer: boolean;
  6616. /** @hidden */
  6617. _generateDepthBuffer: boolean;
  6618. /** @hidden */
  6619. _comparisonFunction: number;
  6620. /** @hidden */
  6621. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6622. /** @hidden */
  6623. _lodGenerationScale: number;
  6624. /** @hidden */
  6625. _lodGenerationOffset: number;
  6626. /** @hidden */
  6627. _colorTextureArray: Nullable<WebGLTexture>;
  6628. /** @hidden */
  6629. _depthStencilTextureArray: Nullable<WebGLTexture>;
  6630. /** @hidden */
  6631. _lodTextureHigh: Nullable<BaseTexture>;
  6632. /** @hidden */
  6633. _lodTextureMid: Nullable<BaseTexture>;
  6634. /** @hidden */
  6635. _lodTextureLow: Nullable<BaseTexture>;
  6636. /** @hidden */
  6637. _isRGBD: boolean;
  6638. /** @hidden */
  6639. _linearSpecularLOD: boolean;
  6640. /** @hidden */
  6641. _irradianceTexture: Nullable<BaseTexture>;
  6642. /** @hidden */
  6643. _webGLTexture: Nullable<WebGLTexture>;
  6644. /** @hidden */
  6645. _references: number;
  6646. private _engine;
  6647. /**
  6648. * Gets the Engine the texture belongs to.
  6649. * @returns The babylon engine
  6650. */
  6651. getEngine(): Engine;
  6652. /**
  6653. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6654. */
  6655. readonly dataSource: number;
  6656. /**
  6657. * Creates a new InternalTexture
  6658. * @param engine defines the engine to use
  6659. * @param dataSource defines the type of data that will be used
  6660. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6661. */
  6662. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6663. /**
  6664. * Increments the number of references (ie. the number of Texture that point to it)
  6665. */
  6666. incrementReferences(): void;
  6667. /**
  6668. * Change the size of the texture (not the size of the content)
  6669. * @param width defines the new width
  6670. * @param height defines the new height
  6671. * @param depth defines the new depth (1 by default)
  6672. */
  6673. updateSize(width: int, height: int, depth?: int): void;
  6674. /** @hidden */
  6675. _rebuild(): void;
  6676. /** @hidden */
  6677. _swapAndDie(target: InternalTexture): void;
  6678. /**
  6679. * Dispose the current allocated resources
  6680. */
  6681. dispose(): void;
  6682. }
  6683. }
  6684. declare module "babylonjs/Animations/easing" {
  6685. /**
  6686. * This represents the main contract an easing function should follow.
  6687. * Easing functions are used throughout the animation system.
  6688. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6689. */
  6690. export interface IEasingFunction {
  6691. /**
  6692. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6693. * of the easing function.
  6694. * The link below provides some of the most common examples of easing functions.
  6695. * @see https://easings.net/
  6696. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6697. * @returns the corresponding value on the curve defined by the easing function
  6698. */
  6699. ease(gradient: number): number;
  6700. }
  6701. /**
  6702. * Base class used for every default easing function.
  6703. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6704. */
  6705. export class EasingFunction implements IEasingFunction {
  6706. /**
  6707. * Interpolation follows the mathematical formula associated with the easing function.
  6708. */
  6709. static readonly EASINGMODE_EASEIN: number;
  6710. /**
  6711. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6712. */
  6713. static readonly EASINGMODE_EASEOUT: number;
  6714. /**
  6715. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6716. */
  6717. static readonly EASINGMODE_EASEINOUT: number;
  6718. private _easingMode;
  6719. /**
  6720. * Sets the easing mode of the current function.
  6721. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6722. */
  6723. setEasingMode(easingMode: number): void;
  6724. /**
  6725. * Gets the current easing mode.
  6726. * @returns the easing mode
  6727. */
  6728. getEasingMode(): number;
  6729. /**
  6730. * @hidden
  6731. */
  6732. easeInCore(gradient: number): number;
  6733. /**
  6734. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6735. * of the easing function.
  6736. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6737. * @returns the corresponding value on the curve defined by the easing function
  6738. */
  6739. ease(gradient: number): number;
  6740. }
  6741. /**
  6742. * Easing function with a circle shape (see link below).
  6743. * @see https://easings.net/#easeInCirc
  6744. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6745. */
  6746. export class CircleEase extends EasingFunction implements IEasingFunction {
  6747. /** @hidden */
  6748. easeInCore(gradient: number): number;
  6749. }
  6750. /**
  6751. * Easing function with a ease back shape (see link below).
  6752. * @see https://easings.net/#easeInBack
  6753. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6754. */
  6755. export class BackEase extends EasingFunction implements IEasingFunction {
  6756. /** Defines the amplitude of the function */
  6757. amplitude: number;
  6758. /**
  6759. * Instantiates a back ease easing
  6760. * @see https://easings.net/#easeInBack
  6761. * @param amplitude Defines the amplitude of the function
  6762. */
  6763. constructor(
  6764. /** Defines the amplitude of the function */
  6765. amplitude?: number);
  6766. /** @hidden */
  6767. easeInCore(gradient: number): number;
  6768. }
  6769. /**
  6770. * Easing function with a bouncing shape (see link below).
  6771. * @see https://easings.net/#easeInBounce
  6772. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6773. */
  6774. export class BounceEase extends EasingFunction implements IEasingFunction {
  6775. /** Defines the number of bounces */
  6776. bounces: number;
  6777. /** Defines the amplitude of the bounce */
  6778. bounciness: number;
  6779. /**
  6780. * Instantiates a bounce easing
  6781. * @see https://easings.net/#easeInBounce
  6782. * @param bounces Defines the number of bounces
  6783. * @param bounciness Defines the amplitude of the bounce
  6784. */
  6785. constructor(
  6786. /** Defines the number of bounces */
  6787. bounces?: number,
  6788. /** Defines the amplitude of the bounce */
  6789. bounciness?: number);
  6790. /** @hidden */
  6791. easeInCore(gradient: number): number;
  6792. }
  6793. /**
  6794. * Easing function with a power of 3 shape (see link below).
  6795. * @see https://easings.net/#easeInCubic
  6796. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6797. */
  6798. export class CubicEase extends EasingFunction implements IEasingFunction {
  6799. /** @hidden */
  6800. easeInCore(gradient: number): number;
  6801. }
  6802. /**
  6803. * Easing function with an elastic shape (see link below).
  6804. * @see https://easings.net/#easeInElastic
  6805. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6806. */
  6807. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6808. /** Defines the number of oscillations*/
  6809. oscillations: number;
  6810. /** Defines the amplitude of the oscillations*/
  6811. springiness: number;
  6812. /**
  6813. * Instantiates an elastic easing function
  6814. * @see https://easings.net/#easeInElastic
  6815. * @param oscillations Defines the number of oscillations
  6816. * @param springiness Defines the amplitude of the oscillations
  6817. */
  6818. constructor(
  6819. /** Defines the number of oscillations*/
  6820. oscillations?: number,
  6821. /** Defines the amplitude of the oscillations*/
  6822. springiness?: number);
  6823. /** @hidden */
  6824. easeInCore(gradient: number): number;
  6825. }
  6826. /**
  6827. * Easing function with an exponential shape (see link below).
  6828. * @see https://easings.net/#easeInExpo
  6829. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6830. */
  6831. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6832. /** Defines the exponent of the function */
  6833. exponent: number;
  6834. /**
  6835. * Instantiates an exponential easing function
  6836. * @see https://easings.net/#easeInExpo
  6837. * @param exponent Defines the exponent of the function
  6838. */
  6839. constructor(
  6840. /** Defines the exponent of the function */
  6841. exponent?: number);
  6842. /** @hidden */
  6843. easeInCore(gradient: number): number;
  6844. }
  6845. /**
  6846. * Easing function with a power shape (see link below).
  6847. * @see https://easings.net/#easeInQuad
  6848. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6849. */
  6850. export class PowerEase extends EasingFunction implements IEasingFunction {
  6851. /** Defines the power of the function */
  6852. power: number;
  6853. /**
  6854. * Instantiates an power base easing function
  6855. * @see https://easings.net/#easeInQuad
  6856. * @param power Defines the power of the function
  6857. */
  6858. constructor(
  6859. /** Defines the power of the function */
  6860. power?: number);
  6861. /** @hidden */
  6862. easeInCore(gradient: number): number;
  6863. }
  6864. /**
  6865. * Easing function with a power of 2 shape (see link below).
  6866. * @see https://easings.net/#easeInQuad
  6867. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6868. */
  6869. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6870. /** @hidden */
  6871. easeInCore(gradient: number): number;
  6872. }
  6873. /**
  6874. * Easing function with a power of 4 shape (see link below).
  6875. * @see https://easings.net/#easeInQuart
  6876. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6877. */
  6878. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6879. /** @hidden */
  6880. easeInCore(gradient: number): number;
  6881. }
  6882. /**
  6883. * Easing function with a power of 5 shape (see link below).
  6884. * @see https://easings.net/#easeInQuint
  6885. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6886. */
  6887. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6888. /** @hidden */
  6889. easeInCore(gradient: number): number;
  6890. }
  6891. /**
  6892. * Easing function with a sin shape (see link below).
  6893. * @see https://easings.net/#easeInSine
  6894. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6895. */
  6896. export class SineEase extends EasingFunction implements IEasingFunction {
  6897. /** @hidden */
  6898. easeInCore(gradient: number): number;
  6899. }
  6900. /**
  6901. * Easing function with a bezier shape (see link below).
  6902. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6903. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6904. */
  6905. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6906. /** Defines the x component of the start tangent in the bezier curve */
  6907. x1: number;
  6908. /** Defines the y component of the start tangent in the bezier curve */
  6909. y1: number;
  6910. /** Defines the x component of the end tangent in the bezier curve */
  6911. x2: number;
  6912. /** Defines the y component of the end tangent in the bezier curve */
  6913. y2: number;
  6914. /**
  6915. * Instantiates a bezier function
  6916. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6917. * @param x1 Defines the x component of the start tangent in the bezier curve
  6918. * @param y1 Defines the y component of the start tangent in the bezier curve
  6919. * @param x2 Defines the x component of the end tangent in the bezier curve
  6920. * @param y2 Defines the y component of the end tangent in the bezier curve
  6921. */
  6922. constructor(
  6923. /** Defines the x component of the start tangent in the bezier curve */
  6924. x1?: number,
  6925. /** Defines the y component of the start tangent in the bezier curve */
  6926. y1?: number,
  6927. /** Defines the x component of the end tangent in the bezier curve */
  6928. x2?: number,
  6929. /** Defines the y component of the end tangent in the bezier curve */
  6930. y2?: number);
  6931. /** @hidden */
  6932. easeInCore(gradient: number): number;
  6933. }
  6934. }
  6935. declare module "babylonjs/Animations/animationKey" {
  6936. /**
  6937. * Defines an interface which represents an animation key frame
  6938. */
  6939. export interface IAnimationKey {
  6940. /**
  6941. * Frame of the key frame
  6942. */
  6943. frame: number;
  6944. /**
  6945. * Value at the specifies key frame
  6946. */
  6947. value: any;
  6948. /**
  6949. * The input tangent for the cubic hermite spline
  6950. */
  6951. inTangent?: any;
  6952. /**
  6953. * The output tangent for the cubic hermite spline
  6954. */
  6955. outTangent?: any;
  6956. /**
  6957. * The animation interpolation type
  6958. */
  6959. interpolation?: AnimationKeyInterpolation;
  6960. }
  6961. /**
  6962. * Enum for the animation key frame interpolation type
  6963. */
  6964. export enum AnimationKeyInterpolation {
  6965. /**
  6966. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6967. */
  6968. STEP = 1
  6969. }
  6970. }
  6971. declare module "babylonjs/Animations/animationRange" {
  6972. /**
  6973. * Represents the range of an animation
  6974. */
  6975. export class AnimationRange {
  6976. /**The name of the animation range**/
  6977. name: string;
  6978. /**The starting frame of the animation */
  6979. from: number;
  6980. /**The ending frame of the animation*/
  6981. to: number;
  6982. /**
  6983. * Initializes the range of an animation
  6984. * @param name The name of the animation range
  6985. * @param from The starting frame of the animation
  6986. * @param to The ending frame of the animation
  6987. */
  6988. constructor(
  6989. /**The name of the animation range**/
  6990. name: string,
  6991. /**The starting frame of the animation */
  6992. from: number,
  6993. /**The ending frame of the animation*/
  6994. to: number);
  6995. /**
  6996. * Makes a copy of the animation range
  6997. * @returns A copy of the animation range
  6998. */
  6999. clone(): AnimationRange;
  7000. }
  7001. }
  7002. declare module "babylonjs/Animations/animationEvent" {
  7003. /**
  7004. * Composed of a frame, and an action function
  7005. */
  7006. export class AnimationEvent {
  7007. /** The frame for which the event is triggered **/
  7008. frame: number;
  7009. /** The event to perform when triggered **/
  7010. action: (currentFrame: number) => void;
  7011. /** Specifies if the event should be triggered only once**/
  7012. onlyOnce?: boolean | undefined;
  7013. /**
  7014. * Specifies if the animation event is done
  7015. */
  7016. isDone: boolean;
  7017. /**
  7018. * Initializes the animation event
  7019. * @param frame The frame for which the event is triggered
  7020. * @param action The event to perform when triggered
  7021. * @param onlyOnce Specifies if the event should be triggered only once
  7022. */
  7023. constructor(
  7024. /** The frame for which the event is triggered **/
  7025. frame: number,
  7026. /** The event to perform when triggered **/
  7027. action: (currentFrame: number) => void,
  7028. /** Specifies if the event should be triggered only once**/
  7029. onlyOnce?: boolean | undefined);
  7030. /** @hidden */
  7031. _clone(): AnimationEvent;
  7032. }
  7033. }
  7034. declare module "babylonjs/Behaviors/behavior" {
  7035. import { Nullable } from "babylonjs/types";
  7036. /**
  7037. * Interface used to define a behavior
  7038. */
  7039. export interface Behavior<T> {
  7040. /** gets or sets behavior's name */
  7041. name: string;
  7042. /**
  7043. * Function called when the behavior needs to be initialized (after attaching it to a target)
  7044. */
  7045. init(): void;
  7046. /**
  7047. * Called when the behavior is attached to a target
  7048. * @param target defines the target where the behavior is attached to
  7049. */
  7050. attach(target: T): void;
  7051. /**
  7052. * Called when the behavior is detached from its target
  7053. */
  7054. detach(): void;
  7055. }
  7056. /**
  7057. * Interface implemented by classes supporting behaviors
  7058. */
  7059. export interface IBehaviorAware<T> {
  7060. /**
  7061. * Attach a behavior
  7062. * @param behavior defines the behavior to attach
  7063. * @returns the current host
  7064. */
  7065. addBehavior(behavior: Behavior<T>): T;
  7066. /**
  7067. * Remove a behavior from the current object
  7068. * @param behavior defines the behavior to detach
  7069. * @returns the current host
  7070. */
  7071. removeBehavior(behavior: Behavior<T>): T;
  7072. /**
  7073. * Gets a behavior using its name to search
  7074. * @param name defines the name to search
  7075. * @returns the behavior or null if not found
  7076. */
  7077. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  7078. }
  7079. }
  7080. declare module "babylonjs/Collisions/intersectionInfo" {
  7081. import { Nullable } from "babylonjs/types";
  7082. /**
  7083. * @hidden
  7084. */
  7085. export class IntersectionInfo {
  7086. bu: Nullable<number>;
  7087. bv: Nullable<number>;
  7088. distance: number;
  7089. faceId: number;
  7090. subMeshId: number;
  7091. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  7092. }
  7093. }
  7094. declare module "babylonjs/Culling/boundingSphere" {
  7095. import { DeepImmutable } from "babylonjs/types";
  7096. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7097. /**
  7098. * Class used to store bounding sphere information
  7099. */
  7100. export class BoundingSphere {
  7101. /**
  7102. * Gets the center of the bounding sphere in local space
  7103. */
  7104. readonly center: Vector3;
  7105. /**
  7106. * Radius of the bounding sphere in local space
  7107. */
  7108. radius: number;
  7109. /**
  7110. * Gets the center of the bounding sphere in world space
  7111. */
  7112. readonly centerWorld: Vector3;
  7113. /**
  7114. * Radius of the bounding sphere in world space
  7115. */
  7116. radiusWorld: number;
  7117. /**
  7118. * Gets the minimum vector in local space
  7119. */
  7120. readonly minimum: Vector3;
  7121. /**
  7122. * Gets the maximum vector in local space
  7123. */
  7124. readonly maximum: Vector3;
  7125. private _worldMatrix;
  7126. private static readonly TmpVector3;
  7127. /**
  7128. * Creates a new bounding sphere
  7129. * @param min defines the minimum vector (in local space)
  7130. * @param max defines the maximum vector (in local space)
  7131. * @param worldMatrix defines the new world matrix
  7132. */
  7133. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7134. /**
  7135. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  7136. * @param min defines the new minimum vector (in local space)
  7137. * @param max defines the new maximum vector (in local space)
  7138. * @param worldMatrix defines the new world matrix
  7139. */
  7140. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7141. /**
  7142. * Scale the current bounding sphere by applying a scale factor
  7143. * @param factor defines the scale factor to apply
  7144. * @returns the current bounding box
  7145. */
  7146. scale(factor: number): BoundingSphere;
  7147. /**
  7148. * Gets the world matrix of the bounding box
  7149. * @returns a matrix
  7150. */
  7151. getWorldMatrix(): DeepImmutable<Matrix>;
  7152. /** @hidden */
  7153. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7154. /**
  7155. * Tests if the bounding sphere is intersecting the frustum planes
  7156. * @param frustumPlanes defines the frustum planes to test
  7157. * @returns true if there is an intersection
  7158. */
  7159. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7160. /**
  7161. * Tests if the bounding sphere center is in between the frustum planes.
  7162. * Used for optimistic fast inclusion.
  7163. * @param frustumPlanes defines the frustum planes to test
  7164. * @returns true if the sphere center is in between the frustum planes
  7165. */
  7166. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7167. /**
  7168. * Tests if a point is inside the bounding sphere
  7169. * @param point defines the point to test
  7170. * @returns true if the point is inside the bounding sphere
  7171. */
  7172. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7173. /**
  7174. * Checks if two sphere intersct
  7175. * @param sphere0 sphere 0
  7176. * @param sphere1 sphere 1
  7177. * @returns true if the speres intersect
  7178. */
  7179. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7180. }
  7181. }
  7182. declare module "babylonjs/Culling/boundingBox" {
  7183. import { DeepImmutable } from "babylonjs/types";
  7184. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7185. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7186. import { ICullable } from "babylonjs/Culling/boundingInfo";
  7187. /**
  7188. * Class used to store bounding box information
  7189. */
  7190. export class BoundingBox implements ICullable {
  7191. /**
  7192. * Gets the 8 vectors representing the bounding box in local space
  7193. */
  7194. readonly vectors: Vector3[];
  7195. /**
  7196. * Gets the center of the bounding box in local space
  7197. */
  7198. readonly center: Vector3;
  7199. /**
  7200. * Gets the center of the bounding box in world space
  7201. */
  7202. readonly centerWorld: Vector3;
  7203. /**
  7204. * Gets the extend size in local space
  7205. */
  7206. readonly extendSize: Vector3;
  7207. /**
  7208. * Gets the extend size in world space
  7209. */
  7210. readonly extendSizeWorld: Vector3;
  7211. /**
  7212. * Gets the OBB (object bounding box) directions
  7213. */
  7214. readonly directions: Vector3[];
  7215. /**
  7216. * Gets the 8 vectors representing the bounding box in world space
  7217. */
  7218. readonly vectorsWorld: Vector3[];
  7219. /**
  7220. * Gets the minimum vector in world space
  7221. */
  7222. readonly minimumWorld: Vector3;
  7223. /**
  7224. * Gets the maximum vector in world space
  7225. */
  7226. readonly maximumWorld: Vector3;
  7227. /**
  7228. * Gets the minimum vector in local space
  7229. */
  7230. readonly minimum: Vector3;
  7231. /**
  7232. * Gets the maximum vector in local space
  7233. */
  7234. readonly maximum: Vector3;
  7235. private _worldMatrix;
  7236. private static readonly TmpVector3;
  7237. /**
  7238. * @hidden
  7239. */
  7240. _tag: number;
  7241. /**
  7242. * Creates a new bounding box
  7243. * @param min defines the minimum vector (in local space)
  7244. * @param max defines the maximum vector (in local space)
  7245. * @param worldMatrix defines the new world matrix
  7246. */
  7247. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7248. /**
  7249. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7250. * @param min defines the new minimum vector (in local space)
  7251. * @param max defines the new maximum vector (in local space)
  7252. * @param worldMatrix defines the new world matrix
  7253. */
  7254. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7255. /**
  7256. * Scale the current bounding box by applying a scale factor
  7257. * @param factor defines the scale factor to apply
  7258. * @returns the current bounding box
  7259. */
  7260. scale(factor: number): BoundingBox;
  7261. /**
  7262. * Gets the world matrix of the bounding box
  7263. * @returns a matrix
  7264. */
  7265. getWorldMatrix(): DeepImmutable<Matrix>;
  7266. /** @hidden */
  7267. _update(world: DeepImmutable<Matrix>): void;
  7268. /**
  7269. * Tests if the bounding box is intersecting the frustum planes
  7270. * @param frustumPlanes defines the frustum planes to test
  7271. * @returns true if there is an intersection
  7272. */
  7273. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7274. /**
  7275. * Tests if the bounding box is entirely inside the frustum planes
  7276. * @param frustumPlanes defines the frustum planes to test
  7277. * @returns true if there is an inclusion
  7278. */
  7279. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7280. /**
  7281. * Tests if a point is inside the bounding box
  7282. * @param point defines the point to test
  7283. * @returns true if the point is inside the bounding box
  7284. */
  7285. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7286. /**
  7287. * Tests if the bounding box intersects with a bounding sphere
  7288. * @param sphere defines the sphere to test
  7289. * @returns true if there is an intersection
  7290. */
  7291. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7292. /**
  7293. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7294. * @param min defines the min vector to use
  7295. * @param max defines the max vector to use
  7296. * @returns true if there is an intersection
  7297. */
  7298. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7299. /**
  7300. * Tests if two bounding boxes are intersections
  7301. * @param box0 defines the first box to test
  7302. * @param box1 defines the second box to test
  7303. * @returns true if there is an intersection
  7304. */
  7305. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7306. /**
  7307. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7308. * @param minPoint defines the minimum vector of the bounding box
  7309. * @param maxPoint defines the maximum vector of the bounding box
  7310. * @param sphereCenter defines the sphere center
  7311. * @param sphereRadius defines the sphere radius
  7312. * @returns true if there is an intersection
  7313. */
  7314. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7315. /**
  7316. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7317. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7318. * @param frustumPlanes defines the frustum planes to test
  7319. * @return true if there is an inclusion
  7320. */
  7321. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7322. /**
  7323. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7324. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7325. * @param frustumPlanes defines the frustum planes to test
  7326. * @return true if there is an intersection
  7327. */
  7328. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7329. }
  7330. }
  7331. declare module "babylonjs/Collisions/collider" {
  7332. import { Nullable, IndicesArray } from "babylonjs/types";
  7333. import { Vector3, Plane } from "babylonjs/Maths/math";
  7334. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7335. /** @hidden */
  7336. export class Collider {
  7337. /** Define if a collision was found */
  7338. collisionFound: boolean;
  7339. /**
  7340. * Define last intersection point in local space
  7341. */
  7342. intersectionPoint: Vector3;
  7343. /**
  7344. * Define last collided mesh
  7345. */
  7346. collidedMesh: Nullable<AbstractMesh>;
  7347. private _collisionPoint;
  7348. private _planeIntersectionPoint;
  7349. private _tempVector;
  7350. private _tempVector2;
  7351. private _tempVector3;
  7352. private _tempVector4;
  7353. private _edge;
  7354. private _baseToVertex;
  7355. private _destinationPoint;
  7356. private _slidePlaneNormal;
  7357. private _displacementVector;
  7358. /** @hidden */
  7359. _radius: Vector3;
  7360. /** @hidden */
  7361. _retry: number;
  7362. private _velocity;
  7363. private _basePoint;
  7364. private _epsilon;
  7365. /** @hidden */
  7366. _velocityWorldLength: number;
  7367. /** @hidden */
  7368. _basePointWorld: Vector3;
  7369. private _velocityWorld;
  7370. private _normalizedVelocity;
  7371. /** @hidden */
  7372. _initialVelocity: Vector3;
  7373. /** @hidden */
  7374. _initialPosition: Vector3;
  7375. private _nearestDistance;
  7376. private _collisionMask;
  7377. collisionMask: number;
  7378. /**
  7379. * Gets the plane normal used to compute the sliding response (in local space)
  7380. */
  7381. readonly slidePlaneNormal: Vector3;
  7382. /** @hidden */
  7383. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7384. /** @hidden */
  7385. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7386. /** @hidden */
  7387. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7388. /** @hidden */
  7389. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7390. /** @hidden */
  7391. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7392. /** @hidden */
  7393. _getResponse(pos: Vector3, vel: Vector3): void;
  7394. }
  7395. }
  7396. declare module "babylonjs/Culling/boundingInfo" {
  7397. import { DeepImmutable } from "babylonjs/types";
  7398. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7399. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7400. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7401. import { Collider } from "babylonjs/Collisions/collider";
  7402. /**
  7403. * Interface for cullable objects
  7404. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7405. */
  7406. export interface ICullable {
  7407. /**
  7408. * Checks if the object or part of the object is in the frustum
  7409. * @param frustumPlanes Camera near/planes
  7410. * @returns true if the object is in frustum otherwise false
  7411. */
  7412. isInFrustum(frustumPlanes: Plane[]): boolean;
  7413. /**
  7414. * Checks if a cullable object (mesh...) is in the camera frustum
  7415. * Unlike isInFrustum this cheks the full bounding box
  7416. * @param frustumPlanes Camera near/planes
  7417. * @returns true if the object is in frustum otherwise false
  7418. */
  7419. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7420. }
  7421. /**
  7422. * Info for a bounding data of a mesh
  7423. */
  7424. export class BoundingInfo implements ICullable {
  7425. /**
  7426. * Bounding box for the mesh
  7427. */
  7428. readonly boundingBox: BoundingBox;
  7429. /**
  7430. * Bounding sphere for the mesh
  7431. */
  7432. readonly boundingSphere: BoundingSphere;
  7433. private _isLocked;
  7434. private static readonly TmpVector3;
  7435. /**
  7436. * Constructs bounding info
  7437. * @param minimum min vector of the bounding box/sphere
  7438. * @param maximum max vector of the bounding box/sphere
  7439. * @param worldMatrix defines the new world matrix
  7440. */
  7441. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7442. /**
  7443. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7444. * @param min defines the new minimum vector (in local space)
  7445. * @param max defines the new maximum vector (in local space)
  7446. * @param worldMatrix defines the new world matrix
  7447. */
  7448. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7449. /**
  7450. * min vector of the bounding box/sphere
  7451. */
  7452. readonly minimum: Vector3;
  7453. /**
  7454. * max vector of the bounding box/sphere
  7455. */
  7456. readonly maximum: Vector3;
  7457. /**
  7458. * If the info is locked and won't be updated to avoid perf overhead
  7459. */
  7460. isLocked: boolean;
  7461. /**
  7462. * Updates the bounding sphere and box
  7463. * @param world world matrix to be used to update
  7464. */
  7465. update(world: DeepImmutable<Matrix>): void;
  7466. /**
  7467. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7468. * @param center New center of the bounding info
  7469. * @param extend New extend of the bounding info
  7470. * @returns the current bounding info
  7471. */
  7472. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7473. /**
  7474. * Scale the current bounding info by applying a scale factor
  7475. * @param factor defines the scale factor to apply
  7476. * @returns the current bounding info
  7477. */
  7478. scale(factor: number): BoundingInfo;
  7479. /**
  7480. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7481. * @param frustumPlanes defines the frustum to test
  7482. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7483. * @returns true if the bounding info is in the frustum planes
  7484. */
  7485. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7486. /**
  7487. * Gets the world distance between the min and max points of the bounding box
  7488. */
  7489. readonly diagonalLength: number;
  7490. /**
  7491. * Checks if a cullable object (mesh...) is in the camera frustum
  7492. * Unlike isInFrustum this cheks the full bounding box
  7493. * @param frustumPlanes Camera near/planes
  7494. * @returns true if the object is in frustum otherwise false
  7495. */
  7496. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7497. /** @hidden */
  7498. _checkCollision(collider: Collider): boolean;
  7499. /**
  7500. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7501. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7502. * @param point the point to check intersection with
  7503. * @returns if the point intersects
  7504. */
  7505. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7506. /**
  7507. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7508. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7509. * @param boundingInfo the bounding info to check intersection with
  7510. * @param precise if the intersection should be done using OBB
  7511. * @returns if the bounding info intersects
  7512. */
  7513. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7514. }
  7515. }
  7516. declare module "babylonjs/Misc/smartArray" {
  7517. /**
  7518. * Defines an array and its length.
  7519. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7520. */
  7521. export interface ISmartArrayLike<T> {
  7522. /**
  7523. * The data of the array.
  7524. */
  7525. data: Array<T>;
  7526. /**
  7527. * The active length of the array.
  7528. */
  7529. length: number;
  7530. }
  7531. /**
  7532. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7533. */
  7534. export class SmartArray<T> implements ISmartArrayLike<T> {
  7535. /**
  7536. * The full set of data from the array.
  7537. */
  7538. data: Array<T>;
  7539. /**
  7540. * The active length of the array.
  7541. */
  7542. length: number;
  7543. protected _id: number;
  7544. /**
  7545. * Instantiates a Smart Array.
  7546. * @param capacity defines the default capacity of the array.
  7547. */
  7548. constructor(capacity: number);
  7549. /**
  7550. * Pushes a value at the end of the active data.
  7551. * @param value defines the object to push in the array.
  7552. */
  7553. push(value: T): void;
  7554. /**
  7555. * Iterates over the active data and apply the lambda to them.
  7556. * @param func defines the action to apply on each value.
  7557. */
  7558. forEach(func: (content: T) => void): void;
  7559. /**
  7560. * Sorts the full sets of data.
  7561. * @param compareFn defines the comparison function to apply.
  7562. */
  7563. sort(compareFn: (a: T, b: T) => number): void;
  7564. /**
  7565. * Resets the active data to an empty array.
  7566. */
  7567. reset(): void;
  7568. /**
  7569. * Releases all the data from the array as well as the array.
  7570. */
  7571. dispose(): void;
  7572. /**
  7573. * Concats the active data with a given array.
  7574. * @param array defines the data to concatenate with.
  7575. */
  7576. concat(array: any): void;
  7577. /**
  7578. * Returns the position of a value in the active data.
  7579. * @param value defines the value to find the index for
  7580. * @returns the index if found in the active data otherwise -1
  7581. */
  7582. indexOf(value: T): number;
  7583. /**
  7584. * Returns whether an element is part of the active data.
  7585. * @param value defines the value to look for
  7586. * @returns true if found in the active data otherwise false
  7587. */
  7588. contains(value: T): boolean;
  7589. private static _GlobalId;
  7590. }
  7591. /**
  7592. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7593. * The data in this array can only be present once
  7594. */
  7595. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7596. private _duplicateId;
  7597. /**
  7598. * Pushes a value at the end of the active data.
  7599. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7600. * @param value defines the object to push in the array.
  7601. */
  7602. push(value: T): void;
  7603. /**
  7604. * Pushes a value at the end of the active data.
  7605. * If the data is already present, it won t be added again
  7606. * @param value defines the object to push in the array.
  7607. * @returns true if added false if it was already present
  7608. */
  7609. pushNoDuplicate(value: T): boolean;
  7610. /**
  7611. * Resets the active data to an empty array.
  7612. */
  7613. reset(): void;
  7614. /**
  7615. * Concats the active data with a given array.
  7616. * This ensures no dupplicate will be present in the result.
  7617. * @param array defines the data to concatenate with.
  7618. */
  7619. concatWithNoDuplicate(array: any): void;
  7620. }
  7621. }
  7622. declare module "babylonjs/Misc/iInspectable" {
  7623. /**
  7624. * Enum that determines the text-wrapping mode to use.
  7625. */
  7626. export enum InspectableType {
  7627. /**
  7628. * Checkbox for booleans
  7629. */
  7630. Checkbox = 0,
  7631. /**
  7632. * Sliders for numbers
  7633. */
  7634. Slider = 1,
  7635. /**
  7636. * Vector3
  7637. */
  7638. Vector3 = 2,
  7639. /**
  7640. * Quaternions
  7641. */
  7642. Quaternion = 3,
  7643. /**
  7644. * Color3
  7645. */
  7646. Color3 = 4
  7647. }
  7648. /**
  7649. * Interface used to define custom inspectable properties.
  7650. * This interface is used by the inspector to display custom property grids
  7651. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7652. */
  7653. export interface IInspectable {
  7654. /**
  7655. * Gets the label to display
  7656. */
  7657. label: string;
  7658. /**
  7659. * Gets the name of the property to edit
  7660. */
  7661. propertyName: string;
  7662. /**
  7663. * Gets the type of the editor to use
  7664. */
  7665. type: InspectableType;
  7666. /**
  7667. * Gets the minimum value of the property when using in "slider" mode
  7668. */
  7669. min?: number;
  7670. /**
  7671. * Gets the maximum value of the property when using in "slider" mode
  7672. */
  7673. max?: number;
  7674. /**
  7675. * Gets the setp to use when using in "slider" mode
  7676. */
  7677. step?: number;
  7678. }
  7679. }
  7680. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  7681. import { Nullable } from "babylonjs/types";
  7682. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7683. /**
  7684. * This represents the required contract to create a new type of texture loader.
  7685. */
  7686. export interface IInternalTextureLoader {
  7687. /**
  7688. * Defines wether the loader supports cascade loading the different faces.
  7689. */
  7690. supportCascades: boolean;
  7691. /**
  7692. * This returns if the loader support the current file information.
  7693. * @param extension defines the file extension of the file being loaded
  7694. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7695. * @param fallback defines the fallback internal texture if any
  7696. * @param isBase64 defines whether the texture is encoded as a base64
  7697. * @param isBuffer defines whether the texture data are stored as a buffer
  7698. * @returns true if the loader can load the specified file
  7699. */
  7700. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  7701. /**
  7702. * Transform the url before loading if required.
  7703. * @param rootUrl the url of the texture
  7704. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7705. * @returns the transformed texture
  7706. */
  7707. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  7708. /**
  7709. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  7710. * @param rootUrl the url of the texture
  7711. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7712. * @returns the fallback texture
  7713. */
  7714. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  7715. /**
  7716. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  7717. * @param data contains the texture data
  7718. * @param texture defines the BabylonJS internal texture
  7719. * @param createPolynomials will be true if polynomials have been requested
  7720. * @param onLoad defines the callback to trigger once the texture is ready
  7721. * @param onError defines the callback to trigger in case of error
  7722. */
  7723. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  7724. /**
  7725. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  7726. * @param data contains the texture data
  7727. * @param texture defines the BabylonJS internal texture
  7728. * @param callback defines the method to call once ready to upload
  7729. */
  7730. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  7731. }
  7732. }
  7733. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7734. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7735. import { Nullable } from "babylonjs/types";
  7736. import { Scene } from "babylonjs/scene";
  7737. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7738. module "babylonjs/Engines/engine" {
  7739. interface Engine {
  7740. /**
  7741. * Creates a depth stencil cube texture.
  7742. * This is only available in WebGL 2.
  7743. * @param size The size of face edge in the cube texture.
  7744. * @param options The options defining the cube texture.
  7745. * @returns The cube texture
  7746. */
  7747. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7748. /**
  7749. * Creates a cube texture
  7750. * @param rootUrl defines the url where the files to load is located
  7751. * @param scene defines the current scene
  7752. * @param files defines the list of files to load (1 per face)
  7753. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7754. * @param onLoad defines an optional callback raised when the texture is loaded
  7755. * @param onError defines an optional callback raised if there is an issue to load the texture
  7756. * @param format defines the format of the data
  7757. * @param forcedExtension defines the extension to use to pick the right loader
  7758. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7759. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7760. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7761. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7762. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7763. * @returns the cube texture as an InternalTexture
  7764. */
  7765. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  7766. /**
  7767. * Creates a cube texture
  7768. * @param rootUrl defines the url where the files to load is located
  7769. * @param scene defines the current scene
  7770. * @param files defines the list of files to load (1 per face)
  7771. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7772. * @param onLoad defines an optional callback raised when the texture is loaded
  7773. * @param onError defines an optional callback raised if there is an issue to load the texture
  7774. * @param format defines the format of the data
  7775. * @param forcedExtension defines the extension to use to pick the right loader
  7776. * @returns the cube texture as an InternalTexture
  7777. */
  7778. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  7779. /**
  7780. * Creates a cube texture
  7781. * @param rootUrl defines the url where the files to load is located
  7782. * @param scene defines the current scene
  7783. * @param files defines the list of files to load (1 per face)
  7784. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7785. * @param onLoad defines an optional callback raised when the texture is loaded
  7786. * @param onError defines an optional callback raised if there is an issue to load the texture
  7787. * @param format defines the format of the data
  7788. * @param forcedExtension defines the extension to use to pick the right loader
  7789. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7790. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7791. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7792. * @returns the cube texture as an InternalTexture
  7793. */
  7794. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  7795. /** @hidden */
  7796. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7797. /** @hidden */
  7798. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7799. /** @hidden */
  7800. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7801. /** @hidden */
  7802. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7803. }
  7804. }
  7805. }
  7806. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7807. import { Nullable } from "babylonjs/types";
  7808. import { Scene } from "babylonjs/scene";
  7809. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  7810. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7811. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7812. /**
  7813. * Class for creating a cube texture
  7814. */
  7815. export class CubeTexture extends BaseTexture {
  7816. private _delayedOnLoad;
  7817. /**
  7818. * The url of the texture
  7819. */
  7820. url: string;
  7821. /**
  7822. * Gets or sets the center of the bounding box associated with the cube texture.
  7823. * It must define where the camera used to render the texture was set
  7824. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7825. */
  7826. boundingBoxPosition: Vector3;
  7827. private _boundingBoxSize;
  7828. /**
  7829. * Gets or sets the size of the bounding box associated with the cube texture
  7830. * When defined, the cubemap will switch to local mode
  7831. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7832. * @example https://www.babylonjs-playground.com/#RNASML
  7833. */
  7834. /**
  7835. * Returns the bounding box size
  7836. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7837. */
  7838. boundingBoxSize: Vector3;
  7839. protected _rotationY: number;
  7840. /**
  7841. * Sets texture matrix rotation angle around Y axis in radians.
  7842. */
  7843. /**
  7844. * Gets texture matrix rotation angle around Y axis radians.
  7845. */
  7846. rotationY: number;
  7847. /**
  7848. * Are mip maps generated for this texture or not.
  7849. */
  7850. readonly noMipmap: boolean;
  7851. private _noMipmap;
  7852. private _files;
  7853. private _extensions;
  7854. private _textureMatrix;
  7855. private _format;
  7856. private _createPolynomials;
  7857. /** @hidden */
  7858. _prefiltered: boolean;
  7859. /**
  7860. * Creates a cube texture from an array of image urls
  7861. * @param files defines an array of image urls
  7862. * @param scene defines the hosting scene
  7863. * @param noMipmap specifies if mip maps are not used
  7864. * @returns a cube texture
  7865. */
  7866. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7867. /**
  7868. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7869. * @param url defines the url of the prefiltered texture
  7870. * @param scene defines the scene the texture is attached to
  7871. * @param forcedExtension defines the extension of the file if different from the url
  7872. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7873. * @return the prefiltered texture
  7874. */
  7875. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7876. /**
  7877. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7878. * as prefiltered data.
  7879. * @param rootUrl defines the url of the texture or the root name of the six images
  7880. * @param scene defines the scene the texture is attached to
  7881. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7882. * @param noMipmap defines if mipmaps should be created or not
  7883. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7884. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7885. * @param onError defines a callback triggered in case of error during load
  7886. * @param format defines the internal format to use for the texture once loaded
  7887. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7888. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7889. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7890. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7891. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7892. * @return the cube texture
  7893. */
  7894. 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);
  7895. /**
  7896. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7897. */
  7898. readonly isPrefiltered: boolean;
  7899. /**
  7900. * Get the current class name of the texture useful for serialization or dynamic coding.
  7901. * @returns "CubeTexture"
  7902. */
  7903. getClassName(): string;
  7904. /**
  7905. * Update the url (and optional buffer) of this texture if url was null during construction.
  7906. * @param url the url of the texture
  7907. * @param forcedExtension defines the extension to use
  7908. * @param onLoad callback called when the texture is loaded (defaults to null)
  7909. */
  7910. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7911. /**
  7912. * Delays loading of the cube texture
  7913. * @param forcedExtension defines the extension to use
  7914. */
  7915. delayLoad(forcedExtension?: string): void;
  7916. /**
  7917. * Returns the reflection texture matrix
  7918. * @returns the reflection texture matrix
  7919. */
  7920. getReflectionTextureMatrix(): Matrix;
  7921. /**
  7922. * Sets the reflection texture matrix
  7923. * @param value Reflection texture matrix
  7924. */
  7925. setReflectionTextureMatrix(value: Matrix): void;
  7926. /**
  7927. * Parses text to create a cube texture
  7928. * @param parsedTexture define the serialized text to read from
  7929. * @param scene defines the hosting scene
  7930. * @param rootUrl defines the root url of the cube texture
  7931. * @returns a cube texture
  7932. */
  7933. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7934. /**
  7935. * Makes a clone, or deep copy, of the cube texture
  7936. * @returns a new cube texture
  7937. */
  7938. clone(): CubeTexture;
  7939. }
  7940. }
  7941. declare module "babylonjs/Shaders/postprocess.vertex" {
  7942. /** @hidden */
  7943. export var postprocessVertexShader: {
  7944. name: string;
  7945. shader: string;
  7946. };
  7947. }
  7948. declare module "babylonjs/Cameras/targetCamera" {
  7949. import { Nullable } from "babylonjs/types";
  7950. import { Camera } from "babylonjs/Cameras/camera";
  7951. import { Scene } from "babylonjs/scene";
  7952. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  7953. /**
  7954. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  7955. * This is the base of the follow, arc rotate cameras and Free camera
  7956. * @see http://doc.babylonjs.com/features/cameras
  7957. */
  7958. export class TargetCamera extends Camera {
  7959. private static _RigCamTransformMatrix;
  7960. private static _TargetTransformMatrix;
  7961. private static _TargetFocalPoint;
  7962. /**
  7963. * Define the current direction the camera is moving to
  7964. */
  7965. cameraDirection: Vector3;
  7966. /**
  7967. * Define the current rotation the camera is rotating to
  7968. */
  7969. cameraRotation: Vector2;
  7970. /**
  7971. * When set, the up vector of the camera will be updated by the rotation of the camera
  7972. */
  7973. updateUpVectorFromRotation: boolean;
  7974. private _tmpQuaternion;
  7975. /**
  7976. * Define the current rotation of the camera
  7977. */
  7978. rotation: Vector3;
  7979. /**
  7980. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  7981. */
  7982. rotationQuaternion: Quaternion;
  7983. /**
  7984. * Define the current speed of the camera
  7985. */
  7986. speed: number;
  7987. /**
  7988. * Add cconstraint to the camera to prevent it to move freely in all directions and
  7989. * around all axis.
  7990. */
  7991. noRotationConstraint: boolean;
  7992. /**
  7993. * Define the current target of the camera as an object or a position.
  7994. */
  7995. lockedTarget: any;
  7996. /** @hidden */
  7997. _currentTarget: Vector3;
  7998. /** @hidden */
  7999. _initialFocalDistance: number;
  8000. /** @hidden */
  8001. _viewMatrix: Matrix;
  8002. /** @hidden */
  8003. _camMatrix: Matrix;
  8004. /** @hidden */
  8005. _cameraTransformMatrix: Matrix;
  8006. /** @hidden */
  8007. _cameraRotationMatrix: Matrix;
  8008. /** @hidden */
  8009. _referencePoint: Vector3;
  8010. /** @hidden */
  8011. _transformedReferencePoint: Vector3;
  8012. protected _globalCurrentTarget: Vector3;
  8013. protected _globalCurrentUpVector: Vector3;
  8014. /** @hidden */
  8015. _reset: () => void;
  8016. private _defaultUp;
  8017. /**
  8018. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8019. * This is the base of the follow, arc rotate cameras and Free camera
  8020. * @see http://doc.babylonjs.com/features/cameras
  8021. * @param name Defines the name of the camera in the scene
  8022. * @param position Defines the start position of the camera in the scene
  8023. * @param scene Defines the scene the camera belongs to
  8024. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8025. */
  8026. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8027. /**
  8028. * Gets the position in front of the camera at a given distance.
  8029. * @param distance The distance from the camera we want the position to be
  8030. * @returns the position
  8031. */
  8032. getFrontPosition(distance: number): Vector3;
  8033. /** @hidden */
  8034. _getLockedTargetPosition(): Nullable<Vector3>;
  8035. private _storedPosition;
  8036. private _storedRotation;
  8037. private _storedRotationQuaternion;
  8038. /**
  8039. * Store current camera state of the camera (fov, position, rotation, etc..)
  8040. * @returns the camera
  8041. */
  8042. storeState(): Camera;
  8043. /**
  8044. * Restored camera state. You must call storeState() first
  8045. * @returns whether it was successful or not
  8046. * @hidden
  8047. */
  8048. _restoreStateValues(): boolean;
  8049. /** @hidden */
  8050. _initCache(): void;
  8051. /** @hidden */
  8052. _updateCache(ignoreParentClass?: boolean): void;
  8053. /** @hidden */
  8054. _isSynchronizedViewMatrix(): boolean;
  8055. /** @hidden */
  8056. _computeLocalCameraSpeed(): number;
  8057. /**
  8058. * Defines the target the camera should look at.
  8059. * This will automatically adapt alpha beta and radius to fit within the new target.
  8060. * @param target Defines the new target as a Vector or a mesh
  8061. */
  8062. setTarget(target: Vector3): void;
  8063. /**
  8064. * Return the current target position of the camera. This value is expressed in local space.
  8065. * @returns the target position
  8066. */
  8067. getTarget(): Vector3;
  8068. /** @hidden */
  8069. _decideIfNeedsToMove(): boolean;
  8070. /** @hidden */
  8071. _updatePosition(): void;
  8072. /** @hidden */
  8073. _checkInputs(): void;
  8074. protected _updateCameraRotationMatrix(): void;
  8075. /**
  8076. * 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)
  8077. * @returns the current camera
  8078. */
  8079. private _rotateUpVectorWithCameraRotationMatrix;
  8080. private _cachedRotationZ;
  8081. private _cachedQuaternionRotationZ;
  8082. /** @hidden */
  8083. _getViewMatrix(): Matrix;
  8084. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8085. /**
  8086. * @hidden
  8087. */
  8088. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8089. /**
  8090. * @hidden
  8091. */
  8092. _updateRigCameras(): void;
  8093. private _getRigCamPositionAndTarget;
  8094. /**
  8095. * Gets the current object class name.
  8096. * @return the class name
  8097. */
  8098. getClassName(): string;
  8099. }
  8100. }
  8101. declare module "babylonjs/Cameras/cameraInputsManager" {
  8102. import { Nullable } from "babylonjs/types";
  8103. import { Camera } from "babylonjs/Cameras/camera";
  8104. /**
  8105. * @ignore
  8106. * This is a list of all the different input types that are available in the application.
  8107. * Fo instance: ArcRotateCameraGamepadInput...
  8108. */
  8109. export var CameraInputTypes: {};
  8110. /**
  8111. * This is the contract to implement in order to create a new input class.
  8112. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8113. */
  8114. export interface ICameraInput<TCamera extends Camera> {
  8115. /**
  8116. * Defines the camera the input is attached to.
  8117. */
  8118. camera: Nullable<TCamera>;
  8119. /**
  8120. * Gets the class name of the current intput.
  8121. * @returns the class name
  8122. */
  8123. getClassName(): string;
  8124. /**
  8125. * Get the friendly name associated with the input class.
  8126. * @returns the input friendly name
  8127. */
  8128. getSimpleName(): string;
  8129. /**
  8130. * Attach the input controls to a specific dom element to get the input from.
  8131. * @param element Defines the element the controls should be listened from
  8132. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8133. */
  8134. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8135. /**
  8136. * Detach the current controls from the specified dom element.
  8137. * @param element Defines the element to stop listening the inputs from
  8138. */
  8139. detachControl(element: Nullable<HTMLElement>): void;
  8140. /**
  8141. * Update the current camera state depending on the inputs that have been used this frame.
  8142. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8143. */
  8144. checkInputs?: () => void;
  8145. }
  8146. /**
  8147. * Represents a map of input types to input instance or input index to input instance.
  8148. */
  8149. export interface CameraInputsMap<TCamera extends Camera> {
  8150. /**
  8151. * Accessor to the input by input type.
  8152. */
  8153. [name: string]: ICameraInput<TCamera>;
  8154. /**
  8155. * Accessor to the input by input index.
  8156. */
  8157. [idx: number]: ICameraInput<TCamera>;
  8158. }
  8159. /**
  8160. * This represents the input manager used within a camera.
  8161. * It helps dealing with all the different kind of input attached to a camera.
  8162. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8163. */
  8164. export class CameraInputsManager<TCamera extends Camera> {
  8165. /**
  8166. * Defines the list of inputs attahed to the camera.
  8167. */
  8168. attached: CameraInputsMap<TCamera>;
  8169. /**
  8170. * Defines the dom element the camera is collecting inputs from.
  8171. * This is null if the controls have not been attached.
  8172. */
  8173. attachedElement: Nullable<HTMLElement>;
  8174. /**
  8175. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8176. */
  8177. noPreventDefault: boolean;
  8178. /**
  8179. * Defined the camera the input manager belongs to.
  8180. */
  8181. camera: TCamera;
  8182. /**
  8183. * Update the current camera state depending on the inputs that have been used this frame.
  8184. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8185. */
  8186. checkInputs: () => void;
  8187. /**
  8188. * Instantiate a new Camera Input Manager.
  8189. * @param camera Defines the camera the input manager blongs to
  8190. */
  8191. constructor(camera: TCamera);
  8192. /**
  8193. * Add an input method to a camera
  8194. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8195. * @param input camera input method
  8196. */
  8197. add(input: ICameraInput<TCamera>): void;
  8198. /**
  8199. * Remove a specific input method from a camera
  8200. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8201. * @param inputToRemove camera input method
  8202. */
  8203. remove(inputToRemove: ICameraInput<TCamera>): void;
  8204. /**
  8205. * Remove a specific input type from a camera
  8206. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8207. * @param inputType the type of the input to remove
  8208. */
  8209. removeByType(inputType: string): void;
  8210. private _addCheckInputs;
  8211. /**
  8212. * Attach the input controls to the currently attached dom element to listen the events from.
  8213. * @param input Defines the input to attach
  8214. */
  8215. attachInput(input: ICameraInput<TCamera>): void;
  8216. /**
  8217. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8218. * @param element Defines the dom element to collect the events from
  8219. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8220. */
  8221. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8222. /**
  8223. * Detach the current manager inputs controls from a specific dom element.
  8224. * @param element Defines the dom element to collect the events from
  8225. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8226. */
  8227. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8228. /**
  8229. * Rebuild the dynamic inputCheck function from the current list of
  8230. * defined inputs in the manager.
  8231. */
  8232. rebuildInputCheck(): void;
  8233. /**
  8234. * Remove all attached input methods from a camera
  8235. */
  8236. clear(): void;
  8237. /**
  8238. * Serialize the current input manager attached to a camera.
  8239. * This ensures than once parsed,
  8240. * the input associated to the camera will be identical to the current ones
  8241. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8242. */
  8243. serialize(serializedCamera: any): void;
  8244. /**
  8245. * Parses an input manager serialized JSON to restore the previous list of inputs
  8246. * and states associated to a camera.
  8247. * @param parsedCamera Defines the JSON to parse
  8248. */
  8249. parse(parsedCamera: any): void;
  8250. }
  8251. }
  8252. declare module "babylonjs/Events/keyboardEvents" {
  8253. /**
  8254. * Gather the list of keyboard event types as constants.
  8255. */
  8256. export class KeyboardEventTypes {
  8257. /**
  8258. * The keydown event is fired when a key becomes active (pressed).
  8259. */
  8260. static readonly KEYDOWN: number;
  8261. /**
  8262. * The keyup event is fired when a key has been released.
  8263. */
  8264. static readonly KEYUP: number;
  8265. }
  8266. /**
  8267. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8268. */
  8269. export class KeyboardInfo {
  8270. /**
  8271. * Defines the type of event (KeyboardEventTypes)
  8272. */
  8273. type: number;
  8274. /**
  8275. * Defines the related dom event
  8276. */
  8277. event: KeyboardEvent;
  8278. /**
  8279. * Instantiates a new keyboard info.
  8280. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8281. * @param type Defines the type of event (KeyboardEventTypes)
  8282. * @param event Defines the related dom event
  8283. */
  8284. constructor(
  8285. /**
  8286. * Defines the type of event (KeyboardEventTypes)
  8287. */
  8288. type: number,
  8289. /**
  8290. * Defines the related dom event
  8291. */
  8292. event: KeyboardEvent);
  8293. }
  8294. /**
  8295. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8296. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8297. */
  8298. export class KeyboardInfoPre extends KeyboardInfo {
  8299. /**
  8300. * Defines the type of event (KeyboardEventTypes)
  8301. */
  8302. type: number;
  8303. /**
  8304. * Defines the related dom event
  8305. */
  8306. event: KeyboardEvent;
  8307. /**
  8308. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8309. */
  8310. skipOnPointerObservable: boolean;
  8311. /**
  8312. * Instantiates a new keyboard pre info.
  8313. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8314. * @param type Defines the type of event (KeyboardEventTypes)
  8315. * @param event Defines the related dom event
  8316. */
  8317. constructor(
  8318. /**
  8319. * Defines the type of event (KeyboardEventTypes)
  8320. */
  8321. type: number,
  8322. /**
  8323. * Defines the related dom event
  8324. */
  8325. event: KeyboardEvent);
  8326. }
  8327. }
  8328. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8329. import { Nullable } from "babylonjs/types";
  8330. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8331. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8332. /**
  8333. * Manage the keyboard inputs to control the movement of a free camera.
  8334. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8335. */
  8336. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8337. /**
  8338. * Defines the camera the input is attached to.
  8339. */
  8340. camera: FreeCamera;
  8341. /**
  8342. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8343. */
  8344. keysUp: number[];
  8345. /**
  8346. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8347. */
  8348. keysDown: number[];
  8349. /**
  8350. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8351. */
  8352. keysLeft: number[];
  8353. /**
  8354. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8355. */
  8356. keysRight: number[];
  8357. private _keys;
  8358. private _onCanvasBlurObserver;
  8359. private _onKeyboardObserver;
  8360. private _engine;
  8361. private _scene;
  8362. /**
  8363. * Attach the input controls to a specific dom element to get the input from.
  8364. * @param element Defines the element the controls should be listened from
  8365. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8366. */
  8367. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8368. /**
  8369. * Detach the current controls from the specified dom element.
  8370. * @param element Defines the element to stop listening the inputs from
  8371. */
  8372. detachControl(element: Nullable<HTMLElement>): void;
  8373. /**
  8374. * Update the current camera state depending on the inputs that have been used this frame.
  8375. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8376. */
  8377. checkInputs(): void;
  8378. /**
  8379. * Gets the class name of the current intput.
  8380. * @returns the class name
  8381. */
  8382. getClassName(): string;
  8383. /** @hidden */
  8384. _onLostFocus(): void;
  8385. /**
  8386. * Get the friendly name associated with the input class.
  8387. * @returns the input friendly name
  8388. */
  8389. getSimpleName(): string;
  8390. }
  8391. }
  8392. declare module "babylonjs/Materials/multiMaterial" {
  8393. import { Nullable } from "babylonjs/types";
  8394. import { Scene } from "babylonjs/scene";
  8395. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8396. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  8397. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8398. import { Material } from "babylonjs/Materials/material";
  8399. /**
  8400. * A multi-material is used to apply different materials to different parts of the same object without the need of
  8401. * separate meshes. This can be use to improve performances.
  8402. * @see http://doc.babylonjs.com/how_to/multi_materials
  8403. */
  8404. export class MultiMaterial extends Material {
  8405. private _subMaterials;
  8406. /**
  8407. * Gets or Sets the list of Materials used within the multi material.
  8408. * They need to be ordered according to the submeshes order in the associated mesh
  8409. */
  8410. subMaterials: Nullable<Material>[];
  8411. /**
  8412. * Function used to align with Node.getChildren()
  8413. * @returns the list of Materials used within the multi material
  8414. */
  8415. getChildren(): Nullable<Material>[];
  8416. /**
  8417. * Instantiates a new Multi Material
  8418. * A multi-material is used to apply different materials to different parts of the same object without the need of
  8419. * separate meshes. This can be use to improve performances.
  8420. * @see http://doc.babylonjs.com/how_to/multi_materials
  8421. * @param name Define the name in the scene
  8422. * @param scene Define the scene the material belongs to
  8423. */
  8424. constructor(name: string, scene: Scene);
  8425. private _hookArray;
  8426. /**
  8427. * Get one of the submaterial by its index in the submaterials array
  8428. * @param index The index to look the sub material at
  8429. * @returns The Material if the index has been defined
  8430. */
  8431. getSubMaterial(index: number): Nullable<Material>;
  8432. /**
  8433. * Get the list of active textures for the whole sub materials list.
  8434. * @returns All the textures that will be used during the rendering
  8435. */
  8436. getActiveTextures(): BaseTexture[];
  8437. /**
  8438. * Gets the current class name of the material e.g. "MultiMaterial"
  8439. * Mainly use in serialization.
  8440. * @returns the class name
  8441. */
  8442. getClassName(): string;
  8443. /**
  8444. * Checks if the material is ready to render the requested sub mesh
  8445. * @param mesh Define the mesh the submesh belongs to
  8446. * @param subMesh Define the sub mesh to look readyness for
  8447. * @param useInstances Define whether or not the material is used with instances
  8448. * @returns true if ready, otherwise false
  8449. */
  8450. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  8451. /**
  8452. * Clones the current material and its related sub materials
  8453. * @param name Define the name of the newly cloned material
  8454. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  8455. * @returns the cloned material
  8456. */
  8457. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  8458. /**
  8459. * Serializes the materials into a JSON representation.
  8460. * @returns the JSON representation
  8461. */
  8462. serialize(): any;
  8463. /**
  8464. * Dispose the material and release its associated resources
  8465. * @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)
  8466. * @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)
  8467. * @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)
  8468. */
  8469. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  8470. /**
  8471. * Creates a MultiMaterial from parsed MultiMaterial data.
  8472. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  8473. * @param scene defines the hosting scene
  8474. * @returns a new MultiMaterial
  8475. */
  8476. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  8477. }
  8478. }
  8479. declare module "babylonjs/Loading/sceneLoaderFlags" {
  8480. /**
  8481. * Class used to represent data loading progression
  8482. */
  8483. export class SceneLoaderFlags {
  8484. private static _ForceFullSceneLoadingForIncremental;
  8485. private static _ShowLoadingScreen;
  8486. private static _CleanBoneMatrixWeights;
  8487. private static _loggingLevel;
  8488. /**
  8489. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  8490. */
  8491. static ForceFullSceneLoadingForIncremental: boolean;
  8492. /**
  8493. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  8494. */
  8495. static ShowLoadingScreen: boolean;
  8496. /**
  8497. * Defines the current logging level (while loading the scene)
  8498. * @ignorenaming
  8499. */
  8500. static loggingLevel: number;
  8501. /**
  8502. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  8503. */
  8504. static CleanBoneMatrixWeights: boolean;
  8505. }
  8506. }
  8507. declare module "babylonjs/Meshes/transformNode" {
  8508. import { DeepImmutable } from "babylonjs/types";
  8509. import { Observable } from "babylonjs/Misc/observable";
  8510. import { Nullable } from "babylonjs/types";
  8511. import { Camera } from "babylonjs/Cameras/camera";
  8512. import { Scene } from "babylonjs/scene";
  8513. import { Quaternion, Matrix, Vector3, Space } from "babylonjs/Maths/math";
  8514. import { Node } from "babylonjs/node";
  8515. import { Bone } from "babylonjs/Bones/bone";
  8516. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8517. /**
  8518. * 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.
  8519. * @see https://doc.babylonjs.com/how_to/transformnode
  8520. */
  8521. export class TransformNode extends Node {
  8522. /**
  8523. * Object will not rotate to face the camera
  8524. */
  8525. static BILLBOARDMODE_NONE: number;
  8526. /**
  8527. * Object will rotate to face the camera but only on the x axis
  8528. */
  8529. static BILLBOARDMODE_X: number;
  8530. /**
  8531. * Object will rotate to face the camera but only on the y axis
  8532. */
  8533. static BILLBOARDMODE_Y: number;
  8534. /**
  8535. * Object will rotate to face the camera but only on the z axis
  8536. */
  8537. static BILLBOARDMODE_Z: number;
  8538. /**
  8539. * Object will rotate to face the camera
  8540. */
  8541. static BILLBOARDMODE_ALL: number;
  8542. private _forward;
  8543. private _forwardInverted;
  8544. private _up;
  8545. private _right;
  8546. private _rightInverted;
  8547. private _position;
  8548. private _rotation;
  8549. private _rotationQuaternion;
  8550. protected _scaling: Vector3;
  8551. protected _isDirty: boolean;
  8552. private _transformToBoneReferal;
  8553. private _billboardMode;
  8554. /**
  8555. * Gets or sets the billboard mode. Default is 0.
  8556. *
  8557. * | Value | Type | Description |
  8558. * | --- | --- | --- |
  8559. * | 0 | BILLBOARDMODE_NONE | |
  8560. * | 1 | BILLBOARDMODE_X | |
  8561. * | 2 | BILLBOARDMODE_Y | |
  8562. * | 4 | BILLBOARDMODE_Z | |
  8563. * | 7 | BILLBOARDMODE_ALL | |
  8564. *
  8565. */
  8566. billboardMode: number;
  8567. private _preserveParentRotationForBillboard;
  8568. /**
  8569. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  8570. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  8571. */
  8572. preserveParentRotationForBillboard: boolean;
  8573. /**
  8574. * 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
  8575. */
  8576. scalingDeterminant: number;
  8577. private _infiniteDistance;
  8578. /**
  8579. * Gets or sets the distance of the object to max, often used by skybox
  8580. */
  8581. infiniteDistance: boolean;
  8582. /**
  8583. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  8584. * By default the system will update normals to compensate
  8585. */
  8586. ignoreNonUniformScaling: boolean;
  8587. /**
  8588. * 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
  8589. */
  8590. reIntegrateRotationIntoRotationQuaternion: boolean;
  8591. /** @hidden */
  8592. _poseMatrix: Nullable<Matrix>;
  8593. /** @hidden */
  8594. _localMatrix: Matrix;
  8595. private _usePivotMatrix;
  8596. private _absolutePosition;
  8597. private _pivotMatrix;
  8598. private _pivotMatrixInverse;
  8599. protected _postMultiplyPivotMatrix: boolean;
  8600. protected _isWorldMatrixFrozen: boolean;
  8601. /** @hidden */
  8602. _indexInSceneTransformNodesArray: number;
  8603. /**
  8604. * An event triggered after the world matrix is updated
  8605. */
  8606. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  8607. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  8608. /**
  8609. * Gets a string identifying the name of the class
  8610. * @returns "TransformNode" string
  8611. */
  8612. getClassName(): string;
  8613. /**
  8614. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  8615. */
  8616. position: Vector3;
  8617. /**
  8618. * 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)).
  8619. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  8620. */
  8621. rotation: Vector3;
  8622. /**
  8623. * 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)).
  8624. */
  8625. scaling: Vector3;
  8626. /**
  8627. * 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).
  8628. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  8629. */
  8630. rotationQuaternion: Nullable<Quaternion>;
  8631. /**
  8632. * The forward direction of that transform in world space.
  8633. */
  8634. readonly forward: Vector3;
  8635. /**
  8636. * The up direction of that transform in world space.
  8637. */
  8638. readonly up: Vector3;
  8639. /**
  8640. * The right direction of that transform in world space.
  8641. */
  8642. readonly right: Vector3;
  8643. /**
  8644. * Copies the parameter passed Matrix into the mesh Pose matrix.
  8645. * @param matrix the matrix to copy the pose from
  8646. * @returns this TransformNode.
  8647. */
  8648. updatePoseMatrix(matrix: Matrix): TransformNode;
  8649. /**
  8650. * Returns the mesh Pose matrix.
  8651. * @returns the pose matrix
  8652. */
  8653. getPoseMatrix(): Matrix;
  8654. /** @hidden */
  8655. _isSynchronized(): boolean;
  8656. /** @hidden */
  8657. _initCache(): void;
  8658. /**
  8659. * Flag the transform node as dirty (Forcing it to update everything)
  8660. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  8661. * @returns this transform node
  8662. */
  8663. markAsDirty(property: string): TransformNode;
  8664. /**
  8665. * Returns the current mesh absolute position.
  8666. * Returns a Vector3.
  8667. */
  8668. readonly absolutePosition: Vector3;
  8669. /**
  8670. * Sets a new matrix to apply before all other transformation
  8671. * @param matrix defines the transform matrix
  8672. * @returns the current TransformNode
  8673. */
  8674. setPreTransformMatrix(matrix: Matrix): TransformNode;
  8675. /**
  8676. * Sets a new pivot matrix to the current node
  8677. * @param matrix defines the new pivot matrix to use
  8678. * @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
  8679. * @returns the current TransformNode
  8680. */
  8681. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  8682. /**
  8683. * Returns the mesh pivot matrix.
  8684. * Default : Identity.
  8685. * @returns the matrix
  8686. */
  8687. getPivotMatrix(): Matrix;
  8688. /**
  8689. * Prevents the World matrix to be computed any longer.
  8690. * @returns the TransformNode.
  8691. */
  8692. freezeWorldMatrix(): TransformNode;
  8693. /**
  8694. * Allows back the World matrix computation.
  8695. * @returns the TransformNode.
  8696. */
  8697. unfreezeWorldMatrix(): this;
  8698. /**
  8699. * True if the World matrix has been frozen.
  8700. */
  8701. readonly isWorldMatrixFrozen: boolean;
  8702. /**
  8703. * Retuns the mesh absolute position in the World.
  8704. * @returns a Vector3.
  8705. */
  8706. getAbsolutePosition(): Vector3;
  8707. /**
  8708. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  8709. * @param absolutePosition the absolute position to set
  8710. * @returns the TransformNode.
  8711. */
  8712. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  8713. /**
  8714. * Sets the mesh position in its local space.
  8715. * @param vector3 the position to set in localspace
  8716. * @returns the TransformNode.
  8717. */
  8718. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  8719. /**
  8720. * Returns the mesh position in the local space from the current World matrix values.
  8721. * @returns a new Vector3.
  8722. */
  8723. getPositionExpressedInLocalSpace(): Vector3;
  8724. /**
  8725. * Translates the mesh along the passed Vector3 in its local space.
  8726. * @param vector3 the distance to translate in localspace
  8727. * @returns the TransformNode.
  8728. */
  8729. locallyTranslate(vector3: Vector3): TransformNode;
  8730. private static _lookAtVectorCache;
  8731. /**
  8732. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  8733. * @param targetPoint the position (must be in same space as current mesh) to look at
  8734. * @param yawCor optional yaw (y-axis) correction in radians
  8735. * @param pitchCor optional pitch (x-axis) correction in radians
  8736. * @param rollCor optional roll (z-axis) correction in radians
  8737. * @param space the choosen space of the target
  8738. * @returns the TransformNode.
  8739. */
  8740. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  8741. /**
  8742. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  8743. * This Vector3 is expressed in the World space.
  8744. * @param localAxis axis to rotate
  8745. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  8746. */
  8747. getDirection(localAxis: Vector3): Vector3;
  8748. /**
  8749. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  8750. * localAxis is expressed in the mesh local space.
  8751. * result is computed in the Wordl space from the mesh World matrix.
  8752. * @param localAxis axis to rotate
  8753. * @param result the resulting transformnode
  8754. * @returns this TransformNode.
  8755. */
  8756. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  8757. /**
  8758. * Sets this transform node rotation to the given local axis.
  8759. * @param localAxis the axis in local space
  8760. * @param yawCor optional yaw (y-axis) correction in radians
  8761. * @param pitchCor optional pitch (x-axis) correction in radians
  8762. * @param rollCor optional roll (z-axis) correction in radians
  8763. * @returns this TransformNode
  8764. */
  8765. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  8766. /**
  8767. * Sets a new pivot point to the current node
  8768. * @param point defines the new pivot point to use
  8769. * @param space defines if the point is in world or local space (local by default)
  8770. * @returns the current TransformNode
  8771. */
  8772. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  8773. /**
  8774. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  8775. * @returns the pivot point
  8776. */
  8777. getPivotPoint(): Vector3;
  8778. /**
  8779. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  8780. * @param result the vector3 to store the result
  8781. * @returns this TransformNode.
  8782. */
  8783. getPivotPointToRef(result: Vector3): TransformNode;
  8784. /**
  8785. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  8786. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  8787. */
  8788. getAbsolutePivotPoint(): Vector3;
  8789. /**
  8790. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  8791. * @param result vector3 to store the result
  8792. * @returns this TransformNode.
  8793. */
  8794. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  8795. /**
  8796. * Defines the passed node as the parent of the current node.
  8797. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  8798. * @see https://doc.babylonjs.com/how_to/parenting
  8799. * @param node the node ot set as the parent
  8800. * @returns this TransformNode.
  8801. */
  8802. setParent(node: Nullable<Node>): TransformNode;
  8803. private _nonUniformScaling;
  8804. /**
  8805. * True if the scaling property of this object is non uniform eg. (1,2,1)
  8806. */
  8807. readonly nonUniformScaling: boolean;
  8808. /** @hidden */
  8809. _updateNonUniformScalingState(value: boolean): boolean;
  8810. /**
  8811. * Attach the current TransformNode to another TransformNode associated with a bone
  8812. * @param bone Bone affecting the TransformNode
  8813. * @param affectedTransformNode TransformNode associated with the bone
  8814. * @returns this object
  8815. */
  8816. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  8817. /**
  8818. * Detach the transform node if its associated with a bone
  8819. * @returns this object
  8820. */
  8821. detachFromBone(): TransformNode;
  8822. private static _rotationAxisCache;
  8823. /**
  8824. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  8825. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  8826. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  8827. * The passed axis is also normalized.
  8828. * @param axis the axis to rotate around
  8829. * @param amount the amount to rotate in radians
  8830. * @param space Space to rotate in (Default: local)
  8831. * @returns the TransformNode.
  8832. */
  8833. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  8834. /**
  8835. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  8836. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  8837. * The passed axis is also normalized. .
  8838. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  8839. * @param point the point to rotate around
  8840. * @param axis the axis to rotate around
  8841. * @param amount the amount to rotate in radians
  8842. * @returns the TransformNode
  8843. */
  8844. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  8845. /**
  8846. * Translates the mesh along the axis vector for the passed distance in the given space.
  8847. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  8848. * @param axis the axis to translate in
  8849. * @param distance the distance to translate
  8850. * @param space Space to rotate in (Default: local)
  8851. * @returns the TransformNode.
  8852. */
  8853. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  8854. /**
  8855. * Adds a rotation step to the mesh current rotation.
  8856. * x, y, z are Euler angles expressed in radians.
  8857. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  8858. * This means this rotation is made in the mesh local space only.
  8859. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  8860. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  8861. * ```javascript
  8862. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  8863. * ```
  8864. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  8865. * 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.
  8866. * @param x Rotation to add
  8867. * @param y Rotation to add
  8868. * @param z Rotation to add
  8869. * @returns the TransformNode.
  8870. */
  8871. addRotation(x: number, y: number, z: number): TransformNode;
  8872. /**
  8873. * @hidden
  8874. */
  8875. protected _getEffectiveParent(): Nullable<Node>;
  8876. /**
  8877. * Computes the world matrix of the node
  8878. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8879. * @returns the world matrix
  8880. */
  8881. computeWorldMatrix(force?: boolean): Matrix;
  8882. protected _afterComputeWorldMatrix(): void;
  8883. /**
  8884. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  8885. * @param func callback function to add
  8886. *
  8887. * @returns the TransformNode.
  8888. */
  8889. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  8890. /**
  8891. * Removes a registered callback function.
  8892. * @param func callback function to remove
  8893. * @returns the TransformNode.
  8894. */
  8895. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  8896. /**
  8897. * Gets the position of the current mesh in camera space
  8898. * @param camera defines the camera to use
  8899. * @returns a position
  8900. */
  8901. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  8902. /**
  8903. * Returns the distance from the mesh to the active camera
  8904. * @param camera defines the camera to use
  8905. * @returns the distance
  8906. */
  8907. getDistanceToCamera(camera?: Nullable<Camera>): number;
  8908. /**
  8909. * Clone the current transform node
  8910. * @param name Name of the new clone
  8911. * @param newParent New parent for the clone
  8912. * @param doNotCloneChildren Do not clone children hierarchy
  8913. * @returns the new transform node
  8914. */
  8915. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  8916. /**
  8917. * Serializes the objects information.
  8918. * @param currentSerializationObject defines the object to serialize in
  8919. * @returns the serialized object
  8920. */
  8921. serialize(currentSerializationObject?: any): any;
  8922. /**
  8923. * Returns a new TransformNode object parsed from the source provided.
  8924. * @param parsedTransformNode is the source.
  8925. * @param scene the scne the object belongs to
  8926. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  8927. * @returns a new TransformNode object parsed from the source provided.
  8928. */
  8929. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  8930. /**
  8931. * Get all child-transformNodes of this node
  8932. * @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
  8933. * @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
  8934. * @returns an array of TransformNode
  8935. */
  8936. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  8937. /**
  8938. * Releases resources associated with this transform node.
  8939. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  8940. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  8941. */
  8942. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  8943. /**
  8944. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  8945. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  8946. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  8947. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  8948. * @returns the current mesh
  8949. */
  8950. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  8951. }
  8952. }
  8953. declare module "babylonjs/Animations/animationPropertiesOverride" {
  8954. /**
  8955. * Class used to override all child animations of a given target
  8956. */
  8957. export class AnimationPropertiesOverride {
  8958. /**
  8959. * Gets or sets a value indicating if animation blending must be used
  8960. */
  8961. enableBlending: boolean;
  8962. /**
  8963. * Gets or sets the blending speed to use when enableBlending is true
  8964. */
  8965. blendingSpeed: number;
  8966. /**
  8967. * Gets or sets the default loop mode to use
  8968. */
  8969. loopMode: number;
  8970. }
  8971. }
  8972. declare module "babylonjs/Bones/bone" {
  8973. import { Skeleton } from "babylonjs/Bones/skeleton";
  8974. import { Vector3, Quaternion, Matrix, Space } from "babylonjs/Maths/math";
  8975. import { Nullable } from "babylonjs/types";
  8976. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8977. import { TransformNode } from "babylonjs/Meshes/transformNode";
  8978. import { Node } from "babylonjs/node";
  8979. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  8980. /**
  8981. * Class used to store bone information
  8982. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  8983. */
  8984. export class Bone extends Node {
  8985. /**
  8986. * defines the bone name
  8987. */
  8988. name: string;
  8989. private static _tmpVecs;
  8990. private static _tmpQuat;
  8991. private static _tmpMats;
  8992. /**
  8993. * Gets the list of child bones
  8994. */
  8995. children: Bone[];
  8996. /** Gets the animations associated with this bone */
  8997. animations: import("babylonjs/Animations/animation").Animation[];
  8998. /**
  8999. * Gets or sets bone length
  9000. */
  9001. length: number;
  9002. /**
  9003. * @hidden Internal only
  9004. * Set this value to map this bone to a different index in the transform matrices
  9005. * Set this value to -1 to exclude the bone from the transform matrices
  9006. */
  9007. _index: Nullable<number>;
  9008. private _skeleton;
  9009. private _localMatrix;
  9010. private _restPose;
  9011. private _baseMatrix;
  9012. private _absoluteTransform;
  9013. private _invertedAbsoluteTransform;
  9014. private _parent;
  9015. private _scalingDeterminant;
  9016. private _worldTransform;
  9017. private _localScaling;
  9018. private _localRotation;
  9019. private _localPosition;
  9020. private _needToDecompose;
  9021. private _needToCompose;
  9022. /** @hidden */
  9023. _linkedTransformNode: Nullable<TransformNode>;
  9024. /** @hidden */
  9025. _waitingTransformNodeId: Nullable<string>;
  9026. /** @hidden */
  9027. /** @hidden */
  9028. _matrix: Matrix;
  9029. /**
  9030. * Create a new bone
  9031. * @param name defines the bone name
  9032. * @param skeleton defines the parent skeleton
  9033. * @param parentBone defines the parent (can be null if the bone is the root)
  9034. * @param localMatrix defines the local matrix
  9035. * @param restPose defines the rest pose matrix
  9036. * @param baseMatrix defines the base matrix
  9037. * @param index defines index of the bone in the hiearchy
  9038. */
  9039. constructor(
  9040. /**
  9041. * defines the bone name
  9042. */
  9043. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  9044. /**
  9045. * Gets the current object class name.
  9046. * @return the class name
  9047. */
  9048. getClassName(): string;
  9049. /**
  9050. * Gets the parent skeleton
  9051. * @returns a skeleton
  9052. */
  9053. getSkeleton(): Skeleton;
  9054. /**
  9055. * Gets parent bone
  9056. * @returns a bone or null if the bone is the root of the bone hierarchy
  9057. */
  9058. getParent(): Nullable<Bone>;
  9059. /**
  9060. * Returns an array containing the root bones
  9061. * @returns an array containing the root bones
  9062. */
  9063. getChildren(): Array<Bone>;
  9064. /**
  9065. * Sets the parent bone
  9066. * @param parent defines the parent (can be null if the bone is the root)
  9067. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  9068. */
  9069. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  9070. /**
  9071. * Gets the local matrix
  9072. * @returns a matrix
  9073. */
  9074. getLocalMatrix(): Matrix;
  9075. /**
  9076. * Gets the base matrix (initial matrix which remains unchanged)
  9077. * @returns a matrix
  9078. */
  9079. getBaseMatrix(): Matrix;
  9080. /**
  9081. * Gets the rest pose matrix
  9082. * @returns a matrix
  9083. */
  9084. getRestPose(): Matrix;
  9085. /**
  9086. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  9087. */
  9088. getWorldMatrix(): Matrix;
  9089. /**
  9090. * Sets the local matrix to rest pose matrix
  9091. */
  9092. returnToRest(): void;
  9093. /**
  9094. * Gets the inverse of the absolute transform matrix.
  9095. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  9096. * @returns a matrix
  9097. */
  9098. getInvertedAbsoluteTransform(): Matrix;
  9099. /**
  9100. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  9101. * @returns a matrix
  9102. */
  9103. getAbsoluteTransform(): Matrix;
  9104. /**
  9105. * Links with the given transform node.
  9106. * The local matrix of this bone is copied from the transform node every frame.
  9107. * @param transformNode defines the transform node to link to
  9108. */
  9109. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  9110. /** Gets or sets current position (in local space) */
  9111. position: Vector3;
  9112. /** Gets or sets current rotation (in local space) */
  9113. rotation: Vector3;
  9114. /** Gets or sets current rotation quaternion (in local space) */
  9115. rotationQuaternion: Quaternion;
  9116. /** Gets or sets current scaling (in local space) */
  9117. scaling: Vector3;
  9118. /**
  9119. * Gets the animation properties override
  9120. */
  9121. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  9122. private _decompose;
  9123. private _compose;
  9124. /**
  9125. * Update the base and local matrices
  9126. * @param matrix defines the new base or local matrix
  9127. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  9128. * @param updateLocalMatrix defines if the local matrix should be updated
  9129. */
  9130. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  9131. /** @hidden */
  9132. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  9133. /**
  9134. * Flag the bone as dirty (Forcing it to update everything)
  9135. */
  9136. markAsDirty(): void;
  9137. /** @hidden */
  9138. _markAsDirtyAndCompose(): void;
  9139. private _markAsDirtyAndDecompose;
  9140. /**
  9141. * Translate the bone in local or world space
  9142. * @param vec The amount to translate the bone
  9143. * @param space The space that the translation is in
  9144. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9145. */
  9146. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  9147. /**
  9148. * Set the postion of the bone in local or world space
  9149. * @param position The position to set the bone
  9150. * @param space The space that the position is in
  9151. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9152. */
  9153. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  9154. /**
  9155. * Set the absolute position of the bone (world space)
  9156. * @param position The position to set the bone
  9157. * @param mesh The mesh that this bone is attached to
  9158. */
  9159. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  9160. /**
  9161. * Scale the bone on the x, y and z axes (in local space)
  9162. * @param x The amount to scale the bone on the x axis
  9163. * @param y The amount to scale the bone on the y axis
  9164. * @param z The amount to scale the bone on the z axis
  9165. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  9166. */
  9167. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  9168. /**
  9169. * Set the bone scaling in local space
  9170. * @param scale defines the scaling vector
  9171. */
  9172. setScale(scale: Vector3): void;
  9173. /**
  9174. * Gets the current scaling in local space
  9175. * @returns the current scaling vector
  9176. */
  9177. getScale(): Vector3;
  9178. /**
  9179. * Gets the current scaling in local space and stores it in a target vector
  9180. * @param result defines the target vector
  9181. */
  9182. getScaleToRef(result: Vector3): void;
  9183. /**
  9184. * Set the yaw, pitch, and roll of the bone in local or world space
  9185. * @param yaw The rotation of the bone on the y axis
  9186. * @param pitch The rotation of the bone on the x axis
  9187. * @param roll The rotation of the bone on the z axis
  9188. * @param space The space that the axes of rotation are in
  9189. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9190. */
  9191. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  9192. /**
  9193. * Add a rotation to the bone on an axis in local or world space
  9194. * @param axis The axis to rotate the bone on
  9195. * @param amount The amount to rotate the bone
  9196. * @param space The space that the axis is in
  9197. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9198. */
  9199. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  9200. /**
  9201. * Set the rotation of the bone to a particular axis angle in local or world space
  9202. * @param axis The axis to rotate the bone on
  9203. * @param angle The angle that the bone should be rotated to
  9204. * @param space The space that the axis is in
  9205. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9206. */
  9207. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  9208. /**
  9209. * Set the euler rotation of the bone in local of world space
  9210. * @param rotation The euler rotation that the bone should be set to
  9211. * @param space The space that the rotation is in
  9212. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9213. */
  9214. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  9215. /**
  9216. * Set the quaternion rotation of the bone in local of world space
  9217. * @param quat The quaternion rotation that the bone should be set to
  9218. * @param space The space that the rotation is in
  9219. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9220. */
  9221. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  9222. /**
  9223. * Set the rotation matrix of the bone in local of world space
  9224. * @param rotMat The rotation matrix that the bone should be set to
  9225. * @param space The space that the rotation is in
  9226. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9227. */
  9228. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  9229. private _rotateWithMatrix;
  9230. private _getNegativeRotationToRef;
  9231. /**
  9232. * Get the position of the bone in local or world space
  9233. * @param space The space that the returned position is in
  9234. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9235. * @returns The position of the bone
  9236. */
  9237. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  9238. /**
  9239. * Copy the position of the bone to a vector3 in local or world space
  9240. * @param space The space that the returned position is in
  9241. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9242. * @param result The vector3 to copy the position to
  9243. */
  9244. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  9245. /**
  9246. * Get the absolute position of the bone (world space)
  9247. * @param mesh The mesh that this bone is attached to
  9248. * @returns The absolute position of the bone
  9249. */
  9250. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  9251. /**
  9252. * Copy the absolute position of the bone (world space) to the result param
  9253. * @param mesh The mesh that this bone is attached to
  9254. * @param result The vector3 to copy the absolute position to
  9255. */
  9256. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  9257. /**
  9258. * Compute the absolute transforms of this bone and its children
  9259. */
  9260. computeAbsoluteTransforms(): void;
  9261. /**
  9262. * Get the world direction from an axis that is in the local space of the bone
  9263. * @param localAxis The local direction that is used to compute the world direction
  9264. * @param mesh The mesh that this bone is attached to
  9265. * @returns The world direction
  9266. */
  9267. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9268. /**
  9269. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  9270. * @param localAxis The local direction that is used to compute the world direction
  9271. * @param mesh The mesh that this bone is attached to
  9272. * @param result The vector3 that the world direction will be copied to
  9273. */
  9274. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9275. /**
  9276. * Get the euler rotation of the bone in local or world space
  9277. * @param space The space that the rotation should be in
  9278. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9279. * @returns The euler rotation
  9280. */
  9281. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  9282. /**
  9283. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  9284. * @param space The space that the rotation should be in
  9285. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9286. * @param result The vector3 that the rotation should be copied to
  9287. */
  9288. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9289. /**
  9290. * Get the quaternion rotation of the bone in either local or world space
  9291. * @param space The space that the rotation should be in
  9292. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9293. * @returns The quaternion rotation
  9294. */
  9295. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  9296. /**
  9297. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  9298. * @param space The space that the rotation should be in
  9299. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9300. * @param result The quaternion that the rotation should be copied to
  9301. */
  9302. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  9303. /**
  9304. * Get the rotation matrix of the bone in local or world space
  9305. * @param space The space that the rotation should be in
  9306. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9307. * @returns The rotation matrix
  9308. */
  9309. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  9310. /**
  9311. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  9312. * @param space The space that the rotation should be in
  9313. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9314. * @param result The quaternion that the rotation should be copied to
  9315. */
  9316. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  9317. /**
  9318. * Get the world position of a point that is in the local space of the bone
  9319. * @param position The local position
  9320. * @param mesh The mesh that this bone is attached to
  9321. * @returns The world position
  9322. */
  9323. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9324. /**
  9325. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  9326. * @param position The local position
  9327. * @param mesh The mesh that this bone is attached to
  9328. * @param result The vector3 that the world position should be copied to
  9329. */
  9330. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9331. /**
  9332. * Get the local position of a point that is in world space
  9333. * @param position The world position
  9334. * @param mesh The mesh that this bone is attached to
  9335. * @returns The local position
  9336. */
  9337. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9338. /**
  9339. * Get the local position of a point that is in world space and copy it to the result param
  9340. * @param position The world position
  9341. * @param mesh The mesh that this bone is attached to
  9342. * @param result The vector3 that the local position should be copied to
  9343. */
  9344. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9345. }
  9346. }
  9347. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  9348. import { Nullable } from "babylonjs/types";
  9349. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  9350. import { Scene } from "babylonjs/scene";
  9351. module "babylonjs/Engines/engine" {
  9352. interface Engine {
  9353. /**
  9354. * Creates a raw texture
  9355. * @param data defines the data to store in the texture
  9356. * @param width defines the width of the texture
  9357. * @param height defines the height of the texture
  9358. * @param format defines the format of the data
  9359. * @param generateMipMaps defines if the engine should generate the mip levels
  9360. * @param invertY defines if data must be stored with Y axis inverted
  9361. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  9362. * @param compression defines the compression used (null by default)
  9363. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9364. * @returns the raw texture inside an InternalTexture
  9365. */
  9366. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  9367. /**
  9368. * Update a raw texture
  9369. * @param texture defines the texture to update
  9370. * @param data defines the data to store in the texture
  9371. * @param format defines the format of the data
  9372. * @param invertY defines if data must be stored with Y axis inverted
  9373. */
  9374. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  9375. /**
  9376. * Update a raw texture
  9377. * @param texture defines the texture to update
  9378. * @param data defines the data to store in the texture
  9379. * @param format defines the format of the data
  9380. * @param invertY defines if data must be stored with Y axis inverted
  9381. * @param compression defines the compression used (null by default)
  9382. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9383. */
  9384. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  9385. /**
  9386. * Creates a new raw cube texture
  9387. * @param data defines the array of data to use to create each face
  9388. * @param size defines the size of the textures
  9389. * @param format defines the format of the data
  9390. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  9391. * @param generateMipMaps defines if the engine should generate the mip levels
  9392. * @param invertY defines if data must be stored with Y axis inverted
  9393. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  9394. * @param compression defines the compression used (null by default)
  9395. * @returns the cube texture as an InternalTexture
  9396. */
  9397. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  9398. /**
  9399. * Update a raw cube texture
  9400. * @param texture defines the texture to udpdate
  9401. * @param data defines the data to store
  9402. * @param format defines the data format
  9403. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9404. * @param invertY defines if data must be stored with Y axis inverted
  9405. */
  9406. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  9407. /**
  9408. * Update a raw cube texture
  9409. * @param texture defines the texture to udpdate
  9410. * @param data defines the data to store
  9411. * @param format defines the data format
  9412. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9413. * @param invertY defines if data must be stored with Y axis inverted
  9414. * @param compression defines the compression used (null by default)
  9415. */
  9416. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  9417. /**
  9418. * Update a raw cube texture
  9419. * @param texture defines the texture to udpdate
  9420. * @param data defines the data to store
  9421. * @param format defines the data format
  9422. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9423. * @param invertY defines if data must be stored with Y axis inverted
  9424. * @param compression defines the compression used (null by default)
  9425. * @param level defines which level of the texture to update
  9426. */
  9427. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  9428. /**
  9429. * Creates a new raw cube texture from a specified url
  9430. * @param url defines the url where the data is located
  9431. * @param scene defines the current scene
  9432. * @param size defines the size of the textures
  9433. * @param format defines the format of the data
  9434. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  9435. * @param noMipmap defines if the engine should avoid generating the mip levels
  9436. * @param callback defines a callback used to extract texture data from loaded data
  9437. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  9438. * @param onLoad defines a callback called when texture is loaded
  9439. * @param onError defines a callback called if there is an error
  9440. * @returns the cube texture as an InternalTexture
  9441. */
  9442. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  9443. /**
  9444. * Creates a new raw cube texture from a specified url
  9445. * @param url defines the url where the data is located
  9446. * @param scene defines the current scene
  9447. * @param size defines the size of the textures
  9448. * @param format defines the format of the data
  9449. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  9450. * @param noMipmap defines if the engine should avoid generating the mip levels
  9451. * @param callback defines a callback used to extract texture data from loaded data
  9452. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  9453. * @param onLoad defines a callback called when texture is loaded
  9454. * @param onError defines a callback called if there is an error
  9455. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  9456. * @param invertY defines if data must be stored with Y axis inverted
  9457. * @returns the cube texture as an InternalTexture
  9458. */
  9459. 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;
  9460. /**
  9461. * Creates a new raw 3D texture
  9462. * @param data defines the data used to create the texture
  9463. * @param width defines the width of the texture
  9464. * @param height defines the height of the texture
  9465. * @param depth defines the depth of the texture
  9466. * @param format defines the format of the texture
  9467. * @param generateMipMaps defines if the engine must generate mip levels
  9468. * @param invertY defines if data must be stored with Y axis inverted
  9469. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  9470. * @param compression defines the compressed used (can be null)
  9471. * @param textureType defines the compressed used (can be null)
  9472. * @returns a new raw 3D texture (stored in an InternalTexture)
  9473. */
  9474. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  9475. /**
  9476. * Update a raw 3D texture
  9477. * @param texture defines the texture to update
  9478. * @param data defines the data to store
  9479. * @param format defines the data format
  9480. * @param invertY defines if data must be stored with Y axis inverted
  9481. */
  9482. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  9483. /**
  9484. * Update a raw 3D texture
  9485. * @param texture defines the texture to update
  9486. * @param data defines the data to store
  9487. * @param format defines the data format
  9488. * @param invertY defines if data must be stored with Y axis inverted
  9489. * @param compression defines the used compression (can be null)
  9490. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  9491. */
  9492. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  9493. }
  9494. }
  9495. }
  9496. declare module "babylonjs/Materials/Textures/rawTexture" {
  9497. import { Scene } from "babylonjs/scene";
  9498. import { Texture } from "babylonjs/Materials/Textures/texture";
  9499. import "babylonjs/Engines/Extensions/engine.rawTexture";
  9500. /**
  9501. * Raw texture can help creating a texture directly from an array of data.
  9502. * This can be super useful if you either get the data from an uncompressed source or
  9503. * if you wish to create your texture pixel by pixel.
  9504. */
  9505. export class RawTexture extends Texture {
  9506. /**
  9507. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  9508. */
  9509. format: number;
  9510. private _engine;
  9511. /**
  9512. * Instantiates a new RawTexture.
  9513. * Raw texture can help creating a texture directly from an array of data.
  9514. * This can be super useful if you either get the data from an uncompressed source or
  9515. * if you wish to create your texture pixel by pixel.
  9516. * @param data define the array of data to use to create the texture
  9517. * @param width define the width of the texture
  9518. * @param height define the height of the texture
  9519. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  9520. * @param scene define the scene the texture belongs to
  9521. * @param generateMipMaps define whether mip maps should be generated or not
  9522. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9523. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9524. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9525. */
  9526. constructor(data: ArrayBufferView, width: number, height: number,
  9527. /**
  9528. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  9529. */
  9530. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  9531. /**
  9532. * Updates the texture underlying data.
  9533. * @param data Define the new data of the texture
  9534. */
  9535. update(data: ArrayBufferView): void;
  9536. /**
  9537. * Creates a luminance texture from some data.
  9538. * @param data Define the texture data
  9539. * @param width Define the width of the texture
  9540. * @param height Define the height of the texture
  9541. * @param scene Define the scene the texture belongs to
  9542. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9543. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9544. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9545. * @returns the luminance texture
  9546. */
  9547. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  9548. /**
  9549. * Creates a luminance alpha texture from some data.
  9550. * @param data Define the texture data
  9551. * @param width Define the width of the texture
  9552. * @param height Define the height of the texture
  9553. * @param scene Define the scene the texture belongs to
  9554. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9555. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9556. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9557. * @returns the luminance alpha texture
  9558. */
  9559. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  9560. /**
  9561. * Creates an alpha texture from some data.
  9562. * @param data Define the texture data
  9563. * @param width Define the width of the texture
  9564. * @param height Define the height of the texture
  9565. * @param scene Define the scene the texture belongs to
  9566. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9567. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9568. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9569. * @returns the alpha texture
  9570. */
  9571. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  9572. /**
  9573. * Creates a RGB texture from some data.
  9574. * @param data Define the texture data
  9575. * @param width Define the width of the texture
  9576. * @param height Define the height of the texture
  9577. * @param scene Define the scene the texture belongs to
  9578. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9579. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9580. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9581. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9582. * @returns the RGB alpha texture
  9583. */
  9584. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  9585. /**
  9586. * Creates a RGBA texture from some data.
  9587. * @param data Define the texture data
  9588. * @param width Define the width of the texture
  9589. * @param height Define the height of the texture
  9590. * @param scene Define the scene the texture belongs to
  9591. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9592. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9593. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9594. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9595. * @returns the RGBA texture
  9596. */
  9597. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  9598. /**
  9599. * Creates a R texture from some data.
  9600. * @param data Define the texture data
  9601. * @param width Define the width of the texture
  9602. * @param height Define the height of the texture
  9603. * @param scene Define the scene the texture belongs to
  9604. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9605. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9606. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9607. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9608. * @returns the R texture
  9609. */
  9610. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  9611. }
  9612. }
  9613. declare module "babylonjs/Animations/runtimeAnimation" {
  9614. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  9615. import { Animatable } from "babylonjs/Animations/animatable";
  9616. import { Scene } from "babylonjs/scene";
  9617. /**
  9618. * Defines a runtime animation
  9619. */
  9620. export class RuntimeAnimation {
  9621. private _events;
  9622. /**
  9623. * The current frame of the runtime animation
  9624. */
  9625. private _currentFrame;
  9626. /**
  9627. * The animation used by the runtime animation
  9628. */
  9629. private _animation;
  9630. /**
  9631. * The target of the runtime animation
  9632. */
  9633. private _target;
  9634. /**
  9635. * The initiating animatable
  9636. */
  9637. private _host;
  9638. /**
  9639. * The original value of the runtime animation
  9640. */
  9641. private _originalValue;
  9642. /**
  9643. * The original blend value of the runtime animation
  9644. */
  9645. private _originalBlendValue;
  9646. /**
  9647. * The offsets cache of the runtime animation
  9648. */
  9649. private _offsetsCache;
  9650. /**
  9651. * The high limits cache of the runtime animation
  9652. */
  9653. private _highLimitsCache;
  9654. /**
  9655. * Specifies if the runtime animation has been stopped
  9656. */
  9657. private _stopped;
  9658. /**
  9659. * The blending factor of the runtime animation
  9660. */
  9661. private _blendingFactor;
  9662. /**
  9663. * The BabylonJS scene
  9664. */
  9665. private _scene;
  9666. /**
  9667. * The current value of the runtime animation
  9668. */
  9669. private _currentValue;
  9670. /** @hidden */
  9671. _animationState: _IAnimationState;
  9672. /**
  9673. * The active target of the runtime animation
  9674. */
  9675. private _activeTargets;
  9676. private _currentActiveTarget;
  9677. private _directTarget;
  9678. /**
  9679. * The target path of the runtime animation
  9680. */
  9681. private _targetPath;
  9682. /**
  9683. * The weight of the runtime animation
  9684. */
  9685. private _weight;
  9686. /**
  9687. * The ratio offset of the runtime animation
  9688. */
  9689. private _ratioOffset;
  9690. /**
  9691. * The previous delay of the runtime animation
  9692. */
  9693. private _previousDelay;
  9694. /**
  9695. * The previous ratio of the runtime animation
  9696. */
  9697. private _previousRatio;
  9698. private _enableBlending;
  9699. private _keys;
  9700. private _minFrame;
  9701. private _maxFrame;
  9702. private _minValue;
  9703. private _maxValue;
  9704. private _targetIsArray;
  9705. /**
  9706. * Gets the current frame of the runtime animation
  9707. */
  9708. readonly currentFrame: number;
  9709. /**
  9710. * Gets the weight of the runtime animation
  9711. */
  9712. readonly weight: number;
  9713. /**
  9714. * Gets the current value of the runtime animation
  9715. */
  9716. readonly currentValue: any;
  9717. /**
  9718. * Gets the target path of the runtime animation
  9719. */
  9720. readonly targetPath: string;
  9721. /**
  9722. * Gets the actual target of the runtime animation
  9723. */
  9724. readonly target: any;
  9725. /** @hidden */
  9726. _onLoop: () => void;
  9727. /**
  9728. * Create a new RuntimeAnimation object
  9729. * @param target defines the target of the animation
  9730. * @param animation defines the source animation object
  9731. * @param scene defines the hosting scene
  9732. * @param host defines the initiating Animatable
  9733. */
  9734. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  9735. private _preparePath;
  9736. /**
  9737. * Gets the animation from the runtime animation
  9738. */
  9739. readonly animation: Animation;
  9740. /**
  9741. * Resets the runtime animation to the beginning
  9742. * @param restoreOriginal defines whether to restore the target property to the original value
  9743. */
  9744. reset(restoreOriginal?: boolean): void;
  9745. /**
  9746. * Specifies if the runtime animation is stopped
  9747. * @returns Boolean specifying if the runtime animation is stopped
  9748. */
  9749. isStopped(): boolean;
  9750. /**
  9751. * Disposes of the runtime animation
  9752. */
  9753. dispose(): void;
  9754. /**
  9755. * Apply the interpolated value to the target
  9756. * @param currentValue defines the value computed by the animation
  9757. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  9758. */
  9759. setValue(currentValue: any, weight: number): void;
  9760. private _getOriginalValues;
  9761. private _setValue;
  9762. /**
  9763. * Gets the loop pmode of the runtime animation
  9764. * @returns Loop Mode
  9765. */
  9766. private _getCorrectLoopMode;
  9767. /**
  9768. * Move the current animation to a given frame
  9769. * @param frame defines the frame to move to
  9770. */
  9771. goToFrame(frame: number): void;
  9772. /**
  9773. * @hidden Internal use only
  9774. */
  9775. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  9776. /**
  9777. * Execute the current animation
  9778. * @param delay defines the delay to add to the current frame
  9779. * @param from defines the lower bound of the animation range
  9780. * @param to defines the upper bound of the animation range
  9781. * @param loop defines if the current animation must loop
  9782. * @param speedRatio defines the current speed ratio
  9783. * @param weight defines the weight of the animation (default is -1 so no weight)
  9784. * @param onLoop optional callback called when animation loops
  9785. * @returns a boolean indicating if the animation is running
  9786. */
  9787. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  9788. }
  9789. }
  9790. declare module "babylonjs/Animations/animatable" {
  9791. import { Animation } from "babylonjs/Animations/animation";
  9792. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  9793. import { Nullable } from "babylonjs/types";
  9794. import { Observable } from "babylonjs/Misc/observable";
  9795. import { Scene } from "babylonjs/scene";
  9796. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math";
  9797. import { Node } from "babylonjs/node";
  9798. /**
  9799. * Class used to store an actual running animation
  9800. */
  9801. export class Animatable {
  9802. /** defines the target object */
  9803. target: any;
  9804. /** defines the starting frame number (default is 0) */
  9805. fromFrame: number;
  9806. /** defines the ending frame number (default is 100) */
  9807. toFrame: number;
  9808. /** defines if the animation must loop (default is false) */
  9809. loopAnimation: boolean;
  9810. /** defines a callback to call when animation ends if it is not looping */
  9811. onAnimationEnd?: (() => void) | null | undefined;
  9812. /** defines a callback to call when animation loops */
  9813. onAnimationLoop?: (() => void) | null | undefined;
  9814. private _localDelayOffset;
  9815. private _pausedDelay;
  9816. private _runtimeAnimations;
  9817. private _paused;
  9818. private _scene;
  9819. private _speedRatio;
  9820. private _weight;
  9821. private _syncRoot;
  9822. /**
  9823. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  9824. * This will only apply for non looping animation (default is true)
  9825. */
  9826. disposeOnEnd: boolean;
  9827. /**
  9828. * Gets a boolean indicating if the animation has started
  9829. */
  9830. animationStarted: boolean;
  9831. /**
  9832. * Observer raised when the animation ends
  9833. */
  9834. onAnimationEndObservable: Observable<Animatable>;
  9835. /**
  9836. * Observer raised when the animation loops
  9837. */
  9838. onAnimationLoopObservable: Observable<Animatable>;
  9839. /**
  9840. * Gets the root Animatable used to synchronize and normalize animations
  9841. */
  9842. readonly syncRoot: Nullable<Animatable>;
  9843. /**
  9844. * Gets the current frame of the first RuntimeAnimation
  9845. * Used to synchronize Animatables
  9846. */
  9847. readonly masterFrame: number;
  9848. /**
  9849. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  9850. */
  9851. weight: number;
  9852. /**
  9853. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  9854. */
  9855. speedRatio: number;
  9856. /**
  9857. * Creates a new Animatable
  9858. * @param scene defines the hosting scene
  9859. * @param target defines the target object
  9860. * @param fromFrame defines the starting frame number (default is 0)
  9861. * @param toFrame defines the ending frame number (default is 100)
  9862. * @param loopAnimation defines if the animation must loop (default is false)
  9863. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  9864. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  9865. * @param animations defines a group of animation to add to the new Animatable
  9866. * @param onAnimationLoop defines a callback to call when animation loops
  9867. */
  9868. constructor(scene: Scene,
  9869. /** defines the target object */
  9870. target: any,
  9871. /** defines the starting frame number (default is 0) */
  9872. fromFrame?: number,
  9873. /** defines the ending frame number (default is 100) */
  9874. toFrame?: number,
  9875. /** defines if the animation must loop (default is false) */
  9876. loopAnimation?: boolean, speedRatio?: number,
  9877. /** defines a callback to call when animation ends if it is not looping */
  9878. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  9879. /** defines a callback to call when animation loops */
  9880. onAnimationLoop?: (() => void) | null | undefined);
  9881. /**
  9882. * Synchronize and normalize current Animatable with a source Animatable
  9883. * This is useful when using animation weights and when animations are not of the same length
  9884. * @param root defines the root Animatable to synchronize with
  9885. * @returns the current Animatable
  9886. */
  9887. syncWith(root: Animatable): Animatable;
  9888. /**
  9889. * Gets the list of runtime animations
  9890. * @returns an array of RuntimeAnimation
  9891. */
  9892. getAnimations(): RuntimeAnimation[];
  9893. /**
  9894. * Adds more animations to the current animatable
  9895. * @param target defines the target of the animations
  9896. * @param animations defines the new animations to add
  9897. */
  9898. appendAnimations(target: any, animations: Animation[]): void;
  9899. /**
  9900. * Gets the source animation for a specific property
  9901. * @param property defines the propertyu to look for
  9902. * @returns null or the source animation for the given property
  9903. */
  9904. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  9905. /**
  9906. * Gets the runtime animation for a specific property
  9907. * @param property defines the propertyu to look for
  9908. * @returns null or the runtime animation for the given property
  9909. */
  9910. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  9911. /**
  9912. * Resets the animatable to its original state
  9913. */
  9914. reset(): void;
  9915. /**
  9916. * Allows the animatable to blend with current running animations
  9917. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  9918. * @param blendingSpeed defines the blending speed to use
  9919. */
  9920. enableBlending(blendingSpeed: number): void;
  9921. /**
  9922. * Disable animation blending
  9923. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  9924. */
  9925. disableBlending(): void;
  9926. /**
  9927. * Jump directly to a given frame
  9928. * @param frame defines the frame to jump to
  9929. */
  9930. goToFrame(frame: number): void;
  9931. /**
  9932. * Pause the animation
  9933. */
  9934. pause(): void;
  9935. /**
  9936. * Restart the animation
  9937. */
  9938. restart(): void;
  9939. private _raiseOnAnimationEnd;
  9940. /**
  9941. * Stop and delete the current animation
  9942. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  9943. * @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)
  9944. */
  9945. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  9946. /**
  9947. * Wait asynchronously for the animation to end
  9948. * @returns a promise which will be fullfilled when the animation ends
  9949. */
  9950. waitAsync(): Promise<Animatable>;
  9951. /** @hidden */
  9952. _animate(delay: number): boolean;
  9953. }
  9954. module "babylonjs/scene" {
  9955. interface Scene {
  9956. /** @hidden */
  9957. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  9958. /** @hidden */
  9959. _processLateAnimationBindingsForMatrices(holder: {
  9960. totalWeight: number;
  9961. animations: RuntimeAnimation[];
  9962. originalValue: Matrix;
  9963. }): any;
  9964. /** @hidden */
  9965. _processLateAnimationBindingsForQuaternions(holder: {
  9966. totalWeight: number;
  9967. animations: RuntimeAnimation[];
  9968. originalValue: Quaternion;
  9969. }, refQuaternion: Quaternion): Quaternion;
  9970. /** @hidden */
  9971. _processLateAnimationBindings(): void;
  9972. /**
  9973. * Will start the animation sequence of a given target
  9974. * @param target defines the target
  9975. * @param from defines from which frame should animation start
  9976. * @param to defines until which frame should animation run.
  9977. * @param weight defines the weight to apply to the animation (1.0 by default)
  9978. * @param loop defines if the animation loops
  9979. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  9980. * @param onAnimationEnd defines the function to be executed when the animation ends
  9981. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  9982. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  9983. * @param onAnimationLoop defines the callback to call when an animation loops
  9984. * @returns the animatable object created for this animation
  9985. */
  9986. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  9987. /**
  9988. * Will start the animation sequence of a given target
  9989. * @param target defines the target
  9990. * @param from defines from which frame should animation start
  9991. * @param to defines until which frame should animation run.
  9992. * @param loop defines if the animation loops
  9993. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  9994. * @param onAnimationEnd defines the function to be executed when the animation ends
  9995. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  9996. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  9997. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  9998. * @param onAnimationLoop defines the callback to call when an animation loops
  9999. * @returns the animatable object created for this animation
  10000. */
  10001. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  10002. /**
  10003. * Will start the animation sequence of a given target and its hierarchy
  10004. * @param target defines the target
  10005. * @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.
  10006. * @param from defines from which frame should animation start
  10007. * @param to defines until which frame should animation run.
  10008. * @param loop defines if the animation loops
  10009. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  10010. * @param onAnimationEnd defines the function to be executed when the animation ends
  10011. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  10012. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  10013. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  10014. * @param onAnimationLoop defines the callback to call when an animation loops
  10015. * @returns the list of created animatables
  10016. */
  10017. 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[];
  10018. /**
  10019. * Begin a new animation on a given node
  10020. * @param target defines the target where the animation will take place
  10021. * @param animations defines the list of animations to start
  10022. * @param from defines the initial value
  10023. * @param to defines the final value
  10024. * @param loop defines if you want animation to loop (off by default)
  10025. * @param speedRatio defines the speed ratio to apply to all animations
  10026. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  10027. * @param onAnimationLoop defines the callback to call when an animation loops
  10028. * @returns the list of created animatables
  10029. */
  10030. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  10031. /**
  10032. * Begin a new animation on a given node and its hierarchy
  10033. * @param target defines the root node where the animation will take place
  10034. * @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.
  10035. * @param animations defines the list of animations to start
  10036. * @param from defines the initial value
  10037. * @param to defines the final value
  10038. * @param loop defines if you want animation to loop (off by default)
  10039. * @param speedRatio defines the speed ratio to apply to all animations
  10040. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  10041. * @param onAnimationLoop defines the callback to call when an animation loops
  10042. * @returns the list of animatables created for all nodes
  10043. */
  10044. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  10045. /**
  10046. * Gets the animatable associated with a specific target
  10047. * @param target defines the target of the animatable
  10048. * @returns the required animatable if found
  10049. */
  10050. getAnimatableByTarget(target: any): Nullable<Animatable>;
  10051. /**
  10052. * Gets all animatables associated with a given target
  10053. * @param target defines the target to look animatables for
  10054. * @returns an array of Animatables
  10055. */
  10056. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  10057. /**
  10058. * Stops and removes all animations that have been applied to the scene
  10059. */
  10060. stopAllAnimations(): void;
  10061. }
  10062. }
  10063. module "babylonjs/Bones/bone" {
  10064. interface Bone {
  10065. /**
  10066. * Copy an animation range from another bone
  10067. * @param source defines the source bone
  10068. * @param rangeName defines the range name to copy
  10069. * @param frameOffset defines the frame offset
  10070. * @param rescaleAsRequired defines if rescaling must be applied if required
  10071. * @param skelDimensionsRatio defines the scaling ratio
  10072. * @returns true if operation was successful
  10073. */
  10074. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  10075. }
  10076. }
  10077. }
  10078. declare module "babylonjs/Bones/skeleton" {
  10079. import { Bone } from "babylonjs/Bones/bone";
  10080. import { IAnimatable } from "babylonjs/Misc/tools";
  10081. import { Observable } from "babylonjs/Misc/observable";
  10082. import { Vector3, Matrix } from "babylonjs/Maths/math";
  10083. import { Scene } from "babylonjs/scene";
  10084. import { Nullable } from "babylonjs/types";
  10085. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10086. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  10087. import { Animatable } from "babylonjs/Animations/animatable";
  10088. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  10089. import { Animation } from "babylonjs/Animations/animation";
  10090. import { AnimationRange } from "babylonjs/Animations/animationRange";
  10091. import { IInspectable } from "babylonjs/Misc/iInspectable";
  10092. /**
  10093. * Class used to handle skinning animations
  10094. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  10095. */
  10096. export class Skeleton implements IAnimatable {
  10097. /** defines the skeleton name */
  10098. name: string;
  10099. /** defines the skeleton Id */
  10100. id: string;
  10101. /**
  10102. * Defines the list of child bones
  10103. */
  10104. bones: Bone[];
  10105. /**
  10106. * Defines an estimate of the dimension of the skeleton at rest
  10107. */
  10108. dimensionsAtRest: Vector3;
  10109. /**
  10110. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  10111. */
  10112. needInitialSkinMatrix: boolean;
  10113. /**
  10114. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  10115. */
  10116. overrideMesh: Nullable<AbstractMesh>;
  10117. /**
  10118. * Gets the list of animations attached to this skeleton
  10119. */
  10120. animations: Array<Animation>;
  10121. private _scene;
  10122. private _isDirty;
  10123. private _transformMatrices;
  10124. private _transformMatrixTexture;
  10125. private _meshesWithPoseMatrix;
  10126. private _animatables;
  10127. private _identity;
  10128. private _synchronizedWithMesh;
  10129. private _ranges;
  10130. private _lastAbsoluteTransformsUpdateId;
  10131. private _canUseTextureForBones;
  10132. private _uniqueId;
  10133. /** @hidden */
  10134. _numBonesWithLinkedTransformNode: number;
  10135. /** @hidden */
  10136. _hasWaitingData: Nullable<boolean>;
  10137. /**
  10138. * Specifies if the skeleton should be serialized
  10139. */
  10140. doNotSerialize: boolean;
  10141. private _useTextureToStoreBoneMatrices;
  10142. /**
  10143. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  10144. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  10145. */
  10146. useTextureToStoreBoneMatrices: boolean;
  10147. private _animationPropertiesOverride;
  10148. /**
  10149. * Gets or sets the animation properties override
  10150. */
  10151. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  10152. /**
  10153. * List of inspectable custom properties (used by the Inspector)
  10154. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  10155. */
  10156. inspectableCustomProperties: IInspectable[];
  10157. /**
  10158. * An observable triggered before computing the skeleton's matrices
  10159. */
  10160. onBeforeComputeObservable: Observable<Skeleton>;
  10161. /**
  10162. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  10163. */
  10164. readonly isUsingTextureForMatrices: boolean;
  10165. /**
  10166. * Gets the unique ID of this skeleton
  10167. */
  10168. readonly uniqueId: number;
  10169. /**
  10170. * Creates a new skeleton
  10171. * @param name defines the skeleton name
  10172. * @param id defines the skeleton Id
  10173. * @param scene defines the hosting scene
  10174. */
  10175. constructor(
  10176. /** defines the skeleton name */
  10177. name: string,
  10178. /** defines the skeleton Id */
  10179. id: string, scene: Scene);
  10180. /**
  10181. * Gets the current object class name.
  10182. * @return the class name
  10183. */
  10184. getClassName(): string;
  10185. /**
  10186. * Returns an array containing the root bones
  10187. * @returns an array containing the root bones
  10188. */
  10189. getChildren(): Array<Bone>;
  10190. /**
  10191. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  10192. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  10193. * @returns a Float32Array containing matrices data
  10194. */
  10195. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  10196. /**
  10197. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  10198. * @returns a raw texture containing the data
  10199. */
  10200. getTransformMatrixTexture(): Nullable<RawTexture>;
  10201. /**
  10202. * Gets the current hosting scene
  10203. * @returns a scene object
  10204. */
  10205. getScene(): Scene;
  10206. /**
  10207. * Gets a string representing the current skeleton data
  10208. * @param fullDetails defines a boolean indicating if we want a verbose version
  10209. * @returns a string representing the current skeleton data
  10210. */
  10211. toString(fullDetails?: boolean): string;
  10212. /**
  10213. * Get bone's index searching by name
  10214. * @param name defines bone's name to search for
  10215. * @return the indice of the bone. Returns -1 if not found
  10216. */
  10217. getBoneIndexByName(name: string): number;
  10218. /**
  10219. * Creater a new animation range
  10220. * @param name defines the name of the range
  10221. * @param from defines the start key
  10222. * @param to defines the end key
  10223. */
  10224. createAnimationRange(name: string, from: number, to: number): void;
  10225. /**
  10226. * Delete a specific animation range
  10227. * @param name defines the name of the range
  10228. * @param deleteFrames defines if frames must be removed as well
  10229. */
  10230. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  10231. /**
  10232. * Gets a specific animation range
  10233. * @param name defines the name of the range to look for
  10234. * @returns the requested animation range or null if not found
  10235. */
  10236. getAnimationRange(name: string): Nullable<AnimationRange>;
  10237. /**
  10238. * Gets the list of all animation ranges defined on this skeleton
  10239. * @returns an array
  10240. */
  10241. getAnimationRanges(): Nullable<AnimationRange>[];
  10242. /**
  10243. * Copy animation range from a source skeleton.
  10244. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  10245. * @param source defines the source skeleton
  10246. * @param name defines the name of the range to copy
  10247. * @param rescaleAsRequired defines if rescaling must be applied if required
  10248. * @returns true if operation was successful
  10249. */
  10250. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  10251. /**
  10252. * Forces the skeleton to go to rest pose
  10253. */
  10254. returnToRest(): void;
  10255. private _getHighestAnimationFrame;
  10256. /**
  10257. * Begin a specific animation range
  10258. * @param name defines the name of the range to start
  10259. * @param loop defines if looping must be turned on (false by default)
  10260. * @param speedRatio defines the speed ratio to apply (1 by default)
  10261. * @param onAnimationEnd defines a callback which will be called when animation will end
  10262. * @returns a new animatable
  10263. */
  10264. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  10265. /** @hidden */
  10266. _markAsDirty(): void;
  10267. /** @hidden */
  10268. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  10269. /** @hidden */
  10270. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  10271. private _computeTransformMatrices;
  10272. /**
  10273. * Build all resources required to render a skeleton
  10274. */
  10275. prepare(): void;
  10276. /**
  10277. * Gets the list of animatables currently running for this skeleton
  10278. * @returns an array of animatables
  10279. */
  10280. getAnimatables(): IAnimatable[];
  10281. /**
  10282. * Clone the current skeleton
  10283. * @param name defines the name of the new skeleton
  10284. * @param id defines the id of the new skeleton
  10285. * @returns the new skeleton
  10286. */
  10287. clone(name: string, id: string): Skeleton;
  10288. /**
  10289. * Enable animation blending for this skeleton
  10290. * @param blendingSpeed defines the blending speed to apply
  10291. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  10292. */
  10293. enableBlending(blendingSpeed?: number): void;
  10294. /**
  10295. * Releases all resources associated with the current skeleton
  10296. */
  10297. dispose(): void;
  10298. /**
  10299. * Serialize the skeleton in a JSON object
  10300. * @returns a JSON object
  10301. */
  10302. serialize(): any;
  10303. /**
  10304. * Creates a new skeleton from serialized data
  10305. * @param parsedSkeleton defines the serialized data
  10306. * @param scene defines the hosting scene
  10307. * @returns a new skeleton
  10308. */
  10309. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  10310. /**
  10311. * Compute all node absolute transforms
  10312. * @param forceUpdate defines if computation must be done even if cache is up to date
  10313. */
  10314. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  10315. /**
  10316. * Gets the root pose matrix
  10317. * @returns a matrix
  10318. */
  10319. getPoseMatrix(): Nullable<Matrix>;
  10320. /**
  10321. * Sorts bones per internal index
  10322. */
  10323. sortBones(): void;
  10324. private _sortBones;
  10325. }
  10326. }
  10327. declare module "babylonjs/Morph/morphTarget" {
  10328. import { IAnimatable } from "babylonjs/Misc/tools";
  10329. import { Observable } from "babylonjs/Misc/observable";
  10330. import { Nullable, FloatArray } from "babylonjs/types";
  10331. import { Scene } from "babylonjs/scene";
  10332. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10333. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  10334. /**
  10335. * Defines a target to use with MorphTargetManager
  10336. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  10337. */
  10338. export class MorphTarget implements IAnimatable {
  10339. /** defines the name of the target */
  10340. name: string;
  10341. /**
  10342. * Gets or sets the list of animations
  10343. */
  10344. animations: import("babylonjs/Animations/animation").Animation[];
  10345. private _scene;
  10346. private _positions;
  10347. private _normals;
  10348. private _tangents;
  10349. private _influence;
  10350. /**
  10351. * Observable raised when the influence changes
  10352. */
  10353. onInfluenceChanged: Observable<boolean>;
  10354. /** @hidden */
  10355. _onDataLayoutChanged: Observable<void>;
  10356. /**
  10357. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  10358. */
  10359. influence: number;
  10360. /**
  10361. * Gets or sets the id of the morph Target
  10362. */
  10363. id: string;
  10364. private _animationPropertiesOverride;
  10365. /**
  10366. * Gets or sets the animation properties override
  10367. */
  10368. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  10369. /**
  10370. * Creates a new MorphTarget
  10371. * @param name defines the name of the target
  10372. * @param influence defines the influence to use
  10373. * @param scene defines the scene the morphtarget belongs to
  10374. */
  10375. constructor(
  10376. /** defines the name of the target */
  10377. name: string, influence?: number, scene?: Nullable<Scene>);
  10378. /**
  10379. * Gets a boolean defining if the target contains position data
  10380. */
  10381. readonly hasPositions: boolean;
  10382. /**
  10383. * Gets a boolean defining if the target contains normal data
  10384. */
  10385. readonly hasNormals: boolean;
  10386. /**
  10387. * Gets a boolean defining if the target contains tangent data
  10388. */
  10389. readonly hasTangents: boolean;
  10390. /**
  10391. * Affects position data to this target
  10392. * @param data defines the position data to use
  10393. */
  10394. setPositions(data: Nullable<FloatArray>): void;
  10395. /**
  10396. * Gets the position data stored in this target
  10397. * @returns a FloatArray containing the position data (or null if not present)
  10398. */
  10399. getPositions(): Nullable<FloatArray>;
  10400. /**
  10401. * Affects normal data to this target
  10402. * @param data defines the normal data to use
  10403. */
  10404. setNormals(data: Nullable<FloatArray>): void;
  10405. /**
  10406. * Gets the normal data stored in this target
  10407. * @returns a FloatArray containing the normal data (or null if not present)
  10408. */
  10409. getNormals(): Nullable<FloatArray>;
  10410. /**
  10411. * Affects tangent data to this target
  10412. * @param data defines the tangent data to use
  10413. */
  10414. setTangents(data: Nullable<FloatArray>): void;
  10415. /**
  10416. * Gets the tangent data stored in this target
  10417. * @returns a FloatArray containing the tangent data (or null if not present)
  10418. */
  10419. getTangents(): Nullable<FloatArray>;
  10420. /**
  10421. * Serializes the current target into a Serialization object
  10422. * @returns the serialized object
  10423. */
  10424. serialize(): any;
  10425. /**
  10426. * Returns the string "MorphTarget"
  10427. * @returns "MorphTarget"
  10428. */
  10429. getClassName(): string;
  10430. /**
  10431. * Creates a new target from serialized data
  10432. * @param serializationObject defines the serialized data to use
  10433. * @returns a new MorphTarget
  10434. */
  10435. static Parse(serializationObject: any): MorphTarget;
  10436. /**
  10437. * Creates a MorphTarget from mesh data
  10438. * @param mesh defines the source mesh
  10439. * @param name defines the name to use for the new target
  10440. * @param influence defines the influence to attach to the target
  10441. * @returns a new MorphTarget
  10442. */
  10443. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  10444. }
  10445. }
  10446. declare module "babylonjs/Morph/morphTargetManager" {
  10447. import { Nullable } from "babylonjs/types";
  10448. import { Scene } from "babylonjs/scene";
  10449. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  10450. /**
  10451. * This class is used to deform meshes using morphing between different targets
  10452. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  10453. */
  10454. export class MorphTargetManager {
  10455. private _targets;
  10456. private _targetInfluenceChangedObservers;
  10457. private _targetDataLayoutChangedObservers;
  10458. private _activeTargets;
  10459. private _scene;
  10460. private _influences;
  10461. private _supportsNormals;
  10462. private _supportsTangents;
  10463. private _vertexCount;
  10464. private _uniqueId;
  10465. private _tempInfluences;
  10466. /**
  10467. * Creates a new MorphTargetManager
  10468. * @param scene defines the current scene
  10469. */
  10470. constructor(scene?: Nullable<Scene>);
  10471. /**
  10472. * Gets the unique ID of this manager
  10473. */
  10474. readonly uniqueId: number;
  10475. /**
  10476. * Gets the number of vertices handled by this manager
  10477. */
  10478. readonly vertexCount: number;
  10479. /**
  10480. * Gets a boolean indicating if this manager supports morphing of normals
  10481. */
  10482. readonly supportsNormals: boolean;
  10483. /**
  10484. * Gets a boolean indicating if this manager supports morphing of tangents
  10485. */
  10486. readonly supportsTangents: boolean;
  10487. /**
  10488. * Gets the number of targets stored in this manager
  10489. */
  10490. readonly numTargets: number;
  10491. /**
  10492. * Gets the number of influencers (ie. the number of targets with influences > 0)
  10493. */
  10494. readonly numInfluencers: number;
  10495. /**
  10496. * Gets the list of influences (one per target)
  10497. */
  10498. readonly influences: Float32Array;
  10499. /**
  10500. * Gets the active target at specified index. An active target is a target with an influence > 0
  10501. * @param index defines the index to check
  10502. * @returns the requested target
  10503. */
  10504. getActiveTarget(index: number): MorphTarget;
  10505. /**
  10506. * Gets the target at specified index
  10507. * @param index defines the index to check
  10508. * @returns the requested target
  10509. */
  10510. getTarget(index: number): MorphTarget;
  10511. /**
  10512. * Add a new target to this manager
  10513. * @param target defines the target to add
  10514. */
  10515. addTarget(target: MorphTarget): void;
  10516. /**
  10517. * Removes a target from the manager
  10518. * @param target defines the target to remove
  10519. */
  10520. removeTarget(target: MorphTarget): void;
  10521. /**
  10522. * Serializes the current manager into a Serialization object
  10523. * @returns the serialized object
  10524. */
  10525. serialize(): any;
  10526. private _syncActiveTargets;
  10527. /**
  10528. * Syncrhonize the targets with all the meshes using this morph target manager
  10529. */
  10530. synchronize(): void;
  10531. /**
  10532. * Creates a new MorphTargetManager from serialized data
  10533. * @param serializationObject defines the serialized data
  10534. * @param scene defines the hosting scene
  10535. * @returns the new MorphTargetManager
  10536. */
  10537. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  10538. }
  10539. }
  10540. declare module "babylonjs/sceneComponent" {
  10541. import { Scene } from "babylonjs/scene";
  10542. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10543. import { SubMesh } from "babylonjs/Meshes/subMesh";
  10544. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  10545. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  10546. import { Nullable } from "babylonjs/types";
  10547. import { Camera } from "babylonjs/Cameras/camera";
  10548. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  10549. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10550. import { AbstractScene } from "babylonjs/abstractScene";
  10551. /**
  10552. * Groups all the scene component constants in one place to ease maintenance.
  10553. * @hidden
  10554. */
  10555. export class SceneComponentConstants {
  10556. static readonly NAME_EFFECTLAYER: string;
  10557. static readonly NAME_LAYER: string;
  10558. static readonly NAME_LENSFLARESYSTEM: string;
  10559. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10560. static readonly NAME_PARTICLESYSTEM: string;
  10561. static readonly NAME_GAMEPAD: string;
  10562. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10563. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10564. static readonly NAME_DEPTHRENDERER: string;
  10565. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10566. static readonly NAME_SPRITE: string;
  10567. static readonly NAME_OUTLINERENDERER: string;
  10568. static readonly NAME_PROCEDURALTEXTURE: string;
  10569. static readonly NAME_SHADOWGENERATOR: string;
  10570. static readonly NAME_OCTREE: string;
  10571. static readonly NAME_PHYSICSENGINE: string;
  10572. static readonly NAME_AUDIO: string;
  10573. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10574. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10575. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10576. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10577. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10578. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10579. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10580. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10581. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10582. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10583. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10584. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10585. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10586. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10587. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10588. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10589. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10590. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10591. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10592. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10593. static readonly STEP_AFTERRENDER_AUDIO: number;
  10594. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10595. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10596. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10597. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10598. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10599. static readonly STEP_POINTERMOVE_SPRITE: number;
  10600. static readonly STEP_POINTERDOWN_SPRITE: number;
  10601. static readonly STEP_POINTERUP_SPRITE: number;
  10602. }
  10603. /**
  10604. * This represents a scene component.
  10605. *
  10606. * This is used to decouple the dependency the scene is having on the different workloads like
  10607. * layers, post processes...
  10608. */
  10609. export interface ISceneComponent {
  10610. /**
  10611. * The name of the component. Each component must have a unique name.
  10612. */
  10613. name: string;
  10614. /**
  10615. * The scene the component belongs to.
  10616. */
  10617. scene: Scene;
  10618. /**
  10619. * Register the component to one instance of a scene.
  10620. */
  10621. register(): void;
  10622. /**
  10623. * Rebuilds the elements related to this component in case of
  10624. * context lost for instance.
  10625. */
  10626. rebuild(): void;
  10627. /**
  10628. * Disposes the component and the associated ressources.
  10629. */
  10630. dispose(): void;
  10631. }
  10632. /**
  10633. * This represents a SERIALIZABLE scene component.
  10634. *
  10635. * This extends Scene Component to add Serialization methods on top.
  10636. */
  10637. export interface ISceneSerializableComponent extends ISceneComponent {
  10638. /**
  10639. * Adds all the elements from the container to the scene
  10640. * @param container the container holding the elements
  10641. */
  10642. addFromContainer(container: AbstractScene): void;
  10643. /**
  10644. * Removes all the elements in the container from the scene
  10645. * @param container contains the elements to remove
  10646. * @param dispose if the removed element should be disposed (default: false)
  10647. */
  10648. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10649. /**
  10650. * Serializes the component data to the specified json object
  10651. * @param serializationObject The object to serialize to
  10652. */
  10653. serialize(serializationObject: any): void;
  10654. }
  10655. /**
  10656. * Strong typing of a Mesh related stage step action
  10657. */
  10658. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10659. /**
  10660. * Strong typing of a Evaluate Sub Mesh related stage step action
  10661. */
  10662. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10663. /**
  10664. * Strong typing of a Active Mesh related stage step action
  10665. */
  10666. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10667. /**
  10668. * Strong typing of a Camera related stage step action
  10669. */
  10670. export type CameraStageAction = (camera: Camera) => void;
  10671. /**
  10672. * Strong typing of a Camera Frame buffer related stage step action
  10673. */
  10674. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10675. /**
  10676. * Strong typing of a Render Target related stage step action
  10677. */
  10678. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10679. /**
  10680. * Strong typing of a RenderingGroup related stage step action
  10681. */
  10682. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10683. /**
  10684. * Strong typing of a Mesh Render related stage step action
  10685. */
  10686. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10687. /**
  10688. * Strong typing of a simple stage step action
  10689. */
  10690. export type SimpleStageAction = () => void;
  10691. /**
  10692. * Strong typing of a render target action.
  10693. */
  10694. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10695. /**
  10696. * Strong typing of a pointer move action.
  10697. */
  10698. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  10699. /**
  10700. * Strong typing of a pointer up/down action.
  10701. */
  10702. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10703. /**
  10704. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  10705. * @hidden
  10706. */
  10707. export class Stage<T extends Function> extends Array<{
  10708. index: number;
  10709. component: ISceneComponent;
  10710. action: T;
  10711. }> {
  10712. /**
  10713. * Hide ctor from the rest of the world.
  10714. * @param items The items to add.
  10715. */
  10716. private constructor();
  10717. /**
  10718. * Creates a new Stage.
  10719. * @returns A new instance of a Stage
  10720. */
  10721. static Create<T extends Function>(): Stage<T>;
  10722. /**
  10723. * Registers a step in an ordered way in the targeted stage.
  10724. * @param index Defines the position to register the step in
  10725. * @param component Defines the component attached to the step
  10726. * @param action Defines the action to launch during the step
  10727. */
  10728. registerStep(index: number, component: ISceneComponent, action: T): void;
  10729. /**
  10730. * Clears all the steps from the stage.
  10731. */
  10732. clear(): void;
  10733. }
  10734. }
  10735. declare module "babylonjs/Meshes/meshLODLevel" {
  10736. import { Mesh } from "babylonjs/Meshes/mesh";
  10737. import { Nullable } from "babylonjs/types";
  10738. /**
  10739. * Class used to represent a specific level of detail of a mesh
  10740. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  10741. */
  10742. export class MeshLODLevel {
  10743. /** Defines the distance where this level should star being displayed */
  10744. distance: number;
  10745. /** Defines the mesh to use to render this level */
  10746. mesh: Nullable<Mesh>;
  10747. /**
  10748. * Creates a new LOD level
  10749. * @param distance defines the distance where this level should star being displayed
  10750. * @param mesh defines the mesh to use to render this level
  10751. */
  10752. constructor(
  10753. /** Defines the distance where this level should star being displayed */
  10754. distance: number,
  10755. /** Defines the mesh to use to render this level */
  10756. mesh: Nullable<Mesh>);
  10757. }
  10758. }
  10759. declare module "babylonjs/Lights/shadowLight" {
  10760. import { Camera } from "babylonjs/Cameras/camera";
  10761. import { Scene } from "babylonjs/scene";
  10762. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  10763. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10764. import { Light } from "babylonjs/Lights/light";
  10765. /**
  10766. * Interface describing all the common properties and methods a shadow light needs to implement.
  10767. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  10768. * as well as binding the different shadow properties to the effects.
  10769. */
  10770. export interface IShadowLight extends Light {
  10771. /**
  10772. * The light id in the scene (used in scene.findLighById for instance)
  10773. */
  10774. id: string;
  10775. /**
  10776. * The position the shdow will be casted from.
  10777. */
  10778. position: Vector3;
  10779. /**
  10780. * In 2d mode (needCube being false), the direction used to cast the shadow.
  10781. */
  10782. direction: Vector3;
  10783. /**
  10784. * The transformed position. Position of the light in world space taking parenting in account.
  10785. */
  10786. transformedPosition: Vector3;
  10787. /**
  10788. * The transformed direction. Direction of the light in world space taking parenting in account.
  10789. */
  10790. transformedDirection: Vector3;
  10791. /**
  10792. * The friendly name of the light in the scene.
  10793. */
  10794. name: string;
  10795. /**
  10796. * Defines the shadow projection clipping minimum z value.
  10797. */
  10798. shadowMinZ: number;
  10799. /**
  10800. * Defines the shadow projection clipping maximum z value.
  10801. */
  10802. shadowMaxZ: number;
  10803. /**
  10804. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  10805. * @returns true if the information has been computed, false if it does not need to (no parenting)
  10806. */
  10807. computeTransformedInformation(): boolean;
  10808. /**
  10809. * Gets the scene the light belongs to.
  10810. * @returns The scene
  10811. */
  10812. getScene(): Scene;
  10813. /**
  10814. * Callback defining a custom Projection Matrix Builder.
  10815. * This can be used to override the default projection matrix computation.
  10816. */
  10817. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  10818. /**
  10819. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  10820. * @param matrix The materix to updated with the projection information
  10821. * @param viewMatrix The transform matrix of the light
  10822. * @param renderList The list of mesh to render in the map
  10823. * @returns The current light
  10824. */
  10825. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  10826. /**
  10827. * Gets the current depth scale used in ESM.
  10828. * @returns The scale
  10829. */
  10830. getDepthScale(): number;
  10831. /**
  10832. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  10833. * @returns true if a cube texture needs to be use
  10834. */
  10835. needCube(): boolean;
  10836. /**
  10837. * Detects if the projection matrix requires to be recomputed this frame.
  10838. * @returns true if it requires to be recomputed otherwise, false.
  10839. */
  10840. needProjectionMatrixCompute(): boolean;
  10841. /**
  10842. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  10843. */
  10844. forceProjectionMatrixCompute(): void;
  10845. /**
  10846. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  10847. * @param faceIndex The index of the face we are computed the direction to generate shadow
  10848. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  10849. */
  10850. getShadowDirection(faceIndex?: number): Vector3;
  10851. /**
  10852. * Gets the minZ used for shadow according to both the scene and the light.
  10853. * @param activeCamera The camera we are returning the min for
  10854. * @returns the depth min z
  10855. */
  10856. getDepthMinZ(activeCamera: Camera): number;
  10857. /**
  10858. * Gets the maxZ used for shadow according to both the scene and the light.
  10859. * @param activeCamera The camera we are returning the max for
  10860. * @returns the depth max z
  10861. */
  10862. getDepthMaxZ(activeCamera: Camera): number;
  10863. }
  10864. /**
  10865. * Base implementation IShadowLight
  10866. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  10867. */
  10868. export abstract class ShadowLight extends Light implements IShadowLight {
  10869. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  10870. protected _position: Vector3;
  10871. protected _setPosition(value: Vector3): void;
  10872. /**
  10873. * Sets the position the shadow will be casted from. Also use as the light position for both
  10874. * point and spot lights.
  10875. */
  10876. /**
  10877. * Sets the position the shadow will be casted from. Also use as the light position for both
  10878. * point and spot lights.
  10879. */
  10880. position: Vector3;
  10881. protected _direction: Vector3;
  10882. protected _setDirection(value: Vector3): void;
  10883. /**
  10884. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  10885. * Also use as the light direction on spot and directional lights.
  10886. */
  10887. /**
  10888. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  10889. * Also use as the light direction on spot and directional lights.
  10890. */
  10891. direction: Vector3;
  10892. private _shadowMinZ;
  10893. /**
  10894. * Gets the shadow projection clipping minimum z value.
  10895. */
  10896. /**
  10897. * Sets the shadow projection clipping minimum z value.
  10898. */
  10899. shadowMinZ: number;
  10900. private _shadowMaxZ;
  10901. /**
  10902. * Sets the shadow projection clipping maximum z value.
  10903. */
  10904. /**
  10905. * Gets the shadow projection clipping maximum z value.
  10906. */
  10907. shadowMaxZ: number;
  10908. /**
  10909. * Callback defining a custom Projection Matrix Builder.
  10910. * This can be used to override the default projection matrix computation.
  10911. */
  10912. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  10913. /**
  10914. * The transformed position. Position of the light in world space taking parenting in account.
  10915. */
  10916. transformedPosition: Vector3;
  10917. /**
  10918. * The transformed direction. Direction of the light in world space taking parenting in account.
  10919. */
  10920. transformedDirection: Vector3;
  10921. private _needProjectionMatrixCompute;
  10922. /**
  10923. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  10924. * @returns true if the information has been computed, false if it does not need to (no parenting)
  10925. */
  10926. computeTransformedInformation(): boolean;
  10927. /**
  10928. * Return the depth scale used for the shadow map.
  10929. * @returns the depth scale.
  10930. */
  10931. getDepthScale(): number;
  10932. /**
  10933. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  10934. * @param faceIndex The index of the face we are computed the direction to generate shadow
  10935. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  10936. */
  10937. getShadowDirection(faceIndex?: number): Vector3;
  10938. /**
  10939. * Returns the ShadowLight absolute position in the World.
  10940. * @returns the position vector in world space
  10941. */
  10942. getAbsolutePosition(): Vector3;
  10943. /**
  10944. * Sets the ShadowLight direction toward the passed target.
  10945. * @param target The point to target in local space
  10946. * @returns the updated ShadowLight direction
  10947. */
  10948. setDirectionToTarget(target: Vector3): Vector3;
  10949. /**
  10950. * Returns the light rotation in euler definition.
  10951. * @returns the x y z rotation in local space.
  10952. */
  10953. getRotation(): Vector3;
  10954. /**
  10955. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  10956. * @returns true if a cube texture needs to be use
  10957. */
  10958. needCube(): boolean;
  10959. /**
  10960. * Detects if the projection matrix requires to be recomputed this frame.
  10961. * @returns true if it requires to be recomputed otherwise, false.
  10962. */
  10963. needProjectionMatrixCompute(): boolean;
  10964. /**
  10965. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  10966. */
  10967. forceProjectionMatrixCompute(): void;
  10968. /** @hidden */
  10969. _initCache(): void;
  10970. /** @hidden */
  10971. _isSynchronized(): boolean;
  10972. /**
  10973. * Computes the world matrix of the node
  10974. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  10975. * @returns the world matrix
  10976. */
  10977. computeWorldMatrix(force?: boolean): Matrix;
  10978. /**
  10979. * Gets the minZ used for shadow according to both the scene and the light.
  10980. * @param activeCamera The camera we are returning the min for
  10981. * @returns the depth min z
  10982. */
  10983. getDepthMinZ(activeCamera: Camera): number;
  10984. /**
  10985. * Gets the maxZ used for shadow according to both the scene and the light.
  10986. * @param activeCamera The camera we are returning the max for
  10987. * @returns the depth max z
  10988. */
  10989. getDepthMaxZ(activeCamera: Camera): number;
  10990. /**
  10991. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  10992. * @param matrix The materix to updated with the projection information
  10993. * @param viewMatrix The transform matrix of the light
  10994. * @param renderList The list of mesh to render in the map
  10995. * @returns The current light
  10996. */
  10997. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  10998. }
  10999. }
  11000. declare module "babylonjs/Materials/materialHelper" {
  11001. import { Nullable } from "babylonjs/types";
  11002. import { Scene } from "babylonjs/scene";
  11003. import { Engine } from "babylonjs/Engines/engine";
  11004. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11005. import { Light } from "babylonjs/Lights/light";
  11006. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  11007. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  11008. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  11009. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  11010. /**
  11011. * "Static Class" containing the most commonly used helper while dealing with material for
  11012. * rendering purpose.
  11013. *
  11014. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  11015. *
  11016. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  11017. */
  11018. export class MaterialHelper {
  11019. /**
  11020. * Bind the current view position to an effect.
  11021. * @param effect The effect to be bound
  11022. * @param scene The scene the eyes position is used from
  11023. */
  11024. static BindEyePosition(effect: Effect, scene: Scene): void;
  11025. /**
  11026. * Helps preparing the defines values about the UVs in used in the effect.
  11027. * UVs are shared as much as we can accross channels in the shaders.
  11028. * @param texture The texture we are preparing the UVs for
  11029. * @param defines The defines to update
  11030. * @param key The channel key "diffuse", "specular"... used in the shader
  11031. */
  11032. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  11033. /**
  11034. * Binds a texture matrix value to its corrsponding uniform
  11035. * @param texture The texture to bind the matrix for
  11036. * @param uniformBuffer The uniform buffer receivin the data
  11037. * @param key The channel key "diffuse", "specular"... used in the shader
  11038. */
  11039. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  11040. /**
  11041. * Gets the current status of the fog (should it be enabled?)
  11042. * @param mesh defines the mesh to evaluate for fog support
  11043. * @param scene defines the hosting scene
  11044. * @returns true if fog must be enabled
  11045. */
  11046. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  11047. /**
  11048. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  11049. * @param mesh defines the current mesh
  11050. * @param scene defines the current scene
  11051. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  11052. * @param pointsCloud defines if point cloud rendering has to be turned on
  11053. * @param fogEnabled defines if fog has to be turned on
  11054. * @param alphaTest defines if alpha testing has to be turned on
  11055. * @param defines defines the current list of defines
  11056. */
  11057. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  11058. /**
  11059. * Helper used to prepare the list of defines associated with frame values for shader compilation
  11060. * @param scene defines the current scene
  11061. * @param engine defines the current engine
  11062. * @param defines specifies the list of active defines
  11063. * @param useInstances defines if instances have to be turned on
  11064. * @param useClipPlane defines if clip plane have to be turned on
  11065. */
  11066. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  11067. /**
  11068. * Prepares the defines for bones
  11069. * @param mesh The mesh containing the geometry data we will draw
  11070. * @param defines The defines to update
  11071. */
  11072. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  11073. /**
  11074. * Prepares the defines for morph targets
  11075. * @param mesh The mesh containing the geometry data we will draw
  11076. * @param defines The defines to update
  11077. */
  11078. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  11079. /**
  11080. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  11081. * @param mesh The mesh containing the geometry data we will draw
  11082. * @param defines The defines to update
  11083. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  11084. * @param useBones Precise whether bones should be used or not (override mesh info)
  11085. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  11086. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  11087. * @returns false if defines are considered not dirty and have not been checked
  11088. */
  11089. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  11090. /**
  11091. * Prepares the defines related to multiview
  11092. * @param scene The scene we are intending to draw
  11093. * @param defines The defines to update
  11094. */
  11095. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  11096. /**
  11097. * Prepares the defines related to the light information passed in parameter
  11098. * @param scene The scene we are intending to draw
  11099. * @param mesh The mesh the effect is compiling for
  11100. * @param defines The defines to update
  11101. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  11102. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  11103. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  11104. * @returns true if normals will be required for the rest of the effect
  11105. */
  11106. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  11107. /**
  11108. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  11109. * that won t be acctive due to defines being turned off.
  11110. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  11111. * @param samplersList The samplers list
  11112. * @param defines The defines helping in the list generation
  11113. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  11114. */
  11115. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  11116. /**
  11117. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  11118. * @param defines The defines to update while falling back
  11119. * @param fallbacks The authorized effect fallbacks
  11120. * @param maxSimultaneousLights The maximum number of lights allowed
  11121. * @param rank the current rank of the Effect
  11122. * @returns The newly affected rank
  11123. */
  11124. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  11125. /**
  11126. * Prepares the list of attributes required for morph targets according to the effect defines.
  11127. * @param attribs The current list of supported attribs
  11128. * @param mesh The mesh to prepare the morph targets attributes for
  11129. * @param defines The current Defines of the effect
  11130. */
  11131. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  11132. /**
  11133. * Prepares the list of attributes required for bones according to the effect defines.
  11134. * @param attribs The current list of supported attribs
  11135. * @param mesh The mesh to prepare the bones attributes for
  11136. * @param defines The current Defines of the effect
  11137. * @param fallbacks The current efffect fallback strategy
  11138. */
  11139. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  11140. /**
  11141. * Check and prepare the list of attributes required for instances according to the effect defines.
  11142. * @param attribs The current list of supported attribs
  11143. * @param defines The current MaterialDefines of the effect
  11144. */
  11145. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  11146. /**
  11147. * Add the list of attributes required for instances to the attribs array.
  11148. * @param attribs The current list of supported attribs
  11149. */
  11150. static PushAttributesForInstances(attribs: string[]): void;
  11151. /**
  11152. * Binds the light shadow information to the effect for the given mesh.
  11153. * @param light The light containing the generator
  11154. * @param scene The scene the lights belongs to
  11155. * @param mesh The mesh we are binding the information to render
  11156. * @param lightIndex The light index in the effect used to render the mesh
  11157. * @param effect The effect we are binding the data to
  11158. */
  11159. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  11160. /**
  11161. * Binds the light information to the effect.
  11162. * @param light The light containing the generator
  11163. * @param effect The effect we are binding the data to
  11164. * @param lightIndex The light index in the effect used to render
  11165. */
  11166. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  11167. /**
  11168. * Binds the lights information from the scene to the effect for the given mesh.
  11169. * @param scene The scene the lights belongs to
  11170. * @param mesh The mesh we are binding the information to render
  11171. * @param effect The effect we are binding the data to
  11172. * @param defines The generated defines for the effect
  11173. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  11174. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  11175. */
  11176. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  11177. private static _tempFogColor;
  11178. /**
  11179. * Binds the fog information from the scene to the effect for the given mesh.
  11180. * @param scene The scene the lights belongs to
  11181. * @param mesh The mesh we are binding the information to render
  11182. * @param effect The effect we are binding the data to
  11183. * @param linearSpace Defines if the fog effect is applied in linear space
  11184. */
  11185. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  11186. /**
  11187. * Binds the bones information from the mesh to the effect.
  11188. * @param mesh The mesh we are binding the information to render
  11189. * @param effect The effect we are binding the data to
  11190. */
  11191. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  11192. /**
  11193. * Binds the morph targets information from the mesh to the effect.
  11194. * @param abstractMesh The mesh we are binding the information to render
  11195. * @param effect The effect we are binding the data to
  11196. */
  11197. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  11198. /**
  11199. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  11200. * @param defines The generated defines used in the effect
  11201. * @param effect The effect we are binding the data to
  11202. * @param scene The scene we are willing to render with logarithmic scale for
  11203. */
  11204. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  11205. /**
  11206. * Binds the clip plane information from the scene to the effect.
  11207. * @param scene The scene the clip plane information are extracted from
  11208. * @param effect The effect we are binding the data to
  11209. */
  11210. static BindClipPlane(effect: Effect, scene: Scene): void;
  11211. }
  11212. }
  11213. declare module "babylonjs/Shaders/shadowMap.fragment" {
  11214. /** @hidden */
  11215. export var shadowMapPixelShader: {
  11216. name: string;
  11217. shader: string;
  11218. };
  11219. }
  11220. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  11221. /** @hidden */
  11222. export var bonesDeclaration: {
  11223. name: string;
  11224. shader: string;
  11225. };
  11226. }
  11227. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  11228. /** @hidden */
  11229. export var morphTargetsVertexGlobalDeclaration: {
  11230. name: string;
  11231. shader: string;
  11232. };
  11233. }
  11234. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  11235. /** @hidden */
  11236. export var morphTargetsVertexDeclaration: {
  11237. name: string;
  11238. shader: string;
  11239. };
  11240. }
  11241. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  11242. /** @hidden */
  11243. export var instancesDeclaration: {
  11244. name: string;
  11245. shader: string;
  11246. };
  11247. }
  11248. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  11249. /** @hidden */
  11250. export var helperFunctions: {
  11251. name: string;
  11252. shader: string;
  11253. };
  11254. }
  11255. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  11256. /** @hidden */
  11257. export var morphTargetsVertex: {
  11258. name: string;
  11259. shader: string;
  11260. };
  11261. }
  11262. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  11263. /** @hidden */
  11264. export var instancesVertex: {
  11265. name: string;
  11266. shader: string;
  11267. };
  11268. }
  11269. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  11270. /** @hidden */
  11271. export var bonesVertex: {
  11272. name: string;
  11273. shader: string;
  11274. };
  11275. }
  11276. declare module "babylonjs/Shaders/shadowMap.vertex" {
  11277. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  11278. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  11279. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  11280. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  11281. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  11282. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  11283. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  11284. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  11285. /** @hidden */
  11286. export var shadowMapVertexShader: {
  11287. name: string;
  11288. shader: string;
  11289. };
  11290. }
  11291. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  11292. /** @hidden */
  11293. export var depthBoxBlurPixelShader: {
  11294. name: string;
  11295. shader: string;
  11296. };
  11297. }
  11298. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  11299. import { Nullable } from "babylonjs/types";
  11300. import { Scene } from "babylonjs/scene";
  11301. import { Matrix } from "babylonjs/Maths/math";
  11302. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11303. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11304. import { Mesh } from "babylonjs/Meshes/mesh";
  11305. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  11306. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  11307. import { Effect } from "babylonjs/Materials/effect";
  11308. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11309. import "babylonjs/Shaders/shadowMap.fragment";
  11310. import "babylonjs/Shaders/shadowMap.vertex";
  11311. import "babylonjs/Shaders/depthBoxBlur.fragment";
  11312. import { Observable } from "babylonjs/Misc/observable";
  11313. /**
  11314. * Defines the options associated with the creation of a custom shader for a shadow generator.
  11315. */
  11316. export interface ICustomShaderOptions {
  11317. /**
  11318. * Gets or sets the custom shader name to use
  11319. */
  11320. shaderName: string;
  11321. /**
  11322. * The list of attribute names used in the shader
  11323. */
  11324. attributes?: string[];
  11325. /**
  11326. * The list of unifrom names used in the shader
  11327. */
  11328. uniforms?: string[];
  11329. /**
  11330. * The list of sampler names used in the shader
  11331. */
  11332. samplers?: string[];
  11333. /**
  11334. * The list of defines used in the shader
  11335. */
  11336. defines?: string[];
  11337. }
  11338. /**
  11339. * Interface to implement to create a shadow generator compatible with BJS.
  11340. */
  11341. export interface IShadowGenerator {
  11342. /**
  11343. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  11344. * @returns The render target texture if present otherwise, null
  11345. */
  11346. getShadowMap(): Nullable<RenderTargetTexture>;
  11347. /**
  11348. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  11349. * @returns The render target texture if the shadow map is present otherwise, null
  11350. */
  11351. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  11352. /**
  11353. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  11354. * @param subMesh The submesh we want to render in the shadow map
  11355. * @param useInstances Defines wether will draw in the map using instances
  11356. * @returns true if ready otherwise, false
  11357. */
  11358. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11359. /**
  11360. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  11361. * @param defines Defines of the material we want to update
  11362. * @param lightIndex Index of the light in the enabled light list of the material
  11363. */
  11364. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  11365. /**
  11366. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  11367. * defined in the generator but impacting the effect).
  11368. * It implies the unifroms available on the materials are the standard BJS ones.
  11369. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  11370. * @param effect The effect we are binfing the information for
  11371. */
  11372. bindShadowLight(lightIndex: string, effect: Effect): void;
  11373. /**
  11374. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  11375. * (eq to shadow prjection matrix * light transform matrix)
  11376. * @returns The transform matrix used to create the shadow map
  11377. */
  11378. getTransformMatrix(): Matrix;
  11379. /**
  11380. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  11381. * Cube and 2D textures for instance.
  11382. */
  11383. recreateShadowMap(): void;
  11384. /**
  11385. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11386. * @param onCompiled Callback triggered at the and of the effects compilation
  11387. * @param options Sets of optional options forcing the compilation with different modes
  11388. */
  11389. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  11390. useInstances: boolean;
  11391. }>): void;
  11392. /**
  11393. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11394. * @param options Sets of optional options forcing the compilation with different modes
  11395. * @returns A promise that resolves when the compilation completes
  11396. */
  11397. forceCompilationAsync(options?: Partial<{
  11398. useInstances: boolean;
  11399. }>): Promise<void>;
  11400. /**
  11401. * Serializes the shadow generator setup to a json object.
  11402. * @returns The serialized JSON object
  11403. */
  11404. serialize(): any;
  11405. /**
  11406. * Disposes the Shadow map and related Textures and effects.
  11407. */
  11408. dispose(): void;
  11409. }
  11410. /**
  11411. * Default implementation IShadowGenerator.
  11412. * This is the main object responsible of generating shadows in the framework.
  11413. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  11414. */
  11415. export class ShadowGenerator implements IShadowGenerator {
  11416. /**
  11417. * Shadow generator mode None: no filtering applied.
  11418. */
  11419. static readonly FILTER_NONE: number;
  11420. /**
  11421. * Shadow generator mode ESM: Exponential Shadow Mapping.
  11422. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11423. */
  11424. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  11425. /**
  11426. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  11427. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  11428. */
  11429. static readonly FILTER_POISSONSAMPLING: number;
  11430. /**
  11431. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  11432. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11433. */
  11434. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  11435. /**
  11436. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  11437. * edge artifacts on steep falloff.
  11438. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11439. */
  11440. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  11441. /**
  11442. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  11443. * edge artifacts on steep falloff.
  11444. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11445. */
  11446. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  11447. /**
  11448. * Shadow generator mode PCF: Percentage Closer Filtering
  11449. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  11450. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  11451. */
  11452. static readonly FILTER_PCF: number;
  11453. /**
  11454. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  11455. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  11456. * Contact Hardening
  11457. */
  11458. static readonly FILTER_PCSS: number;
  11459. /**
  11460. * Reserved for PCF and PCSS
  11461. * Highest Quality.
  11462. *
  11463. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  11464. *
  11465. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  11466. */
  11467. static readonly QUALITY_HIGH: number;
  11468. /**
  11469. * Reserved for PCF and PCSS
  11470. * Good tradeoff for quality/perf cross devices
  11471. *
  11472. * Execute PCF on a 3*3 kernel.
  11473. *
  11474. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  11475. */
  11476. static readonly QUALITY_MEDIUM: number;
  11477. /**
  11478. * Reserved for PCF and PCSS
  11479. * The lowest quality but the fastest.
  11480. *
  11481. * Execute PCF on a 1*1 kernel.
  11482. *
  11483. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  11484. */
  11485. static readonly QUALITY_LOW: number;
  11486. /** Gets or sets the custom shader name to use */
  11487. customShaderOptions: ICustomShaderOptions;
  11488. /**
  11489. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  11490. */
  11491. onBeforeShadowMapRenderObservable: Observable<Effect>;
  11492. /**
  11493. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  11494. */
  11495. onAfterShadowMapRenderObservable: Observable<Effect>;
  11496. /**
  11497. * Observable triggered before a mesh is rendered in the shadow map.
  11498. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  11499. */
  11500. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  11501. /**
  11502. * Observable triggered after a mesh is rendered in the shadow map.
  11503. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  11504. */
  11505. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  11506. private _bias;
  11507. /**
  11508. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  11509. */
  11510. /**
  11511. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  11512. */
  11513. bias: number;
  11514. private _normalBias;
  11515. /**
  11516. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  11517. */
  11518. /**
  11519. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  11520. */
  11521. normalBias: number;
  11522. private _blurBoxOffset;
  11523. /**
  11524. * Gets the blur box offset: offset applied during the blur pass.
  11525. * Only useful if useKernelBlur = false
  11526. */
  11527. /**
  11528. * Sets the blur box offset: offset applied during the blur pass.
  11529. * Only useful if useKernelBlur = false
  11530. */
  11531. blurBoxOffset: number;
  11532. private _blurScale;
  11533. /**
  11534. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  11535. * 2 means half of the size.
  11536. */
  11537. /**
  11538. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  11539. * 2 means half of the size.
  11540. */
  11541. blurScale: number;
  11542. private _blurKernel;
  11543. /**
  11544. * Gets the blur kernel: kernel size of the blur pass.
  11545. * Only useful if useKernelBlur = true
  11546. */
  11547. /**
  11548. * Sets the blur kernel: kernel size of the blur pass.
  11549. * Only useful if useKernelBlur = true
  11550. */
  11551. blurKernel: number;
  11552. private _useKernelBlur;
  11553. /**
  11554. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  11555. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  11556. */
  11557. /**
  11558. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  11559. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  11560. */
  11561. useKernelBlur: boolean;
  11562. private _depthScale;
  11563. /**
  11564. * Gets the depth scale used in ESM mode.
  11565. */
  11566. /**
  11567. * Sets the depth scale used in ESM mode.
  11568. * This can override the scale stored on the light.
  11569. */
  11570. depthScale: number;
  11571. private _filter;
  11572. /**
  11573. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  11574. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  11575. */
  11576. /**
  11577. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  11578. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  11579. */
  11580. filter: number;
  11581. /**
  11582. * Gets if the current filter is set to Poisson Sampling.
  11583. */
  11584. /**
  11585. * Sets the current filter to Poisson Sampling.
  11586. */
  11587. usePoissonSampling: boolean;
  11588. /**
  11589. * Gets if the current filter is set to ESM.
  11590. */
  11591. /**
  11592. * Sets the current filter is to ESM.
  11593. */
  11594. useExponentialShadowMap: boolean;
  11595. /**
  11596. * Gets if the current filter is set to filtered ESM.
  11597. */
  11598. /**
  11599. * Gets if the current filter is set to filtered ESM.
  11600. */
  11601. useBlurExponentialShadowMap: boolean;
  11602. /**
  11603. * Gets if the current filter is set to "close ESM" (using the inverse of the
  11604. * exponential to prevent steep falloff artifacts).
  11605. */
  11606. /**
  11607. * Sets the current filter to "close ESM" (using the inverse of the
  11608. * exponential to prevent steep falloff artifacts).
  11609. */
  11610. useCloseExponentialShadowMap: boolean;
  11611. /**
  11612. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  11613. * exponential to prevent steep falloff artifacts).
  11614. */
  11615. /**
  11616. * Sets the current filter to filtered "close ESM" (using the inverse of the
  11617. * exponential to prevent steep falloff artifacts).
  11618. */
  11619. useBlurCloseExponentialShadowMap: boolean;
  11620. /**
  11621. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  11622. */
  11623. /**
  11624. * Sets the current filter to "PCF" (percentage closer filtering).
  11625. */
  11626. usePercentageCloserFiltering: boolean;
  11627. private _filteringQuality;
  11628. /**
  11629. * Gets the PCF or PCSS Quality.
  11630. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  11631. */
  11632. /**
  11633. * Sets the PCF or PCSS Quality.
  11634. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  11635. */
  11636. filteringQuality: number;
  11637. /**
  11638. * Gets if the current filter is set to "PCSS" (contact hardening).
  11639. */
  11640. /**
  11641. * Sets the current filter to "PCSS" (contact hardening).
  11642. */
  11643. useContactHardeningShadow: boolean;
  11644. private _contactHardeningLightSizeUVRatio;
  11645. /**
  11646. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  11647. * Using a ratio helps keeping shape stability independently of the map size.
  11648. *
  11649. * It does not account for the light projection as it was having too much
  11650. * instability during the light setup or during light position changes.
  11651. *
  11652. * Only valid if useContactHardeningShadow is true.
  11653. */
  11654. /**
  11655. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  11656. * Using a ratio helps keeping shape stability independently of the map size.
  11657. *
  11658. * It does not account for the light projection as it was having too much
  11659. * instability during the light setup or during light position changes.
  11660. *
  11661. * Only valid if useContactHardeningShadow is true.
  11662. */
  11663. contactHardeningLightSizeUVRatio: number;
  11664. private _darkness;
  11665. /** Gets or sets the actual darkness of a shadow */
  11666. darkness: number;
  11667. /**
  11668. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  11669. * 0 means strongest and 1 would means no shadow.
  11670. * @returns the darkness.
  11671. */
  11672. getDarkness(): number;
  11673. /**
  11674. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  11675. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  11676. * @returns the shadow generator allowing fluent coding.
  11677. */
  11678. setDarkness(darkness: number): ShadowGenerator;
  11679. private _transparencyShadow;
  11680. /** Gets or sets the ability to have transparent shadow */
  11681. transparencyShadow: boolean;
  11682. /**
  11683. * Sets the ability to have transparent shadow (boolean).
  11684. * @param transparent True if transparent else False
  11685. * @returns the shadow generator allowing fluent coding
  11686. */
  11687. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  11688. private _shadowMap;
  11689. private _shadowMap2;
  11690. /**
  11691. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  11692. * @returns The render target texture if present otherwise, null
  11693. */
  11694. getShadowMap(): Nullable<RenderTargetTexture>;
  11695. /**
  11696. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  11697. * @returns The render target texture if the shadow map is present otherwise, null
  11698. */
  11699. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  11700. /**
  11701. * Gets the class name of that object
  11702. * @returns "ShadowGenerator"
  11703. */
  11704. getClassName(): string;
  11705. /**
  11706. * Helper function to add a mesh and its descendants to the list of shadow casters.
  11707. * @param mesh Mesh to add
  11708. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  11709. * @returns the Shadow Generator itself
  11710. */
  11711. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  11712. /**
  11713. * Helper function to remove a mesh and its descendants from the list of shadow casters
  11714. * @param mesh Mesh to remove
  11715. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  11716. * @returns the Shadow Generator itself
  11717. */
  11718. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  11719. /**
  11720. * Controls the extent to which the shadows fade out at the edge of the frustum
  11721. * Used only by directionals and spots
  11722. */
  11723. frustumEdgeFalloff: number;
  11724. private _light;
  11725. /**
  11726. * Returns the associated light object.
  11727. * @returns the light generating the shadow
  11728. */
  11729. getLight(): IShadowLight;
  11730. /**
  11731. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  11732. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  11733. * It might on the other hand introduce peter panning.
  11734. */
  11735. forceBackFacesOnly: boolean;
  11736. private _scene;
  11737. private _lightDirection;
  11738. private _effect;
  11739. private _viewMatrix;
  11740. private _projectionMatrix;
  11741. private _transformMatrix;
  11742. private _cachedPosition;
  11743. private _cachedDirection;
  11744. private _cachedDefines;
  11745. private _currentRenderID;
  11746. private _boxBlurPostprocess;
  11747. private _kernelBlurXPostprocess;
  11748. private _kernelBlurYPostprocess;
  11749. private _blurPostProcesses;
  11750. private _mapSize;
  11751. private _currentFaceIndex;
  11752. private _currentFaceIndexCache;
  11753. private _textureType;
  11754. private _defaultTextureMatrix;
  11755. /** @hidden */
  11756. static _SceneComponentInitialization: (scene: Scene) => void;
  11757. /**
  11758. * Creates a ShadowGenerator object.
  11759. * A ShadowGenerator is the required tool to use the shadows.
  11760. * Each light casting shadows needs to use its own ShadowGenerator.
  11761. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  11762. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  11763. * @param light The light object generating the shadows.
  11764. * @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.
  11765. */
  11766. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  11767. private _initializeGenerator;
  11768. private _initializeShadowMap;
  11769. private _initializeBlurRTTAndPostProcesses;
  11770. private _renderForShadowMap;
  11771. private _renderSubMeshForShadowMap;
  11772. private _applyFilterValues;
  11773. /**
  11774. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11775. * @param onCompiled Callback triggered at the and of the effects compilation
  11776. * @param options Sets of optional options forcing the compilation with different modes
  11777. */
  11778. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  11779. useInstances: boolean;
  11780. }>): void;
  11781. /**
  11782. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11783. * @param options Sets of optional options forcing the compilation with different modes
  11784. * @returns A promise that resolves when the compilation completes
  11785. */
  11786. forceCompilationAsync(options?: Partial<{
  11787. useInstances: boolean;
  11788. }>): Promise<void>;
  11789. /**
  11790. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  11791. * @param subMesh The submesh we want to render in the shadow map
  11792. * @param useInstances Defines wether will draw in the map using instances
  11793. * @returns true if ready otherwise, false
  11794. */
  11795. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11796. /**
  11797. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  11798. * @param defines Defines of the material we want to update
  11799. * @param lightIndex Index of the light in the enabled light list of the material
  11800. */
  11801. prepareDefines(defines: any, lightIndex: number): void;
  11802. /**
  11803. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  11804. * defined in the generator but impacting the effect).
  11805. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  11806. * @param effect The effect we are binfing the information for
  11807. */
  11808. bindShadowLight(lightIndex: string, effect: Effect): void;
  11809. /**
  11810. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  11811. * (eq to shadow prjection matrix * light transform matrix)
  11812. * @returns The transform matrix used to create the shadow map
  11813. */
  11814. getTransformMatrix(): Matrix;
  11815. /**
  11816. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  11817. * Cube and 2D textures for instance.
  11818. */
  11819. recreateShadowMap(): void;
  11820. private _disposeBlurPostProcesses;
  11821. private _disposeRTTandPostProcesses;
  11822. /**
  11823. * Disposes the ShadowGenerator.
  11824. * Returns nothing.
  11825. */
  11826. dispose(): void;
  11827. /**
  11828. * Serializes the shadow generator setup to a json object.
  11829. * @returns The serialized JSON object
  11830. */
  11831. serialize(): any;
  11832. /**
  11833. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  11834. * @param parsedShadowGenerator The JSON object to parse
  11835. * @param scene The scene to create the shadow map for
  11836. * @returns The parsed shadow generator
  11837. */
  11838. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  11839. }
  11840. }
  11841. declare module "babylonjs/Lights/light" {
  11842. import { Nullable } from "babylonjs/types";
  11843. import { Scene } from "babylonjs/scene";
  11844. import { Vector3, Color3 } from "babylonjs/Maths/math";
  11845. import { Node } from "babylonjs/node";
  11846. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11847. import { Effect } from "babylonjs/Materials/effect";
  11848. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  11849. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  11850. /**
  11851. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  11852. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  11853. * 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.
  11854. */
  11855. export abstract class Light extends Node {
  11856. /**
  11857. * Falloff Default: light is falling off following the material specification:
  11858. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  11859. */
  11860. static readonly FALLOFF_DEFAULT: number;
  11861. /**
  11862. * Falloff Physical: light is falling off following the inverse squared distance law.
  11863. */
  11864. static readonly FALLOFF_PHYSICAL: number;
  11865. /**
  11866. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  11867. * to enhance interoperability with other engines.
  11868. */
  11869. static readonly FALLOFF_GLTF: number;
  11870. /**
  11871. * Falloff Standard: light is falling off like in the standard material
  11872. * to enhance interoperability with other materials.
  11873. */
  11874. static readonly FALLOFF_STANDARD: number;
  11875. /**
  11876. * If every light affecting the material is in this lightmapMode,
  11877. * material.lightmapTexture adds or multiplies
  11878. * (depends on material.useLightmapAsShadowmap)
  11879. * after every other light calculations.
  11880. */
  11881. static readonly LIGHTMAP_DEFAULT: number;
  11882. /**
  11883. * material.lightmapTexture as only diffuse lighting from this light
  11884. * adds only specular lighting from this light
  11885. * adds dynamic shadows
  11886. */
  11887. static readonly LIGHTMAP_SPECULAR: number;
  11888. /**
  11889. * material.lightmapTexture as only lighting
  11890. * no light calculation from this light
  11891. * only adds dynamic shadows from this light
  11892. */
  11893. static readonly LIGHTMAP_SHADOWSONLY: number;
  11894. /**
  11895. * Each light type uses the default quantity according to its type:
  11896. * point/spot lights use luminous intensity
  11897. * directional lights use illuminance
  11898. */
  11899. static readonly INTENSITYMODE_AUTOMATIC: number;
  11900. /**
  11901. * lumen (lm)
  11902. */
  11903. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  11904. /**
  11905. * candela (lm/sr)
  11906. */
  11907. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  11908. /**
  11909. * lux (lm/m^2)
  11910. */
  11911. static readonly INTENSITYMODE_ILLUMINANCE: number;
  11912. /**
  11913. * nit (cd/m^2)
  11914. */
  11915. static readonly INTENSITYMODE_LUMINANCE: number;
  11916. /**
  11917. * Light type const id of the point light.
  11918. */
  11919. static readonly LIGHTTYPEID_POINTLIGHT: number;
  11920. /**
  11921. * Light type const id of the directional light.
  11922. */
  11923. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  11924. /**
  11925. * Light type const id of the spot light.
  11926. */
  11927. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  11928. /**
  11929. * Light type const id of the hemispheric light.
  11930. */
  11931. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  11932. /**
  11933. * Diffuse gives the basic color to an object.
  11934. */
  11935. diffuse: Color3;
  11936. /**
  11937. * Specular produces a highlight color on an object.
  11938. * Note: This is note affecting PBR materials.
  11939. */
  11940. specular: Color3;
  11941. /**
  11942. * Defines the falloff type for this light. This lets overrriding how punctual light are
  11943. * falling off base on range or angle.
  11944. * This can be set to any values in Light.FALLOFF_x.
  11945. *
  11946. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  11947. * other types of materials.
  11948. */
  11949. falloffType: number;
  11950. /**
  11951. * Strength of the light.
  11952. * Note: By default it is define in the framework own unit.
  11953. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  11954. */
  11955. intensity: number;
  11956. private _range;
  11957. protected _inverseSquaredRange: number;
  11958. /**
  11959. * Defines how far from the source the light is impacting in scene units.
  11960. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  11961. */
  11962. /**
  11963. * Defines how far from the source the light is impacting in scene units.
  11964. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  11965. */
  11966. range: number;
  11967. /**
  11968. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  11969. * of light.
  11970. */
  11971. private _photometricScale;
  11972. private _intensityMode;
  11973. /**
  11974. * Gets the photometric scale used to interpret the intensity.
  11975. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  11976. */
  11977. /**
  11978. * Sets the photometric scale used to interpret the intensity.
  11979. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  11980. */
  11981. intensityMode: number;
  11982. private _radius;
  11983. /**
  11984. * Gets the light radius used by PBR Materials to simulate soft area lights.
  11985. */
  11986. /**
  11987. * sets the light radius used by PBR Materials to simulate soft area lights.
  11988. */
  11989. radius: number;
  11990. private _renderPriority;
  11991. /**
  11992. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  11993. * exceeding the number allowed of the materials.
  11994. */
  11995. renderPriority: number;
  11996. private _shadowEnabled;
  11997. /**
  11998. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  11999. * the current shadow generator.
  12000. */
  12001. /**
  12002. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  12003. * the current shadow generator.
  12004. */
  12005. shadowEnabled: boolean;
  12006. private _includedOnlyMeshes;
  12007. /**
  12008. * Gets the only meshes impacted by this light.
  12009. */
  12010. /**
  12011. * Sets the only meshes impacted by this light.
  12012. */
  12013. includedOnlyMeshes: AbstractMesh[];
  12014. private _excludedMeshes;
  12015. /**
  12016. * Gets the meshes not impacted by this light.
  12017. */
  12018. /**
  12019. * Sets the meshes not impacted by this light.
  12020. */
  12021. excludedMeshes: AbstractMesh[];
  12022. private _excludeWithLayerMask;
  12023. /**
  12024. * Gets the layer id use to find what meshes are not impacted by the light.
  12025. * Inactive if 0
  12026. */
  12027. /**
  12028. * Sets the layer id use to find what meshes are not impacted by the light.
  12029. * Inactive if 0
  12030. */
  12031. excludeWithLayerMask: number;
  12032. private _includeOnlyWithLayerMask;
  12033. /**
  12034. * Gets the layer id use to find what meshes are impacted by the light.
  12035. * Inactive if 0
  12036. */
  12037. /**
  12038. * Sets the layer id use to find what meshes are impacted by the light.
  12039. * Inactive if 0
  12040. */
  12041. includeOnlyWithLayerMask: number;
  12042. private _lightmapMode;
  12043. /**
  12044. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  12045. */
  12046. /**
  12047. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  12048. */
  12049. lightmapMode: number;
  12050. /**
  12051. * Shadow generator associted to the light.
  12052. * @hidden Internal use only.
  12053. */
  12054. _shadowGenerator: Nullable<IShadowGenerator>;
  12055. /**
  12056. * @hidden Internal use only.
  12057. */
  12058. _excludedMeshesIds: string[];
  12059. /**
  12060. * @hidden Internal use only.
  12061. */
  12062. _includedOnlyMeshesIds: string[];
  12063. /**
  12064. * The current light unifom buffer.
  12065. * @hidden Internal use only.
  12066. */
  12067. _uniformBuffer: UniformBuffer;
  12068. /**
  12069. * Creates a Light object in the scene.
  12070. * Documentation : https://doc.babylonjs.com/babylon101/lights
  12071. * @param name The firendly name of the light
  12072. * @param scene The scene the light belongs too
  12073. */
  12074. constructor(name: string, scene: Scene);
  12075. protected abstract _buildUniformLayout(): void;
  12076. /**
  12077. * Sets the passed Effect "effect" with the Light information.
  12078. * @param effect The effect to update
  12079. * @param lightIndex The index of the light in the effect to update
  12080. * @returns The light
  12081. */
  12082. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  12083. /**
  12084. * Returns the string "Light".
  12085. * @returns the class name
  12086. */
  12087. getClassName(): string;
  12088. /** @hidden */
  12089. readonly _isLight: boolean;
  12090. /**
  12091. * Converts the light information to a readable string for debug purpose.
  12092. * @param fullDetails Supports for multiple levels of logging within scene loading
  12093. * @returns the human readable light info
  12094. */
  12095. toString(fullDetails?: boolean): string;
  12096. /** @hidden */
  12097. protected _syncParentEnabledState(): void;
  12098. /**
  12099. * Set the enabled state of this node.
  12100. * @param value - the new enabled state
  12101. */
  12102. setEnabled(value: boolean): void;
  12103. /**
  12104. * Returns the Light associated shadow generator if any.
  12105. * @return the associated shadow generator.
  12106. */
  12107. getShadowGenerator(): Nullable<IShadowGenerator>;
  12108. /**
  12109. * Returns a Vector3, the absolute light position in the World.
  12110. * @returns the world space position of the light
  12111. */
  12112. getAbsolutePosition(): Vector3;
  12113. /**
  12114. * Specifies if the light will affect the passed mesh.
  12115. * @param mesh The mesh to test against the light
  12116. * @return true the mesh is affected otherwise, false.
  12117. */
  12118. canAffectMesh(mesh: AbstractMesh): boolean;
  12119. /**
  12120. * Sort function to order lights for rendering.
  12121. * @param a First Light object to compare to second.
  12122. * @param b Second Light object to compare first.
  12123. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  12124. */
  12125. static CompareLightsPriority(a: Light, b: Light): number;
  12126. /**
  12127. * Releases resources associated with this node.
  12128. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  12129. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  12130. */
  12131. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  12132. /**
  12133. * Returns the light type ID (integer).
  12134. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12135. */
  12136. getTypeID(): number;
  12137. /**
  12138. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  12139. * @returns the scaled intensity in intensity mode unit
  12140. */
  12141. getScaledIntensity(): number;
  12142. /**
  12143. * Returns a new Light object, named "name", from the current one.
  12144. * @param name The name of the cloned light
  12145. * @returns the new created light
  12146. */
  12147. clone(name: string): Nullable<Light>;
  12148. /**
  12149. * Serializes the current light into a Serialization object.
  12150. * @returns the serialized object.
  12151. */
  12152. serialize(): any;
  12153. /**
  12154. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  12155. * This new light is named "name" and added to the passed scene.
  12156. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  12157. * @param name The friendly name of the light
  12158. * @param scene The scene the new light will belong to
  12159. * @returns the constructor function
  12160. */
  12161. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  12162. /**
  12163. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  12164. * @param parsedLight The JSON representation of the light
  12165. * @param scene The scene to create the parsed light in
  12166. * @returns the created light after parsing
  12167. */
  12168. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  12169. private _hookArrayForExcluded;
  12170. private _hookArrayForIncludedOnly;
  12171. private _resyncMeshes;
  12172. /**
  12173. * Forces the meshes to update their light related information in their rendering used effects
  12174. * @hidden Internal Use Only
  12175. */
  12176. _markMeshesAsLightDirty(): void;
  12177. /**
  12178. * Recomputes the cached photometric scale if needed.
  12179. */
  12180. private _computePhotometricScale;
  12181. /**
  12182. * Returns the Photometric Scale according to the light type and intensity mode.
  12183. */
  12184. private _getPhotometricScale;
  12185. /**
  12186. * Reorder the light in the scene according to their defined priority.
  12187. * @hidden Internal Use Only
  12188. */
  12189. _reorderLightsInScene(): void;
  12190. /**
  12191. * Prepares the list of defines specific to the light type.
  12192. * @param defines the list of defines
  12193. * @param lightIndex defines the index of the light for the effect
  12194. */
  12195. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12196. }
  12197. }
  12198. declare module "babylonjs/Meshes/instancedMesh" {
  12199. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  12200. import { Vector3, Matrix } from "babylonjs/Maths/math";
  12201. import { Camera } from "babylonjs/Cameras/camera";
  12202. import { Node } from "babylonjs/node";
  12203. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12204. import { Mesh } from "babylonjs/Meshes/mesh";
  12205. import { Material } from "babylonjs/Materials/material";
  12206. import { Skeleton } from "babylonjs/Bones/skeleton";
  12207. import { Light } from "babylonjs/Lights/light";
  12208. /**
  12209. * Creates an instance based on a source mesh.
  12210. */
  12211. export class InstancedMesh extends AbstractMesh {
  12212. private _sourceMesh;
  12213. private _currentLOD;
  12214. /** @hidden */
  12215. _indexInSourceMeshInstanceArray: number;
  12216. constructor(name: string, source: Mesh);
  12217. /**
  12218. * Returns the string "InstancedMesh".
  12219. */
  12220. getClassName(): string;
  12221. /** Gets the list of lights affecting that mesh */
  12222. readonly lightSources: Light[];
  12223. _resyncLightSources(): void;
  12224. _resyncLighSource(light: Light): void;
  12225. _removeLightSource(light: Light): void;
  12226. /**
  12227. * If the source mesh receives shadows
  12228. */
  12229. readonly receiveShadows: boolean;
  12230. /**
  12231. * The material of the source mesh
  12232. */
  12233. readonly material: Nullable<Material>;
  12234. /**
  12235. * Visibility of the source mesh
  12236. */
  12237. readonly visibility: number;
  12238. /**
  12239. * Skeleton of the source mesh
  12240. */
  12241. readonly skeleton: Nullable<Skeleton>;
  12242. /**
  12243. * Rendering ground id of the source mesh
  12244. */
  12245. renderingGroupId: number;
  12246. /**
  12247. * Returns the total number of vertices (integer).
  12248. */
  12249. getTotalVertices(): number;
  12250. /**
  12251. * Returns a positive integer : the total number of indices in this mesh geometry.
  12252. * @returns the numner of indices or zero if the mesh has no geometry.
  12253. */
  12254. getTotalIndices(): number;
  12255. /**
  12256. * The source mesh of the instance
  12257. */
  12258. readonly sourceMesh: Mesh;
  12259. /**
  12260. * Is this node ready to be used/rendered
  12261. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  12262. * @return {boolean} is it ready
  12263. */
  12264. isReady(completeCheck?: boolean): boolean;
  12265. /**
  12266. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  12267. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  12268. * @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.
  12269. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  12270. */
  12271. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  12272. /**
  12273. * Sets the vertex data of the mesh geometry for the requested `kind`.
  12274. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  12275. * The `data` are either a numeric array either a Float32Array.
  12276. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  12277. * 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).
  12278. * Note that a new underlying VertexBuffer object is created each call.
  12279. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  12280. *
  12281. * Possible `kind` values :
  12282. * - VertexBuffer.PositionKind
  12283. * - VertexBuffer.UVKind
  12284. * - VertexBuffer.UV2Kind
  12285. * - VertexBuffer.UV3Kind
  12286. * - VertexBuffer.UV4Kind
  12287. * - VertexBuffer.UV5Kind
  12288. * - VertexBuffer.UV6Kind
  12289. * - VertexBuffer.ColorKind
  12290. * - VertexBuffer.MatricesIndicesKind
  12291. * - VertexBuffer.MatricesIndicesExtraKind
  12292. * - VertexBuffer.MatricesWeightsKind
  12293. * - VertexBuffer.MatricesWeightsExtraKind
  12294. *
  12295. * Returns the Mesh.
  12296. */
  12297. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  12298. /**
  12299. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  12300. * If the mesh has no geometry, it is simply returned as it is.
  12301. * The `data` are either a numeric array either a Float32Array.
  12302. * No new underlying VertexBuffer object is created.
  12303. * 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.
  12304. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  12305. *
  12306. * Possible `kind` values :
  12307. * - VertexBuffer.PositionKind
  12308. * - VertexBuffer.UVKind
  12309. * - VertexBuffer.UV2Kind
  12310. * - VertexBuffer.UV3Kind
  12311. * - VertexBuffer.UV4Kind
  12312. * - VertexBuffer.UV5Kind
  12313. * - VertexBuffer.UV6Kind
  12314. * - VertexBuffer.ColorKind
  12315. * - VertexBuffer.MatricesIndicesKind
  12316. * - VertexBuffer.MatricesIndicesExtraKind
  12317. * - VertexBuffer.MatricesWeightsKind
  12318. * - VertexBuffer.MatricesWeightsExtraKind
  12319. *
  12320. * Returns the Mesh.
  12321. */
  12322. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  12323. /**
  12324. * Sets the mesh indices.
  12325. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  12326. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  12327. * This method creates a new index buffer each call.
  12328. * Returns the Mesh.
  12329. */
  12330. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  12331. /**
  12332. * Boolean : True if the mesh owns the requested kind of data.
  12333. */
  12334. isVerticesDataPresent(kind: string): boolean;
  12335. /**
  12336. * Returns an array of indices (IndicesArray).
  12337. */
  12338. getIndices(): Nullable<IndicesArray>;
  12339. readonly _positions: Nullable<Vector3[]>;
  12340. /**
  12341. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  12342. * This means the mesh underlying bounding box and sphere are recomputed.
  12343. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  12344. * @returns the current mesh
  12345. */
  12346. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  12347. /** @hidden */
  12348. _preActivate(): InstancedMesh;
  12349. /** @hidden */
  12350. _activate(renderId: number, intermediateRendering: boolean): boolean;
  12351. /** @hidden */
  12352. _postActivate(): void;
  12353. getWorldMatrix(): Matrix;
  12354. readonly isAnInstance: boolean;
  12355. /**
  12356. * Returns the current associated LOD AbstractMesh.
  12357. */
  12358. getLOD(camera: Camera): AbstractMesh;
  12359. /** @hidden */
  12360. _syncSubMeshes(): InstancedMesh;
  12361. /** @hidden */
  12362. _generatePointsArray(): boolean;
  12363. /**
  12364. * Creates a new InstancedMesh from the current mesh.
  12365. * - name (string) : the cloned mesh name
  12366. * - newParent (optional Node) : the optional Node to parent the clone to.
  12367. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  12368. *
  12369. * Returns the clone.
  12370. */
  12371. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  12372. /**
  12373. * Disposes the InstancedMesh.
  12374. * Returns nothing.
  12375. */
  12376. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  12377. }
  12378. }
  12379. declare module "babylonjs/Materials/shaderMaterial" {
  12380. import { Scene } from "babylonjs/scene";
  12381. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  12382. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12383. import { Mesh } from "babylonjs/Meshes/mesh";
  12384. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  12385. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  12386. import { Texture } from "babylonjs/Materials/Textures/texture";
  12387. import { Material } from "babylonjs/Materials/material";
  12388. /**
  12389. * Defines the options associated with the creation of a shader material.
  12390. */
  12391. export interface IShaderMaterialOptions {
  12392. /**
  12393. * Does the material work in alpha blend mode
  12394. */
  12395. needAlphaBlending: boolean;
  12396. /**
  12397. * Does the material work in alpha test mode
  12398. */
  12399. needAlphaTesting: boolean;
  12400. /**
  12401. * The list of attribute names used in the shader
  12402. */
  12403. attributes: string[];
  12404. /**
  12405. * The list of unifrom names used in the shader
  12406. */
  12407. uniforms: string[];
  12408. /**
  12409. * The list of UBO names used in the shader
  12410. */
  12411. uniformBuffers: string[];
  12412. /**
  12413. * The list of sampler names used in the shader
  12414. */
  12415. samplers: string[];
  12416. /**
  12417. * The list of defines used in the shader
  12418. */
  12419. defines: string[];
  12420. }
  12421. /**
  12422. * 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.
  12423. *
  12424. * This returned material effects how the mesh will look based on the code in the shaders.
  12425. *
  12426. * @see http://doc.babylonjs.com/how_to/shader_material
  12427. */
  12428. export class ShaderMaterial extends Material {
  12429. private _shaderPath;
  12430. private _options;
  12431. private _textures;
  12432. private _textureArrays;
  12433. private _floats;
  12434. private _ints;
  12435. private _floatsArrays;
  12436. private _colors3;
  12437. private _colors3Arrays;
  12438. private _colors4;
  12439. private _vectors2;
  12440. private _vectors3;
  12441. private _vectors4;
  12442. private _matrices;
  12443. private _matrices3x3;
  12444. private _matrices2x2;
  12445. private _vectors2Arrays;
  12446. private _vectors3Arrays;
  12447. private _cachedWorldViewMatrix;
  12448. private _cachedWorldViewProjectionMatrix;
  12449. private _renderId;
  12450. /**
  12451. * Instantiate a new shader material.
  12452. * 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.
  12453. * This returned material effects how the mesh will look based on the code in the shaders.
  12454. * @see http://doc.babylonjs.com/how_to/shader_material
  12455. * @param name Define the name of the material in the scene
  12456. * @param scene Define the scene the material belongs to
  12457. * @param shaderPath Defines the route to the shader code in one of three ways:
  12458. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  12459. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  12460. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  12461. * @param options Define the options used to create the shader
  12462. */
  12463. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  12464. /**
  12465. * Gets the options used to compile the shader.
  12466. * They can be modified to trigger a new compilation
  12467. */
  12468. readonly options: IShaderMaterialOptions;
  12469. /**
  12470. * Gets the current class name of the material e.g. "ShaderMaterial"
  12471. * Mainly use in serialization.
  12472. * @returns the class name
  12473. */
  12474. getClassName(): string;
  12475. /**
  12476. * Specifies if the material will require alpha blending
  12477. * @returns a boolean specifying if alpha blending is needed
  12478. */
  12479. needAlphaBlending(): boolean;
  12480. /**
  12481. * Specifies if this material should be rendered in alpha test mode
  12482. * @returns a boolean specifying if an alpha test is needed.
  12483. */
  12484. needAlphaTesting(): boolean;
  12485. private _checkUniform;
  12486. /**
  12487. * Set a texture in the shader.
  12488. * @param name Define the name of the uniform samplers as defined in the shader
  12489. * @param texture Define the texture to bind to this sampler
  12490. * @return the material itself allowing "fluent" like uniform updates
  12491. */
  12492. setTexture(name: string, texture: Texture): ShaderMaterial;
  12493. /**
  12494. * Set a texture array in the shader.
  12495. * @param name Define the name of the uniform sampler array as defined in the shader
  12496. * @param textures Define the list of textures to bind to this sampler
  12497. * @return the material itself allowing "fluent" like uniform updates
  12498. */
  12499. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  12500. /**
  12501. * Set a float in the shader.
  12502. * @param name Define the name of the uniform as defined in the shader
  12503. * @param value Define the value to give to the uniform
  12504. * @return the material itself allowing "fluent" like uniform updates
  12505. */
  12506. setFloat(name: string, value: number): ShaderMaterial;
  12507. /**
  12508. * Set a int in the shader.
  12509. * @param name Define the name of the uniform as defined in the shader
  12510. * @param value Define the value to give to the uniform
  12511. * @return the material itself allowing "fluent" like uniform updates
  12512. */
  12513. setInt(name: string, value: number): ShaderMaterial;
  12514. /**
  12515. * Set an array of floats in the shader.
  12516. * @param name Define the name of the uniform as defined in the shader
  12517. * @param value Define the value to give to the uniform
  12518. * @return the material itself allowing "fluent" like uniform updates
  12519. */
  12520. setFloats(name: string, value: number[]): ShaderMaterial;
  12521. /**
  12522. * Set a vec3 in the shader from a Color3.
  12523. * @param name Define the name of the uniform as defined in the shader
  12524. * @param value Define the value to give to the uniform
  12525. * @return the material itself allowing "fluent" like uniform updates
  12526. */
  12527. setColor3(name: string, value: Color3): ShaderMaterial;
  12528. /**
  12529. * Set a vec3 array in the shader from a Color3 array.
  12530. * @param name Define the name of the uniform as defined in the shader
  12531. * @param value Define the value to give to the uniform
  12532. * @return the material itself allowing "fluent" like uniform updates
  12533. */
  12534. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  12535. /**
  12536. * Set a vec4 in the shader from a Color4.
  12537. * @param name Define the name of the uniform as defined in the shader
  12538. * @param value Define the value to give to the uniform
  12539. * @return the material itself allowing "fluent" like uniform updates
  12540. */
  12541. setColor4(name: string, value: Color4): ShaderMaterial;
  12542. /**
  12543. * Set a vec2 in the shader from a Vector2.
  12544. * @param name Define the name of the uniform as defined in the shader
  12545. * @param value Define the value to give to the uniform
  12546. * @return the material itself allowing "fluent" like uniform updates
  12547. */
  12548. setVector2(name: string, value: Vector2): ShaderMaterial;
  12549. /**
  12550. * Set a vec3 in the shader from a Vector3.
  12551. * @param name Define the name of the uniform as defined in the shader
  12552. * @param value Define the value to give to the uniform
  12553. * @return the material itself allowing "fluent" like uniform updates
  12554. */
  12555. setVector3(name: string, value: Vector3): ShaderMaterial;
  12556. /**
  12557. * Set a vec4 in the shader from a Vector4.
  12558. * @param name Define the name of the uniform as defined in the shader
  12559. * @param value Define the value to give to the uniform
  12560. * @return the material itself allowing "fluent" like uniform updates
  12561. */
  12562. setVector4(name: string, value: Vector4): ShaderMaterial;
  12563. /**
  12564. * Set a mat4 in the shader from a Matrix.
  12565. * @param name Define the name of the uniform as defined in the shader
  12566. * @param value Define the value to give to the uniform
  12567. * @return the material itself allowing "fluent" like uniform updates
  12568. */
  12569. setMatrix(name: string, value: Matrix): ShaderMaterial;
  12570. /**
  12571. * Set a mat3 in the shader from a Float32Array.
  12572. * @param name Define the name of the uniform as defined in the shader
  12573. * @param value Define the value to give to the uniform
  12574. * @return the material itself allowing "fluent" like uniform updates
  12575. */
  12576. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  12577. /**
  12578. * Set a mat2 in the shader from a Float32Array.
  12579. * @param name Define the name of the uniform as defined in the shader
  12580. * @param value Define the value to give to the uniform
  12581. * @return the material itself allowing "fluent" like uniform updates
  12582. */
  12583. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  12584. /**
  12585. * Set a vec2 array in the shader from a number array.
  12586. * @param name Define the name of the uniform as defined in the shader
  12587. * @param value Define the value to give to the uniform
  12588. * @return the material itself allowing "fluent" like uniform updates
  12589. */
  12590. setArray2(name: string, value: number[]): ShaderMaterial;
  12591. /**
  12592. * Set a vec3 array in the shader from a number array.
  12593. * @param name Define the name of the uniform as defined in the shader
  12594. * @param value Define the value to give to the uniform
  12595. * @return the material itself allowing "fluent" like uniform updates
  12596. */
  12597. setArray3(name: string, value: number[]): ShaderMaterial;
  12598. private _checkCache;
  12599. /**
  12600. * Specifies that the submesh is ready to be used
  12601. * @param mesh defines the mesh to check
  12602. * @param subMesh defines which submesh to check
  12603. * @param useInstances specifies that instances should be used
  12604. * @returns a boolean indicating that the submesh is ready or not
  12605. */
  12606. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  12607. /**
  12608. * Checks if the material is ready to render the requested mesh
  12609. * @param mesh Define the mesh to render
  12610. * @param useInstances Define whether or not the material is used with instances
  12611. * @returns true if ready, otherwise false
  12612. */
  12613. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  12614. /**
  12615. * Binds the world matrix to the material
  12616. * @param world defines the world transformation matrix
  12617. */
  12618. bindOnlyWorldMatrix(world: Matrix): void;
  12619. /**
  12620. * Binds the material to the mesh
  12621. * @param world defines the world transformation matrix
  12622. * @param mesh defines the mesh to bind the material to
  12623. */
  12624. bind(world: Matrix, mesh?: Mesh): void;
  12625. /**
  12626. * Gets the active textures from the material
  12627. * @returns an array of textures
  12628. */
  12629. getActiveTextures(): BaseTexture[];
  12630. /**
  12631. * Specifies if the material uses a texture
  12632. * @param texture defines the texture to check against the material
  12633. * @returns a boolean specifying if the material uses the texture
  12634. */
  12635. hasTexture(texture: BaseTexture): boolean;
  12636. /**
  12637. * Makes a duplicate of the material, and gives it a new name
  12638. * @param name defines the new name for the duplicated material
  12639. * @returns the cloned material
  12640. */
  12641. clone(name: string): ShaderMaterial;
  12642. /**
  12643. * Disposes the material
  12644. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  12645. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  12646. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  12647. */
  12648. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  12649. /**
  12650. * Serializes this material in a JSON representation
  12651. * @returns the serialized material object
  12652. */
  12653. serialize(): any;
  12654. /**
  12655. * Creates a shader material from parsed shader material data
  12656. * @param source defines the JSON represnetation of the material
  12657. * @param scene defines the hosting scene
  12658. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  12659. * @returns a new material
  12660. */
  12661. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  12662. }
  12663. }
  12664. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  12665. /** @hidden */
  12666. export var clipPlaneFragmentDeclaration: {
  12667. name: string;
  12668. shader: string;
  12669. };
  12670. }
  12671. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  12672. /** @hidden */
  12673. export var clipPlaneFragment: {
  12674. name: string;
  12675. shader: string;
  12676. };
  12677. }
  12678. declare module "babylonjs/Shaders/color.fragment" {
  12679. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  12680. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  12681. /** @hidden */
  12682. export var colorPixelShader: {
  12683. name: string;
  12684. shader: string;
  12685. };
  12686. }
  12687. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  12688. /** @hidden */
  12689. export var clipPlaneVertexDeclaration: {
  12690. name: string;
  12691. shader: string;
  12692. };
  12693. }
  12694. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  12695. /** @hidden */
  12696. export var clipPlaneVertex: {
  12697. name: string;
  12698. shader: string;
  12699. };
  12700. }
  12701. declare module "babylonjs/Shaders/color.vertex" {
  12702. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  12703. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  12704. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  12705. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  12706. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  12707. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  12708. /** @hidden */
  12709. export var colorVertexShader: {
  12710. name: string;
  12711. shader: string;
  12712. };
  12713. }
  12714. declare module "babylonjs/Meshes/linesMesh" {
  12715. import { Nullable } from "babylonjs/types";
  12716. import { Scene } from "babylonjs/scene";
  12717. import { Color3 } from "babylonjs/Maths/math";
  12718. import { Node } from "babylonjs/node";
  12719. import { SubMesh } from "babylonjs/Meshes/subMesh";
  12720. import { Mesh } from "babylonjs/Meshes/mesh";
  12721. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  12722. import { Effect } from "babylonjs/Materials/effect";
  12723. import { Material } from "babylonjs/Materials/material";
  12724. import "babylonjs/Shaders/color.fragment";
  12725. import "babylonjs/Shaders/color.vertex";
  12726. /**
  12727. * Line mesh
  12728. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  12729. */
  12730. export class LinesMesh extends Mesh {
  12731. /**
  12732. * If vertex color should be applied to the mesh
  12733. */
  12734. readonly useVertexColor?: boolean | undefined;
  12735. /**
  12736. * If vertex alpha should be applied to the mesh
  12737. */
  12738. readonly useVertexAlpha?: boolean | undefined;
  12739. /**
  12740. * Color of the line (Default: White)
  12741. */
  12742. color: Color3;
  12743. /**
  12744. * Alpha of the line (Default: 1)
  12745. */
  12746. alpha: number;
  12747. /**
  12748. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  12749. * This margin is expressed in world space coordinates, so its value may vary.
  12750. * Default value is 0.1
  12751. */
  12752. intersectionThreshold: number;
  12753. private _colorShader;
  12754. private color4;
  12755. /**
  12756. * Creates a new LinesMesh
  12757. * @param name defines the name
  12758. * @param scene defines the hosting scene
  12759. * @param parent defines the parent mesh if any
  12760. * @param source defines the optional source LinesMesh used to clone data from
  12761. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  12762. * When false, achieved by calling a clone(), also passing False.
  12763. * This will make creation of children, recursive.
  12764. * @param useVertexColor defines if this LinesMesh supports vertex color
  12765. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  12766. */
  12767. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  12768. /**
  12769. * If vertex color should be applied to the mesh
  12770. */
  12771. useVertexColor?: boolean | undefined,
  12772. /**
  12773. * If vertex alpha should be applied to the mesh
  12774. */
  12775. useVertexAlpha?: boolean | undefined);
  12776. private _addClipPlaneDefine;
  12777. private _removeClipPlaneDefine;
  12778. isReady(): boolean;
  12779. /**
  12780. * Returns the string "LineMesh"
  12781. */
  12782. getClassName(): string;
  12783. /**
  12784. * @hidden
  12785. */
  12786. /**
  12787. * @hidden
  12788. */
  12789. material: Material;
  12790. /**
  12791. * @hidden
  12792. */
  12793. readonly checkCollisions: boolean;
  12794. /** @hidden */
  12795. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  12796. /** @hidden */
  12797. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  12798. /**
  12799. * Disposes of the line mesh
  12800. * @param doNotRecurse If children should be disposed
  12801. */
  12802. dispose(doNotRecurse?: boolean): void;
  12803. /**
  12804. * Returns a new LineMesh object cloned from the current one.
  12805. */
  12806. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  12807. /**
  12808. * Creates a new InstancedLinesMesh object from the mesh model.
  12809. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  12810. * @param name defines the name of the new instance
  12811. * @returns a new InstancedLinesMesh
  12812. */
  12813. createInstance(name: string): InstancedLinesMesh;
  12814. }
  12815. /**
  12816. * Creates an instance based on a source LinesMesh
  12817. */
  12818. export class InstancedLinesMesh extends InstancedMesh {
  12819. /**
  12820. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  12821. * This margin is expressed in world space coordinates, so its value may vary.
  12822. * Initilized with the intersectionThreshold value of the source LinesMesh
  12823. */
  12824. intersectionThreshold: number;
  12825. constructor(name: string, source: LinesMesh);
  12826. /**
  12827. * Returns the string "InstancedLinesMesh".
  12828. */
  12829. getClassName(): string;
  12830. }
  12831. }
  12832. declare module "babylonjs/Meshes/groundMesh" {
  12833. import { Scene } from "babylonjs/scene";
  12834. import { Vector3 } from "babylonjs/Maths/math";
  12835. import { Mesh } from "babylonjs/Meshes/mesh";
  12836. /**
  12837. * Mesh representing the gorund
  12838. */
  12839. export class GroundMesh extends Mesh {
  12840. /** If octree should be generated */
  12841. generateOctree: boolean;
  12842. private _heightQuads;
  12843. /** @hidden */
  12844. _subdivisionsX: number;
  12845. /** @hidden */
  12846. _subdivisionsY: number;
  12847. /** @hidden */
  12848. _width: number;
  12849. /** @hidden */
  12850. _height: number;
  12851. /** @hidden */
  12852. _minX: number;
  12853. /** @hidden */
  12854. _maxX: number;
  12855. /** @hidden */
  12856. _minZ: number;
  12857. /** @hidden */
  12858. _maxZ: number;
  12859. constructor(name: string, scene: Scene);
  12860. /**
  12861. * "GroundMesh"
  12862. * @returns "GroundMesh"
  12863. */
  12864. getClassName(): string;
  12865. /**
  12866. * The minimum of x and y subdivisions
  12867. */
  12868. readonly subdivisions: number;
  12869. /**
  12870. * X subdivisions
  12871. */
  12872. readonly subdivisionsX: number;
  12873. /**
  12874. * Y subdivisions
  12875. */
  12876. readonly subdivisionsY: number;
  12877. /**
  12878. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  12879. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  12880. * @param chunksCount the number of subdivisions for x and y
  12881. * @param octreeBlocksSize (Default: 32)
  12882. */
  12883. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  12884. /**
  12885. * Returns a height (y) value in the Worl system :
  12886. * the ground altitude at the coordinates (x, z) expressed in the World system.
  12887. * @param x x coordinate
  12888. * @param z z coordinate
  12889. * @returns the ground y position if (x, z) are outside the ground surface.
  12890. */
  12891. getHeightAtCoordinates(x: number, z: number): number;
  12892. /**
  12893. * Returns a normalized vector (Vector3) orthogonal to the ground
  12894. * at the ground coordinates (x, z) expressed in the World system.
  12895. * @param x x coordinate
  12896. * @param z z coordinate
  12897. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  12898. */
  12899. getNormalAtCoordinates(x: number, z: number): Vector3;
  12900. /**
  12901. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  12902. * at the ground coordinates (x, z) expressed in the World system.
  12903. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  12904. * @param x x coordinate
  12905. * @param z z coordinate
  12906. * @param ref vector to store the result
  12907. * @returns the GroundMesh.
  12908. */
  12909. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  12910. /**
  12911. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  12912. * if the ground has been updated.
  12913. * This can be used in the render loop.
  12914. * @returns the GroundMesh.
  12915. */
  12916. updateCoordinateHeights(): GroundMesh;
  12917. private _getFacetAt;
  12918. private _initHeightQuads;
  12919. private _computeHeightQuads;
  12920. /**
  12921. * Serializes this ground mesh
  12922. * @param serializationObject object to write serialization to
  12923. */
  12924. serialize(serializationObject: any): void;
  12925. /**
  12926. * Parses a serialized ground mesh
  12927. * @param parsedMesh the serialized mesh
  12928. * @param scene the scene to create the ground mesh in
  12929. * @returns the created ground mesh
  12930. */
  12931. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  12932. }
  12933. }
  12934. declare module "babylonjs/Physics/physicsJoint" {
  12935. import { Vector3 } from "babylonjs/Maths/math";
  12936. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  12937. /**
  12938. * Interface for Physics-Joint data
  12939. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  12940. */
  12941. export interface PhysicsJointData {
  12942. /**
  12943. * The main pivot of the joint
  12944. */
  12945. mainPivot?: Vector3;
  12946. /**
  12947. * The connected pivot of the joint
  12948. */
  12949. connectedPivot?: Vector3;
  12950. /**
  12951. * The main axis of the joint
  12952. */
  12953. mainAxis?: Vector3;
  12954. /**
  12955. * The connected axis of the joint
  12956. */
  12957. connectedAxis?: Vector3;
  12958. /**
  12959. * The collision of the joint
  12960. */
  12961. collision?: boolean;
  12962. /**
  12963. * Native Oimo/Cannon/Energy data
  12964. */
  12965. nativeParams?: any;
  12966. }
  12967. /**
  12968. * This is a holder class for the physics joint created by the physics plugin
  12969. * It holds a set of functions to control the underlying joint
  12970. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  12971. */
  12972. export class PhysicsJoint {
  12973. /**
  12974. * The type of the physics joint
  12975. */
  12976. type: number;
  12977. /**
  12978. * The data for the physics joint
  12979. */
  12980. jointData: PhysicsJointData;
  12981. private _physicsJoint;
  12982. protected _physicsPlugin: IPhysicsEnginePlugin;
  12983. /**
  12984. * Initializes the physics joint
  12985. * @param type The type of the physics joint
  12986. * @param jointData The data for the physics joint
  12987. */
  12988. constructor(
  12989. /**
  12990. * The type of the physics joint
  12991. */
  12992. type: number,
  12993. /**
  12994. * The data for the physics joint
  12995. */
  12996. jointData: PhysicsJointData);
  12997. /**
  12998. * Gets the physics joint
  12999. */
  13000. /**
  13001. * Sets the physics joint
  13002. */
  13003. physicsJoint: any;
  13004. /**
  13005. * Sets the physics plugin
  13006. */
  13007. physicsPlugin: IPhysicsEnginePlugin;
  13008. /**
  13009. * Execute a function that is physics-plugin specific.
  13010. * @param {Function} func the function that will be executed.
  13011. * It accepts two parameters: the physics world and the physics joint
  13012. */
  13013. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  13014. /**
  13015. * Distance-Joint type
  13016. */
  13017. static DistanceJoint: number;
  13018. /**
  13019. * Hinge-Joint type
  13020. */
  13021. static HingeJoint: number;
  13022. /**
  13023. * Ball-and-Socket joint type
  13024. */
  13025. static BallAndSocketJoint: number;
  13026. /**
  13027. * Wheel-Joint type
  13028. */
  13029. static WheelJoint: number;
  13030. /**
  13031. * Slider-Joint type
  13032. */
  13033. static SliderJoint: number;
  13034. /**
  13035. * Prismatic-Joint type
  13036. */
  13037. static PrismaticJoint: number;
  13038. /**
  13039. * Universal-Joint type
  13040. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  13041. */
  13042. static UniversalJoint: number;
  13043. /**
  13044. * Hinge-Joint 2 type
  13045. */
  13046. static Hinge2Joint: number;
  13047. /**
  13048. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  13049. */
  13050. static PointToPointJoint: number;
  13051. /**
  13052. * Spring-Joint type
  13053. */
  13054. static SpringJoint: number;
  13055. /**
  13056. * Lock-Joint type
  13057. */
  13058. static LockJoint: number;
  13059. }
  13060. /**
  13061. * A class representing a physics distance joint
  13062. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13063. */
  13064. export class DistanceJoint extends PhysicsJoint {
  13065. /**
  13066. *
  13067. * @param jointData The data for the Distance-Joint
  13068. */
  13069. constructor(jointData: DistanceJointData);
  13070. /**
  13071. * Update the predefined distance.
  13072. * @param maxDistance The maximum preferred distance
  13073. * @param minDistance The minimum preferred distance
  13074. */
  13075. updateDistance(maxDistance: number, minDistance?: number): void;
  13076. }
  13077. /**
  13078. * Represents a Motor-Enabled Joint
  13079. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13080. */
  13081. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  13082. /**
  13083. * Initializes the Motor-Enabled Joint
  13084. * @param type The type of the joint
  13085. * @param jointData The physica joint data for the joint
  13086. */
  13087. constructor(type: number, jointData: PhysicsJointData);
  13088. /**
  13089. * Set the motor values.
  13090. * Attention, this function is plugin specific. Engines won't react 100% the same.
  13091. * @param force the force to apply
  13092. * @param maxForce max force for this motor.
  13093. */
  13094. setMotor(force?: number, maxForce?: number): void;
  13095. /**
  13096. * Set the motor's limits.
  13097. * Attention, this function is plugin specific. Engines won't react 100% the same.
  13098. * @param upperLimit The upper limit of the motor
  13099. * @param lowerLimit The lower limit of the motor
  13100. */
  13101. setLimit(upperLimit: number, lowerLimit?: number): void;
  13102. }
  13103. /**
  13104. * This class represents a single physics Hinge-Joint
  13105. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13106. */
  13107. export class HingeJoint extends MotorEnabledJoint {
  13108. /**
  13109. * Initializes the Hinge-Joint
  13110. * @param jointData The joint data for the Hinge-Joint
  13111. */
  13112. constructor(jointData: PhysicsJointData);
  13113. /**
  13114. * Set the motor values.
  13115. * Attention, this function is plugin specific. Engines won't react 100% the same.
  13116. * @param {number} force the force to apply
  13117. * @param {number} maxForce max force for this motor.
  13118. */
  13119. setMotor(force?: number, maxForce?: number): void;
  13120. /**
  13121. * Set the motor's limits.
  13122. * Attention, this function is plugin specific. Engines won't react 100% the same.
  13123. * @param upperLimit The upper limit of the motor
  13124. * @param lowerLimit The lower limit of the motor
  13125. */
  13126. setLimit(upperLimit: number, lowerLimit?: number): void;
  13127. }
  13128. /**
  13129. * This class represents a dual hinge physics joint (same as wheel joint)
  13130. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13131. */
  13132. export class Hinge2Joint extends MotorEnabledJoint {
  13133. /**
  13134. * Initializes the Hinge2-Joint
  13135. * @param jointData The joint data for the Hinge2-Joint
  13136. */
  13137. constructor(jointData: PhysicsJointData);
  13138. /**
  13139. * Set the motor values.
  13140. * Attention, this function is plugin specific. Engines won't react 100% the same.
  13141. * @param {number} targetSpeed the speed the motor is to reach
  13142. * @param {number} maxForce max force for this motor.
  13143. * @param {motorIndex} the motor's index, 0 or 1.
  13144. */
  13145. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  13146. /**
  13147. * Set the motor limits.
  13148. * Attention, this function is plugin specific. Engines won't react 100% the same.
  13149. * @param {number} upperLimit the upper limit
  13150. * @param {number} lowerLimit lower limit
  13151. * @param {motorIndex} the motor's index, 0 or 1.
  13152. */
  13153. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  13154. }
  13155. /**
  13156. * Interface for a motor enabled joint
  13157. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13158. */
  13159. export interface IMotorEnabledJoint {
  13160. /**
  13161. * Physics joint
  13162. */
  13163. physicsJoint: any;
  13164. /**
  13165. * Sets the motor of the motor-enabled joint
  13166. * @param force The force of the motor
  13167. * @param maxForce The maximum force of the motor
  13168. * @param motorIndex The index of the motor
  13169. */
  13170. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  13171. /**
  13172. * Sets the limit of the motor
  13173. * @param upperLimit The upper limit of the motor
  13174. * @param lowerLimit The lower limit of the motor
  13175. * @param motorIndex The index of the motor
  13176. */
  13177. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  13178. }
  13179. /**
  13180. * Joint data for a Distance-Joint
  13181. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13182. */
  13183. export interface DistanceJointData extends PhysicsJointData {
  13184. /**
  13185. * Max distance the 2 joint objects can be apart
  13186. */
  13187. maxDistance: number;
  13188. }
  13189. /**
  13190. * Joint data from a spring joint
  13191. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13192. */
  13193. export interface SpringJointData extends PhysicsJointData {
  13194. /**
  13195. * Length of the spring
  13196. */
  13197. length: number;
  13198. /**
  13199. * Stiffness of the spring
  13200. */
  13201. stiffness: number;
  13202. /**
  13203. * Damping of the spring
  13204. */
  13205. damping: number;
  13206. /** this callback will be called when applying the force to the impostors. */
  13207. forceApplicationCallback: () => void;
  13208. }
  13209. }
  13210. declare module "babylonjs/Physics/physicsRaycastResult" {
  13211. import { Vector3 } from "babylonjs/Maths/math";
  13212. /**
  13213. * Holds the data for the raycast result
  13214. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13215. */
  13216. export class PhysicsRaycastResult {
  13217. private _hasHit;
  13218. private _hitDistance;
  13219. private _hitNormalWorld;
  13220. private _hitPointWorld;
  13221. private _rayFromWorld;
  13222. private _rayToWorld;
  13223. /**
  13224. * Gets if there was a hit
  13225. */
  13226. readonly hasHit: boolean;
  13227. /**
  13228. * Gets the distance from the hit
  13229. */
  13230. readonly hitDistance: number;
  13231. /**
  13232. * Gets the hit normal/direction in the world
  13233. */
  13234. readonly hitNormalWorld: Vector3;
  13235. /**
  13236. * Gets the hit point in the world
  13237. */
  13238. readonly hitPointWorld: Vector3;
  13239. /**
  13240. * Gets the ray "start point" of the ray in the world
  13241. */
  13242. readonly rayFromWorld: Vector3;
  13243. /**
  13244. * Gets the ray "end point" of the ray in the world
  13245. */
  13246. readonly rayToWorld: Vector3;
  13247. /**
  13248. * Sets the hit data (normal & point in world space)
  13249. * @param hitNormalWorld defines the normal in world space
  13250. * @param hitPointWorld defines the point in world space
  13251. */
  13252. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  13253. /**
  13254. * Sets the distance from the start point to the hit point
  13255. * @param distance
  13256. */
  13257. setHitDistance(distance: number): void;
  13258. /**
  13259. * Calculates the distance manually
  13260. */
  13261. calculateHitDistance(): void;
  13262. /**
  13263. * Resets all the values to default
  13264. * @param from The from point on world space
  13265. * @param to The to point on world space
  13266. */
  13267. reset(from?: Vector3, to?: Vector3): void;
  13268. }
  13269. /**
  13270. * Interface for the size containing width and height
  13271. */
  13272. interface IXYZ {
  13273. /**
  13274. * X
  13275. */
  13276. x: number;
  13277. /**
  13278. * Y
  13279. */
  13280. y: number;
  13281. /**
  13282. * Z
  13283. */
  13284. z: number;
  13285. }
  13286. }
  13287. declare module "babylonjs/Physics/IPhysicsEngine" {
  13288. import { Nullable } from "babylonjs/types";
  13289. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  13290. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13291. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  13292. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  13293. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  13294. /**
  13295. * Interface used to describe a physics joint
  13296. */
  13297. export interface PhysicsImpostorJoint {
  13298. /** Defines the main impostor to which the joint is linked */
  13299. mainImpostor: PhysicsImpostor;
  13300. /** Defines the impostor that is connected to the main impostor using this joint */
  13301. connectedImpostor: PhysicsImpostor;
  13302. /** Defines the joint itself */
  13303. joint: PhysicsJoint;
  13304. }
  13305. /** @hidden */
  13306. export interface IPhysicsEnginePlugin {
  13307. world: any;
  13308. name: string;
  13309. setGravity(gravity: Vector3): void;
  13310. setTimeStep(timeStep: number): void;
  13311. getTimeStep(): number;
  13312. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  13313. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  13314. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  13315. generatePhysicsBody(impostor: PhysicsImpostor): void;
  13316. removePhysicsBody(impostor: PhysicsImpostor): void;
  13317. generateJoint(joint: PhysicsImpostorJoint): void;
  13318. removeJoint(joint: PhysicsImpostorJoint): void;
  13319. isSupported(): boolean;
  13320. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  13321. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  13322. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  13323. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  13324. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  13325. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  13326. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  13327. getBodyMass(impostor: PhysicsImpostor): number;
  13328. getBodyFriction(impostor: PhysicsImpostor): number;
  13329. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  13330. getBodyRestitution(impostor: PhysicsImpostor): number;
  13331. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  13332. getBodyPressure?(impostor: PhysicsImpostor): number;
  13333. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  13334. getBodyStiffness?(impostor: PhysicsImpostor): number;
  13335. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  13336. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  13337. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  13338. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  13339. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  13340. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  13341. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  13342. sleepBody(impostor: PhysicsImpostor): void;
  13343. wakeUpBody(impostor: PhysicsImpostor): void;
  13344. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  13345. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  13346. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  13347. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  13348. getRadius(impostor: PhysicsImpostor): number;
  13349. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  13350. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  13351. dispose(): void;
  13352. }
  13353. /**
  13354. * Interface used to define a physics engine
  13355. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  13356. */
  13357. export interface IPhysicsEngine {
  13358. /**
  13359. * Gets the gravity vector used by the simulation
  13360. */
  13361. gravity: Vector3;
  13362. /**
  13363. * Sets the gravity vector used by the simulation
  13364. * @param gravity defines the gravity vector to use
  13365. */
  13366. setGravity(gravity: Vector3): void;
  13367. /**
  13368. * Set the time step of the physics engine.
  13369. * Default is 1/60.
  13370. * To slow it down, enter 1/600 for example.
  13371. * To speed it up, 1/30
  13372. * @param newTimeStep the new timestep to apply to this world.
  13373. */
  13374. setTimeStep(newTimeStep: number): void;
  13375. /**
  13376. * Get the time step of the physics engine.
  13377. * @returns the current time step
  13378. */
  13379. getTimeStep(): number;
  13380. /**
  13381. * Release all resources
  13382. */
  13383. dispose(): void;
  13384. /**
  13385. * Gets the name of the current physics plugin
  13386. * @returns the name of the plugin
  13387. */
  13388. getPhysicsPluginName(): string;
  13389. /**
  13390. * Adding a new impostor for the impostor tracking.
  13391. * This will be done by the impostor itself.
  13392. * @param impostor the impostor to add
  13393. */
  13394. addImpostor(impostor: PhysicsImpostor): void;
  13395. /**
  13396. * Remove an impostor from the engine.
  13397. * This impostor and its mesh will not longer be updated by the physics engine.
  13398. * @param impostor the impostor to remove
  13399. */
  13400. removeImpostor(impostor: PhysicsImpostor): void;
  13401. /**
  13402. * Add a joint to the physics engine
  13403. * @param mainImpostor defines the main impostor to which the joint is added.
  13404. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  13405. * @param joint defines the joint that will connect both impostors.
  13406. */
  13407. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  13408. /**
  13409. * Removes a joint from the simulation
  13410. * @param mainImpostor defines the impostor used with the joint
  13411. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  13412. * @param joint defines the joint to remove
  13413. */
  13414. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  13415. /**
  13416. * Gets the current plugin used to run the simulation
  13417. * @returns current plugin
  13418. */
  13419. getPhysicsPlugin(): IPhysicsEnginePlugin;
  13420. /**
  13421. * Gets the list of physic impostors
  13422. * @returns an array of PhysicsImpostor
  13423. */
  13424. getImpostors(): Array<PhysicsImpostor>;
  13425. /**
  13426. * Gets the impostor for a physics enabled object
  13427. * @param object defines the object impersonated by the impostor
  13428. * @returns the PhysicsImpostor or null if not found
  13429. */
  13430. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  13431. /**
  13432. * Gets the impostor for a physics body object
  13433. * @param body defines physics body used by the impostor
  13434. * @returns the PhysicsImpostor or null if not found
  13435. */
  13436. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  13437. /**
  13438. * Does a raycast in the physics world
  13439. * @param from when should the ray start?
  13440. * @param to when should the ray end?
  13441. * @returns PhysicsRaycastResult
  13442. */
  13443. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  13444. /**
  13445. * Called by the scene. No need to call it.
  13446. * @param delta defines the timespam between frames
  13447. */
  13448. _step(delta: number): void;
  13449. }
  13450. }
  13451. declare module "babylonjs/Physics/physicsImpostor" {
  13452. import { Nullable, IndicesArray } from "babylonjs/types";
  13453. import { Vector3, Matrix, Quaternion, Space } from "babylonjs/Maths/math";
  13454. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13455. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13456. import { Scene } from "babylonjs/scene";
  13457. import { Bone } from "babylonjs/Bones/bone";
  13458. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  13459. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  13460. /**
  13461. * The interface for the physics imposter parameters
  13462. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13463. */
  13464. export interface PhysicsImpostorParameters {
  13465. /**
  13466. * The mass of the physics imposter
  13467. */
  13468. mass: number;
  13469. /**
  13470. * The friction of the physics imposter
  13471. */
  13472. friction?: number;
  13473. /**
  13474. * The coefficient of restitution of the physics imposter
  13475. */
  13476. restitution?: number;
  13477. /**
  13478. * The native options of the physics imposter
  13479. */
  13480. nativeOptions?: any;
  13481. /**
  13482. * Specifies if the parent should be ignored
  13483. */
  13484. ignoreParent?: boolean;
  13485. /**
  13486. * Specifies if bi-directional transformations should be disabled
  13487. */
  13488. disableBidirectionalTransformation?: boolean;
  13489. /**
  13490. * The pressure inside the physics imposter, soft object only
  13491. */
  13492. pressure?: number;
  13493. /**
  13494. * The stiffness the physics imposter, soft object only
  13495. */
  13496. stiffness?: number;
  13497. /**
  13498. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  13499. */
  13500. velocityIterations?: number;
  13501. /**
  13502. * The number of iterations used in maintaining consistent vertex positions, soft object only
  13503. */
  13504. positionIterations?: number;
  13505. /**
  13506. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  13507. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  13508. * Add to fix multiple points
  13509. */
  13510. fixedPoints?: number;
  13511. /**
  13512. * The collision margin around a soft object
  13513. */
  13514. margin?: number;
  13515. /**
  13516. * The collision margin around a soft object
  13517. */
  13518. damping?: number;
  13519. /**
  13520. * The path for a rope based on an extrusion
  13521. */
  13522. path?: any;
  13523. /**
  13524. * The shape of an extrusion used for a rope based on an extrusion
  13525. */
  13526. shape?: any;
  13527. }
  13528. /**
  13529. * Interface for a physics-enabled object
  13530. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13531. */
  13532. export interface IPhysicsEnabledObject {
  13533. /**
  13534. * The position of the physics-enabled object
  13535. */
  13536. position: Vector3;
  13537. /**
  13538. * The rotation of the physics-enabled object
  13539. */
  13540. rotationQuaternion: Nullable<Quaternion>;
  13541. /**
  13542. * The scale of the physics-enabled object
  13543. */
  13544. scaling: Vector3;
  13545. /**
  13546. * The rotation of the physics-enabled object
  13547. */
  13548. rotation?: Vector3;
  13549. /**
  13550. * The parent of the physics-enabled object
  13551. */
  13552. parent?: any;
  13553. /**
  13554. * The bounding info of the physics-enabled object
  13555. * @returns The bounding info of the physics-enabled object
  13556. */
  13557. getBoundingInfo(): BoundingInfo;
  13558. /**
  13559. * Computes the world matrix
  13560. * @param force Specifies if the world matrix should be computed by force
  13561. * @returns A world matrix
  13562. */
  13563. computeWorldMatrix(force: boolean): Matrix;
  13564. /**
  13565. * Gets the world matrix
  13566. * @returns A world matrix
  13567. */
  13568. getWorldMatrix?(): Matrix;
  13569. /**
  13570. * Gets the child meshes
  13571. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  13572. * @returns An array of abstract meshes
  13573. */
  13574. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  13575. /**
  13576. * Gets the vertex data
  13577. * @param kind The type of vertex data
  13578. * @returns A nullable array of numbers, or a float32 array
  13579. */
  13580. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  13581. /**
  13582. * Gets the indices from the mesh
  13583. * @returns A nullable array of index arrays
  13584. */
  13585. getIndices?(): Nullable<IndicesArray>;
  13586. /**
  13587. * Gets the scene from the mesh
  13588. * @returns the indices array or null
  13589. */
  13590. getScene?(): Scene;
  13591. /**
  13592. * Gets the absolute position from the mesh
  13593. * @returns the absolute position
  13594. */
  13595. getAbsolutePosition(): Vector3;
  13596. /**
  13597. * Gets the absolute pivot point from the mesh
  13598. * @returns the absolute pivot point
  13599. */
  13600. getAbsolutePivotPoint(): Vector3;
  13601. /**
  13602. * Rotates the mesh
  13603. * @param axis The axis of rotation
  13604. * @param amount The amount of rotation
  13605. * @param space The space of the rotation
  13606. * @returns The rotation transform node
  13607. */
  13608. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  13609. /**
  13610. * Translates the mesh
  13611. * @param axis The axis of translation
  13612. * @param distance The distance of translation
  13613. * @param space The space of the translation
  13614. * @returns The transform node
  13615. */
  13616. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  13617. /**
  13618. * Sets the absolute position of the mesh
  13619. * @param absolutePosition The absolute position of the mesh
  13620. * @returns The transform node
  13621. */
  13622. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13623. /**
  13624. * Gets the class name of the mesh
  13625. * @returns The class name
  13626. */
  13627. getClassName(): string;
  13628. }
  13629. /**
  13630. * Represents a physics imposter
  13631. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13632. */
  13633. export class PhysicsImpostor {
  13634. /**
  13635. * The physics-enabled object used as the physics imposter
  13636. */
  13637. object: IPhysicsEnabledObject;
  13638. /**
  13639. * The type of the physics imposter
  13640. */
  13641. type: number;
  13642. private _options;
  13643. private _scene?;
  13644. /**
  13645. * The default object size of the imposter
  13646. */
  13647. static DEFAULT_OBJECT_SIZE: Vector3;
  13648. /**
  13649. * The identity quaternion of the imposter
  13650. */
  13651. static IDENTITY_QUATERNION: Quaternion;
  13652. /** @hidden */
  13653. _pluginData: any;
  13654. private _physicsEngine;
  13655. private _physicsBody;
  13656. private _bodyUpdateRequired;
  13657. private _onBeforePhysicsStepCallbacks;
  13658. private _onAfterPhysicsStepCallbacks;
  13659. /** @hidden */
  13660. _onPhysicsCollideCallbacks: Array<{
  13661. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  13662. otherImpostors: Array<PhysicsImpostor>;
  13663. }>;
  13664. private _deltaPosition;
  13665. private _deltaRotation;
  13666. private _deltaRotationConjugated;
  13667. /** @hidden */
  13668. _isFromLine: boolean;
  13669. private _parent;
  13670. private _isDisposed;
  13671. private static _tmpVecs;
  13672. private static _tmpQuat;
  13673. /**
  13674. * Specifies if the physics imposter is disposed
  13675. */
  13676. readonly isDisposed: boolean;
  13677. /**
  13678. * Gets the mass of the physics imposter
  13679. */
  13680. mass: number;
  13681. /**
  13682. * Gets the coefficient of friction
  13683. */
  13684. /**
  13685. * Sets the coefficient of friction
  13686. */
  13687. friction: number;
  13688. /**
  13689. * Gets the coefficient of restitution
  13690. */
  13691. /**
  13692. * Sets the coefficient of restitution
  13693. */
  13694. restitution: number;
  13695. /**
  13696. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  13697. */
  13698. /**
  13699. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  13700. */
  13701. pressure: number;
  13702. /**
  13703. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  13704. */
  13705. /**
  13706. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  13707. */
  13708. stiffness: number;
  13709. /**
  13710. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  13711. */
  13712. /**
  13713. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  13714. */
  13715. velocityIterations: number;
  13716. /**
  13717. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  13718. */
  13719. /**
  13720. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  13721. */
  13722. positionIterations: number;
  13723. /**
  13724. * The unique id of the physics imposter
  13725. * set by the physics engine when adding this impostor to the array
  13726. */
  13727. uniqueId: number;
  13728. /**
  13729. * @hidden
  13730. */
  13731. soft: boolean;
  13732. /**
  13733. * @hidden
  13734. */
  13735. segments: number;
  13736. private _joints;
  13737. /**
  13738. * Initializes the physics imposter
  13739. * @param object The physics-enabled object used as the physics imposter
  13740. * @param type The type of the physics imposter
  13741. * @param _options The options for the physics imposter
  13742. * @param _scene The Babylon scene
  13743. */
  13744. constructor(
  13745. /**
  13746. * The physics-enabled object used as the physics imposter
  13747. */
  13748. object: IPhysicsEnabledObject,
  13749. /**
  13750. * The type of the physics imposter
  13751. */
  13752. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  13753. /**
  13754. * This function will completly initialize this impostor.
  13755. * It will create a new body - but only if this mesh has no parent.
  13756. * If it has, this impostor will not be used other than to define the impostor
  13757. * of the child mesh.
  13758. * @hidden
  13759. */
  13760. _init(): void;
  13761. private _getPhysicsParent;
  13762. /**
  13763. * Should a new body be generated.
  13764. * @returns boolean specifying if body initialization is required
  13765. */
  13766. isBodyInitRequired(): boolean;
  13767. /**
  13768. * Sets the updated scaling
  13769. * @param updated Specifies if the scaling is updated
  13770. */
  13771. setScalingUpdated(): void;
  13772. /**
  13773. * Force a regeneration of this or the parent's impostor's body.
  13774. * Use under cautious - This will remove all joints already implemented.
  13775. */
  13776. forceUpdate(): void;
  13777. /**
  13778. * Gets the body that holds this impostor. Either its own, or its parent.
  13779. */
  13780. /**
  13781. * Set the physics body. Used mainly by the physics engine/plugin
  13782. */
  13783. physicsBody: any;
  13784. /**
  13785. * Get the parent of the physics imposter
  13786. * @returns Physics imposter or null
  13787. */
  13788. /**
  13789. * Sets the parent of the physics imposter
  13790. */
  13791. parent: Nullable<PhysicsImpostor>;
  13792. /**
  13793. * Resets the update flags
  13794. */
  13795. resetUpdateFlags(): void;
  13796. /**
  13797. * Gets the object extend size
  13798. * @returns the object extend size
  13799. */
  13800. getObjectExtendSize(): Vector3;
  13801. /**
  13802. * Gets the object center
  13803. * @returns The object center
  13804. */
  13805. getObjectCenter(): Vector3;
  13806. /**
  13807. * Get a specific parametes from the options parameter
  13808. * @param paramName The object parameter name
  13809. * @returns The object parameter
  13810. */
  13811. getParam(paramName: string): any;
  13812. /**
  13813. * Sets a specific parameter in the options given to the physics plugin
  13814. * @param paramName The parameter name
  13815. * @param value The value of the parameter
  13816. */
  13817. setParam(paramName: string, value: number): void;
  13818. /**
  13819. * Specifically change the body's mass option. Won't recreate the physics body object
  13820. * @param mass The mass of the physics imposter
  13821. */
  13822. setMass(mass: number): void;
  13823. /**
  13824. * Gets the linear velocity
  13825. * @returns linear velocity or null
  13826. */
  13827. getLinearVelocity(): Nullable<Vector3>;
  13828. /**
  13829. * Sets the linear velocity
  13830. * @param velocity linear velocity or null
  13831. */
  13832. setLinearVelocity(velocity: Nullable<Vector3>): void;
  13833. /**
  13834. * Gets the angular velocity
  13835. * @returns angular velocity or null
  13836. */
  13837. getAngularVelocity(): Nullable<Vector3>;
  13838. /**
  13839. * Sets the angular velocity
  13840. * @param velocity The velocity or null
  13841. */
  13842. setAngularVelocity(velocity: Nullable<Vector3>): void;
  13843. /**
  13844. * Execute a function with the physics plugin native code
  13845. * Provide a function the will have two variables - the world object and the physics body object
  13846. * @param func The function to execute with the physics plugin native code
  13847. */
  13848. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  13849. /**
  13850. * Register a function that will be executed before the physics world is stepping forward
  13851. * @param func The function to execute before the physics world is stepped forward
  13852. */
  13853. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13854. /**
  13855. * Unregister a function that will be executed before the physics world is stepping forward
  13856. * @param func The function to execute before the physics world is stepped forward
  13857. */
  13858. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13859. /**
  13860. * Register a function that will be executed after the physics step
  13861. * @param func The function to execute after physics step
  13862. */
  13863. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13864. /**
  13865. * Unregisters a function that will be executed after the physics step
  13866. * @param func The function to execute after physics step
  13867. */
  13868. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13869. /**
  13870. * register a function that will be executed when this impostor collides against a different body
  13871. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  13872. * @param func Callback that is executed on collision
  13873. */
  13874. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  13875. /**
  13876. * Unregisters the physics imposter on contact
  13877. * @param collideAgainst The physics object to collide against
  13878. * @param func Callback to execute on collision
  13879. */
  13880. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  13881. private _tmpQuat;
  13882. private _tmpQuat2;
  13883. /**
  13884. * Get the parent rotation
  13885. * @returns The parent rotation
  13886. */
  13887. getParentsRotation(): Quaternion;
  13888. /**
  13889. * this function is executed by the physics engine.
  13890. */
  13891. beforeStep: () => void;
  13892. /**
  13893. * this function is executed by the physics engine
  13894. */
  13895. afterStep: () => void;
  13896. /**
  13897. * Legacy collision detection event support
  13898. */
  13899. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  13900. /**
  13901. * event and body object due to cannon's event-based architecture.
  13902. */
  13903. onCollide: (e: {
  13904. body: any;
  13905. }) => void;
  13906. /**
  13907. * Apply a force
  13908. * @param force The force to apply
  13909. * @param contactPoint The contact point for the force
  13910. * @returns The physics imposter
  13911. */
  13912. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  13913. /**
  13914. * Apply an impulse
  13915. * @param force The impulse force
  13916. * @param contactPoint The contact point for the impulse force
  13917. * @returns The physics imposter
  13918. */
  13919. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  13920. /**
  13921. * A help function to create a joint
  13922. * @param otherImpostor A physics imposter used to create a joint
  13923. * @param jointType The type of joint
  13924. * @param jointData The data for the joint
  13925. * @returns The physics imposter
  13926. */
  13927. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  13928. /**
  13929. * Add a joint to this impostor with a different impostor
  13930. * @param otherImpostor A physics imposter used to add a joint
  13931. * @param joint The joint to add
  13932. * @returns The physics imposter
  13933. */
  13934. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  13935. /**
  13936. * Add an anchor to a cloth impostor
  13937. * @param otherImpostor rigid impostor to anchor to
  13938. * @param width ratio across width from 0 to 1
  13939. * @param height ratio up height from 0 to 1
  13940. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  13941. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  13942. * @returns impostor the soft imposter
  13943. */
  13944. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  13945. /**
  13946. * Add a hook to a rope impostor
  13947. * @param otherImpostor rigid impostor to anchor to
  13948. * @param length ratio across rope from 0 to 1
  13949. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  13950. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  13951. * @returns impostor the rope imposter
  13952. */
  13953. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  13954. /**
  13955. * Will keep this body still, in a sleep mode.
  13956. * @returns the physics imposter
  13957. */
  13958. sleep(): PhysicsImpostor;
  13959. /**
  13960. * Wake the body up.
  13961. * @returns The physics imposter
  13962. */
  13963. wakeUp(): PhysicsImpostor;
  13964. /**
  13965. * Clones the physics imposter
  13966. * @param newObject The physics imposter clones to this physics-enabled object
  13967. * @returns A nullable physics imposter
  13968. */
  13969. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  13970. /**
  13971. * Disposes the physics imposter
  13972. */
  13973. dispose(): void;
  13974. /**
  13975. * Sets the delta position
  13976. * @param position The delta position amount
  13977. */
  13978. setDeltaPosition(position: Vector3): void;
  13979. /**
  13980. * Sets the delta rotation
  13981. * @param rotation The delta rotation amount
  13982. */
  13983. setDeltaRotation(rotation: Quaternion): void;
  13984. /**
  13985. * Gets the box size of the physics imposter and stores the result in the input parameter
  13986. * @param result Stores the box size
  13987. * @returns The physics imposter
  13988. */
  13989. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  13990. /**
  13991. * Gets the radius of the physics imposter
  13992. * @returns Radius of the physics imposter
  13993. */
  13994. getRadius(): number;
  13995. /**
  13996. * Sync a bone with this impostor
  13997. * @param bone The bone to sync to the impostor.
  13998. * @param boneMesh The mesh that the bone is influencing.
  13999. * @param jointPivot The pivot of the joint / bone in local space.
  14000. * @param distToJoint Optional distance from the impostor to the joint.
  14001. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  14002. */
  14003. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  14004. /**
  14005. * Sync impostor to a bone
  14006. * @param bone The bone that the impostor will be synced to.
  14007. * @param boneMesh The mesh that the bone is influencing.
  14008. * @param jointPivot The pivot of the joint / bone in local space.
  14009. * @param distToJoint Optional distance from the impostor to the joint.
  14010. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  14011. * @param boneAxis Optional vector3 axis the bone is aligned with
  14012. */
  14013. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  14014. /**
  14015. * No-Imposter type
  14016. */
  14017. static NoImpostor: number;
  14018. /**
  14019. * Sphere-Imposter type
  14020. */
  14021. static SphereImpostor: number;
  14022. /**
  14023. * Box-Imposter type
  14024. */
  14025. static BoxImpostor: number;
  14026. /**
  14027. * Plane-Imposter type
  14028. */
  14029. static PlaneImpostor: number;
  14030. /**
  14031. * Mesh-imposter type
  14032. */
  14033. static MeshImpostor: number;
  14034. /**
  14035. * Cylinder-Imposter type
  14036. */
  14037. static CylinderImpostor: number;
  14038. /**
  14039. * Particle-Imposter type
  14040. */
  14041. static ParticleImpostor: number;
  14042. /**
  14043. * Heightmap-Imposter type
  14044. */
  14045. static HeightmapImpostor: number;
  14046. /**
  14047. * ConvexHull-Impostor type (Ammo.js plugin only)
  14048. */
  14049. static ConvexHullImpostor: number;
  14050. /**
  14051. * Rope-Imposter type
  14052. */
  14053. static RopeImpostor: number;
  14054. /**
  14055. * Cloth-Imposter type
  14056. */
  14057. static ClothImpostor: number;
  14058. /**
  14059. * Softbody-Imposter type
  14060. */
  14061. static SoftbodyImpostor: number;
  14062. }
  14063. }
  14064. declare module "babylonjs/Meshes/mesh" {
  14065. import { Observable } from "babylonjs/Misc/observable";
  14066. import { IAnimatable } from "babylonjs/Misc/tools";
  14067. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  14068. import { Camera } from "babylonjs/Cameras/camera";
  14069. import { Scene } from "babylonjs/scene";
  14070. import { Matrix, Vector3, Vector2, Color4, Plane, Vector4, Path3D } from "babylonjs/Maths/math";
  14071. import { Engine } from "babylonjs/Engines/engine";
  14072. import { Node } from "babylonjs/node";
  14073. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  14074. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  14075. import { Buffer } from "babylonjs/Meshes/buffer";
  14076. import { Geometry } from "babylonjs/Meshes/geometry";
  14077. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14078. import { SubMesh } from "babylonjs/Meshes/subMesh";
  14079. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  14080. import { Effect } from "babylonjs/Materials/effect";
  14081. import { Material } from "babylonjs/Materials/material";
  14082. import { Skeleton } from "babylonjs/Bones/skeleton";
  14083. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  14084. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  14085. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  14086. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  14087. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  14088. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  14089. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  14090. /**
  14091. * @hidden
  14092. **/
  14093. export class _CreationDataStorage {
  14094. closePath?: boolean;
  14095. closeArray?: boolean;
  14096. idx: number[];
  14097. dashSize: number;
  14098. gapSize: number;
  14099. path3D: Path3D;
  14100. pathArray: Vector3[][];
  14101. arc: number;
  14102. radius: number;
  14103. cap: number;
  14104. tessellation: number;
  14105. }
  14106. /**
  14107. * @hidden
  14108. **/
  14109. class _InstanceDataStorage {
  14110. visibleInstances: any;
  14111. batchCache: _InstancesBatch;
  14112. instancesBufferSize: number;
  14113. instancesBuffer: Nullable<Buffer>;
  14114. instancesData: Float32Array;
  14115. overridenInstanceCount: number;
  14116. isFrozen: boolean;
  14117. previousBatch: Nullable<_InstancesBatch>;
  14118. hardwareInstancedRendering: boolean;
  14119. sideOrientation: number;
  14120. }
  14121. /**
  14122. * @hidden
  14123. **/
  14124. export class _InstancesBatch {
  14125. mustReturn: boolean;
  14126. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  14127. renderSelf: boolean[];
  14128. hardwareInstancedRendering: boolean[];
  14129. }
  14130. /**
  14131. * Class used to represent renderable models
  14132. */
  14133. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  14134. /**
  14135. * Mesh side orientation : usually the external or front surface
  14136. */
  14137. static readonly FRONTSIDE: number;
  14138. /**
  14139. * Mesh side orientation : usually the internal or back surface
  14140. */
  14141. static readonly BACKSIDE: number;
  14142. /**
  14143. * Mesh side orientation : both internal and external or front and back surfaces
  14144. */
  14145. static readonly DOUBLESIDE: number;
  14146. /**
  14147. * Mesh side orientation : by default, `FRONTSIDE`
  14148. */
  14149. static readonly DEFAULTSIDE: number;
  14150. /**
  14151. * Mesh cap setting : no cap
  14152. */
  14153. static readonly NO_CAP: number;
  14154. /**
  14155. * Mesh cap setting : one cap at the beginning of the mesh
  14156. */
  14157. static readonly CAP_START: number;
  14158. /**
  14159. * Mesh cap setting : one cap at the end of the mesh
  14160. */
  14161. static readonly CAP_END: number;
  14162. /**
  14163. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  14164. */
  14165. static readonly CAP_ALL: number;
  14166. /**
  14167. * Mesh pattern setting : no flip or rotate
  14168. */
  14169. static readonly NO_FLIP: number;
  14170. /**
  14171. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  14172. */
  14173. static readonly FLIP_TILE: number;
  14174. /**
  14175. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  14176. */
  14177. static readonly ROTATE_TILE: number;
  14178. /**
  14179. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  14180. */
  14181. static readonly FLIP_ROW: number;
  14182. /**
  14183. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  14184. */
  14185. static readonly ROTATE_ROW: number;
  14186. /**
  14187. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  14188. */
  14189. static readonly FLIP_N_ROTATE_TILE: number;
  14190. /**
  14191. * Mesh pattern setting : rotate pattern and rotate
  14192. */
  14193. static readonly FLIP_N_ROTATE_ROW: number;
  14194. /**
  14195. * Mesh tile positioning : part tiles same on left/right or top/bottom
  14196. */
  14197. static readonly CENTER: number;
  14198. /**
  14199. * Mesh tile positioning : part tiles on left
  14200. */
  14201. static readonly LEFT: number;
  14202. /**
  14203. * Mesh tile positioning : part tiles on right
  14204. */
  14205. static readonly RIGHT: number;
  14206. /**
  14207. * Mesh tile positioning : part tiles on top
  14208. */
  14209. static readonly TOP: number;
  14210. /**
  14211. * Mesh tile positioning : part tiles on bottom
  14212. */
  14213. static readonly BOTTOM: number;
  14214. /**
  14215. * Gets the default side orientation.
  14216. * @param orientation the orientation to value to attempt to get
  14217. * @returns the default orientation
  14218. * @hidden
  14219. */
  14220. static _GetDefaultSideOrientation(orientation?: number): number;
  14221. private _internalMeshDataInfo;
  14222. /**
  14223. * An event triggered before rendering the mesh
  14224. */
  14225. readonly onBeforeRenderObservable: Observable<Mesh>;
  14226. /**
  14227. * An event triggered before binding the mesh
  14228. */
  14229. readonly onBeforeBindObservable: Observable<Mesh>;
  14230. /**
  14231. * An event triggered after rendering the mesh
  14232. */
  14233. readonly onAfterRenderObservable: Observable<Mesh>;
  14234. /**
  14235. * An event triggered before drawing the mesh
  14236. */
  14237. readonly onBeforeDrawObservable: Observable<Mesh>;
  14238. private _onBeforeDrawObserver;
  14239. /**
  14240. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  14241. */
  14242. onBeforeDraw: () => void;
  14243. /**
  14244. * Gets the delay loading state of the mesh (when delay loading is turned on)
  14245. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  14246. */
  14247. delayLoadState: number;
  14248. /**
  14249. * Gets the list of instances created from this mesh
  14250. * it is not supposed to be modified manually.
  14251. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  14252. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  14253. */
  14254. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  14255. /**
  14256. * Gets the file containing delay loading data for this mesh
  14257. */
  14258. delayLoadingFile: string;
  14259. /** @hidden */
  14260. _binaryInfo: any;
  14261. /**
  14262. * User defined function used to change how LOD level selection is done
  14263. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  14264. */
  14265. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  14266. /**
  14267. * Gets or sets the morph target manager
  14268. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  14269. */
  14270. morphTargetManager: Nullable<MorphTargetManager>;
  14271. /** @hidden */
  14272. _creationDataStorage: Nullable<_CreationDataStorage>;
  14273. /** @hidden */
  14274. _geometry: Nullable<Geometry>;
  14275. /** @hidden */
  14276. _delayInfo: Array<string>;
  14277. /** @hidden */
  14278. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  14279. /** @hidden */
  14280. _instanceDataStorage: _InstanceDataStorage;
  14281. private _effectiveMaterial;
  14282. /** @hidden */
  14283. _shouldGenerateFlatShading: boolean;
  14284. /** @hidden */
  14285. _originalBuilderSideOrientation: number;
  14286. /**
  14287. * Use this property to change the original side orientation defined at construction time
  14288. */
  14289. overrideMaterialSideOrientation: Nullable<number>;
  14290. /**
  14291. * Gets the source mesh (the one used to clone this one from)
  14292. */
  14293. readonly source: Nullable<Mesh>;
  14294. /**
  14295. * Gets or sets a boolean indicating that this mesh does not use index buffer
  14296. */
  14297. isUnIndexed: boolean;
  14298. /**
  14299. * @constructor
  14300. * @param name The value used by scene.getMeshByName() to do a lookup.
  14301. * @param scene The scene to add this mesh to.
  14302. * @param parent The parent of this mesh, if it has one
  14303. * @param source An optional Mesh from which geometry is shared, cloned.
  14304. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  14305. * When false, achieved by calling a clone(), also passing False.
  14306. * This will make creation of children, recursive.
  14307. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  14308. */
  14309. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  14310. /**
  14311. * Gets the class name
  14312. * @returns the string "Mesh".
  14313. */
  14314. getClassName(): string;
  14315. /** @hidden */
  14316. readonly _isMesh: boolean;
  14317. /**
  14318. * Returns a description of this mesh
  14319. * @param fullDetails define if full details about this mesh must be used
  14320. * @returns a descriptive string representing this mesh
  14321. */
  14322. toString(fullDetails?: boolean): string;
  14323. /** @hidden */
  14324. _unBindEffect(): void;
  14325. /**
  14326. * Gets a boolean indicating if this mesh has LOD
  14327. */
  14328. readonly hasLODLevels: boolean;
  14329. /**
  14330. * Gets the list of MeshLODLevel associated with the current mesh
  14331. * @returns an array of MeshLODLevel
  14332. */
  14333. getLODLevels(): MeshLODLevel[];
  14334. private _sortLODLevels;
  14335. /**
  14336. * Add a mesh as LOD level triggered at the given distance.
  14337. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  14338. * @param distance The distance from the center of the object to show this level
  14339. * @param mesh The mesh to be added as LOD level (can be null)
  14340. * @return This mesh (for chaining)
  14341. */
  14342. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  14343. /**
  14344. * Returns the LOD level mesh at the passed distance or null if not found.
  14345. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  14346. * @param distance The distance from the center of the object to show this level
  14347. * @returns a Mesh or `null`
  14348. */
  14349. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  14350. /**
  14351. * Remove a mesh from the LOD array
  14352. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  14353. * @param mesh defines the mesh to be removed
  14354. * @return This mesh (for chaining)
  14355. */
  14356. removeLODLevel(mesh: Mesh): Mesh;
  14357. /**
  14358. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  14359. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  14360. * @param camera defines the camera to use to compute distance
  14361. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  14362. * @return This mesh (for chaining)
  14363. */
  14364. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  14365. /**
  14366. * Gets the mesh internal Geometry object
  14367. */
  14368. readonly geometry: Nullable<Geometry>;
  14369. /**
  14370. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  14371. * @returns the total number of vertices
  14372. */
  14373. getTotalVertices(): number;
  14374. /**
  14375. * Returns the content of an associated vertex buffer
  14376. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  14377. * - VertexBuffer.PositionKind
  14378. * - VertexBuffer.UVKind
  14379. * - VertexBuffer.UV2Kind
  14380. * - VertexBuffer.UV3Kind
  14381. * - VertexBuffer.UV4Kind
  14382. * - VertexBuffer.UV5Kind
  14383. * - VertexBuffer.UV6Kind
  14384. * - VertexBuffer.ColorKind
  14385. * - VertexBuffer.MatricesIndicesKind
  14386. * - VertexBuffer.MatricesIndicesExtraKind
  14387. * - VertexBuffer.MatricesWeightsKind
  14388. * - VertexBuffer.MatricesWeightsExtraKind
  14389. * @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
  14390. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  14391. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  14392. */
  14393. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  14394. /**
  14395. * Returns the mesh VertexBuffer object from the requested `kind`
  14396. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  14397. * - VertexBuffer.PositionKind
  14398. * - VertexBuffer.NormalKind
  14399. * - VertexBuffer.UVKind
  14400. * - VertexBuffer.UV2Kind
  14401. * - VertexBuffer.UV3Kind
  14402. * - VertexBuffer.UV4Kind
  14403. * - VertexBuffer.UV5Kind
  14404. * - VertexBuffer.UV6Kind
  14405. * - VertexBuffer.ColorKind
  14406. * - VertexBuffer.MatricesIndicesKind
  14407. * - VertexBuffer.MatricesIndicesExtraKind
  14408. * - VertexBuffer.MatricesWeightsKind
  14409. * - VertexBuffer.MatricesWeightsExtraKind
  14410. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  14411. */
  14412. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  14413. /**
  14414. * Tests if a specific vertex buffer is associated with this mesh
  14415. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  14416. * - VertexBuffer.PositionKind
  14417. * - VertexBuffer.NormalKind
  14418. * - VertexBuffer.UVKind
  14419. * - VertexBuffer.UV2Kind
  14420. * - VertexBuffer.UV3Kind
  14421. * - VertexBuffer.UV4Kind
  14422. * - VertexBuffer.UV5Kind
  14423. * - VertexBuffer.UV6Kind
  14424. * - VertexBuffer.ColorKind
  14425. * - VertexBuffer.MatricesIndicesKind
  14426. * - VertexBuffer.MatricesIndicesExtraKind
  14427. * - VertexBuffer.MatricesWeightsKind
  14428. * - VertexBuffer.MatricesWeightsExtraKind
  14429. * @returns a boolean
  14430. */
  14431. isVerticesDataPresent(kind: string): boolean;
  14432. /**
  14433. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  14434. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  14435. * - VertexBuffer.PositionKind
  14436. * - VertexBuffer.UVKind
  14437. * - VertexBuffer.UV2Kind
  14438. * - VertexBuffer.UV3Kind
  14439. * - VertexBuffer.UV4Kind
  14440. * - VertexBuffer.UV5Kind
  14441. * - VertexBuffer.UV6Kind
  14442. * - VertexBuffer.ColorKind
  14443. * - VertexBuffer.MatricesIndicesKind
  14444. * - VertexBuffer.MatricesIndicesExtraKind
  14445. * - VertexBuffer.MatricesWeightsKind
  14446. * - VertexBuffer.MatricesWeightsExtraKind
  14447. * @returns a boolean
  14448. */
  14449. isVertexBufferUpdatable(kind: string): boolean;
  14450. /**
  14451. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  14452. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  14453. * - VertexBuffer.PositionKind
  14454. * - VertexBuffer.NormalKind
  14455. * - VertexBuffer.UVKind
  14456. * - VertexBuffer.UV2Kind
  14457. * - VertexBuffer.UV3Kind
  14458. * - VertexBuffer.UV4Kind
  14459. * - VertexBuffer.UV5Kind
  14460. * - VertexBuffer.UV6Kind
  14461. * - VertexBuffer.ColorKind
  14462. * - VertexBuffer.MatricesIndicesKind
  14463. * - VertexBuffer.MatricesIndicesExtraKind
  14464. * - VertexBuffer.MatricesWeightsKind
  14465. * - VertexBuffer.MatricesWeightsExtraKind
  14466. * @returns an array of strings
  14467. */
  14468. getVerticesDataKinds(): string[];
  14469. /**
  14470. * Returns a positive integer : the total number of indices in this mesh geometry.
  14471. * @returns the numner of indices or zero if the mesh has no geometry.
  14472. */
  14473. getTotalIndices(): number;
  14474. /**
  14475. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  14476. * @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.
  14477. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  14478. * @returns the indices array or an empty array if the mesh has no geometry
  14479. */
  14480. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  14481. readonly isBlocked: boolean;
  14482. /**
  14483. * Determine if the current mesh is ready to be rendered
  14484. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  14485. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  14486. * @returns true if all associated assets are ready (material, textures, shaders)
  14487. */
  14488. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  14489. /**
  14490. * 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.
  14491. */
  14492. readonly areNormalsFrozen: boolean;
  14493. /**
  14494. * 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.
  14495. * @returns the current mesh
  14496. */
  14497. freezeNormals(): Mesh;
  14498. /**
  14499. * 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
  14500. * @returns the current mesh
  14501. */
  14502. unfreezeNormals(): Mesh;
  14503. /**
  14504. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  14505. */
  14506. overridenInstanceCount: number;
  14507. /** @hidden */
  14508. _preActivate(): Mesh;
  14509. /** @hidden */
  14510. _preActivateForIntermediateRendering(renderId: number): Mesh;
  14511. /** @hidden */
  14512. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  14513. /**
  14514. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  14515. * This means the mesh underlying bounding box and sphere are recomputed.
  14516. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  14517. * @returns the current mesh
  14518. */
  14519. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  14520. /** @hidden */
  14521. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  14522. /**
  14523. * This function will subdivide the mesh into multiple submeshes
  14524. * @param count defines the expected number of submeshes
  14525. */
  14526. subdivide(count: number): void;
  14527. /**
  14528. * Copy a FloatArray into a specific associated vertex buffer
  14529. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  14530. * - VertexBuffer.PositionKind
  14531. * - VertexBuffer.UVKind
  14532. * - VertexBuffer.UV2Kind
  14533. * - VertexBuffer.UV3Kind
  14534. * - VertexBuffer.UV4Kind
  14535. * - VertexBuffer.UV5Kind
  14536. * - VertexBuffer.UV6Kind
  14537. * - VertexBuffer.ColorKind
  14538. * - VertexBuffer.MatricesIndicesKind
  14539. * - VertexBuffer.MatricesIndicesExtraKind
  14540. * - VertexBuffer.MatricesWeightsKind
  14541. * - VertexBuffer.MatricesWeightsExtraKind
  14542. * @param data defines the data source
  14543. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  14544. * @param stride defines the data stride size (can be null)
  14545. * @returns the current mesh
  14546. */
  14547. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  14548. /**
  14549. * Flags an associated vertex buffer as updatable
  14550. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  14551. * - VertexBuffer.PositionKind
  14552. * - VertexBuffer.UVKind
  14553. * - VertexBuffer.UV2Kind
  14554. * - VertexBuffer.UV3Kind
  14555. * - VertexBuffer.UV4Kind
  14556. * - VertexBuffer.UV5Kind
  14557. * - VertexBuffer.UV6Kind
  14558. * - VertexBuffer.ColorKind
  14559. * - VertexBuffer.MatricesIndicesKind
  14560. * - VertexBuffer.MatricesIndicesExtraKind
  14561. * - VertexBuffer.MatricesWeightsKind
  14562. * - VertexBuffer.MatricesWeightsExtraKind
  14563. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  14564. */
  14565. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  14566. /**
  14567. * Sets the mesh global Vertex Buffer
  14568. * @param buffer defines the buffer to use
  14569. * @returns the current mesh
  14570. */
  14571. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  14572. /**
  14573. * Update a specific associated vertex buffer
  14574. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  14575. * - VertexBuffer.PositionKind
  14576. * - VertexBuffer.UVKind
  14577. * - VertexBuffer.UV2Kind
  14578. * - VertexBuffer.UV3Kind
  14579. * - VertexBuffer.UV4Kind
  14580. * - VertexBuffer.UV5Kind
  14581. * - VertexBuffer.UV6Kind
  14582. * - VertexBuffer.ColorKind
  14583. * - VertexBuffer.MatricesIndicesKind
  14584. * - VertexBuffer.MatricesIndicesExtraKind
  14585. * - VertexBuffer.MatricesWeightsKind
  14586. * - VertexBuffer.MatricesWeightsExtraKind
  14587. * @param data defines the data source
  14588. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  14589. * @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)
  14590. * @returns the current mesh
  14591. */
  14592. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  14593. /**
  14594. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  14595. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  14596. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  14597. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  14598. * @returns the current mesh
  14599. */
  14600. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  14601. /**
  14602. * Creates a un-shared specific occurence of the geometry for the mesh.
  14603. * @returns the current mesh
  14604. */
  14605. makeGeometryUnique(): Mesh;
  14606. /**
  14607. * Set the index buffer of this mesh
  14608. * @param indices defines the source data
  14609. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  14610. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  14611. * @returns the current mesh
  14612. */
  14613. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  14614. /**
  14615. * Update the current index buffer
  14616. * @param indices defines the source data
  14617. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  14618. * @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)
  14619. * @returns the current mesh
  14620. */
  14621. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  14622. /**
  14623. * Invert the geometry to move from a right handed system to a left handed one.
  14624. * @returns the current mesh
  14625. */
  14626. toLeftHanded(): Mesh;
  14627. /** @hidden */
  14628. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  14629. /** @hidden */
  14630. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  14631. /**
  14632. * Registers for this mesh a javascript function called just before the rendering process
  14633. * @param func defines the function to call before rendering this mesh
  14634. * @returns the current mesh
  14635. */
  14636. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  14637. /**
  14638. * Disposes a previously registered javascript function called before the rendering
  14639. * @param func defines the function to remove
  14640. * @returns the current mesh
  14641. */
  14642. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  14643. /**
  14644. * Registers for this mesh a javascript function called just after the rendering is complete
  14645. * @param func defines the function to call after rendering this mesh
  14646. * @returns the current mesh
  14647. */
  14648. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  14649. /**
  14650. * Disposes a previously registered javascript function called after the rendering.
  14651. * @param func defines the function to remove
  14652. * @returns the current mesh
  14653. */
  14654. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  14655. /** @hidden */
  14656. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  14657. /** @hidden */
  14658. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  14659. /** @hidden */
  14660. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  14661. /** @hidden */
  14662. _freeze(): void;
  14663. /** @hidden */
  14664. _unFreeze(): void;
  14665. /**
  14666. * 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
  14667. * @param subMesh defines the subMesh to render
  14668. * @param enableAlphaMode defines if alpha mode can be changed
  14669. * @returns the current mesh
  14670. */
  14671. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  14672. private _onBeforeDraw;
  14673. /**
  14674. * Renormalize the mesh and patch it up if there are no weights
  14675. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  14676. * However in the case of zero weights then we set just a single influence to 1.
  14677. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  14678. */
  14679. cleanMatrixWeights(): void;
  14680. private normalizeSkinFourWeights;
  14681. private normalizeSkinWeightsAndExtra;
  14682. /**
  14683. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  14684. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  14685. * the user know there was an issue with importing the mesh
  14686. * @returns a validation object with skinned, valid and report string
  14687. */
  14688. validateSkinning(): {
  14689. skinned: boolean;
  14690. valid: boolean;
  14691. report: string;
  14692. };
  14693. /** @hidden */
  14694. _checkDelayState(): Mesh;
  14695. private _queueLoad;
  14696. /**
  14697. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  14698. * A mesh is in the frustum if its bounding box intersects the frustum
  14699. * @param frustumPlanes defines the frustum to test
  14700. * @returns true if the mesh is in the frustum planes
  14701. */
  14702. isInFrustum(frustumPlanes: Plane[]): boolean;
  14703. /**
  14704. * Sets the mesh material by the material or multiMaterial `id` property
  14705. * @param id is a string identifying the material or the multiMaterial
  14706. * @returns the current mesh
  14707. */
  14708. setMaterialByID(id: string): Mesh;
  14709. /**
  14710. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  14711. * @returns an array of IAnimatable
  14712. */
  14713. getAnimatables(): IAnimatable[];
  14714. /**
  14715. * Modifies the mesh geometry according to the passed transformation matrix.
  14716. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  14717. * The mesh normals are modified using the same transformation.
  14718. * Note that, under the hood, this method sets a new VertexBuffer each call.
  14719. * @param transform defines the transform matrix to use
  14720. * @see http://doc.babylonjs.com/resources/baking_transformations
  14721. * @returns the current mesh
  14722. */
  14723. bakeTransformIntoVertices(transform: Matrix): Mesh;
  14724. /**
  14725. * Modifies the mesh geometry according to its own current World Matrix.
  14726. * The mesh World Matrix is then reset.
  14727. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  14728. * Note that, under the hood, this method sets a new VertexBuffer each call.
  14729. * @see http://doc.babylonjs.com/resources/baking_transformations
  14730. * @returns the current mesh
  14731. */
  14732. bakeCurrentTransformIntoVertices(): Mesh;
  14733. /** @hidden */
  14734. readonly _positions: Nullable<Vector3[]>;
  14735. /** @hidden */
  14736. _resetPointsArrayCache(): Mesh;
  14737. /** @hidden */
  14738. _generatePointsArray(): boolean;
  14739. /**
  14740. * Returns a new Mesh object generated from the current mesh properties.
  14741. * This method must not get confused with createInstance()
  14742. * @param name is a string, the name given to the new mesh
  14743. * @param newParent can be any Node object (default `null`)
  14744. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  14745. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  14746. * @returns a new mesh
  14747. */
  14748. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  14749. /**
  14750. * Releases resources associated with this mesh.
  14751. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14752. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14753. */
  14754. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14755. /**
  14756. * Modifies the mesh geometry according to a displacement map.
  14757. * 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.
  14758. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  14759. * @param url is a string, the URL from the image file is to be downloaded.
  14760. * @param minHeight is the lower limit of the displacement.
  14761. * @param maxHeight is the upper limit of the displacement.
  14762. * @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.
  14763. * @param uvOffset is an optional vector2 used to offset UV.
  14764. * @param uvScale is an optional vector2 used to scale UV.
  14765. * @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.
  14766. * @returns the Mesh.
  14767. */
  14768. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  14769. /**
  14770. * Modifies the mesh geometry according to a displacementMap buffer.
  14771. * 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.
  14772. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  14773. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  14774. * @param heightMapWidth is the width of the buffer image.
  14775. * @param heightMapHeight is the height of the buffer image.
  14776. * @param minHeight is the lower limit of the displacement.
  14777. * @param maxHeight is the upper limit of the displacement.
  14778. * @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.
  14779. * @param uvOffset is an optional vector2 used to offset UV.
  14780. * @param uvScale is an optional vector2 used to scale UV.
  14781. * @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.
  14782. * @returns the Mesh.
  14783. */
  14784. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  14785. /**
  14786. * Modify the mesh to get a flat shading rendering.
  14787. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  14788. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  14789. * @returns current mesh
  14790. */
  14791. convertToFlatShadedMesh(): Mesh;
  14792. /**
  14793. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  14794. * In other words, more vertices, no more indices and a single bigger VBO.
  14795. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  14796. * @returns current mesh
  14797. */
  14798. convertToUnIndexedMesh(): Mesh;
  14799. /**
  14800. * Inverses facet orientations.
  14801. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  14802. * @param flipNormals will also inverts the normals
  14803. * @returns current mesh
  14804. */
  14805. flipFaces(flipNormals?: boolean): Mesh;
  14806. /**
  14807. * Increase the number of facets and hence vertices in a mesh
  14808. * Vertex normals are interpolated from existing vertex normals
  14809. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  14810. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  14811. */
  14812. increaseVertices(numberPerEdge: number): void;
  14813. /**
  14814. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  14815. * This will undo any application of covertToFlatShadedMesh
  14816. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  14817. */
  14818. forceSharedVertices(): void;
  14819. /** @hidden */
  14820. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  14821. /** @hidden */
  14822. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  14823. /**
  14824. * Creates a new InstancedMesh object from the mesh model.
  14825. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  14826. * @param name defines the name of the new instance
  14827. * @returns a new InstancedMesh
  14828. */
  14829. createInstance(name: string): InstancedMesh;
  14830. /**
  14831. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  14832. * After this call, all the mesh instances have the same submeshes than the current mesh.
  14833. * @returns the current mesh
  14834. */
  14835. synchronizeInstances(): Mesh;
  14836. /**
  14837. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  14838. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  14839. * This should be used together with the simplification to avoid disappearing triangles.
  14840. * @param successCallback an optional success callback to be called after the optimization finished.
  14841. * @returns the current mesh
  14842. */
  14843. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  14844. /**
  14845. * Serialize current mesh
  14846. * @param serializationObject defines the object which will receive the serialization data
  14847. */
  14848. serialize(serializationObject: any): void;
  14849. /** @hidden */
  14850. _syncGeometryWithMorphTargetManager(): void;
  14851. /** @hidden */
  14852. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  14853. /**
  14854. * Returns a new Mesh object parsed from the source provided.
  14855. * @param parsedMesh is the source
  14856. * @param scene defines the hosting scene
  14857. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  14858. * @returns a new Mesh
  14859. */
  14860. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  14861. /**
  14862. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  14863. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  14864. * @param name defines the name of the mesh to create
  14865. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  14866. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  14867. * @param closePath creates a seam between the first and the last points of each path of the path array
  14868. * @param offset is taken in account only if the `pathArray` is containing a single path
  14869. * @param scene defines the hosting scene
  14870. * @param updatable defines if the mesh must be flagged as updatable
  14871. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14872. * @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)
  14873. * @returns a new Mesh
  14874. */
  14875. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  14876. /**
  14877. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  14878. * @param name defines the name of the mesh to create
  14879. * @param radius sets the radius size (float) of the polygon (default 0.5)
  14880. * @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
  14881. * @param scene defines the hosting scene
  14882. * @param updatable defines if the mesh must be flagged as updatable
  14883. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14884. * @returns a new Mesh
  14885. */
  14886. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  14887. /**
  14888. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  14889. * @param name defines the name of the mesh to create
  14890. * @param size sets the size (float) of each box side (default 1)
  14891. * @param scene defines the hosting scene
  14892. * @param updatable defines if the mesh must be flagged as updatable
  14893. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14894. * @returns a new Mesh
  14895. */
  14896. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  14897. /**
  14898. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  14899. * @param name defines the name of the mesh to create
  14900. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  14901. * @param diameter sets the diameter size (float) of the sphere (default 1)
  14902. * @param scene defines the hosting scene
  14903. * @param updatable defines if the mesh must be flagged as updatable
  14904. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14905. * @returns a new Mesh
  14906. */
  14907. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  14908. /**
  14909. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  14910. * @param name defines the name of the mesh to create
  14911. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  14912. * @param diameter sets the diameter size (float) of the sphere (default 1)
  14913. * @param scene defines the hosting scene
  14914. * @returns a new Mesh
  14915. */
  14916. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  14917. /**
  14918. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  14919. * @param name defines the name of the mesh to create
  14920. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  14921. * @param diameterTop set the top cap diameter (floats, default 1)
  14922. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  14923. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  14924. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  14925. * @param scene defines the hosting scene
  14926. * @param updatable defines if the mesh must be flagged as updatable
  14927. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14928. * @returns a new Mesh
  14929. */
  14930. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  14931. /**
  14932. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  14933. * @param name defines the name of the mesh to create
  14934. * @param diameter sets the diameter size (float) of the torus (default 1)
  14935. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  14936. * @param tessellation sets the number of torus sides (postive integer, default 16)
  14937. * @param scene defines the hosting scene
  14938. * @param updatable defines if the mesh must be flagged as updatable
  14939. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14940. * @returns a new Mesh
  14941. */
  14942. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  14943. /**
  14944. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  14945. * @param name defines the name of the mesh to create
  14946. * @param radius sets the global radius size (float) of the torus knot (default 2)
  14947. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  14948. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  14949. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  14950. * @param p the number of windings on X axis (positive integers, default 2)
  14951. * @param q the number of windings on Y axis (positive integers, default 3)
  14952. * @param scene defines the hosting scene
  14953. * @param updatable defines if the mesh must be flagged as updatable
  14954. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14955. * @returns a new Mesh
  14956. */
  14957. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  14958. /**
  14959. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  14960. * @param name defines the name of the mesh to create
  14961. * @param points is an array successive Vector3
  14962. * @param scene defines the hosting scene
  14963. * @param updatable defines if the mesh must be flagged as updatable
  14964. * @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).
  14965. * @returns a new Mesh
  14966. */
  14967. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  14968. /**
  14969. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  14970. * @param name defines the name of the mesh to create
  14971. * @param points is an array successive Vector3
  14972. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  14973. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  14974. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  14975. * @param scene defines the hosting scene
  14976. * @param updatable defines if the mesh must be flagged as updatable
  14977. * @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)
  14978. * @returns a new Mesh
  14979. */
  14980. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  14981. /**
  14982. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  14983. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  14984. * 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.
  14985. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  14986. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  14987. * Remember you can only change the shape positions, not their number when updating a polygon.
  14988. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  14989. * @param name defines the name of the mesh to create
  14990. * @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
  14991. * @param scene defines the hosting scene
  14992. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  14993. * @param updatable defines if the mesh must be flagged as updatable
  14994. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14995. * @param earcutInjection can be used to inject your own earcut reference
  14996. * @returns a new Mesh
  14997. */
  14998. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  14999. /**
  15000. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  15001. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  15002. * @param name defines the name of the mesh to create
  15003. * @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
  15004. * @param depth defines the height of extrusion
  15005. * @param scene defines the hosting scene
  15006. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  15007. * @param updatable defines if the mesh must be flagged as updatable
  15008. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15009. * @param earcutInjection can be used to inject your own earcut reference
  15010. * @returns a new Mesh
  15011. */
  15012. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  15013. /**
  15014. * Creates an extruded shape mesh.
  15015. * 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
  15016. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  15017. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  15018. * @param name defines the name of the mesh to create
  15019. * @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
  15020. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  15021. * @param scale is the value to scale the shape
  15022. * @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
  15023. * @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
  15024. * @param scene defines the hosting scene
  15025. * @param updatable defines if the mesh must be flagged as updatable
  15026. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15027. * @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)
  15028. * @returns a new Mesh
  15029. */
  15030. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  15031. /**
  15032. * Creates an custom extruded shape mesh.
  15033. * The custom extrusion is a parametric shape.
  15034. * It has no predefined shape. Its final shape will depend on the input parameters.
  15035. * Please consider using the same method from the MeshBuilder class instead
  15036. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  15037. * @param name defines the name of the mesh to create
  15038. * @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
  15039. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  15040. * @param scaleFunction is a custom Javascript function called on each path point
  15041. * @param rotationFunction is a custom Javascript function called on each path point
  15042. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  15043. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  15044. * @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
  15045. * @param scene defines the hosting scene
  15046. * @param updatable defines if the mesh must be flagged as updatable
  15047. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15048. * @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)
  15049. * @returns a new Mesh
  15050. */
  15051. 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;
  15052. /**
  15053. * Creates lathe mesh.
  15054. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  15055. * Please consider using the same method from the MeshBuilder class instead
  15056. * @param name defines the name of the mesh to create
  15057. * @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
  15058. * @param radius is the radius value of the lathe
  15059. * @param tessellation is the side number of the lathe.
  15060. * @param scene defines the hosting scene
  15061. * @param updatable defines if the mesh must be flagged as updatable
  15062. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15063. * @returns a new Mesh
  15064. */
  15065. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  15066. /**
  15067. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  15068. * @param name defines the name of the mesh to create
  15069. * @param size sets the size (float) of both sides of the plane at once (default 1)
  15070. * @param scene defines the hosting scene
  15071. * @param updatable defines if the mesh must be flagged as updatable
  15072. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15073. * @returns a new Mesh
  15074. */
  15075. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  15076. /**
  15077. * Creates a ground mesh.
  15078. * Please consider using the same method from the MeshBuilder class instead
  15079. * @param name defines the name of the mesh to create
  15080. * @param width set the width of the ground
  15081. * @param height set the height of the ground
  15082. * @param subdivisions sets the number of subdivisions per side
  15083. * @param scene defines the hosting scene
  15084. * @param updatable defines if the mesh must be flagged as updatable
  15085. * @returns a new Mesh
  15086. */
  15087. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  15088. /**
  15089. * Creates a tiled ground mesh.
  15090. * Please consider using the same method from the MeshBuilder class instead
  15091. * @param name defines the name of the mesh to create
  15092. * @param xmin set the ground minimum X coordinate
  15093. * @param zmin set the ground minimum Y coordinate
  15094. * @param xmax set the ground maximum X coordinate
  15095. * @param zmax set the ground maximum Z coordinate
  15096. * @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
  15097. * @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
  15098. * @param scene defines the hosting scene
  15099. * @param updatable defines if the mesh must be flagged as updatable
  15100. * @returns a new Mesh
  15101. */
  15102. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  15103. w: number;
  15104. h: number;
  15105. }, precision: {
  15106. w: number;
  15107. h: number;
  15108. }, scene: Scene, updatable?: boolean): Mesh;
  15109. /**
  15110. * Creates a ground mesh from a height map.
  15111. * Please consider using the same method from the MeshBuilder class instead
  15112. * @see http://doc.babylonjs.com/babylon101/height_map
  15113. * @param name defines the name of the mesh to create
  15114. * @param url sets the URL of the height map image resource
  15115. * @param width set the ground width size
  15116. * @param height set the ground height size
  15117. * @param subdivisions sets the number of subdivision per side
  15118. * @param minHeight is the minimum altitude on the ground
  15119. * @param maxHeight is the maximum altitude on the ground
  15120. * @param scene defines the hosting scene
  15121. * @param updatable defines if the mesh must be flagged as updatable
  15122. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  15123. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  15124. * @returns a new Mesh
  15125. */
  15126. 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;
  15127. /**
  15128. * Creates a tube mesh.
  15129. * The tube is a parametric shape.
  15130. * It has no predefined shape. Its final shape will depend on the input parameters.
  15131. * Please consider using the same method from the MeshBuilder class instead
  15132. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  15133. * @param name defines the name of the mesh to create
  15134. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  15135. * @param radius sets the tube radius size
  15136. * @param tessellation is the number of sides on the tubular surface
  15137. * @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
  15138. * @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
  15139. * @param scene defines the hosting scene
  15140. * @param updatable defines if the mesh must be flagged as updatable
  15141. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15142. * @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)
  15143. * @returns a new Mesh
  15144. */
  15145. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  15146. (i: number, distance: number): number;
  15147. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  15148. /**
  15149. * Creates a polyhedron mesh.
  15150. * Please consider using the same method from the MeshBuilder class instead.
  15151. * * 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
  15152. * * The parameter `size` (positive float, default 1) sets the polygon size
  15153. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  15154. * * 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`
  15155. * * 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
  15156. * * 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)`)
  15157. * * 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
  15158. * * 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
  15159. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  15160. * * If you create a double-sided mesh, you can choose what parts of 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
  15161. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  15162. * @param name defines the name of the mesh to create
  15163. * @param options defines the options used to create the mesh
  15164. * @param scene defines the hosting scene
  15165. * @returns a new Mesh
  15166. */
  15167. static CreatePolyhedron(name: string, options: {
  15168. type?: number;
  15169. size?: number;
  15170. sizeX?: number;
  15171. sizeY?: number;
  15172. sizeZ?: number;
  15173. custom?: any;
  15174. faceUV?: Vector4[];
  15175. faceColors?: Color4[];
  15176. updatable?: boolean;
  15177. sideOrientation?: number;
  15178. }, scene: Scene): Mesh;
  15179. /**
  15180. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  15181. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  15182. * * 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`)
  15183. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  15184. * * 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
  15185. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  15186. * * If you create a double-sided mesh, you can choose what parts of 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
  15187. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  15188. * @param name defines the name of the mesh
  15189. * @param options defines the options used to create the mesh
  15190. * @param scene defines the hosting scene
  15191. * @returns a new Mesh
  15192. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  15193. */
  15194. static CreateIcoSphere(name: string, options: {
  15195. radius?: number;
  15196. flat?: boolean;
  15197. subdivisions?: number;
  15198. sideOrientation?: number;
  15199. updatable?: boolean;
  15200. }, scene: Scene): Mesh;
  15201. /**
  15202. * Creates a decal mesh.
  15203. * Please consider using the same method from the MeshBuilder class instead.
  15204. * A decal is a mesh usually applied as a model onto the surface of another mesh
  15205. * @param name defines the name of the mesh
  15206. * @param sourceMesh defines the mesh receiving the decal
  15207. * @param position sets the position of the decal in world coordinates
  15208. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  15209. * @param size sets the decal scaling
  15210. * @param angle sets the angle to rotate the decal
  15211. * @returns a new Mesh
  15212. */
  15213. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  15214. /**
  15215. * Prepare internal position array for software CPU skinning
  15216. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  15217. */
  15218. setPositionsForCPUSkinning(): Float32Array;
  15219. /**
  15220. * Prepare internal normal array for software CPU skinning
  15221. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  15222. */
  15223. setNormalsForCPUSkinning(): Float32Array;
  15224. /**
  15225. * Updates the vertex buffer by applying transformation from the bones
  15226. * @param skeleton defines the skeleton to apply to current mesh
  15227. * @returns the current mesh
  15228. */
  15229. applySkeleton(skeleton: Skeleton): Mesh;
  15230. /**
  15231. * 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
  15232. * @param meshes defines the list of meshes to scan
  15233. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  15234. */
  15235. static MinMax(meshes: AbstractMesh[]): {
  15236. min: Vector3;
  15237. max: Vector3;
  15238. };
  15239. /**
  15240. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  15241. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  15242. * @returns a vector3
  15243. */
  15244. static Center(meshesOrMinMaxVector: {
  15245. min: Vector3;
  15246. max: Vector3;
  15247. } | AbstractMesh[]): Vector3;
  15248. /**
  15249. * Merge the array of meshes into a single mesh for performance reasons.
  15250. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  15251. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  15252. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  15253. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  15254. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  15255. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  15256. * @returns a new mesh
  15257. */
  15258. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  15259. /** @hidden */
  15260. addInstance(instance: InstancedMesh): void;
  15261. /** @hidden */
  15262. removeInstance(instance: InstancedMesh): void;
  15263. }
  15264. }
  15265. declare module "babylonjs/Actions/action" {
  15266. import { Observable } from "babylonjs/Misc/observable";
  15267. import { Condition } from "babylonjs/Actions/condition";
  15268. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  15269. import { ActionManager } from "babylonjs/Actions/actionManager";
  15270. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  15271. /**
  15272. * Interface used to define Action
  15273. */
  15274. export interface IAction {
  15275. /**
  15276. * Trigger for the action
  15277. */
  15278. trigger: number;
  15279. /** Options of the trigger */
  15280. triggerOptions: any;
  15281. /**
  15282. * Gets the trigger parameters
  15283. * @returns the trigger parameters
  15284. */
  15285. getTriggerParameter(): any;
  15286. /**
  15287. * Internal only - executes current action event
  15288. * @hidden
  15289. */
  15290. _executeCurrent(evt?: ActionEvent): void;
  15291. /**
  15292. * Serialize placeholder for child classes
  15293. * @param parent of child
  15294. * @returns the serialized object
  15295. */
  15296. serialize(parent: any): any;
  15297. /**
  15298. * Internal only
  15299. * @hidden
  15300. */
  15301. _prepare(): void;
  15302. /**
  15303. * Internal only - manager for action
  15304. * @hidden
  15305. */
  15306. _actionManager: AbstractActionManager;
  15307. /**
  15308. * Adds action to chain of actions, may be a DoNothingAction
  15309. * @param action defines the next action to execute
  15310. * @returns The action passed in
  15311. * @see https://www.babylonjs-playground.com/#1T30HR#0
  15312. */
  15313. then(action: IAction): IAction;
  15314. }
  15315. /**
  15316. * The action to be carried out following a trigger
  15317. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  15318. */
  15319. export class Action implements IAction {
  15320. /** the trigger, with or without parameters, for the action */
  15321. triggerOptions: any;
  15322. /**
  15323. * Trigger for the action
  15324. */
  15325. trigger: number;
  15326. /**
  15327. * Internal only - manager for action
  15328. * @hidden
  15329. */
  15330. _actionManager: ActionManager;
  15331. private _nextActiveAction;
  15332. private _child;
  15333. private _condition?;
  15334. private _triggerParameter;
  15335. /**
  15336. * An event triggered prior to action being executed.
  15337. */
  15338. onBeforeExecuteObservable: Observable<Action>;
  15339. /**
  15340. * Creates a new Action
  15341. * @param triggerOptions the trigger, with or without parameters, for the action
  15342. * @param condition an optional determinant of action
  15343. */
  15344. constructor(
  15345. /** the trigger, with or without parameters, for the action */
  15346. triggerOptions: any, condition?: Condition);
  15347. /**
  15348. * Internal only
  15349. * @hidden
  15350. */
  15351. _prepare(): void;
  15352. /**
  15353. * Gets the trigger parameters
  15354. * @returns the trigger parameters
  15355. */
  15356. getTriggerParameter(): any;
  15357. /**
  15358. * Internal only - executes current action event
  15359. * @hidden
  15360. */
  15361. _executeCurrent(evt?: ActionEvent): void;
  15362. /**
  15363. * Execute placeholder for child classes
  15364. * @param evt optional action event
  15365. */
  15366. execute(evt?: ActionEvent): void;
  15367. /**
  15368. * Skips to next active action
  15369. */
  15370. skipToNextActiveAction(): void;
  15371. /**
  15372. * Adds action to chain of actions, may be a DoNothingAction
  15373. * @param action defines the next action to execute
  15374. * @returns The action passed in
  15375. * @see https://www.babylonjs-playground.com/#1T30HR#0
  15376. */
  15377. then(action: Action): Action;
  15378. /**
  15379. * Internal only
  15380. * @hidden
  15381. */
  15382. _getProperty(propertyPath: string): string;
  15383. /**
  15384. * Internal only
  15385. * @hidden
  15386. */
  15387. _getEffectiveTarget(target: any, propertyPath: string): any;
  15388. /**
  15389. * Serialize placeholder for child classes
  15390. * @param parent of child
  15391. * @returns the serialized object
  15392. */
  15393. serialize(parent: any): any;
  15394. /**
  15395. * Internal only called by serialize
  15396. * @hidden
  15397. */
  15398. protected _serialize(serializedAction: any, parent?: any): any;
  15399. /**
  15400. * Internal only
  15401. * @hidden
  15402. */
  15403. static _SerializeValueAsString: (value: any) => string;
  15404. /**
  15405. * Internal only
  15406. * @hidden
  15407. */
  15408. static _GetTargetProperty: (target: import("babylonjs/scene").Scene | import("babylonjs/node").Node) => {
  15409. name: string;
  15410. targetType: string;
  15411. value: string;
  15412. };
  15413. }
  15414. }
  15415. declare module "babylonjs/Actions/condition" {
  15416. import { ActionManager } from "babylonjs/Actions/actionManager";
  15417. /**
  15418. * A Condition applied to an Action
  15419. */
  15420. export class Condition {
  15421. /**
  15422. * Internal only - manager for action
  15423. * @hidden
  15424. */
  15425. _actionManager: ActionManager;
  15426. /**
  15427. * Internal only
  15428. * @hidden
  15429. */
  15430. _evaluationId: number;
  15431. /**
  15432. * Internal only
  15433. * @hidden
  15434. */
  15435. _currentResult: boolean;
  15436. /**
  15437. * Creates a new Condition
  15438. * @param actionManager the manager of the action the condition is applied to
  15439. */
  15440. constructor(actionManager: ActionManager);
  15441. /**
  15442. * Check if the current condition is valid
  15443. * @returns a boolean
  15444. */
  15445. isValid(): boolean;
  15446. /**
  15447. * Internal only
  15448. * @hidden
  15449. */
  15450. _getProperty(propertyPath: string): string;
  15451. /**
  15452. * Internal only
  15453. * @hidden
  15454. */
  15455. _getEffectiveTarget(target: any, propertyPath: string): any;
  15456. /**
  15457. * Serialize placeholder for child classes
  15458. * @returns the serialized object
  15459. */
  15460. serialize(): any;
  15461. /**
  15462. * Internal only
  15463. * @hidden
  15464. */
  15465. protected _serialize(serializedCondition: any): any;
  15466. }
  15467. /**
  15468. * Defines specific conditional operators as extensions of Condition
  15469. */
  15470. export class ValueCondition extends Condition {
  15471. /** path to specify the property of the target the conditional operator uses */
  15472. propertyPath: string;
  15473. /** the value compared by the conditional operator against the current value of the property */
  15474. value: any;
  15475. /** the conditional operator, default ValueCondition.IsEqual */
  15476. operator: number;
  15477. /**
  15478. * Internal only
  15479. * @hidden
  15480. */
  15481. private static _IsEqual;
  15482. /**
  15483. * Internal only
  15484. * @hidden
  15485. */
  15486. private static _IsDifferent;
  15487. /**
  15488. * Internal only
  15489. * @hidden
  15490. */
  15491. private static _IsGreater;
  15492. /**
  15493. * Internal only
  15494. * @hidden
  15495. */
  15496. private static _IsLesser;
  15497. /**
  15498. * returns the number for IsEqual
  15499. */
  15500. static readonly IsEqual: number;
  15501. /**
  15502. * Returns the number for IsDifferent
  15503. */
  15504. static readonly IsDifferent: number;
  15505. /**
  15506. * Returns the number for IsGreater
  15507. */
  15508. static readonly IsGreater: number;
  15509. /**
  15510. * Returns the number for IsLesser
  15511. */
  15512. static readonly IsLesser: number;
  15513. /**
  15514. * Internal only The action manager for the condition
  15515. * @hidden
  15516. */
  15517. _actionManager: ActionManager;
  15518. /**
  15519. * Internal only
  15520. * @hidden
  15521. */
  15522. private _target;
  15523. /**
  15524. * Internal only
  15525. * @hidden
  15526. */
  15527. private _effectiveTarget;
  15528. /**
  15529. * Internal only
  15530. * @hidden
  15531. */
  15532. private _property;
  15533. /**
  15534. * Creates a new ValueCondition
  15535. * @param actionManager manager for the action the condition applies to
  15536. * @param target for the action
  15537. * @param propertyPath path to specify the property of the target the conditional operator uses
  15538. * @param value the value compared by the conditional operator against the current value of the property
  15539. * @param operator the conditional operator, default ValueCondition.IsEqual
  15540. */
  15541. constructor(actionManager: ActionManager, target: any,
  15542. /** path to specify the property of the target the conditional operator uses */
  15543. propertyPath: string,
  15544. /** the value compared by the conditional operator against the current value of the property */
  15545. value: any,
  15546. /** the conditional operator, default ValueCondition.IsEqual */
  15547. operator?: number);
  15548. /**
  15549. * Compares the given value with the property value for the specified conditional operator
  15550. * @returns the result of the comparison
  15551. */
  15552. isValid(): boolean;
  15553. /**
  15554. * Serialize the ValueCondition into a JSON compatible object
  15555. * @returns serialization object
  15556. */
  15557. serialize(): any;
  15558. /**
  15559. * Gets the name of the conditional operator for the ValueCondition
  15560. * @param operator the conditional operator
  15561. * @returns the name
  15562. */
  15563. static GetOperatorName(operator: number): string;
  15564. }
  15565. /**
  15566. * Defines a predicate condition as an extension of Condition
  15567. */
  15568. export class PredicateCondition extends Condition {
  15569. /** defines the predicate function used to validate the condition */
  15570. predicate: () => boolean;
  15571. /**
  15572. * Internal only - manager for action
  15573. * @hidden
  15574. */
  15575. _actionManager: ActionManager;
  15576. /**
  15577. * Creates a new PredicateCondition
  15578. * @param actionManager manager for the action the condition applies to
  15579. * @param predicate defines the predicate function used to validate the condition
  15580. */
  15581. constructor(actionManager: ActionManager,
  15582. /** defines the predicate function used to validate the condition */
  15583. predicate: () => boolean);
  15584. /**
  15585. * @returns the validity of the predicate condition
  15586. */
  15587. isValid(): boolean;
  15588. }
  15589. /**
  15590. * Defines a state condition as an extension of Condition
  15591. */
  15592. export class StateCondition extends Condition {
  15593. /** Value to compare with target state */
  15594. value: string;
  15595. /**
  15596. * Internal only - manager for action
  15597. * @hidden
  15598. */
  15599. _actionManager: ActionManager;
  15600. /**
  15601. * Internal only
  15602. * @hidden
  15603. */
  15604. private _target;
  15605. /**
  15606. * Creates a new StateCondition
  15607. * @param actionManager manager for the action the condition applies to
  15608. * @param target of the condition
  15609. * @param value to compare with target state
  15610. */
  15611. constructor(actionManager: ActionManager, target: any,
  15612. /** Value to compare with target state */
  15613. value: string);
  15614. /**
  15615. * Gets a boolean indicating if the current condition is met
  15616. * @returns the validity of the state
  15617. */
  15618. isValid(): boolean;
  15619. /**
  15620. * Serialize the StateCondition into a JSON compatible object
  15621. * @returns serialization object
  15622. */
  15623. serialize(): any;
  15624. }
  15625. }
  15626. declare module "babylonjs/Actions/directActions" {
  15627. import { Action } from "babylonjs/Actions/action";
  15628. import { Condition } from "babylonjs/Actions/condition";
  15629. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  15630. /**
  15631. * This defines an action responsible to toggle a boolean once triggered.
  15632. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15633. */
  15634. export class SwitchBooleanAction extends Action {
  15635. /**
  15636. * The path to the boolean property in the target object
  15637. */
  15638. propertyPath: string;
  15639. private _target;
  15640. private _effectiveTarget;
  15641. private _property;
  15642. /**
  15643. * Instantiate the action
  15644. * @param triggerOptions defines the trigger options
  15645. * @param target defines the object containing the boolean
  15646. * @param propertyPath defines the path to the boolean property in the target object
  15647. * @param condition defines the trigger related conditions
  15648. */
  15649. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  15650. /** @hidden */
  15651. _prepare(): void;
  15652. /**
  15653. * Execute the action toggle the boolean value.
  15654. */
  15655. execute(): void;
  15656. /**
  15657. * Serializes the actions and its related information.
  15658. * @param parent defines the object to serialize in
  15659. * @returns the serialized object
  15660. */
  15661. serialize(parent: any): any;
  15662. }
  15663. /**
  15664. * This defines an action responsible to set a the state field of the target
  15665. * to a desired value once triggered.
  15666. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15667. */
  15668. export class SetStateAction extends Action {
  15669. /**
  15670. * The value to store in the state field.
  15671. */
  15672. value: string;
  15673. private _target;
  15674. /**
  15675. * Instantiate the action
  15676. * @param triggerOptions defines the trigger options
  15677. * @param target defines the object containing the state property
  15678. * @param value defines the value to store in the state field
  15679. * @param condition defines the trigger related conditions
  15680. */
  15681. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  15682. /**
  15683. * Execute the action and store the value on the target state property.
  15684. */
  15685. execute(): void;
  15686. /**
  15687. * Serializes the actions and its related information.
  15688. * @param parent defines the object to serialize in
  15689. * @returns the serialized object
  15690. */
  15691. serialize(parent: any): any;
  15692. }
  15693. /**
  15694. * This defines an action responsible to set a property of the target
  15695. * to a desired value once triggered.
  15696. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15697. */
  15698. export class SetValueAction extends Action {
  15699. /**
  15700. * The path of the property to set in the target.
  15701. */
  15702. propertyPath: string;
  15703. /**
  15704. * The value to set in the property
  15705. */
  15706. value: any;
  15707. private _target;
  15708. private _effectiveTarget;
  15709. private _property;
  15710. /**
  15711. * Instantiate the action
  15712. * @param triggerOptions defines the trigger options
  15713. * @param target defines the object containing the property
  15714. * @param propertyPath defines the path of the property to set in the target
  15715. * @param value defines the value to set in the property
  15716. * @param condition defines the trigger related conditions
  15717. */
  15718. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  15719. /** @hidden */
  15720. _prepare(): void;
  15721. /**
  15722. * Execute the action and set the targetted property to the desired value.
  15723. */
  15724. execute(): void;
  15725. /**
  15726. * Serializes the actions and its related information.
  15727. * @param parent defines the object to serialize in
  15728. * @returns the serialized object
  15729. */
  15730. serialize(parent: any): any;
  15731. }
  15732. /**
  15733. * This defines an action responsible to increment the target value
  15734. * to a desired value once triggered.
  15735. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15736. */
  15737. export class IncrementValueAction extends Action {
  15738. /**
  15739. * The path of the property to increment in the target.
  15740. */
  15741. propertyPath: string;
  15742. /**
  15743. * The value we should increment the property by.
  15744. */
  15745. value: any;
  15746. private _target;
  15747. private _effectiveTarget;
  15748. private _property;
  15749. /**
  15750. * Instantiate the action
  15751. * @param triggerOptions defines the trigger options
  15752. * @param target defines the object containing the property
  15753. * @param propertyPath defines the path of the property to increment in the target
  15754. * @param value defines the value value we should increment the property by
  15755. * @param condition defines the trigger related conditions
  15756. */
  15757. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  15758. /** @hidden */
  15759. _prepare(): void;
  15760. /**
  15761. * Execute the action and increment the target of the value amount.
  15762. */
  15763. execute(): void;
  15764. /**
  15765. * Serializes the actions and its related information.
  15766. * @param parent defines the object to serialize in
  15767. * @returns the serialized object
  15768. */
  15769. serialize(parent: any): any;
  15770. }
  15771. /**
  15772. * This defines an action responsible to start an animation once triggered.
  15773. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15774. */
  15775. export class PlayAnimationAction extends Action {
  15776. /**
  15777. * Where the animation should start (animation frame)
  15778. */
  15779. from: number;
  15780. /**
  15781. * Where the animation should stop (animation frame)
  15782. */
  15783. to: number;
  15784. /**
  15785. * Define if the animation should loop or stop after the first play.
  15786. */
  15787. loop?: boolean;
  15788. private _target;
  15789. /**
  15790. * Instantiate the action
  15791. * @param triggerOptions defines the trigger options
  15792. * @param target defines the target animation or animation name
  15793. * @param from defines from where the animation should start (animation frame)
  15794. * @param end defines where the animation should stop (animation frame)
  15795. * @param loop defines if the animation should loop or stop after the first play
  15796. * @param condition defines the trigger related conditions
  15797. */
  15798. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  15799. /** @hidden */
  15800. _prepare(): void;
  15801. /**
  15802. * Execute the action and play the animation.
  15803. */
  15804. execute(): void;
  15805. /**
  15806. * Serializes the actions and its related information.
  15807. * @param parent defines the object to serialize in
  15808. * @returns the serialized object
  15809. */
  15810. serialize(parent: any): any;
  15811. }
  15812. /**
  15813. * This defines an action responsible to stop an animation once triggered.
  15814. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15815. */
  15816. export class StopAnimationAction extends Action {
  15817. private _target;
  15818. /**
  15819. * Instantiate the action
  15820. * @param triggerOptions defines the trigger options
  15821. * @param target defines the target animation or animation name
  15822. * @param condition defines the trigger related conditions
  15823. */
  15824. constructor(triggerOptions: any, target: any, condition?: Condition);
  15825. /** @hidden */
  15826. _prepare(): void;
  15827. /**
  15828. * Execute the action and stop the animation.
  15829. */
  15830. execute(): void;
  15831. /**
  15832. * Serializes the actions and its related information.
  15833. * @param parent defines the object to serialize in
  15834. * @returns the serialized object
  15835. */
  15836. serialize(parent: any): any;
  15837. }
  15838. /**
  15839. * This defines an action responsible that does nothing once triggered.
  15840. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15841. */
  15842. export class DoNothingAction extends Action {
  15843. /**
  15844. * Instantiate the action
  15845. * @param triggerOptions defines the trigger options
  15846. * @param condition defines the trigger related conditions
  15847. */
  15848. constructor(triggerOptions?: any, condition?: Condition);
  15849. /**
  15850. * Execute the action and do nothing.
  15851. */
  15852. execute(): void;
  15853. /**
  15854. * Serializes the actions and its related information.
  15855. * @param parent defines the object to serialize in
  15856. * @returns the serialized object
  15857. */
  15858. serialize(parent: any): any;
  15859. }
  15860. /**
  15861. * This defines an action responsible to trigger several actions once triggered.
  15862. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15863. */
  15864. export class CombineAction extends Action {
  15865. /**
  15866. * The list of aggregated animations to run.
  15867. */
  15868. children: Action[];
  15869. /**
  15870. * Instantiate the action
  15871. * @param triggerOptions defines the trigger options
  15872. * @param children defines the list of aggregated animations to run
  15873. * @param condition defines the trigger related conditions
  15874. */
  15875. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  15876. /** @hidden */
  15877. _prepare(): void;
  15878. /**
  15879. * Execute the action and executes all the aggregated actions.
  15880. */
  15881. execute(evt: ActionEvent): void;
  15882. /**
  15883. * Serializes the actions and its related information.
  15884. * @param parent defines the object to serialize in
  15885. * @returns the serialized object
  15886. */
  15887. serialize(parent: any): any;
  15888. }
  15889. /**
  15890. * This defines an action responsible to run code (external event) once triggered.
  15891. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15892. */
  15893. export class ExecuteCodeAction extends Action {
  15894. /**
  15895. * The callback function to run.
  15896. */
  15897. func: (evt: ActionEvent) => void;
  15898. /**
  15899. * Instantiate the action
  15900. * @param triggerOptions defines the trigger options
  15901. * @param func defines the callback function to run
  15902. * @param condition defines the trigger related conditions
  15903. */
  15904. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  15905. /**
  15906. * Execute the action and run the attached code.
  15907. */
  15908. execute(evt: ActionEvent): void;
  15909. }
  15910. /**
  15911. * This defines an action responsible to set the parent property of the target once triggered.
  15912. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15913. */
  15914. export class SetParentAction extends Action {
  15915. private _parent;
  15916. private _target;
  15917. /**
  15918. * Instantiate the action
  15919. * @param triggerOptions defines the trigger options
  15920. * @param target defines the target containing the parent property
  15921. * @param parent defines from where the animation should start (animation frame)
  15922. * @param condition defines the trigger related conditions
  15923. */
  15924. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  15925. /** @hidden */
  15926. _prepare(): void;
  15927. /**
  15928. * Execute the action and set the parent property.
  15929. */
  15930. execute(): void;
  15931. /**
  15932. * Serializes the actions and its related information.
  15933. * @param parent defines the object to serialize in
  15934. * @returns the serialized object
  15935. */
  15936. serialize(parent: any): any;
  15937. }
  15938. }
  15939. declare module "babylonjs/Actions/actionManager" {
  15940. import { Nullable } from "babylonjs/types";
  15941. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15942. import { Scene } from "babylonjs/scene";
  15943. import { IAction } from "babylonjs/Actions/action";
  15944. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  15945. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  15946. /**
  15947. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  15948. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  15949. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15950. */
  15951. export class ActionManager extends AbstractActionManager {
  15952. /**
  15953. * Nothing
  15954. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15955. */
  15956. static readonly NothingTrigger: number;
  15957. /**
  15958. * On pick
  15959. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15960. */
  15961. static readonly OnPickTrigger: number;
  15962. /**
  15963. * On left pick
  15964. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15965. */
  15966. static readonly OnLeftPickTrigger: number;
  15967. /**
  15968. * On right pick
  15969. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15970. */
  15971. static readonly OnRightPickTrigger: number;
  15972. /**
  15973. * On center pick
  15974. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15975. */
  15976. static readonly OnCenterPickTrigger: number;
  15977. /**
  15978. * On pick down
  15979. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15980. */
  15981. static readonly OnPickDownTrigger: number;
  15982. /**
  15983. * On double pick
  15984. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15985. */
  15986. static readonly OnDoublePickTrigger: number;
  15987. /**
  15988. * On pick up
  15989. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15990. */
  15991. static readonly OnPickUpTrigger: number;
  15992. /**
  15993. * On pick out.
  15994. * This trigger will only be raised if you also declared a OnPickDown
  15995. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15996. */
  15997. static readonly OnPickOutTrigger: number;
  15998. /**
  15999. * On long press
  16000. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16001. */
  16002. static readonly OnLongPressTrigger: number;
  16003. /**
  16004. * On pointer over
  16005. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16006. */
  16007. static readonly OnPointerOverTrigger: number;
  16008. /**
  16009. * On pointer out
  16010. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16011. */
  16012. static readonly OnPointerOutTrigger: number;
  16013. /**
  16014. * On every frame
  16015. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16016. */
  16017. static readonly OnEveryFrameTrigger: number;
  16018. /**
  16019. * On intersection enter
  16020. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16021. */
  16022. static readonly OnIntersectionEnterTrigger: number;
  16023. /**
  16024. * On intersection exit
  16025. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16026. */
  16027. static readonly OnIntersectionExitTrigger: number;
  16028. /**
  16029. * On key down
  16030. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16031. */
  16032. static readonly OnKeyDownTrigger: number;
  16033. /**
  16034. * On key up
  16035. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16036. */
  16037. static readonly OnKeyUpTrigger: number;
  16038. private _scene;
  16039. /**
  16040. * Creates a new action manager
  16041. * @param scene defines the hosting scene
  16042. */
  16043. constructor(scene: Scene);
  16044. /**
  16045. * Releases all associated resources
  16046. */
  16047. dispose(): void;
  16048. /**
  16049. * Gets hosting scene
  16050. * @returns the hosting scene
  16051. */
  16052. getScene(): Scene;
  16053. /**
  16054. * Does this action manager handles actions of any of the given triggers
  16055. * @param triggers defines the triggers to be tested
  16056. * @return a boolean indicating whether one (or more) of the triggers is handled
  16057. */
  16058. hasSpecificTriggers(triggers: number[]): boolean;
  16059. /**
  16060. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  16061. * speed.
  16062. * @param triggerA defines the trigger to be tested
  16063. * @param triggerB defines the trigger to be tested
  16064. * @return a boolean indicating whether one (or more) of the triggers is handled
  16065. */
  16066. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  16067. /**
  16068. * Does this action manager handles actions of a given trigger
  16069. * @param trigger defines the trigger to be tested
  16070. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  16071. * @return whether the trigger is handled
  16072. */
  16073. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  16074. /**
  16075. * Does this action manager has pointer triggers
  16076. */
  16077. readonly hasPointerTriggers: boolean;
  16078. /**
  16079. * Does this action manager has pick triggers
  16080. */
  16081. readonly hasPickTriggers: boolean;
  16082. /**
  16083. * Registers an action to this action manager
  16084. * @param action defines the action to be registered
  16085. * @return the action amended (prepared) after registration
  16086. */
  16087. registerAction(action: IAction): Nullable<IAction>;
  16088. /**
  16089. * Unregisters an action to this action manager
  16090. * @param action defines the action to be unregistered
  16091. * @return a boolean indicating whether the action has been unregistered
  16092. */
  16093. unregisterAction(action: IAction): Boolean;
  16094. /**
  16095. * Process a specific trigger
  16096. * @param trigger defines the trigger to process
  16097. * @param evt defines the event details to be processed
  16098. */
  16099. processTrigger(trigger: number, evt?: IActionEvent): void;
  16100. /** @hidden */
  16101. _getEffectiveTarget(target: any, propertyPath: string): any;
  16102. /** @hidden */
  16103. _getProperty(propertyPath: string): string;
  16104. /**
  16105. * Serialize this manager to a JSON object
  16106. * @param name defines the property name to store this manager
  16107. * @returns a JSON representation of this manager
  16108. */
  16109. serialize(name: string): any;
  16110. /**
  16111. * Creates a new ActionManager from a JSON data
  16112. * @param parsedActions defines the JSON data to read from
  16113. * @param object defines the hosting mesh
  16114. * @param scene defines the hosting scene
  16115. */
  16116. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  16117. /**
  16118. * Get a trigger name by index
  16119. * @param trigger defines the trigger index
  16120. * @returns a trigger name
  16121. */
  16122. static GetTriggerName(trigger: number): string;
  16123. }
  16124. }
  16125. declare module "babylonjs/Culling/ray" {
  16126. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  16127. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  16128. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16129. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  16130. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  16131. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  16132. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  16133. /**
  16134. * Class representing a ray with position and direction
  16135. */
  16136. export class Ray {
  16137. /** origin point */
  16138. origin: Vector3;
  16139. /** direction */
  16140. direction: Vector3;
  16141. /** length of the ray */
  16142. length: number;
  16143. private static readonly TmpVector3;
  16144. private _tmpRay;
  16145. /**
  16146. * Creates a new ray
  16147. * @param origin origin point
  16148. * @param direction direction
  16149. * @param length length of the ray
  16150. */
  16151. constructor(
  16152. /** origin point */
  16153. origin: Vector3,
  16154. /** direction */
  16155. direction: Vector3,
  16156. /** length of the ray */
  16157. length?: number);
  16158. /**
  16159. * Checks if the ray intersects a box
  16160. * @param minimum bound of the box
  16161. * @param maximum bound of the box
  16162. * @param intersectionTreshold extra extend to be added to the box in all direction
  16163. * @returns if the box was hit
  16164. */
  16165. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  16166. /**
  16167. * Checks if the ray intersects a box
  16168. * @param box the bounding box to check
  16169. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  16170. * @returns if the box was hit
  16171. */
  16172. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  16173. /**
  16174. * If the ray hits a sphere
  16175. * @param sphere the bounding sphere to check
  16176. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  16177. * @returns true if it hits the sphere
  16178. */
  16179. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  16180. /**
  16181. * If the ray hits a triange
  16182. * @param vertex0 triangle vertex
  16183. * @param vertex1 triangle vertex
  16184. * @param vertex2 triangle vertex
  16185. * @returns intersection information if hit
  16186. */
  16187. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  16188. /**
  16189. * Checks if ray intersects a plane
  16190. * @param plane the plane to check
  16191. * @returns the distance away it was hit
  16192. */
  16193. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  16194. /**
  16195. * Checks if ray intersects a mesh
  16196. * @param mesh the mesh to check
  16197. * @param fastCheck if only the bounding box should checked
  16198. * @returns picking info of the intersecton
  16199. */
  16200. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  16201. /**
  16202. * Checks if ray intersects a mesh
  16203. * @param meshes the meshes to check
  16204. * @param fastCheck if only the bounding box should checked
  16205. * @param results array to store result in
  16206. * @returns Array of picking infos
  16207. */
  16208. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  16209. private _comparePickingInfo;
  16210. private static smallnum;
  16211. private static rayl;
  16212. /**
  16213. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  16214. * @param sega the first point of the segment to test the intersection against
  16215. * @param segb the second point of the segment to test the intersection against
  16216. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  16217. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  16218. */
  16219. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  16220. /**
  16221. * Update the ray from viewport position
  16222. * @param x position
  16223. * @param y y position
  16224. * @param viewportWidth viewport width
  16225. * @param viewportHeight viewport height
  16226. * @param world world matrix
  16227. * @param view view matrix
  16228. * @param projection projection matrix
  16229. * @returns this ray updated
  16230. */
  16231. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  16232. /**
  16233. * Creates a ray with origin and direction of 0,0,0
  16234. * @returns the new ray
  16235. */
  16236. static Zero(): Ray;
  16237. /**
  16238. * Creates a new ray from screen space and viewport
  16239. * @param x position
  16240. * @param y y position
  16241. * @param viewportWidth viewport width
  16242. * @param viewportHeight viewport height
  16243. * @param world world matrix
  16244. * @param view view matrix
  16245. * @param projection projection matrix
  16246. * @returns new ray
  16247. */
  16248. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  16249. /**
  16250. * 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
  16251. * transformed to the given world matrix.
  16252. * @param origin The origin point
  16253. * @param end The end point
  16254. * @param world a matrix to transform the ray to. Default is the identity matrix.
  16255. * @returns the new ray
  16256. */
  16257. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  16258. /**
  16259. * Transforms a ray by a matrix
  16260. * @param ray ray to transform
  16261. * @param matrix matrix to apply
  16262. * @returns the resulting new ray
  16263. */
  16264. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  16265. /**
  16266. * Transforms a ray by a matrix
  16267. * @param ray ray to transform
  16268. * @param matrix matrix to apply
  16269. * @param result ray to store result in
  16270. */
  16271. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  16272. /**
  16273. * Unproject a ray from screen space to object space
  16274. * @param sourceX defines the screen space x coordinate to use
  16275. * @param sourceY defines the screen space y coordinate to use
  16276. * @param viewportWidth defines the current width of the viewport
  16277. * @param viewportHeight defines the current height of the viewport
  16278. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  16279. * @param view defines the view matrix to use
  16280. * @param projection defines the projection matrix to use
  16281. */
  16282. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  16283. }
  16284. /**
  16285. * Type used to define predicate used to select faces when a mesh intersection is detected
  16286. */
  16287. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  16288. module "babylonjs/scene" {
  16289. interface Scene {
  16290. /** @hidden */
  16291. _tempPickingRay: Nullable<Ray>;
  16292. /** @hidden */
  16293. _cachedRayForTransform: Ray;
  16294. /** @hidden */
  16295. _pickWithRayInverseMatrix: Matrix;
  16296. /** @hidden */
  16297. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  16298. /** @hidden */
  16299. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  16300. }
  16301. }
  16302. }
  16303. declare module "babylonjs/Sprites/spriteSceneComponent" {
  16304. import { Nullable } from "babylonjs/types";
  16305. import { Observable } from "babylonjs/Misc/observable";
  16306. import { Scene } from "babylonjs/scene";
  16307. import { Sprite } from "babylonjs/Sprites/sprite";
  16308. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16309. import { Ray } from "babylonjs/Culling/ray";
  16310. import { Camera } from "babylonjs/Cameras/camera";
  16311. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  16312. import { ISceneComponent } from "babylonjs/sceneComponent";
  16313. module "babylonjs/scene" {
  16314. interface Scene {
  16315. /** @hidden */
  16316. _pointerOverSprite: Nullable<Sprite>;
  16317. /** @hidden */
  16318. _pickedDownSprite: Nullable<Sprite>;
  16319. /** @hidden */
  16320. _tempSpritePickingRay: Nullable<Ray>;
  16321. /**
  16322. * All of the sprite managers added to this scene
  16323. * @see http://doc.babylonjs.com/babylon101/sprites
  16324. */
  16325. spriteManagers: Array<ISpriteManager>;
  16326. /**
  16327. * An event triggered when sprites rendering is about to start
  16328. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  16329. */
  16330. onBeforeSpritesRenderingObservable: Observable<Scene>;
  16331. /**
  16332. * An event triggered when sprites rendering is done
  16333. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  16334. */
  16335. onAfterSpritesRenderingObservable: Observable<Scene>;
  16336. /** @hidden */
  16337. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  16338. /** Launch a ray to try to pick a sprite in the scene
  16339. * @param x position on screen
  16340. * @param y position on screen
  16341. * @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
  16342. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  16343. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  16344. * @returns a PickingInfo
  16345. */
  16346. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  16347. /** Use the given ray to pick a sprite in the scene
  16348. * @param ray The ray (in world space) to use to pick meshes
  16349. * @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
  16350. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  16351. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  16352. * @returns a PickingInfo
  16353. */
  16354. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  16355. /**
  16356. * Force the sprite under the pointer
  16357. * @param sprite defines the sprite to use
  16358. */
  16359. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  16360. /**
  16361. * Gets the sprite under the pointer
  16362. * @returns a Sprite or null if no sprite is under the pointer
  16363. */
  16364. getPointerOverSprite(): Nullable<Sprite>;
  16365. }
  16366. }
  16367. /**
  16368. * Defines the sprite scene component responsible to manage sprites
  16369. * in a given scene.
  16370. */
  16371. export class SpriteSceneComponent implements ISceneComponent {
  16372. /**
  16373. * The component name helpfull to identify the component in the list of scene components.
  16374. */
  16375. readonly name: string;
  16376. /**
  16377. * The scene the component belongs to.
  16378. */
  16379. scene: Scene;
  16380. /** @hidden */
  16381. private _spritePredicate;
  16382. /**
  16383. * Creates a new instance of the component for the given scene
  16384. * @param scene Defines the scene to register the component in
  16385. */
  16386. constructor(scene: Scene);
  16387. /**
  16388. * Registers the component in a given scene
  16389. */
  16390. register(): void;
  16391. /**
  16392. * Rebuilds the elements related to this component in case of
  16393. * context lost for instance.
  16394. */
  16395. rebuild(): void;
  16396. /**
  16397. * Disposes the component and the associated ressources.
  16398. */
  16399. dispose(): void;
  16400. private _pickSpriteButKeepRay;
  16401. private _pointerMove;
  16402. private _pointerDown;
  16403. private _pointerUp;
  16404. }
  16405. }
  16406. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  16407. /** @hidden */
  16408. export var fogFragmentDeclaration: {
  16409. name: string;
  16410. shader: string;
  16411. };
  16412. }
  16413. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  16414. /** @hidden */
  16415. export var fogFragment: {
  16416. name: string;
  16417. shader: string;
  16418. };
  16419. }
  16420. declare module "babylonjs/Shaders/sprites.fragment" {
  16421. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  16422. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  16423. /** @hidden */
  16424. export var spritesPixelShader: {
  16425. name: string;
  16426. shader: string;
  16427. };
  16428. }
  16429. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  16430. /** @hidden */
  16431. export var fogVertexDeclaration: {
  16432. name: string;
  16433. shader: string;
  16434. };
  16435. }
  16436. declare module "babylonjs/Shaders/sprites.vertex" {
  16437. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  16438. /** @hidden */
  16439. export var spritesVertexShader: {
  16440. name: string;
  16441. shader: string;
  16442. };
  16443. }
  16444. declare module "babylonjs/Sprites/spriteManager" {
  16445. import { IDisposable, Scene } from "babylonjs/scene";
  16446. import { Nullable } from "babylonjs/types";
  16447. import { Observable } from "babylonjs/Misc/observable";
  16448. import { Sprite } from "babylonjs/Sprites/sprite";
  16449. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  16450. import { Camera } from "babylonjs/Cameras/camera";
  16451. import { Texture } from "babylonjs/Materials/Textures/texture";
  16452. import "babylonjs/Shaders/sprites.fragment";
  16453. import "babylonjs/Shaders/sprites.vertex";
  16454. import { Ray } from "babylonjs/Culling/ray";
  16455. /**
  16456. * Defines the minimum interface to fullfil in order to be a sprite manager.
  16457. */
  16458. export interface ISpriteManager extends IDisposable {
  16459. /**
  16460. * Restricts the camera to viewing objects with the same layerMask.
  16461. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  16462. */
  16463. layerMask: number;
  16464. /**
  16465. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  16466. */
  16467. isPickable: boolean;
  16468. /**
  16469. * Specifies the rendering group id for this mesh (0 by default)
  16470. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  16471. */
  16472. renderingGroupId: number;
  16473. /**
  16474. * Defines the list of sprites managed by the manager.
  16475. */
  16476. sprites: Array<Sprite>;
  16477. /**
  16478. * Tests the intersection of a sprite with a specific ray.
  16479. * @param ray The ray we are sending to test the collision
  16480. * @param camera The camera space we are sending rays in
  16481. * @param predicate A predicate allowing excluding sprites from the list of object to test
  16482. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  16483. * @returns picking info or null.
  16484. */
  16485. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  16486. /**
  16487. * Renders the list of sprites on screen.
  16488. */
  16489. render(): void;
  16490. }
  16491. /**
  16492. * Class used to manage multiple sprites on the same spritesheet
  16493. * @see http://doc.babylonjs.com/babylon101/sprites
  16494. */
  16495. export class SpriteManager implements ISpriteManager {
  16496. /** defines the manager's name */
  16497. name: string;
  16498. /** Gets the list of sprites */
  16499. sprites: Sprite[];
  16500. /** Gets or sets the rendering group id (0 by default) */
  16501. renderingGroupId: number;
  16502. /** Gets or sets camera layer mask */
  16503. layerMask: number;
  16504. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  16505. fogEnabled: boolean;
  16506. /** Gets or sets a boolean indicating if the sprites are pickable */
  16507. isPickable: boolean;
  16508. /** Defines the default width of a cell in the spritesheet */
  16509. cellWidth: number;
  16510. /** Defines the default height of a cell in the spritesheet */
  16511. cellHeight: number;
  16512. /**
  16513. * An event triggered when the manager is disposed.
  16514. */
  16515. onDisposeObservable: Observable<SpriteManager>;
  16516. private _onDisposeObserver;
  16517. /**
  16518. * Callback called when the manager is disposed
  16519. */
  16520. onDispose: () => void;
  16521. private _capacity;
  16522. private _spriteTexture;
  16523. private _epsilon;
  16524. private _scene;
  16525. private _vertexData;
  16526. private _buffer;
  16527. private _vertexBuffers;
  16528. private _indexBuffer;
  16529. private _effectBase;
  16530. private _effectFog;
  16531. /**
  16532. * Gets or sets the spritesheet texture
  16533. */
  16534. texture: Texture;
  16535. /**
  16536. * Creates a new sprite manager
  16537. * @param name defines the manager's name
  16538. * @param imgUrl defines the sprite sheet url
  16539. * @param capacity defines the maximum allowed number of sprites
  16540. * @param cellSize defines the size of a sprite cell
  16541. * @param scene defines the hosting scene
  16542. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  16543. * @param samplingMode defines the smapling mode to use with spritesheet
  16544. */
  16545. constructor(
  16546. /** defines the manager's name */
  16547. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  16548. private _appendSpriteVertex;
  16549. /**
  16550. * Intersects the sprites with a ray
  16551. * @param ray defines the ray to intersect with
  16552. * @param camera defines the current active camera
  16553. * @param predicate defines a predicate used to select candidate sprites
  16554. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  16555. * @returns null if no hit or a PickingInfo
  16556. */
  16557. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  16558. /**
  16559. * Render all child sprites
  16560. */
  16561. render(): void;
  16562. /**
  16563. * Release associated resources
  16564. */
  16565. dispose(): void;
  16566. }
  16567. }
  16568. declare module "babylonjs/Sprites/sprite" {
  16569. import { Vector3, Color4 } from "babylonjs/Maths/math";
  16570. import { Nullable } from "babylonjs/types";
  16571. import { ActionManager } from "babylonjs/Actions/actionManager";
  16572. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16573. /**
  16574. * Class used to represent a sprite
  16575. * @see http://doc.babylonjs.com/babylon101/sprites
  16576. */
  16577. export class Sprite {
  16578. /** defines the name */
  16579. name: string;
  16580. /** Gets or sets the current world position */
  16581. position: Vector3;
  16582. /** Gets or sets the main color */
  16583. color: Color4;
  16584. /** Gets or sets the width */
  16585. width: number;
  16586. /** Gets or sets the height */
  16587. height: number;
  16588. /** Gets or sets rotation angle */
  16589. angle: number;
  16590. /** Gets or sets the cell index in the sprite sheet */
  16591. cellIndex: number;
  16592. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  16593. invertU: number;
  16594. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  16595. invertV: number;
  16596. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  16597. disposeWhenFinishedAnimating: boolean;
  16598. /** Gets the list of attached animations */
  16599. animations: Animation[];
  16600. /** Gets or sets a boolean indicating if the sprite can be picked */
  16601. isPickable: boolean;
  16602. /**
  16603. * Gets or sets the associated action manager
  16604. */
  16605. actionManager: Nullable<ActionManager>;
  16606. private _animationStarted;
  16607. private _loopAnimation;
  16608. private _fromIndex;
  16609. private _toIndex;
  16610. private _delay;
  16611. private _direction;
  16612. private _manager;
  16613. private _time;
  16614. private _onAnimationEnd;
  16615. /**
  16616. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  16617. */
  16618. isVisible: boolean;
  16619. /**
  16620. * Gets or sets the sprite size
  16621. */
  16622. size: number;
  16623. /**
  16624. * Creates a new Sprite
  16625. * @param name defines the name
  16626. * @param manager defines the manager
  16627. */
  16628. constructor(
  16629. /** defines the name */
  16630. name: string, manager: ISpriteManager);
  16631. /**
  16632. * Starts an animation
  16633. * @param from defines the initial key
  16634. * @param to defines the end key
  16635. * @param loop defines if the animation must loop
  16636. * @param delay defines the start delay (in ms)
  16637. * @param onAnimationEnd defines a callback to call when animation ends
  16638. */
  16639. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  16640. /** Stops current animation (if any) */
  16641. stopAnimation(): void;
  16642. /** @hidden */
  16643. _animate(deltaTime: number): void;
  16644. /** Release associated resources */
  16645. dispose(): void;
  16646. }
  16647. }
  16648. declare module "babylonjs/Collisions/pickingInfo" {
  16649. import { Nullable } from "babylonjs/types";
  16650. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  16651. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16652. import { Sprite } from "babylonjs/Sprites/sprite";
  16653. import { Ray } from "babylonjs/Culling/ray";
  16654. /**
  16655. * Information about the result of picking within a scene
  16656. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  16657. */
  16658. export class PickingInfo {
  16659. /** @hidden */
  16660. _pickingUnavailable: boolean;
  16661. /**
  16662. * If the pick collided with an object
  16663. */
  16664. hit: boolean;
  16665. /**
  16666. * Distance away where the pick collided
  16667. */
  16668. distance: number;
  16669. /**
  16670. * The location of pick collision
  16671. */
  16672. pickedPoint: Nullable<Vector3>;
  16673. /**
  16674. * The mesh corresponding the the pick collision
  16675. */
  16676. pickedMesh: Nullable<AbstractMesh>;
  16677. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  16678. bu: number;
  16679. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  16680. bv: number;
  16681. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  16682. faceId: number;
  16683. /** Id of the the submesh that was picked */
  16684. subMeshId: number;
  16685. /** If a sprite was picked, this will be the sprite the pick collided with */
  16686. pickedSprite: Nullable<Sprite>;
  16687. /**
  16688. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  16689. */
  16690. originMesh: Nullable<AbstractMesh>;
  16691. /**
  16692. * The ray that was used to perform the picking.
  16693. */
  16694. ray: Nullable<Ray>;
  16695. /**
  16696. * Gets the normal correspodning to the face the pick collided with
  16697. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  16698. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  16699. * @returns The normal correspodning to the face the pick collided with
  16700. */
  16701. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  16702. /**
  16703. * Gets the texture coordinates of where the pick occured
  16704. * @returns the vector containing the coordnates of the texture
  16705. */
  16706. getTextureCoordinates(): Nullable<Vector2>;
  16707. }
  16708. }
  16709. declare module "babylonjs/Events/pointerEvents" {
  16710. import { Nullable } from "babylonjs/types";
  16711. import { Vector2 } from "babylonjs/Maths/math";
  16712. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  16713. import { Ray } from "babylonjs/Culling/ray";
  16714. /**
  16715. * Gather the list of pointer event types as constants.
  16716. */
  16717. export class PointerEventTypes {
  16718. /**
  16719. * 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.
  16720. */
  16721. static readonly POINTERDOWN: number;
  16722. /**
  16723. * The pointerup event is fired when a pointer is no longer active.
  16724. */
  16725. static readonly POINTERUP: number;
  16726. /**
  16727. * The pointermove event is fired when a pointer changes coordinates.
  16728. */
  16729. static readonly POINTERMOVE: number;
  16730. /**
  16731. * The pointerwheel event is fired when a mouse wheel has been rotated.
  16732. */
  16733. static readonly POINTERWHEEL: number;
  16734. /**
  16735. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  16736. */
  16737. static readonly POINTERPICK: number;
  16738. /**
  16739. * The pointertap event is fired when a the object has been touched and released without drag.
  16740. */
  16741. static readonly POINTERTAP: number;
  16742. /**
  16743. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  16744. */
  16745. static readonly POINTERDOUBLETAP: number;
  16746. }
  16747. /**
  16748. * Base class of pointer info types.
  16749. */
  16750. export class PointerInfoBase {
  16751. /**
  16752. * Defines the type of event (PointerEventTypes)
  16753. */
  16754. type: number;
  16755. /**
  16756. * Defines the related dom event
  16757. */
  16758. event: PointerEvent | MouseWheelEvent;
  16759. /**
  16760. * Instantiates the base class of pointers info.
  16761. * @param type Defines the type of event (PointerEventTypes)
  16762. * @param event Defines the related dom event
  16763. */
  16764. constructor(
  16765. /**
  16766. * Defines the type of event (PointerEventTypes)
  16767. */
  16768. type: number,
  16769. /**
  16770. * Defines the related dom event
  16771. */
  16772. event: PointerEvent | MouseWheelEvent);
  16773. }
  16774. /**
  16775. * This class is used to store pointer related info for the onPrePointerObservable event.
  16776. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  16777. */
  16778. export class PointerInfoPre extends PointerInfoBase {
  16779. /**
  16780. * Ray from a pointer if availible (eg. 6dof controller)
  16781. */
  16782. ray: Nullable<Ray>;
  16783. /**
  16784. * Defines the local position of the pointer on the canvas.
  16785. */
  16786. localPosition: Vector2;
  16787. /**
  16788. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  16789. */
  16790. skipOnPointerObservable: boolean;
  16791. /**
  16792. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  16793. * @param type Defines the type of event (PointerEventTypes)
  16794. * @param event Defines the related dom event
  16795. * @param localX Defines the local x coordinates of the pointer when the event occured
  16796. * @param localY Defines the local y coordinates of the pointer when the event occured
  16797. */
  16798. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  16799. }
  16800. /**
  16801. * This type contains all the data related to a pointer event in Babylon.js.
  16802. * 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.
  16803. */
  16804. export class PointerInfo extends PointerInfoBase {
  16805. /**
  16806. * Defines the picking info associated to the info (if any)\
  16807. */
  16808. pickInfo: Nullable<PickingInfo>;
  16809. /**
  16810. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  16811. * @param type Defines the type of event (PointerEventTypes)
  16812. * @param event Defines the related dom event
  16813. * @param pickInfo Defines the picking info associated to the info (if any)\
  16814. */
  16815. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  16816. /**
  16817. * Defines the picking info associated to the info (if any)\
  16818. */
  16819. pickInfo: Nullable<PickingInfo>);
  16820. }
  16821. /**
  16822. * Data relating to a touch event on the screen.
  16823. */
  16824. export interface PointerTouch {
  16825. /**
  16826. * X coordinate of touch.
  16827. */
  16828. x: number;
  16829. /**
  16830. * Y coordinate of touch.
  16831. */
  16832. y: number;
  16833. /**
  16834. * Id of touch. Unique for each finger.
  16835. */
  16836. pointerId: number;
  16837. /**
  16838. * Event type passed from DOM.
  16839. */
  16840. type: any;
  16841. }
  16842. }
  16843. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  16844. import { Observable } from "babylonjs/Misc/observable";
  16845. import { Nullable } from "babylonjs/types";
  16846. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  16847. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  16848. /**
  16849. * Manage the mouse inputs to control the movement of a free camera.
  16850. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  16851. */
  16852. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  16853. /**
  16854. * Define if touch is enabled in the mouse input
  16855. */
  16856. touchEnabled: boolean;
  16857. /**
  16858. * Defines the camera the input is attached to.
  16859. */
  16860. camera: FreeCamera;
  16861. /**
  16862. * Defines the buttons associated with the input to handle camera move.
  16863. */
  16864. buttons: number[];
  16865. /**
  16866. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  16867. */
  16868. angularSensibility: number;
  16869. private _pointerInput;
  16870. private _onMouseMove;
  16871. private _observer;
  16872. private previousPosition;
  16873. /**
  16874. * Observable for when a pointer move event occurs containing the move offset
  16875. */
  16876. onPointerMovedObservable: Observable<{
  16877. offsetX: number;
  16878. offsetY: number;
  16879. }>;
  16880. /**
  16881. * @hidden
  16882. * If the camera should be rotated automatically based on pointer movement
  16883. */
  16884. _allowCameraRotation: boolean;
  16885. /**
  16886. * Manage the mouse inputs to control the movement of a free camera.
  16887. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  16888. * @param touchEnabled Defines if touch is enabled or not
  16889. */
  16890. constructor(
  16891. /**
  16892. * Define if touch is enabled in the mouse input
  16893. */
  16894. touchEnabled?: boolean);
  16895. /**
  16896. * Attach the input controls to a specific dom element to get the input from.
  16897. * @param element Defines the element the controls should be listened from
  16898. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  16899. */
  16900. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  16901. /**
  16902. * Called on JS contextmenu event.
  16903. * Override this method to provide functionality.
  16904. */
  16905. protected onContextMenu(evt: PointerEvent): void;
  16906. /**
  16907. * Detach the current controls from the specified dom element.
  16908. * @param element Defines the element to stop listening the inputs from
  16909. */
  16910. detachControl(element: Nullable<HTMLElement>): void;
  16911. /**
  16912. * Gets the class name of the current intput.
  16913. * @returns the class name
  16914. */
  16915. getClassName(): string;
  16916. /**
  16917. * Get the friendly name associated with the input class.
  16918. * @returns the input friendly name
  16919. */
  16920. getSimpleName(): string;
  16921. }
  16922. }
  16923. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  16924. import { Nullable } from "babylonjs/types";
  16925. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  16926. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  16927. /**
  16928. * Manage the touch inputs to control the movement of a free camera.
  16929. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  16930. */
  16931. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  16932. /**
  16933. * Defines the camera the input is attached to.
  16934. */
  16935. camera: FreeCamera;
  16936. /**
  16937. * Defines the touch sensibility for rotation.
  16938. * The higher the faster.
  16939. */
  16940. touchAngularSensibility: number;
  16941. /**
  16942. * Defines the touch sensibility for move.
  16943. * The higher the faster.
  16944. */
  16945. touchMoveSensibility: number;
  16946. private _offsetX;
  16947. private _offsetY;
  16948. private _pointerPressed;
  16949. private _pointerInput;
  16950. private _observer;
  16951. private _onLostFocus;
  16952. /**
  16953. * Attach the input controls to a specific dom element to get the input from.
  16954. * @param element Defines the element the controls should be listened from
  16955. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  16956. */
  16957. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  16958. /**
  16959. * Detach the current controls from the specified dom element.
  16960. * @param element Defines the element to stop listening the inputs from
  16961. */
  16962. detachControl(element: Nullable<HTMLElement>): void;
  16963. /**
  16964. * Update the current camera state depending on the inputs that have been used this frame.
  16965. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  16966. */
  16967. checkInputs(): void;
  16968. /**
  16969. * Gets the class name of the current intput.
  16970. * @returns the class name
  16971. */
  16972. getClassName(): string;
  16973. /**
  16974. * Get the friendly name associated with the input class.
  16975. * @returns the input friendly name
  16976. */
  16977. getSimpleName(): string;
  16978. }
  16979. }
  16980. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  16981. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  16982. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  16983. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  16984. import { Nullable } from "babylonjs/types";
  16985. /**
  16986. * Default Inputs manager for the FreeCamera.
  16987. * It groups all the default supported inputs for ease of use.
  16988. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  16989. */
  16990. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  16991. /**
  16992. * @hidden
  16993. */
  16994. _mouseInput: Nullable<FreeCameraMouseInput>;
  16995. /**
  16996. * Instantiates a new FreeCameraInputsManager.
  16997. * @param camera Defines the camera the inputs belong to
  16998. */
  16999. constructor(camera: FreeCamera);
  17000. /**
  17001. * Add keyboard input support to the input manager.
  17002. * @returns the current input manager
  17003. */
  17004. addKeyboard(): FreeCameraInputsManager;
  17005. /**
  17006. * Add mouse input support to the input manager.
  17007. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  17008. * @returns the current input manager
  17009. */
  17010. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  17011. /**
  17012. * Removes the mouse input support from the manager
  17013. * @returns the current input manager
  17014. */
  17015. removeMouse(): FreeCameraInputsManager;
  17016. /**
  17017. * Add touch input support to the input manager.
  17018. * @returns the current input manager
  17019. */
  17020. addTouch(): FreeCameraInputsManager;
  17021. /**
  17022. * Remove all attached input methods from a camera
  17023. */
  17024. clear(): void;
  17025. }
  17026. }
  17027. declare module "babylonjs/Cameras/freeCamera" {
  17028. import { Vector3 } from "babylonjs/Maths/math";
  17029. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17030. import { Scene } from "babylonjs/scene";
  17031. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  17032. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  17033. /**
  17034. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  17035. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  17036. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  17037. */
  17038. export class FreeCamera extends TargetCamera {
  17039. /**
  17040. * Define the collision ellipsoid of the camera.
  17041. * This is helpful to simulate a camera body like the player body around the camera
  17042. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  17043. */
  17044. ellipsoid: Vector3;
  17045. /**
  17046. * Define an offset for the position of the ellipsoid around the camera.
  17047. * This can be helpful to determine the center of the body near the gravity center of the body
  17048. * instead of its head.
  17049. */
  17050. ellipsoidOffset: Vector3;
  17051. /**
  17052. * Enable or disable collisions of the camera with the rest of the scene objects.
  17053. */
  17054. checkCollisions: boolean;
  17055. /**
  17056. * Enable or disable gravity on the camera.
  17057. */
  17058. applyGravity: boolean;
  17059. /**
  17060. * Define the input manager associated to the camera.
  17061. */
  17062. inputs: FreeCameraInputsManager;
  17063. /**
  17064. * Gets the input sensibility for a mouse input. (default is 2000.0)
  17065. * Higher values reduce sensitivity.
  17066. */
  17067. /**
  17068. * Sets the input sensibility for a mouse input. (default is 2000.0)
  17069. * Higher values reduce sensitivity.
  17070. */
  17071. angularSensibility: number;
  17072. /**
  17073. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  17074. */
  17075. keysUp: number[];
  17076. /**
  17077. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  17078. */
  17079. keysDown: number[];
  17080. /**
  17081. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  17082. */
  17083. keysLeft: number[];
  17084. /**
  17085. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  17086. */
  17087. keysRight: number[];
  17088. /**
  17089. * Event raised when the camera collide with a mesh in the scene.
  17090. */
  17091. onCollide: (collidedMesh: AbstractMesh) => void;
  17092. private _collider;
  17093. private _needMoveForGravity;
  17094. private _oldPosition;
  17095. private _diffPosition;
  17096. private _newPosition;
  17097. /** @hidden */
  17098. _localDirection: Vector3;
  17099. /** @hidden */
  17100. _transformedDirection: Vector3;
  17101. /**
  17102. * Instantiates a Free Camera.
  17103. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  17104. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  17105. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  17106. * @param name Define the name of the camera in the scene
  17107. * @param position Define the start position of the camera in the scene
  17108. * @param scene Define the scene the camera belongs to
  17109. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  17110. */
  17111. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  17112. /**
  17113. * Attached controls to the current camera.
  17114. * @param element Defines the element the controls should be listened from
  17115. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  17116. */
  17117. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  17118. /**
  17119. * Detach the current controls from the camera.
  17120. * The camera will stop reacting to inputs.
  17121. * @param element Defines the element to stop listening the inputs from
  17122. */
  17123. detachControl(element: HTMLElement): void;
  17124. private _collisionMask;
  17125. /**
  17126. * Define a collision mask to limit the list of object the camera can collide with
  17127. */
  17128. collisionMask: number;
  17129. /** @hidden */
  17130. _collideWithWorld(displacement: Vector3): void;
  17131. private _onCollisionPositionChange;
  17132. /** @hidden */
  17133. _checkInputs(): void;
  17134. /** @hidden */
  17135. _decideIfNeedsToMove(): boolean;
  17136. /** @hidden */
  17137. _updatePosition(): void;
  17138. /**
  17139. * Destroy the camera and release the current resources hold by it.
  17140. */
  17141. dispose(): void;
  17142. /**
  17143. * Gets the current object class name.
  17144. * @return the class name
  17145. */
  17146. getClassName(): string;
  17147. }
  17148. }
  17149. declare module "babylonjs/Gamepads/gamepad" {
  17150. import { Observable } from "babylonjs/Misc/observable";
  17151. /**
  17152. * Represents a gamepad control stick position
  17153. */
  17154. export class StickValues {
  17155. /**
  17156. * The x component of the control stick
  17157. */
  17158. x: number;
  17159. /**
  17160. * The y component of the control stick
  17161. */
  17162. y: number;
  17163. /**
  17164. * Initializes the gamepad x and y control stick values
  17165. * @param x The x component of the gamepad control stick value
  17166. * @param y The y component of the gamepad control stick value
  17167. */
  17168. constructor(
  17169. /**
  17170. * The x component of the control stick
  17171. */
  17172. x: number,
  17173. /**
  17174. * The y component of the control stick
  17175. */
  17176. y: number);
  17177. }
  17178. /**
  17179. * An interface which manages callbacks for gamepad button changes
  17180. */
  17181. export interface GamepadButtonChanges {
  17182. /**
  17183. * Called when a gamepad has been changed
  17184. */
  17185. changed: boolean;
  17186. /**
  17187. * Called when a gamepad press event has been triggered
  17188. */
  17189. pressChanged: boolean;
  17190. /**
  17191. * Called when a touch event has been triggered
  17192. */
  17193. touchChanged: boolean;
  17194. /**
  17195. * Called when a value has changed
  17196. */
  17197. valueChanged: boolean;
  17198. }
  17199. /**
  17200. * Represents a gamepad
  17201. */
  17202. export class Gamepad {
  17203. /**
  17204. * The id of the gamepad
  17205. */
  17206. id: string;
  17207. /**
  17208. * The index of the gamepad
  17209. */
  17210. index: number;
  17211. /**
  17212. * The browser gamepad
  17213. */
  17214. browserGamepad: any;
  17215. /**
  17216. * Specifies what type of gamepad this represents
  17217. */
  17218. type: number;
  17219. private _leftStick;
  17220. private _rightStick;
  17221. /** @hidden */
  17222. _isConnected: boolean;
  17223. private _leftStickAxisX;
  17224. private _leftStickAxisY;
  17225. private _rightStickAxisX;
  17226. private _rightStickAxisY;
  17227. /**
  17228. * Triggered when the left control stick has been changed
  17229. */
  17230. private _onleftstickchanged;
  17231. /**
  17232. * Triggered when the right control stick has been changed
  17233. */
  17234. private _onrightstickchanged;
  17235. /**
  17236. * Represents a gamepad controller
  17237. */
  17238. static GAMEPAD: number;
  17239. /**
  17240. * Represents a generic controller
  17241. */
  17242. static GENERIC: number;
  17243. /**
  17244. * Represents an XBox controller
  17245. */
  17246. static XBOX: number;
  17247. /**
  17248. * Represents a pose-enabled controller
  17249. */
  17250. static POSE_ENABLED: number;
  17251. /**
  17252. * Specifies whether the left control stick should be Y-inverted
  17253. */
  17254. protected _invertLeftStickY: boolean;
  17255. /**
  17256. * Specifies if the gamepad has been connected
  17257. */
  17258. readonly isConnected: boolean;
  17259. /**
  17260. * Initializes the gamepad
  17261. * @param id The id of the gamepad
  17262. * @param index The index of the gamepad
  17263. * @param browserGamepad The browser gamepad
  17264. * @param leftStickX The x component of the left joystick
  17265. * @param leftStickY The y component of the left joystick
  17266. * @param rightStickX The x component of the right joystick
  17267. * @param rightStickY The y component of the right joystick
  17268. */
  17269. constructor(
  17270. /**
  17271. * The id of the gamepad
  17272. */
  17273. id: string,
  17274. /**
  17275. * The index of the gamepad
  17276. */
  17277. index: number,
  17278. /**
  17279. * The browser gamepad
  17280. */
  17281. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  17282. /**
  17283. * Callback triggered when the left joystick has changed
  17284. * @param callback
  17285. */
  17286. onleftstickchanged(callback: (values: StickValues) => void): void;
  17287. /**
  17288. * Callback triggered when the right joystick has changed
  17289. * @param callback
  17290. */
  17291. onrightstickchanged(callback: (values: StickValues) => void): void;
  17292. /**
  17293. * Gets the left joystick
  17294. */
  17295. /**
  17296. * Sets the left joystick values
  17297. */
  17298. leftStick: StickValues;
  17299. /**
  17300. * Gets the right joystick
  17301. */
  17302. /**
  17303. * Sets the right joystick value
  17304. */
  17305. rightStick: StickValues;
  17306. /**
  17307. * Updates the gamepad joystick positions
  17308. */
  17309. update(): void;
  17310. /**
  17311. * Disposes the gamepad
  17312. */
  17313. dispose(): void;
  17314. }
  17315. /**
  17316. * Represents a generic gamepad
  17317. */
  17318. export class GenericPad extends Gamepad {
  17319. private _buttons;
  17320. private _onbuttondown;
  17321. private _onbuttonup;
  17322. /**
  17323. * Observable triggered when a button has been pressed
  17324. */
  17325. onButtonDownObservable: Observable<number>;
  17326. /**
  17327. * Observable triggered when a button has been released
  17328. */
  17329. onButtonUpObservable: Observable<number>;
  17330. /**
  17331. * Callback triggered when a button has been pressed
  17332. * @param callback Called when a button has been pressed
  17333. */
  17334. onbuttondown(callback: (buttonPressed: number) => void): void;
  17335. /**
  17336. * Callback triggered when a button has been released
  17337. * @param callback Called when a button has been released
  17338. */
  17339. onbuttonup(callback: (buttonReleased: number) => void): void;
  17340. /**
  17341. * Initializes the generic gamepad
  17342. * @param id The id of the generic gamepad
  17343. * @param index The index of the generic gamepad
  17344. * @param browserGamepad The browser gamepad
  17345. */
  17346. constructor(id: string, index: number, browserGamepad: any);
  17347. private _setButtonValue;
  17348. /**
  17349. * Updates the generic gamepad
  17350. */
  17351. update(): void;
  17352. /**
  17353. * Disposes the generic gamepad
  17354. */
  17355. dispose(): void;
  17356. }
  17357. }
  17358. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  17359. import { Observable } from "babylonjs/Misc/observable";
  17360. import { Nullable } from "babylonjs/types";
  17361. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  17362. import { TransformNode } from "babylonjs/Meshes/transformNode";
  17363. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17364. import { Ray } from "babylonjs/Culling/ray";
  17365. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  17366. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  17367. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  17368. /**
  17369. * Defines the types of pose enabled controllers that are supported
  17370. */
  17371. export enum PoseEnabledControllerType {
  17372. /**
  17373. * HTC Vive
  17374. */
  17375. VIVE = 0,
  17376. /**
  17377. * Oculus Rift
  17378. */
  17379. OCULUS = 1,
  17380. /**
  17381. * Windows mixed reality
  17382. */
  17383. WINDOWS = 2,
  17384. /**
  17385. * Samsung gear VR
  17386. */
  17387. GEAR_VR = 3,
  17388. /**
  17389. * Google Daydream
  17390. */
  17391. DAYDREAM = 4,
  17392. /**
  17393. * Generic
  17394. */
  17395. GENERIC = 5
  17396. }
  17397. /**
  17398. * Defines the MutableGamepadButton interface for the state of a gamepad button
  17399. */
  17400. export interface MutableGamepadButton {
  17401. /**
  17402. * Value of the button/trigger
  17403. */
  17404. value: number;
  17405. /**
  17406. * If the button/trigger is currently touched
  17407. */
  17408. touched: boolean;
  17409. /**
  17410. * If the button/trigger is currently pressed
  17411. */
  17412. pressed: boolean;
  17413. }
  17414. /**
  17415. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  17416. * @hidden
  17417. */
  17418. export interface ExtendedGamepadButton extends GamepadButton {
  17419. /**
  17420. * If the button/trigger is currently pressed
  17421. */
  17422. readonly pressed: boolean;
  17423. /**
  17424. * If the button/trigger is currently touched
  17425. */
  17426. readonly touched: boolean;
  17427. /**
  17428. * Value of the button/trigger
  17429. */
  17430. readonly value: number;
  17431. }
  17432. /** @hidden */
  17433. export interface _GamePadFactory {
  17434. /**
  17435. * Returns wether or not the current gamepad can be created for this type of controller.
  17436. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  17437. * @returns true if it can be created, otherwise false
  17438. */
  17439. canCreate(gamepadInfo: any): boolean;
  17440. /**
  17441. * Creates a new instance of the Gamepad.
  17442. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  17443. * @returns the new gamepad instance
  17444. */
  17445. create(gamepadInfo: any): Gamepad;
  17446. }
  17447. /**
  17448. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  17449. */
  17450. export class PoseEnabledControllerHelper {
  17451. /** @hidden */
  17452. static _ControllerFactories: _GamePadFactory[];
  17453. /** @hidden */
  17454. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  17455. /**
  17456. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  17457. * @param vrGamepad the gamepad to initialized
  17458. * @returns a vr controller of the type the gamepad identified as
  17459. */
  17460. static InitiateController(vrGamepad: any): Gamepad;
  17461. }
  17462. /**
  17463. * Defines the PoseEnabledController object that contains state of a vr capable controller
  17464. */
  17465. export class PoseEnabledController extends Gamepad implements PoseControlled {
  17466. private _deviceRoomPosition;
  17467. private _deviceRoomRotationQuaternion;
  17468. /**
  17469. * The device position in babylon space
  17470. */
  17471. devicePosition: Vector3;
  17472. /**
  17473. * The device rotation in babylon space
  17474. */
  17475. deviceRotationQuaternion: Quaternion;
  17476. /**
  17477. * The scale factor of the device in babylon space
  17478. */
  17479. deviceScaleFactor: number;
  17480. /**
  17481. * (Likely devicePosition should be used instead) The device position in its room space
  17482. */
  17483. position: Vector3;
  17484. /**
  17485. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  17486. */
  17487. rotationQuaternion: Quaternion;
  17488. /**
  17489. * The type of controller (Eg. Windows mixed reality)
  17490. */
  17491. controllerType: PoseEnabledControllerType;
  17492. protected _calculatedPosition: Vector3;
  17493. private _calculatedRotation;
  17494. /**
  17495. * The raw pose from the device
  17496. */
  17497. rawPose: DevicePose;
  17498. private _trackPosition;
  17499. private _maxRotationDistFromHeadset;
  17500. private _draggedRoomRotation;
  17501. /**
  17502. * @hidden
  17503. */
  17504. _disableTrackPosition(fixedPosition: Vector3): void;
  17505. /**
  17506. * Internal, the mesh attached to the controller
  17507. * @hidden
  17508. */
  17509. _mesh: Nullable<AbstractMesh>;
  17510. private _poseControlledCamera;
  17511. private _leftHandSystemQuaternion;
  17512. /**
  17513. * Internal, matrix used to convert room space to babylon space
  17514. * @hidden
  17515. */
  17516. _deviceToWorld: Matrix;
  17517. /**
  17518. * Node to be used when casting a ray from the controller
  17519. * @hidden
  17520. */
  17521. _pointingPoseNode: Nullable<TransformNode>;
  17522. /**
  17523. * Name of the child mesh that can be used to cast a ray from the controller
  17524. */
  17525. static readonly POINTING_POSE: string;
  17526. /**
  17527. * Creates a new PoseEnabledController from a gamepad
  17528. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  17529. */
  17530. constructor(browserGamepad: any);
  17531. private _workingMatrix;
  17532. /**
  17533. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  17534. */
  17535. update(): void;
  17536. /**
  17537. * Updates only the pose device and mesh without doing any button event checking
  17538. */
  17539. protected _updatePoseAndMesh(): void;
  17540. /**
  17541. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  17542. * @param poseData raw pose fromthe device
  17543. */
  17544. updateFromDevice(poseData: DevicePose): void;
  17545. /**
  17546. * @hidden
  17547. */
  17548. _meshAttachedObservable: Observable<AbstractMesh>;
  17549. /**
  17550. * Attaches a mesh to the controller
  17551. * @param mesh the mesh to be attached
  17552. */
  17553. attachToMesh(mesh: AbstractMesh): void;
  17554. /**
  17555. * Attaches the controllers mesh to a camera
  17556. * @param camera the camera the mesh should be attached to
  17557. */
  17558. attachToPoseControlledCamera(camera: TargetCamera): void;
  17559. /**
  17560. * Disposes of the controller
  17561. */
  17562. dispose(): void;
  17563. /**
  17564. * The mesh that is attached to the controller
  17565. */
  17566. readonly mesh: Nullable<AbstractMesh>;
  17567. /**
  17568. * Gets the ray of the controller in the direction the controller is pointing
  17569. * @param length the length the resulting ray should be
  17570. * @returns a ray in the direction the controller is pointing
  17571. */
  17572. getForwardRay(length?: number): Ray;
  17573. }
  17574. }
  17575. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  17576. import { Observable } from "babylonjs/Misc/observable";
  17577. import { Scene } from "babylonjs/scene";
  17578. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17579. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  17580. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  17581. /**
  17582. * Defines the WebVRController object that represents controllers tracked in 3D space
  17583. */
  17584. export abstract class WebVRController extends PoseEnabledController {
  17585. /**
  17586. * Internal, the default controller model for the controller
  17587. */
  17588. protected _defaultModel: AbstractMesh;
  17589. /**
  17590. * Fired when the trigger state has changed
  17591. */
  17592. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  17593. /**
  17594. * Fired when the main button state has changed
  17595. */
  17596. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  17597. /**
  17598. * Fired when the secondary button state has changed
  17599. */
  17600. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  17601. /**
  17602. * Fired when the pad state has changed
  17603. */
  17604. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  17605. /**
  17606. * Fired when controllers stick values have changed
  17607. */
  17608. onPadValuesChangedObservable: Observable<StickValues>;
  17609. /**
  17610. * Array of button availible on the controller
  17611. */
  17612. protected _buttons: Array<MutableGamepadButton>;
  17613. private _onButtonStateChange;
  17614. /**
  17615. * Fired when a controller button's state has changed
  17616. * @param callback the callback containing the button that was modified
  17617. */
  17618. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  17619. /**
  17620. * X and Y axis corresponding to the controllers joystick
  17621. */
  17622. pad: StickValues;
  17623. /**
  17624. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  17625. */
  17626. hand: string;
  17627. /**
  17628. * The default controller model for the controller
  17629. */
  17630. readonly defaultModel: AbstractMesh;
  17631. /**
  17632. * Creates a new WebVRController from a gamepad
  17633. * @param vrGamepad the gamepad that the WebVRController should be created from
  17634. */
  17635. constructor(vrGamepad: any);
  17636. /**
  17637. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  17638. */
  17639. update(): void;
  17640. /**
  17641. * Function to be called when a button is modified
  17642. */
  17643. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  17644. /**
  17645. * Loads a mesh and attaches it to the controller
  17646. * @param scene the scene the mesh should be added to
  17647. * @param meshLoaded callback for when the mesh has been loaded
  17648. */
  17649. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  17650. private _setButtonValue;
  17651. private _changes;
  17652. private _checkChanges;
  17653. /**
  17654. * Disposes of th webVRCOntroller
  17655. */
  17656. dispose(): void;
  17657. }
  17658. }
  17659. declare module "babylonjs/Lights/hemisphericLight" {
  17660. import { Nullable } from "babylonjs/types";
  17661. import { Scene } from "babylonjs/scene";
  17662. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  17663. import { Effect } from "babylonjs/Materials/effect";
  17664. import { Light } from "babylonjs/Lights/light";
  17665. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  17666. /**
  17667. * The HemisphericLight simulates the ambient environment light,
  17668. * so the passed direction is the light reflection direction, not the incoming direction.
  17669. */
  17670. export class HemisphericLight extends Light {
  17671. /**
  17672. * The groundColor is the light in the opposite direction to the one specified during creation.
  17673. * 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.
  17674. */
  17675. groundColor: Color3;
  17676. /**
  17677. * The light reflection direction, not the incoming direction.
  17678. */
  17679. direction: Vector3;
  17680. /**
  17681. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  17682. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  17683. * The HemisphericLight can't cast shadows.
  17684. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17685. * @param name The friendly name of the light
  17686. * @param direction The direction of the light reflection
  17687. * @param scene The scene the light belongs to
  17688. */
  17689. constructor(name: string, direction: Vector3, scene: Scene);
  17690. protected _buildUniformLayout(): void;
  17691. /**
  17692. * Returns the string "HemisphericLight".
  17693. * @return The class name
  17694. */
  17695. getClassName(): string;
  17696. /**
  17697. * Sets the HemisphericLight direction towards the passed target (Vector3).
  17698. * Returns the updated direction.
  17699. * @param target The target the direction should point to
  17700. * @return The computed direction
  17701. */
  17702. setDirectionToTarget(target: Vector3): Vector3;
  17703. /**
  17704. * Returns the shadow generator associated to the light.
  17705. * @returns Always null for hemispheric lights because it does not support shadows.
  17706. */
  17707. getShadowGenerator(): Nullable<IShadowGenerator>;
  17708. /**
  17709. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  17710. * @param effect The effect to update
  17711. * @param lightIndex The index of the light in the effect to update
  17712. * @returns The hemispheric light
  17713. */
  17714. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  17715. /**
  17716. * Computes the world matrix of the node
  17717. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  17718. * @param useWasUpdatedFlag defines a reserved property
  17719. * @returns the world matrix
  17720. */
  17721. computeWorldMatrix(): Matrix;
  17722. /**
  17723. * Returns the integer 3.
  17724. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  17725. */
  17726. getTypeID(): number;
  17727. /**
  17728. * Prepares the list of defines specific to the light type.
  17729. * @param defines the list of defines
  17730. * @param lightIndex defines the index of the light for the effect
  17731. */
  17732. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  17733. }
  17734. }
  17735. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  17736. /** @hidden */
  17737. export var vrMultiviewToSingleviewPixelShader: {
  17738. name: string;
  17739. shader: string;
  17740. };
  17741. }
  17742. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  17743. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17744. import { Scene } from "babylonjs/scene";
  17745. /**
  17746. * Renders to multiple views with a single draw call
  17747. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  17748. */
  17749. export class MultiviewRenderTarget extends RenderTargetTexture {
  17750. /**
  17751. * Creates a multiview render target
  17752. * @param scene scene used with the render target
  17753. * @param size the size of the render target (used for each view)
  17754. */
  17755. constructor(scene: Scene, size?: number | {
  17756. width: number;
  17757. height: number;
  17758. } | {
  17759. ratio: number;
  17760. });
  17761. /**
  17762. * @hidden
  17763. * @param faceIndex the face index, if its a cube texture
  17764. */
  17765. _bindFrameBuffer(faceIndex?: number): void;
  17766. /**
  17767. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  17768. * @returns the view count
  17769. */
  17770. getViewCount(): number;
  17771. }
  17772. }
  17773. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  17774. import { Camera } from "babylonjs/Cameras/camera";
  17775. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  17776. import { Nullable } from "babylonjs/types";
  17777. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17778. import { Matrix } from "babylonjs/Maths/math";
  17779. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  17780. module "babylonjs/Engines/engine" {
  17781. interface Engine {
  17782. /**
  17783. * Creates a new multiview render target
  17784. * @param width defines the width of the texture
  17785. * @param height defines the height of the texture
  17786. * @returns the created multiview texture
  17787. */
  17788. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  17789. /**
  17790. * Binds a multiview framebuffer to be drawn to
  17791. * @param multiviewTexture texture to bind
  17792. */
  17793. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  17794. }
  17795. }
  17796. module "babylonjs/Cameras/camera" {
  17797. interface Camera {
  17798. /**
  17799. * @hidden
  17800. * 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)
  17801. */
  17802. _useMultiviewToSingleView: boolean;
  17803. /**
  17804. * @hidden
  17805. * 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)
  17806. */
  17807. _multiviewTexture: Nullable<RenderTargetTexture>;
  17808. /**
  17809. * @hidden
  17810. * ensures the multiview texture of the camera exists and has the specified width/height
  17811. * @param width height to set on the multiview texture
  17812. * @param height width to set on the multiview texture
  17813. */
  17814. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  17815. }
  17816. }
  17817. module "babylonjs/scene" {
  17818. interface Scene {
  17819. /** @hidden */
  17820. _transformMatrixR: Matrix;
  17821. /** @hidden */
  17822. _multiviewSceneUbo: Nullable<UniformBuffer>;
  17823. /** @hidden */
  17824. _createMultiviewUbo(): void;
  17825. /** @hidden */
  17826. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  17827. /** @hidden */
  17828. _renderMultiviewToSingleView(camera: Camera): void;
  17829. }
  17830. }
  17831. }
  17832. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  17833. import { Camera } from "babylonjs/Cameras/camera";
  17834. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17835. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  17836. import "babylonjs/Engines/Extensions/engine.multiview";
  17837. /**
  17838. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  17839. * This will not be used for webXR as it supports displaying texture arrays directly
  17840. */
  17841. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  17842. /**
  17843. * Initializes a VRMultiviewToSingleview
  17844. * @param name name of the post process
  17845. * @param camera camera to be applied to
  17846. * @param scaleFactor scaling factor to the size of the output texture
  17847. */
  17848. constructor(name: string, camera: Camera, scaleFactor: number);
  17849. }
  17850. }
  17851. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  17852. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  17853. import { Nullable } from "babylonjs/types";
  17854. import { Size } from "babylonjs/Maths/math";
  17855. import { Observable } from "babylonjs/Misc/observable";
  17856. module "babylonjs/Engines/engine" {
  17857. interface Engine {
  17858. /** @hidden */
  17859. _vrDisplay: any;
  17860. /** @hidden */
  17861. _vrSupported: boolean;
  17862. /** @hidden */
  17863. _oldSize: Size;
  17864. /** @hidden */
  17865. _oldHardwareScaleFactor: number;
  17866. /** @hidden */
  17867. _vrExclusivePointerMode: boolean;
  17868. /** @hidden */
  17869. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  17870. /** @hidden */
  17871. _onVRDisplayPointerRestricted: () => void;
  17872. /** @hidden */
  17873. _onVRDisplayPointerUnrestricted: () => void;
  17874. /** @hidden */
  17875. _onVrDisplayConnect: Nullable<(display: any) => void>;
  17876. /** @hidden */
  17877. _onVrDisplayDisconnect: Nullable<() => void>;
  17878. /** @hidden */
  17879. _onVrDisplayPresentChange: Nullable<() => void>;
  17880. /**
  17881. * Observable signaled when VR display mode changes
  17882. */
  17883. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  17884. /**
  17885. * Observable signaled when VR request present is complete
  17886. */
  17887. onVRRequestPresentComplete: Observable<boolean>;
  17888. /**
  17889. * Observable signaled when VR request present starts
  17890. */
  17891. onVRRequestPresentStart: Observable<Engine>;
  17892. /**
  17893. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  17894. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  17895. */
  17896. isInVRExclusivePointerMode: boolean;
  17897. /**
  17898. * Gets a boolean indicating if a webVR device was detected
  17899. * @returns true if a webVR device was detected
  17900. */
  17901. isVRDevicePresent(): boolean;
  17902. /**
  17903. * Gets the current webVR device
  17904. * @returns the current webVR device (or null)
  17905. */
  17906. getVRDevice(): any;
  17907. /**
  17908. * Initializes a webVR display and starts listening to display change events
  17909. * The onVRDisplayChangedObservable will be notified upon these changes
  17910. * @returns A promise containing a VRDisplay and if vr is supported
  17911. */
  17912. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  17913. /** @hidden */
  17914. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  17915. /**
  17916. * Call this function to switch to webVR mode
  17917. * Will do nothing if webVR is not supported or if there is no webVR device
  17918. * @see http://doc.babylonjs.com/how_to/webvr_camera
  17919. */
  17920. enableVR(): void;
  17921. /** @hidden */
  17922. _onVRFullScreenTriggered(): void;
  17923. }
  17924. }
  17925. }
  17926. declare module "babylonjs/Cameras/VR/webVRCamera" {
  17927. import { Nullable } from "babylonjs/types";
  17928. import { Observable } from "babylonjs/Misc/observable";
  17929. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  17930. import { Scene } from "babylonjs/scene";
  17931. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  17932. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  17933. import { Node } from "babylonjs/node";
  17934. import { Ray } from "babylonjs/Culling/ray";
  17935. import "babylonjs/Cameras/RigModes/webVRRigMode";
  17936. import "babylonjs/Engines/Extensions/engine.webVR";
  17937. /**
  17938. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  17939. * IMPORTANT!! The data is right-hand data.
  17940. * @export
  17941. * @interface DevicePose
  17942. */
  17943. export interface DevicePose {
  17944. /**
  17945. * The position of the device, values in array are [x,y,z].
  17946. */
  17947. readonly position: Nullable<Float32Array>;
  17948. /**
  17949. * The linearVelocity of the device, values in array are [x,y,z].
  17950. */
  17951. readonly linearVelocity: Nullable<Float32Array>;
  17952. /**
  17953. * The linearAcceleration of the device, values in array are [x,y,z].
  17954. */
  17955. readonly linearAcceleration: Nullable<Float32Array>;
  17956. /**
  17957. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  17958. */
  17959. readonly orientation: Nullable<Float32Array>;
  17960. /**
  17961. * The angularVelocity of the device, values in array are [x,y,z].
  17962. */
  17963. readonly angularVelocity: Nullable<Float32Array>;
  17964. /**
  17965. * The angularAcceleration of the device, values in array are [x,y,z].
  17966. */
  17967. readonly angularAcceleration: Nullable<Float32Array>;
  17968. }
  17969. /**
  17970. * Interface representing a pose controlled object in Babylon.
  17971. * A pose controlled object has both regular pose values as well as pose values
  17972. * from an external device such as a VR head mounted display
  17973. */
  17974. export interface PoseControlled {
  17975. /**
  17976. * The position of the object in babylon space.
  17977. */
  17978. position: Vector3;
  17979. /**
  17980. * The rotation quaternion of the object in babylon space.
  17981. */
  17982. rotationQuaternion: Quaternion;
  17983. /**
  17984. * The position of the device in babylon space.
  17985. */
  17986. devicePosition?: Vector3;
  17987. /**
  17988. * The rotation quaternion of the device in babylon space.
  17989. */
  17990. deviceRotationQuaternion: Quaternion;
  17991. /**
  17992. * The raw pose coming from the device.
  17993. */
  17994. rawPose: Nullable<DevicePose>;
  17995. /**
  17996. * The scale of the device to be used when translating from device space to babylon space.
  17997. */
  17998. deviceScaleFactor: number;
  17999. /**
  18000. * Updates the poseControlled values based on the input device pose.
  18001. * @param poseData the pose data to update the object with
  18002. */
  18003. updateFromDevice(poseData: DevicePose): void;
  18004. }
  18005. /**
  18006. * Set of options to customize the webVRCamera
  18007. */
  18008. export interface WebVROptions {
  18009. /**
  18010. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  18011. */
  18012. trackPosition?: boolean;
  18013. /**
  18014. * Sets the scale of the vrDevice in babylon space. (default: 1)
  18015. */
  18016. positionScale?: number;
  18017. /**
  18018. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  18019. */
  18020. displayName?: string;
  18021. /**
  18022. * Should the native controller meshes be initialized. (default: true)
  18023. */
  18024. controllerMeshes?: boolean;
  18025. /**
  18026. * Creating a default HemiLight only on controllers. (default: true)
  18027. */
  18028. defaultLightingOnControllers?: boolean;
  18029. /**
  18030. * If you don't want to use the default VR button of the helper. (default: false)
  18031. */
  18032. useCustomVRButton?: boolean;
  18033. /**
  18034. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  18035. */
  18036. customVRButton?: HTMLButtonElement;
  18037. /**
  18038. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  18039. */
  18040. rayLength?: number;
  18041. /**
  18042. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  18043. */
  18044. defaultHeight?: number;
  18045. /**
  18046. * If multiview should be used if availible (default: false)
  18047. */
  18048. useMultiview?: boolean;
  18049. }
  18050. /**
  18051. * This represents a WebVR camera.
  18052. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  18053. * @example http://doc.babylonjs.com/how_to/webvr_camera
  18054. */
  18055. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  18056. private webVROptions;
  18057. /**
  18058. * @hidden
  18059. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  18060. */
  18061. _vrDevice: any;
  18062. /**
  18063. * The rawPose of the vrDevice.
  18064. */
  18065. rawPose: Nullable<DevicePose>;
  18066. private _onVREnabled;
  18067. private _specsVersion;
  18068. private _attached;
  18069. private _frameData;
  18070. protected _descendants: Array<Node>;
  18071. private _deviceRoomPosition;
  18072. /** @hidden */
  18073. _deviceRoomRotationQuaternion: Quaternion;
  18074. private _standingMatrix;
  18075. /**
  18076. * Represents device position in babylon space.
  18077. */
  18078. devicePosition: Vector3;
  18079. /**
  18080. * Represents device rotation in babylon space.
  18081. */
  18082. deviceRotationQuaternion: Quaternion;
  18083. /**
  18084. * The scale of the device to be used when translating from device space to babylon space.
  18085. */
  18086. deviceScaleFactor: number;
  18087. private _deviceToWorld;
  18088. private _worldToDevice;
  18089. /**
  18090. * References to the webVR controllers for the vrDevice.
  18091. */
  18092. controllers: Array<WebVRController>;
  18093. /**
  18094. * Emits an event when a controller is attached.
  18095. */
  18096. onControllersAttachedObservable: Observable<WebVRController[]>;
  18097. /**
  18098. * Emits an event when a controller's mesh has been loaded;
  18099. */
  18100. onControllerMeshLoadedObservable: Observable<WebVRController>;
  18101. /**
  18102. * Emits an event when the HMD's pose has been updated.
  18103. */
  18104. onPoseUpdatedFromDeviceObservable: Observable<any>;
  18105. private _poseSet;
  18106. /**
  18107. * If the rig cameras be used as parent instead of this camera.
  18108. */
  18109. rigParenting: boolean;
  18110. private _lightOnControllers;
  18111. private _defaultHeight?;
  18112. /**
  18113. * Instantiates a WebVRFreeCamera.
  18114. * @param name The name of the WebVRFreeCamera
  18115. * @param position The starting anchor position for the camera
  18116. * @param scene The scene the camera belongs to
  18117. * @param webVROptions a set of customizable options for the webVRCamera
  18118. */
  18119. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  18120. /**
  18121. * Gets the device distance from the ground in meters.
  18122. * @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.
  18123. */
  18124. deviceDistanceToRoomGround(): number;
  18125. /**
  18126. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  18127. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  18128. */
  18129. useStandingMatrix(callback?: (bool: boolean) => void): void;
  18130. /**
  18131. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  18132. * @returns A promise with a boolean set to if the standing matrix is supported.
  18133. */
  18134. useStandingMatrixAsync(): Promise<boolean>;
  18135. /**
  18136. * Disposes the camera
  18137. */
  18138. dispose(): void;
  18139. /**
  18140. * Gets a vrController by name.
  18141. * @param name The name of the controller to retreive
  18142. * @returns the controller matching the name specified or null if not found
  18143. */
  18144. getControllerByName(name: string): Nullable<WebVRController>;
  18145. private _leftController;
  18146. /**
  18147. * The controller corresponding to the users left hand.
  18148. */
  18149. readonly leftController: Nullable<WebVRController>;
  18150. private _rightController;
  18151. /**
  18152. * The controller corresponding to the users right hand.
  18153. */
  18154. readonly rightController: Nullable<WebVRController>;
  18155. /**
  18156. * Casts a ray forward from the vrCamera's gaze.
  18157. * @param length Length of the ray (default: 100)
  18158. * @returns the ray corresponding to the gaze
  18159. */
  18160. getForwardRay(length?: number): Ray;
  18161. /**
  18162. * @hidden
  18163. * Updates the camera based on device's frame data
  18164. */
  18165. _checkInputs(): void;
  18166. /**
  18167. * Updates the poseControlled values based on the input device pose.
  18168. * @param poseData Pose coming from the device
  18169. */
  18170. updateFromDevice(poseData: DevicePose): void;
  18171. private _htmlElementAttached;
  18172. private _detachIfAttached;
  18173. /**
  18174. * WebVR's attach control will start broadcasting frames to the device.
  18175. * Note that in certain browsers (chrome for example) this function must be called
  18176. * within a user-interaction callback. Example:
  18177. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  18178. *
  18179. * @param element html element to attach the vrDevice to
  18180. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  18181. */
  18182. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18183. /**
  18184. * Detaches the camera from the html element and disables VR
  18185. *
  18186. * @param element html element to detach from
  18187. */
  18188. detachControl(element: HTMLElement): void;
  18189. /**
  18190. * @returns the name of this class
  18191. */
  18192. getClassName(): string;
  18193. /**
  18194. * Calls resetPose on the vrDisplay
  18195. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  18196. */
  18197. resetToCurrentRotation(): void;
  18198. /**
  18199. * @hidden
  18200. * Updates the rig cameras (left and right eye)
  18201. */
  18202. _updateRigCameras(): void;
  18203. private _workingVector;
  18204. private _oneVector;
  18205. private _workingMatrix;
  18206. private updateCacheCalled;
  18207. private _correctPositionIfNotTrackPosition;
  18208. /**
  18209. * @hidden
  18210. * Updates the cached values of the camera
  18211. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  18212. */
  18213. _updateCache(ignoreParentClass?: boolean): void;
  18214. /**
  18215. * @hidden
  18216. * Get current device position in babylon world
  18217. */
  18218. _computeDevicePosition(): void;
  18219. /**
  18220. * Updates the current device position and rotation in the babylon world
  18221. */
  18222. update(): void;
  18223. /**
  18224. * @hidden
  18225. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  18226. * @returns an identity matrix
  18227. */
  18228. _getViewMatrix(): Matrix;
  18229. private _tmpMatrix;
  18230. /**
  18231. * This function is called by the two RIG cameras.
  18232. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  18233. * @hidden
  18234. */
  18235. _getWebVRViewMatrix(): Matrix;
  18236. /** @hidden */
  18237. _getWebVRProjectionMatrix(): Matrix;
  18238. private _onGamepadConnectedObserver;
  18239. private _onGamepadDisconnectedObserver;
  18240. private _updateCacheWhenTrackingDisabledObserver;
  18241. /**
  18242. * Initializes the controllers and their meshes
  18243. */
  18244. initControllers(): void;
  18245. }
  18246. }
  18247. declare module "babylonjs/PostProcesses/postProcess" {
  18248. import { Nullable } from "babylonjs/types";
  18249. import { SmartArray } from "babylonjs/Misc/smartArray";
  18250. import { Observable } from "babylonjs/Misc/observable";
  18251. import { Color4, Vector2 } from "babylonjs/Maths/math";
  18252. import { Camera } from "babylonjs/Cameras/camera";
  18253. import { Effect } from "babylonjs/Materials/effect";
  18254. import "babylonjs/Shaders/postprocess.vertex";
  18255. import { IInspectable } from "babylonjs/Misc/iInspectable";
  18256. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  18257. import { Engine } from "babylonjs/Engines/engine";
  18258. /**
  18259. * Size options for a post process
  18260. */
  18261. export type PostProcessOptions = {
  18262. width: number;
  18263. height: number;
  18264. };
  18265. /**
  18266. * PostProcess can be used to apply a shader to a texture after it has been rendered
  18267. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  18268. */
  18269. export class PostProcess {
  18270. /** Name of the PostProcess. */
  18271. name: string;
  18272. /**
  18273. * Gets or sets the unique id of the post process
  18274. */
  18275. uniqueId: number;
  18276. /**
  18277. * Width of the texture to apply the post process on
  18278. */
  18279. width: number;
  18280. /**
  18281. * Height of the texture to apply the post process on
  18282. */
  18283. height: number;
  18284. /**
  18285. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  18286. * @hidden
  18287. */
  18288. _outputTexture: Nullable<InternalTexture>;
  18289. /**
  18290. * Sampling mode used by the shader
  18291. * See https://doc.babylonjs.com/classes/3.1/texture
  18292. */
  18293. renderTargetSamplingMode: number;
  18294. /**
  18295. * Clear color to use when screen clearing
  18296. */
  18297. clearColor: Color4;
  18298. /**
  18299. * If the buffer needs to be cleared before applying the post process. (default: true)
  18300. * Should be set to false if shader will overwrite all previous pixels.
  18301. */
  18302. autoClear: boolean;
  18303. /**
  18304. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  18305. */
  18306. alphaMode: number;
  18307. /**
  18308. * Sets the setAlphaBlendConstants of the babylon engine
  18309. */
  18310. alphaConstants: Color4;
  18311. /**
  18312. * Animations to be used for the post processing
  18313. */
  18314. animations: import("babylonjs/Animations/animation").Animation[];
  18315. /**
  18316. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  18317. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  18318. */
  18319. enablePixelPerfectMode: boolean;
  18320. /**
  18321. * Force the postprocess to be applied without taking in account viewport
  18322. */
  18323. forceFullscreenViewport: boolean;
  18324. /**
  18325. * List of inspectable custom properties (used by the Inspector)
  18326. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18327. */
  18328. inspectableCustomProperties: IInspectable[];
  18329. /**
  18330. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  18331. *
  18332. * | Value | Type | Description |
  18333. * | ----- | ----------------------------------- | ----------- |
  18334. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  18335. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  18336. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  18337. *
  18338. */
  18339. scaleMode: number;
  18340. /**
  18341. * Force textures to be a power of two (default: false)
  18342. */
  18343. alwaysForcePOT: boolean;
  18344. private _samples;
  18345. /**
  18346. * Number of sample textures (default: 1)
  18347. */
  18348. samples: number;
  18349. /**
  18350. * Modify the scale of the post process to be the same as the viewport (default: false)
  18351. */
  18352. adaptScaleToCurrentViewport: boolean;
  18353. private _camera;
  18354. private _scene;
  18355. private _engine;
  18356. private _options;
  18357. private _reusable;
  18358. private _textureType;
  18359. /**
  18360. * Smart array of input and output textures for the post process.
  18361. * @hidden
  18362. */
  18363. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  18364. /**
  18365. * The index in _textures that corresponds to the output texture.
  18366. * @hidden
  18367. */
  18368. _currentRenderTextureInd: number;
  18369. private _effect;
  18370. private _samplers;
  18371. private _fragmentUrl;
  18372. private _vertexUrl;
  18373. private _parameters;
  18374. private _scaleRatio;
  18375. protected _indexParameters: any;
  18376. private _shareOutputWithPostProcess;
  18377. private _texelSize;
  18378. private _forcedOutputTexture;
  18379. /**
  18380. * Returns the fragment url or shader name used in the post process.
  18381. * @returns the fragment url or name in the shader store.
  18382. */
  18383. getEffectName(): string;
  18384. /**
  18385. * An event triggered when the postprocess is activated.
  18386. */
  18387. onActivateObservable: Observable<Camera>;
  18388. private _onActivateObserver;
  18389. /**
  18390. * A function that is added to the onActivateObservable
  18391. */
  18392. onActivate: Nullable<(camera: Camera) => void>;
  18393. /**
  18394. * An event triggered when the postprocess changes its size.
  18395. */
  18396. onSizeChangedObservable: Observable<PostProcess>;
  18397. private _onSizeChangedObserver;
  18398. /**
  18399. * A function that is added to the onSizeChangedObservable
  18400. */
  18401. onSizeChanged: (postProcess: PostProcess) => void;
  18402. /**
  18403. * An event triggered when the postprocess applies its effect.
  18404. */
  18405. onApplyObservable: Observable<Effect>;
  18406. private _onApplyObserver;
  18407. /**
  18408. * A function that is added to the onApplyObservable
  18409. */
  18410. onApply: (effect: Effect) => void;
  18411. /**
  18412. * An event triggered before rendering the postprocess
  18413. */
  18414. onBeforeRenderObservable: Observable<Effect>;
  18415. private _onBeforeRenderObserver;
  18416. /**
  18417. * A function that is added to the onBeforeRenderObservable
  18418. */
  18419. onBeforeRender: (effect: Effect) => void;
  18420. /**
  18421. * An event triggered after rendering the postprocess
  18422. */
  18423. onAfterRenderObservable: Observable<Effect>;
  18424. private _onAfterRenderObserver;
  18425. /**
  18426. * A function that is added to the onAfterRenderObservable
  18427. */
  18428. onAfterRender: (efect: Effect) => void;
  18429. /**
  18430. * 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
  18431. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  18432. */
  18433. inputTexture: InternalTexture;
  18434. /**
  18435. * Gets the camera which post process is applied to.
  18436. * @returns The camera the post process is applied to.
  18437. */
  18438. getCamera(): Camera;
  18439. /**
  18440. * Gets the texel size of the postprocess.
  18441. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  18442. */
  18443. readonly texelSize: Vector2;
  18444. /**
  18445. * Creates a new instance PostProcess
  18446. * @param name The name of the PostProcess.
  18447. * @param fragmentUrl The url of the fragment shader to be used.
  18448. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  18449. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  18450. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  18451. * @param camera The camera to apply the render pass to.
  18452. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  18453. * @param engine The engine which the post process will be applied. (default: current engine)
  18454. * @param reusable If the post process can be reused on the same frame. (default: false)
  18455. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  18456. * @param textureType Type of textures used when performing the post process. (default: 0)
  18457. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  18458. * @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
  18459. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  18460. */
  18461. constructor(
  18462. /** Name of the PostProcess. */
  18463. 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);
  18464. /**
  18465. * Gets a string idenfifying the name of the class
  18466. * @returns "PostProcess" string
  18467. */
  18468. getClassName(): string;
  18469. /**
  18470. * Gets the engine which this post process belongs to.
  18471. * @returns The engine the post process was enabled with.
  18472. */
  18473. getEngine(): Engine;
  18474. /**
  18475. * The effect that is created when initializing the post process.
  18476. * @returns The created effect corresponding the the postprocess.
  18477. */
  18478. getEffect(): Effect;
  18479. /**
  18480. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  18481. * @param postProcess The post process to share the output with.
  18482. * @returns This post process.
  18483. */
  18484. shareOutputWith(postProcess: PostProcess): PostProcess;
  18485. /**
  18486. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  18487. * This should be called if the post process that shares output with this post process is disabled/disposed.
  18488. */
  18489. useOwnOutput(): void;
  18490. /**
  18491. * Updates the effect with the current post process compile time values and recompiles the shader.
  18492. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  18493. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  18494. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  18495. * @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
  18496. * @param onCompiled Called when the shader has been compiled.
  18497. * @param onError Called if there is an error when compiling a shader.
  18498. */
  18499. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18500. /**
  18501. * The post process is reusable if it can be used multiple times within one frame.
  18502. * @returns If the post process is reusable
  18503. */
  18504. isReusable(): boolean;
  18505. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  18506. markTextureDirty(): void;
  18507. /**
  18508. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  18509. * 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.
  18510. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  18511. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  18512. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  18513. * @returns The target texture that was bound to be written to.
  18514. */
  18515. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  18516. /**
  18517. * If the post process is supported.
  18518. */
  18519. readonly isSupported: boolean;
  18520. /**
  18521. * The aspect ratio of the output texture.
  18522. */
  18523. readonly aspectRatio: number;
  18524. /**
  18525. * Get a value indicating if the post-process is ready to be used
  18526. * @returns true if the post-process is ready (shader is compiled)
  18527. */
  18528. isReady(): boolean;
  18529. /**
  18530. * Binds all textures and uniforms to the shader, this will be run on every pass.
  18531. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  18532. */
  18533. apply(): Nullable<Effect>;
  18534. private _disposeTextures;
  18535. /**
  18536. * Disposes the post process.
  18537. * @param camera The camera to dispose the post process on.
  18538. */
  18539. dispose(camera?: Camera): void;
  18540. }
  18541. }
  18542. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  18543. /** @hidden */
  18544. export var kernelBlurVaryingDeclaration: {
  18545. name: string;
  18546. shader: string;
  18547. };
  18548. }
  18549. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  18550. /** @hidden */
  18551. export var kernelBlurFragment: {
  18552. name: string;
  18553. shader: string;
  18554. };
  18555. }
  18556. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  18557. /** @hidden */
  18558. export var kernelBlurFragment2: {
  18559. name: string;
  18560. shader: string;
  18561. };
  18562. }
  18563. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  18564. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  18565. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  18566. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  18567. /** @hidden */
  18568. export var kernelBlurPixelShader: {
  18569. name: string;
  18570. shader: string;
  18571. };
  18572. }
  18573. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  18574. /** @hidden */
  18575. export var kernelBlurVertex: {
  18576. name: string;
  18577. shader: string;
  18578. };
  18579. }
  18580. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  18581. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  18582. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  18583. /** @hidden */
  18584. export var kernelBlurVertexShader: {
  18585. name: string;
  18586. shader: string;
  18587. };
  18588. }
  18589. declare module "babylonjs/PostProcesses/blurPostProcess" {
  18590. import { Vector2 } from "babylonjs/Maths/math";
  18591. import { Nullable } from "babylonjs/types";
  18592. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  18593. import { Camera } from "babylonjs/Cameras/camera";
  18594. import { Effect } from "babylonjs/Materials/effect";
  18595. import { Engine } from "babylonjs/Engines/engine";
  18596. import "babylonjs/Shaders/kernelBlur.fragment";
  18597. import "babylonjs/Shaders/kernelBlur.vertex";
  18598. /**
  18599. * The Blur Post Process which blurs an image based on a kernel and direction.
  18600. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  18601. */
  18602. export class BlurPostProcess extends PostProcess {
  18603. /** The direction in which to blur the image. */
  18604. direction: Vector2;
  18605. private blockCompilation;
  18606. protected _kernel: number;
  18607. protected _idealKernel: number;
  18608. protected _packedFloat: boolean;
  18609. private _staticDefines;
  18610. /**
  18611. * Sets the length in pixels of the blur sample region
  18612. */
  18613. /**
  18614. * Gets the length in pixels of the blur sample region
  18615. */
  18616. kernel: number;
  18617. /**
  18618. * Sets wether or not the blur needs to unpack/repack floats
  18619. */
  18620. /**
  18621. * Gets wether or not the blur is unpacking/repacking floats
  18622. */
  18623. packedFloat: boolean;
  18624. /**
  18625. * Creates a new instance BlurPostProcess
  18626. * @param name The name of the effect.
  18627. * @param direction The direction in which to blur the image.
  18628. * @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.
  18629. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  18630. * @param camera The camera to apply the render pass to.
  18631. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  18632. * @param engine The engine which the post process will be applied. (default: current engine)
  18633. * @param reusable If the post process can be reused on the same frame. (default: false)
  18634. * @param textureType Type of textures used when performing the post process. (default: 0)
  18635. * @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)
  18636. */
  18637. constructor(name: string,
  18638. /** The direction in which to blur the image. */
  18639. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  18640. /**
  18641. * Updates the effect with the current post process compile time values and recompiles the shader.
  18642. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  18643. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  18644. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  18645. * @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
  18646. * @param onCompiled Called when the shader has been compiled.
  18647. * @param onError Called if there is an error when compiling a shader.
  18648. */
  18649. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18650. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18651. /**
  18652. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  18653. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  18654. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  18655. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  18656. * The gaps between physical kernels are compensated for in the weighting of the samples
  18657. * @param idealKernel Ideal blur kernel.
  18658. * @return Nearest best kernel.
  18659. */
  18660. protected _nearestBestKernel(idealKernel: number): number;
  18661. /**
  18662. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  18663. * @param x The point on the Gaussian distribution to sample.
  18664. * @return the value of the Gaussian function at x.
  18665. */
  18666. protected _gaussianWeight(x: number): number;
  18667. /**
  18668. * Generates a string that can be used as a floating point number in GLSL.
  18669. * @param x Value to print.
  18670. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  18671. * @return GLSL float string.
  18672. */
  18673. protected _glslFloat(x: number, decimalFigures?: number): string;
  18674. }
  18675. }
  18676. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  18677. import { Scene } from "babylonjs/scene";
  18678. import { Plane } from "babylonjs/Maths/math";
  18679. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  18680. /**
  18681. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18682. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18683. * You can then easily use it as a reflectionTexture on a flat surface.
  18684. * In case the surface is not a plane, please consider relying on reflection probes.
  18685. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18686. */
  18687. export class MirrorTexture extends RenderTargetTexture {
  18688. private scene;
  18689. /**
  18690. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  18691. * 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.
  18692. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18693. */
  18694. mirrorPlane: Plane;
  18695. /**
  18696. * Define the blur ratio used to blur the reflection if needed.
  18697. */
  18698. blurRatio: number;
  18699. /**
  18700. * Define the adaptive blur kernel used to blur the reflection if needed.
  18701. * This will autocompute the closest best match for the `blurKernel`
  18702. */
  18703. adaptiveBlurKernel: number;
  18704. /**
  18705. * Define the blur kernel used to blur the reflection if needed.
  18706. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18707. */
  18708. blurKernel: number;
  18709. /**
  18710. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  18711. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18712. */
  18713. blurKernelX: number;
  18714. /**
  18715. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  18716. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18717. */
  18718. blurKernelY: number;
  18719. private _autoComputeBlurKernel;
  18720. protected _onRatioRescale(): void;
  18721. private _updateGammaSpace;
  18722. private _imageProcessingConfigChangeObserver;
  18723. private _transformMatrix;
  18724. private _mirrorMatrix;
  18725. private _savedViewMatrix;
  18726. private _blurX;
  18727. private _blurY;
  18728. private _adaptiveBlurKernel;
  18729. private _blurKernelX;
  18730. private _blurKernelY;
  18731. private _blurRatio;
  18732. /**
  18733. * Instantiates a Mirror Texture.
  18734. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18735. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18736. * You can then easily use it as a reflectionTexture on a flat surface.
  18737. * In case the surface is not a plane, please consider relying on reflection probes.
  18738. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18739. * @param name
  18740. * @param size
  18741. * @param scene
  18742. * @param generateMipMaps
  18743. * @param type
  18744. * @param samplingMode
  18745. * @param generateDepthBuffer
  18746. */
  18747. constructor(name: string, size: number | {
  18748. width: number;
  18749. height: number;
  18750. } | {
  18751. ratio: number;
  18752. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  18753. private _preparePostProcesses;
  18754. /**
  18755. * Clone the mirror texture.
  18756. * @returns the cloned texture
  18757. */
  18758. clone(): MirrorTexture;
  18759. /**
  18760. * Serialize the texture to a JSON representation you could use in Parse later on
  18761. * @returns the serialized JSON representation
  18762. */
  18763. serialize(): any;
  18764. /**
  18765. * Dispose the texture and release its associated resources.
  18766. */
  18767. dispose(): void;
  18768. }
  18769. }
  18770. declare module "babylonjs/Materials/Textures/texture" {
  18771. import { Observable } from "babylonjs/Misc/observable";
  18772. import { Nullable } from "babylonjs/types";
  18773. import { Scene } from "babylonjs/scene";
  18774. import { Matrix } from "babylonjs/Maths/math";
  18775. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18776. import { IInspectable } from "babylonjs/Misc/iInspectable";
  18777. /**
  18778. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18779. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18780. */
  18781. export class Texture extends BaseTexture {
  18782. /** @hidden */
  18783. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  18784. /** @hidden */
  18785. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  18786. /** @hidden */
  18787. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  18788. /** nearest is mag = nearest and min = nearest and mip = linear */
  18789. static readonly NEAREST_SAMPLINGMODE: number;
  18790. /** nearest is mag = nearest and min = nearest and mip = linear */
  18791. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  18792. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18793. static readonly BILINEAR_SAMPLINGMODE: number;
  18794. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18795. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  18796. /** Trilinear is mag = linear and min = linear and mip = linear */
  18797. static readonly TRILINEAR_SAMPLINGMODE: number;
  18798. /** Trilinear is mag = linear and min = linear and mip = linear */
  18799. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  18800. /** mag = nearest and min = nearest and mip = nearest */
  18801. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  18802. /** mag = nearest and min = linear and mip = nearest */
  18803. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  18804. /** mag = nearest and min = linear and mip = linear */
  18805. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  18806. /** mag = nearest and min = linear and mip = none */
  18807. static readonly NEAREST_LINEAR: number;
  18808. /** mag = nearest and min = nearest and mip = none */
  18809. static readonly NEAREST_NEAREST: number;
  18810. /** mag = linear and min = nearest and mip = nearest */
  18811. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  18812. /** mag = linear and min = nearest and mip = linear */
  18813. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  18814. /** mag = linear and min = linear and mip = none */
  18815. static readonly LINEAR_LINEAR: number;
  18816. /** mag = linear and min = nearest and mip = none */
  18817. static readonly LINEAR_NEAREST: number;
  18818. /** Explicit coordinates mode */
  18819. static readonly EXPLICIT_MODE: number;
  18820. /** Spherical coordinates mode */
  18821. static readonly SPHERICAL_MODE: number;
  18822. /** Planar coordinates mode */
  18823. static readonly PLANAR_MODE: number;
  18824. /** Cubic coordinates mode */
  18825. static readonly CUBIC_MODE: number;
  18826. /** Projection coordinates mode */
  18827. static readonly PROJECTION_MODE: number;
  18828. /** Inverse Cubic coordinates mode */
  18829. static readonly SKYBOX_MODE: number;
  18830. /** Inverse Cubic coordinates mode */
  18831. static readonly INVCUBIC_MODE: number;
  18832. /** Equirectangular coordinates mode */
  18833. static readonly EQUIRECTANGULAR_MODE: number;
  18834. /** Equirectangular Fixed coordinates mode */
  18835. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  18836. /** Equirectangular Fixed Mirrored coordinates mode */
  18837. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  18838. /** Texture is not repeating outside of 0..1 UVs */
  18839. static readonly CLAMP_ADDRESSMODE: number;
  18840. /** Texture is repeating outside of 0..1 UVs */
  18841. static readonly WRAP_ADDRESSMODE: number;
  18842. /** Texture is repeating and mirrored */
  18843. static readonly MIRROR_ADDRESSMODE: number;
  18844. /**
  18845. * 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
  18846. */
  18847. static UseSerializedUrlIfAny: boolean;
  18848. /**
  18849. * Define the url of the texture.
  18850. */
  18851. url: Nullable<string>;
  18852. /**
  18853. * Define an offset on the texture to offset the u coordinates of the UVs
  18854. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18855. */
  18856. uOffset: number;
  18857. /**
  18858. * Define an offset on the texture to offset the v coordinates of the UVs
  18859. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18860. */
  18861. vOffset: number;
  18862. /**
  18863. * Define an offset on the texture to scale the u coordinates of the UVs
  18864. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18865. */
  18866. uScale: number;
  18867. /**
  18868. * Define an offset on the texture to scale the v coordinates of the UVs
  18869. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18870. */
  18871. vScale: number;
  18872. /**
  18873. * Define an offset on the texture to rotate around the u coordinates of the UVs
  18874. * @see http://doc.babylonjs.com/how_to/more_materials
  18875. */
  18876. uAng: number;
  18877. /**
  18878. * Define an offset on the texture to rotate around the v coordinates of the UVs
  18879. * @see http://doc.babylonjs.com/how_to/more_materials
  18880. */
  18881. vAng: number;
  18882. /**
  18883. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  18884. * @see http://doc.babylonjs.com/how_to/more_materials
  18885. */
  18886. wAng: number;
  18887. /**
  18888. * Defines the center of rotation (U)
  18889. */
  18890. uRotationCenter: number;
  18891. /**
  18892. * Defines the center of rotation (V)
  18893. */
  18894. vRotationCenter: number;
  18895. /**
  18896. * Defines the center of rotation (W)
  18897. */
  18898. wRotationCenter: number;
  18899. /**
  18900. * Are mip maps generated for this texture or not.
  18901. */
  18902. readonly noMipmap: boolean;
  18903. /**
  18904. * List of inspectable custom properties (used by the Inspector)
  18905. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18906. */
  18907. inspectableCustomProperties: Nullable<IInspectable[]>;
  18908. private _noMipmap;
  18909. /** @hidden */
  18910. _invertY: boolean;
  18911. private _rowGenerationMatrix;
  18912. private _cachedTextureMatrix;
  18913. private _projectionModeMatrix;
  18914. private _t0;
  18915. private _t1;
  18916. private _t2;
  18917. private _cachedUOffset;
  18918. private _cachedVOffset;
  18919. private _cachedUScale;
  18920. private _cachedVScale;
  18921. private _cachedUAng;
  18922. private _cachedVAng;
  18923. private _cachedWAng;
  18924. private _cachedProjectionMatrixId;
  18925. private _cachedCoordinatesMode;
  18926. /** @hidden */
  18927. protected _initialSamplingMode: number;
  18928. /** @hidden */
  18929. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  18930. private _deleteBuffer;
  18931. protected _format: Nullable<number>;
  18932. private _delayedOnLoad;
  18933. private _delayedOnError;
  18934. /**
  18935. * Observable triggered once the texture has been loaded.
  18936. */
  18937. onLoadObservable: Observable<Texture>;
  18938. protected _isBlocking: boolean;
  18939. /**
  18940. * Is the texture preventing material to render while loading.
  18941. * If false, a default texture will be used instead of the loading one during the preparation step.
  18942. */
  18943. isBlocking: boolean;
  18944. /**
  18945. * Get the current sampling mode associated with the texture.
  18946. */
  18947. readonly samplingMode: number;
  18948. /**
  18949. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18950. */
  18951. readonly invertY: boolean;
  18952. /**
  18953. * Instantiates a new texture.
  18954. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18955. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18956. * @param url define the url of the picture to load as a texture
  18957. * @param scene define the scene the texture will belong to
  18958. * @param noMipmap define if the texture will require mip maps or not
  18959. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18960. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18961. * @param onLoad define a callback triggered when the texture has been loaded
  18962. * @param onError define a callback triggered when an error occurred during the loading session
  18963. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18964. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18965. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18966. */
  18967. 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);
  18968. /**
  18969. * Update the url (and optional buffer) of this texture if url was null during construction.
  18970. * @param url the url of the texture
  18971. * @param buffer the buffer of the texture (defaults to null)
  18972. * @param onLoad callback called when the texture is loaded (defaults to null)
  18973. */
  18974. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18975. /**
  18976. * Finish the loading sequence of a texture flagged as delayed load.
  18977. * @hidden
  18978. */
  18979. delayLoad(): void;
  18980. private _prepareRowForTextureGeneration;
  18981. /**
  18982. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18983. * @returns the transform matrix of the texture.
  18984. */
  18985. getTextureMatrix(): Matrix;
  18986. /**
  18987. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18988. * @returns The reflection texture transform
  18989. */
  18990. getReflectionTextureMatrix(): Matrix;
  18991. /**
  18992. * Clones the texture.
  18993. * @returns the cloned texture
  18994. */
  18995. clone(): Texture;
  18996. /**
  18997. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18998. * @returns The JSON representation of the texture
  18999. */
  19000. serialize(): any;
  19001. /**
  19002. * Get the current class name of the texture useful for serialization or dynamic coding.
  19003. * @returns "Texture"
  19004. */
  19005. getClassName(): string;
  19006. /**
  19007. * Dispose the texture and release its associated resources.
  19008. */
  19009. dispose(): void;
  19010. /**
  19011. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  19012. * @param parsedTexture Define the JSON representation of the texture
  19013. * @param scene Define the scene the parsed texture should be instantiated in
  19014. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  19015. * @returns The parsed texture if successful
  19016. */
  19017. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  19018. /**
  19019. * Creates a texture from its base 64 representation.
  19020. * @param data Define the base64 payload without the data: prefix
  19021. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  19022. * @param scene Define the scene the texture should belong to
  19023. * @param noMipmap Forces the texture to not create mip map information if true
  19024. * @param invertY define if the texture needs to be inverted on the y axis during loading
  19025. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  19026. * @param onLoad define a callback triggered when the texture has been loaded
  19027. * @param onError define a callback triggered when an error occurred during the loading session
  19028. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  19029. * @returns the created texture
  19030. */
  19031. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  19032. /**
  19033. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  19034. * @param data Define the base64 payload without the data: prefix
  19035. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  19036. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  19037. * @param scene Define the scene the texture should belong to
  19038. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  19039. * @param noMipmap Forces the texture to not create mip map information if true
  19040. * @param invertY define if the texture needs to be inverted on the y axis during loading
  19041. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  19042. * @param onLoad define a callback triggered when the texture has been loaded
  19043. * @param onError define a callback triggered when an error occurred during the loading session
  19044. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  19045. * @returns the created texture
  19046. */
  19047. 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;
  19048. }
  19049. }
  19050. declare module "babylonjs/PostProcesses/postProcessManager" {
  19051. import { Nullable } from "babylonjs/types";
  19052. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  19053. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  19054. import { Scene } from "babylonjs/scene";
  19055. /**
  19056. * PostProcessManager is used to manage one or more post processes or post process pipelines
  19057. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  19058. */
  19059. export class PostProcessManager {
  19060. private _scene;
  19061. private _indexBuffer;
  19062. private _vertexBuffers;
  19063. /**
  19064. * Creates a new instance PostProcess
  19065. * @param scene The scene that the post process is associated with.
  19066. */
  19067. constructor(scene: Scene);
  19068. private _prepareBuffers;
  19069. private _buildIndexBuffer;
  19070. /**
  19071. * Rebuilds the vertex buffers of the manager.
  19072. * @hidden
  19073. */
  19074. _rebuild(): void;
  19075. /**
  19076. * Prepares a frame to be run through a post process.
  19077. * @param sourceTexture The input texture to the post procesess. (default: null)
  19078. * @param postProcesses An array of post processes to be run. (default: null)
  19079. * @returns True if the post processes were able to be run.
  19080. * @hidden
  19081. */
  19082. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  19083. /**
  19084. * Manually render a set of post processes to a texture.
  19085. * @param postProcesses An array of post processes to be run.
  19086. * @param targetTexture The target texture to render to.
  19087. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  19088. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  19089. * @param lodLevel defines which lod of the texture to render to
  19090. */
  19091. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  19092. /**
  19093. * Finalize the result of the output of the postprocesses.
  19094. * @param doNotPresent If true the result will not be displayed to the screen.
  19095. * @param targetTexture The target texture to render to.
  19096. * @param faceIndex The index of the face to bind the target texture to.
  19097. * @param postProcesses The array of post processes to render.
  19098. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  19099. * @hidden
  19100. */
  19101. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  19102. /**
  19103. * Disposes of the post process manager.
  19104. */
  19105. dispose(): void;
  19106. }
  19107. }
  19108. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  19109. import { Scene } from "babylonjs/scene";
  19110. import { ISceneComponent } from "babylonjs/sceneComponent";
  19111. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  19112. module "babylonjs/abstractScene" {
  19113. interface AbstractScene {
  19114. /**
  19115. * The list of procedural textures added to the scene
  19116. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  19117. */
  19118. proceduralTextures: Array<ProceduralTexture>;
  19119. }
  19120. }
  19121. /**
  19122. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  19123. * in a given scene.
  19124. */
  19125. export class ProceduralTextureSceneComponent implements ISceneComponent {
  19126. /**
  19127. * The component name helpfull to identify the component in the list of scene components.
  19128. */
  19129. readonly name: string;
  19130. /**
  19131. * The scene the component belongs to.
  19132. */
  19133. scene: Scene;
  19134. /**
  19135. * Creates a new instance of the component for the given scene
  19136. * @param scene Defines the scene to register the component in
  19137. */
  19138. constructor(scene: Scene);
  19139. /**
  19140. * Registers the component in a given scene
  19141. */
  19142. register(): void;
  19143. /**
  19144. * Rebuilds the elements related to this component in case of
  19145. * context lost for instance.
  19146. */
  19147. rebuild(): void;
  19148. /**
  19149. * Disposes the component and the associated ressources.
  19150. */
  19151. dispose(): void;
  19152. private _beforeClear;
  19153. }
  19154. }
  19155. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  19156. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  19157. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  19158. module "babylonjs/Engines/engine" {
  19159. interface Engine {
  19160. /**
  19161. * Creates a new render target cube texture
  19162. * @param size defines the size of the texture
  19163. * @param options defines the options used to create the texture
  19164. * @returns a new render target cube texture stored in an InternalTexture
  19165. */
  19166. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  19167. }
  19168. }
  19169. }
  19170. declare module "babylonjs/Shaders/procedural.vertex" {
  19171. /** @hidden */
  19172. export var proceduralVertexShader: {
  19173. name: string;
  19174. shader: string;
  19175. };
  19176. }
  19177. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  19178. import { Observable } from "babylonjs/Misc/observable";
  19179. import { Nullable } from "babylonjs/types";
  19180. import { Scene } from "babylonjs/scene";
  19181. import { Matrix, Vector3, Vector2, Color3, Color4 } from "babylonjs/Maths/math";
  19182. import { Effect } from "babylonjs/Materials/effect";
  19183. import { Texture } from "babylonjs/Materials/Textures/texture";
  19184. import "babylonjs/Engines/Extensions/engine.renderTarget";
  19185. import "babylonjs/Shaders/procedural.vertex";
  19186. /**
  19187. * 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.
  19188. * This is the base class of any Procedural texture and contains most of the shareable code.
  19189. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  19190. */
  19191. export class ProceduralTexture extends Texture {
  19192. isCube: boolean;
  19193. /**
  19194. * Define if the texture is enabled or not (disabled texture will not render)
  19195. */
  19196. isEnabled: boolean;
  19197. /**
  19198. * Define if the texture must be cleared before rendering (default is true)
  19199. */
  19200. autoClear: boolean;
  19201. /**
  19202. * Callback called when the texture is generated
  19203. */
  19204. onGenerated: () => void;
  19205. /**
  19206. * Event raised when the texture is generated
  19207. */
  19208. onGeneratedObservable: Observable<ProceduralTexture>;
  19209. /** @hidden */
  19210. _generateMipMaps: boolean;
  19211. /** @hidden **/
  19212. _effect: Effect;
  19213. /** @hidden */
  19214. _textures: {
  19215. [key: string]: Texture;
  19216. };
  19217. private _size;
  19218. private _currentRefreshId;
  19219. private _refreshRate;
  19220. private _vertexBuffers;
  19221. private _indexBuffer;
  19222. private _uniforms;
  19223. private _samplers;
  19224. private _fragment;
  19225. private _floats;
  19226. private _ints;
  19227. private _floatsArrays;
  19228. private _colors3;
  19229. private _colors4;
  19230. private _vectors2;
  19231. private _vectors3;
  19232. private _matrices;
  19233. private _fallbackTexture;
  19234. private _fallbackTextureUsed;
  19235. private _engine;
  19236. private _cachedDefines;
  19237. private _contentUpdateId;
  19238. private _contentData;
  19239. /**
  19240. * Instantiates a new procedural texture.
  19241. * 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.
  19242. * This is the base class of any Procedural texture and contains most of the shareable code.
  19243. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  19244. * @param name Define the name of the texture
  19245. * @param size Define the size of the texture to create
  19246. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  19247. * @param scene Define the scene the texture belongs to
  19248. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  19249. * @param generateMipMaps Define if the texture should creates mip maps or not
  19250. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  19251. */
  19252. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  19253. /**
  19254. * The effect that is created when initializing the post process.
  19255. * @returns The created effect corresponding the the postprocess.
  19256. */
  19257. getEffect(): Effect;
  19258. /**
  19259. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  19260. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  19261. */
  19262. getContent(): Nullable<ArrayBufferView>;
  19263. private _createIndexBuffer;
  19264. /** @hidden */
  19265. _rebuild(): void;
  19266. /**
  19267. * Resets the texture in order to recreate its associated resources.
  19268. * This can be called in case of context loss
  19269. */
  19270. reset(): void;
  19271. protected _getDefines(): string;
  19272. /**
  19273. * Is the texture ready to be used ? (rendered at least once)
  19274. * @returns true if ready, otherwise, false.
  19275. */
  19276. isReady(): boolean;
  19277. /**
  19278. * Resets the refresh counter of the texture and start bak from scratch.
  19279. * Could be useful to regenerate the texture if it is setup to render only once.
  19280. */
  19281. resetRefreshCounter(): void;
  19282. /**
  19283. * Set the fragment shader to use in order to render the texture.
  19284. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  19285. */
  19286. setFragment(fragment: any): void;
  19287. /**
  19288. * Define the refresh rate of the texture or the rendering frequency.
  19289. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  19290. */
  19291. refreshRate: number;
  19292. /** @hidden */
  19293. _shouldRender(): boolean;
  19294. /**
  19295. * Get the size the texture is rendering at.
  19296. * @returns the size (texture is always squared)
  19297. */
  19298. getRenderSize(): number;
  19299. /**
  19300. * Resize the texture to new value.
  19301. * @param size Define the new size the texture should have
  19302. * @param generateMipMaps Define whether the new texture should create mip maps
  19303. */
  19304. resize(size: number, generateMipMaps: boolean): void;
  19305. private _checkUniform;
  19306. /**
  19307. * Set a texture in the shader program used to render.
  19308. * @param name Define the name of the uniform samplers as defined in the shader
  19309. * @param texture Define the texture to bind to this sampler
  19310. * @return the texture itself allowing "fluent" like uniform updates
  19311. */
  19312. setTexture(name: string, texture: Texture): ProceduralTexture;
  19313. /**
  19314. * Set a float in the shader.
  19315. * @param name Define the name of the uniform as defined in the shader
  19316. * @param value Define the value to give to the uniform
  19317. * @return the texture itself allowing "fluent" like uniform updates
  19318. */
  19319. setFloat(name: string, value: number): ProceduralTexture;
  19320. /**
  19321. * Set a int in the shader.
  19322. * @param name Define the name of the uniform as defined in the shader
  19323. * @param value Define the value to give to the uniform
  19324. * @return the texture itself allowing "fluent" like uniform updates
  19325. */
  19326. setInt(name: string, value: number): ProceduralTexture;
  19327. /**
  19328. * Set an array of floats in the shader.
  19329. * @param name Define the name of the uniform as defined in the shader
  19330. * @param value Define the value to give to the uniform
  19331. * @return the texture itself allowing "fluent" like uniform updates
  19332. */
  19333. setFloats(name: string, value: number[]): ProceduralTexture;
  19334. /**
  19335. * Set a vec3 in the shader from a Color3.
  19336. * @param name Define the name of the uniform as defined in the shader
  19337. * @param value Define the value to give to the uniform
  19338. * @return the texture itself allowing "fluent" like uniform updates
  19339. */
  19340. setColor3(name: string, value: Color3): ProceduralTexture;
  19341. /**
  19342. * Set a vec4 in the shader from a Color4.
  19343. * @param name Define the name of the uniform as defined in the shader
  19344. * @param value Define the value to give to the uniform
  19345. * @return the texture itself allowing "fluent" like uniform updates
  19346. */
  19347. setColor4(name: string, value: Color4): ProceduralTexture;
  19348. /**
  19349. * Set a vec2 in the shader from a Vector2.
  19350. * @param name Define the name of the uniform as defined in the shader
  19351. * @param value Define the value to give to the uniform
  19352. * @return the texture itself allowing "fluent" like uniform updates
  19353. */
  19354. setVector2(name: string, value: Vector2): ProceduralTexture;
  19355. /**
  19356. * Set a vec3 in the shader from a Vector3.
  19357. * @param name Define the name of the uniform as defined in the shader
  19358. * @param value Define the value to give to the uniform
  19359. * @return the texture itself allowing "fluent" like uniform updates
  19360. */
  19361. setVector3(name: string, value: Vector3): ProceduralTexture;
  19362. /**
  19363. * Set a mat4 in the shader from a MAtrix.
  19364. * @param name Define the name of the uniform as defined in the shader
  19365. * @param value Define the value to give to the uniform
  19366. * @return the texture itself allowing "fluent" like uniform updates
  19367. */
  19368. setMatrix(name: string, value: Matrix): ProceduralTexture;
  19369. /**
  19370. * Render the texture to its associated render target.
  19371. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  19372. */
  19373. render(useCameraPostProcess?: boolean): void;
  19374. /**
  19375. * Clone the texture.
  19376. * @returns the cloned texture
  19377. */
  19378. clone(): ProceduralTexture;
  19379. /**
  19380. * Dispose the texture and release its asoociated resources.
  19381. */
  19382. dispose(): void;
  19383. }
  19384. }
  19385. declare module "babylonjs/Particles/baseParticleSystem" {
  19386. import { Nullable } from "babylonjs/types";
  19387. import { Color4, Vector2, Vector3 } from "babylonjs/Maths/math";
  19388. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19389. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  19390. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  19391. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  19392. import { Scene } from "babylonjs/scene";
  19393. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/tools";
  19394. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  19395. import { Texture } from "babylonjs/Materials/Textures/texture";
  19396. import { Animation } from "babylonjs/Animations/animation";
  19397. /**
  19398. * This represents the base class for particle system in Babylon.
  19399. * 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.
  19400. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  19401. * @example https://doc.babylonjs.com/babylon101/particles
  19402. */
  19403. export class BaseParticleSystem {
  19404. /**
  19405. * Source color is added to the destination color without alpha affecting the result
  19406. */
  19407. static BLENDMODE_ONEONE: number;
  19408. /**
  19409. * Blend current color and particle color using particle’s alpha
  19410. */
  19411. static BLENDMODE_STANDARD: number;
  19412. /**
  19413. * Add current color and particle color multiplied by particle’s alpha
  19414. */
  19415. static BLENDMODE_ADD: number;
  19416. /**
  19417. * Multiply current color with particle color
  19418. */
  19419. static BLENDMODE_MULTIPLY: number;
  19420. /**
  19421. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  19422. */
  19423. static BLENDMODE_MULTIPLYADD: number;
  19424. /**
  19425. * List of animations used by the particle system.
  19426. */
  19427. animations: Animation[];
  19428. /**
  19429. * The id of the Particle system.
  19430. */
  19431. id: string;
  19432. /**
  19433. * The friendly name of the Particle system.
  19434. */
  19435. name: string;
  19436. /**
  19437. * The rendering group used by the Particle system to chose when to render.
  19438. */
  19439. renderingGroupId: number;
  19440. /**
  19441. * The emitter represents the Mesh or position we are attaching the particle system to.
  19442. */
  19443. emitter: Nullable<AbstractMesh | Vector3>;
  19444. /**
  19445. * The maximum number of particles to emit per frame
  19446. */
  19447. emitRate: number;
  19448. /**
  19449. * If you want to launch only a few particles at once, that can be done, as well.
  19450. */
  19451. manualEmitCount: number;
  19452. /**
  19453. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  19454. */
  19455. updateSpeed: number;
  19456. /**
  19457. * The amount of time the particle system is running (depends of the overall update speed).
  19458. */
  19459. targetStopDuration: number;
  19460. /**
  19461. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  19462. */
  19463. disposeOnStop: boolean;
  19464. /**
  19465. * Minimum power of emitting particles.
  19466. */
  19467. minEmitPower: number;
  19468. /**
  19469. * Maximum power of emitting particles.
  19470. */
  19471. maxEmitPower: number;
  19472. /**
  19473. * Minimum life time of emitting particles.
  19474. */
  19475. minLifeTime: number;
  19476. /**
  19477. * Maximum life time of emitting particles.
  19478. */
  19479. maxLifeTime: number;
  19480. /**
  19481. * Minimum Size of emitting particles.
  19482. */
  19483. minSize: number;
  19484. /**
  19485. * Maximum Size of emitting particles.
  19486. */
  19487. maxSize: number;
  19488. /**
  19489. * Minimum scale of emitting particles on X axis.
  19490. */
  19491. minScaleX: number;
  19492. /**
  19493. * Maximum scale of emitting particles on X axis.
  19494. */
  19495. maxScaleX: number;
  19496. /**
  19497. * Minimum scale of emitting particles on Y axis.
  19498. */
  19499. minScaleY: number;
  19500. /**
  19501. * Maximum scale of emitting particles on Y axis.
  19502. */
  19503. maxScaleY: number;
  19504. /**
  19505. * Gets or sets the minimal initial rotation in radians.
  19506. */
  19507. minInitialRotation: number;
  19508. /**
  19509. * Gets or sets the maximal initial rotation in radians.
  19510. */
  19511. maxInitialRotation: number;
  19512. /**
  19513. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  19514. */
  19515. minAngularSpeed: number;
  19516. /**
  19517. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  19518. */
  19519. maxAngularSpeed: number;
  19520. /**
  19521. * The texture used to render each particle. (this can be a spritesheet)
  19522. */
  19523. particleTexture: Nullable<Texture>;
  19524. /**
  19525. * The layer mask we are rendering the particles through.
  19526. */
  19527. layerMask: number;
  19528. /**
  19529. * This can help using your own shader to render the particle system.
  19530. * The according effect will be created
  19531. */
  19532. customShader: any;
  19533. /**
  19534. * By default particle system starts as soon as they are created. This prevents the
  19535. * automatic start to happen and let you decide when to start emitting particles.
  19536. */
  19537. preventAutoStart: boolean;
  19538. private _noiseTexture;
  19539. /**
  19540. * Gets or sets a texture used to add random noise to particle positions
  19541. */
  19542. noiseTexture: Nullable<ProceduralTexture>;
  19543. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  19544. noiseStrength: Vector3;
  19545. /**
  19546. * Callback triggered when the particle animation is ending.
  19547. */
  19548. onAnimationEnd: Nullable<() => void>;
  19549. /**
  19550. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  19551. */
  19552. blendMode: number;
  19553. /**
  19554. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  19555. * to override the particles.
  19556. */
  19557. forceDepthWrite: boolean;
  19558. /** 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 */
  19559. preWarmCycles: number;
  19560. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  19561. preWarmStepOffset: number;
  19562. /**
  19563. * 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)
  19564. */
  19565. spriteCellChangeSpeed: number;
  19566. /**
  19567. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  19568. */
  19569. startSpriteCellID: number;
  19570. /**
  19571. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  19572. */
  19573. endSpriteCellID: number;
  19574. /**
  19575. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  19576. */
  19577. spriteCellWidth: number;
  19578. /**
  19579. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  19580. */
  19581. spriteCellHeight: number;
  19582. /**
  19583. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  19584. */
  19585. spriteRandomStartCell: boolean;
  19586. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  19587. translationPivot: Vector2;
  19588. /** @hidden */
  19589. protected _isAnimationSheetEnabled: boolean;
  19590. /**
  19591. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  19592. */
  19593. beginAnimationOnStart: boolean;
  19594. /**
  19595. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  19596. */
  19597. beginAnimationFrom: number;
  19598. /**
  19599. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  19600. */
  19601. beginAnimationTo: number;
  19602. /**
  19603. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  19604. */
  19605. beginAnimationLoop: boolean;
  19606. /**
  19607. * Gets or sets a world offset applied to all particles
  19608. */
  19609. worldOffset: Vector3;
  19610. /**
  19611. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  19612. */
  19613. isAnimationSheetEnabled: boolean;
  19614. /**
  19615. * Get hosting scene
  19616. * @returns the scene
  19617. */
  19618. getScene(): Scene;
  19619. /**
  19620. * You can use gravity if you want to give an orientation to your particles.
  19621. */
  19622. gravity: Vector3;
  19623. protected _colorGradients: Nullable<Array<ColorGradient>>;
  19624. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  19625. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  19626. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  19627. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  19628. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  19629. protected _dragGradients: Nullable<Array<FactorGradient>>;
  19630. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  19631. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  19632. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  19633. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  19634. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  19635. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  19636. /**
  19637. * Defines the delay in milliseconds before starting the system (0 by default)
  19638. */
  19639. startDelay: number;
  19640. /**
  19641. * Gets the current list of drag gradients.
  19642. * You must use addDragGradient and removeDragGradient to udpate this list
  19643. * @returns the list of drag gradients
  19644. */
  19645. getDragGradients(): Nullable<Array<FactorGradient>>;
  19646. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  19647. limitVelocityDamping: number;
  19648. /**
  19649. * Gets the current list of limit velocity gradients.
  19650. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  19651. * @returns the list of limit velocity gradients
  19652. */
  19653. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  19654. /**
  19655. * Gets the current list of color gradients.
  19656. * You must use addColorGradient and removeColorGradient to udpate this list
  19657. * @returns the list of color gradients
  19658. */
  19659. getColorGradients(): Nullable<Array<ColorGradient>>;
  19660. /**
  19661. * Gets the current list of size gradients.
  19662. * You must use addSizeGradient and removeSizeGradient to udpate this list
  19663. * @returns the list of size gradients
  19664. */
  19665. getSizeGradients(): Nullable<Array<FactorGradient>>;
  19666. /**
  19667. * Gets the current list of color remap gradients.
  19668. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19669. * @returns the list of color remap gradients
  19670. */
  19671. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19672. /**
  19673. * Gets the current list of alpha remap gradients.
  19674. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19675. * @returns the list of alpha remap gradients
  19676. */
  19677. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19678. /**
  19679. * Gets the current list of life time gradients.
  19680. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19681. * @returns the list of life time gradients
  19682. */
  19683. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19684. /**
  19685. * Gets the current list of angular speed gradients.
  19686. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  19687. * @returns the list of angular speed gradients
  19688. */
  19689. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  19690. /**
  19691. * Gets the current list of velocity gradients.
  19692. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  19693. * @returns the list of velocity gradients
  19694. */
  19695. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  19696. /**
  19697. * Gets the current list of start size gradients.
  19698. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19699. * @returns the list of start size gradients
  19700. */
  19701. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19702. /**
  19703. * Gets the current list of emit rate gradients.
  19704. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19705. * @returns the list of emit rate gradients
  19706. */
  19707. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19708. /**
  19709. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  19710. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19711. */
  19712. direction1: Vector3;
  19713. /**
  19714. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  19715. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19716. */
  19717. direction2: Vector3;
  19718. /**
  19719. * 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.
  19720. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19721. */
  19722. minEmitBox: Vector3;
  19723. /**
  19724. * 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.
  19725. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19726. */
  19727. maxEmitBox: Vector3;
  19728. /**
  19729. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  19730. */
  19731. color1: Color4;
  19732. /**
  19733. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  19734. */
  19735. color2: Color4;
  19736. /**
  19737. * Color the particle will have at the end of its lifetime
  19738. */
  19739. colorDead: Color4;
  19740. /**
  19741. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  19742. */
  19743. textureMask: Color4;
  19744. /**
  19745. * The particle emitter type defines the emitter used by the particle system.
  19746. * It can be for example box, sphere, or cone...
  19747. */
  19748. particleEmitterType: IParticleEmitterType;
  19749. /** @hidden */
  19750. _isSubEmitter: boolean;
  19751. /**
  19752. * Gets or sets the billboard mode to use when isBillboardBased = true.
  19753. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  19754. */
  19755. billboardMode: number;
  19756. protected _isBillboardBased: boolean;
  19757. /**
  19758. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  19759. */
  19760. isBillboardBased: boolean;
  19761. /**
  19762. * The scene the particle system belongs to.
  19763. */
  19764. protected _scene: Scene;
  19765. /**
  19766. * Local cache of defines for image processing.
  19767. */
  19768. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  19769. /**
  19770. * Default configuration related to image processing available in the standard Material.
  19771. */
  19772. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  19773. /**
  19774. * Gets the image processing configuration used either in this material.
  19775. */
  19776. /**
  19777. * Sets the Default image processing configuration used either in the this material.
  19778. *
  19779. * If sets to null, the scene one is in use.
  19780. */
  19781. imageProcessingConfiguration: ImageProcessingConfiguration;
  19782. /**
  19783. * Attaches a new image processing configuration to the Standard Material.
  19784. * @param configuration
  19785. */
  19786. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  19787. /** @hidden */
  19788. protected _reset(): void;
  19789. /** @hidden */
  19790. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  19791. /**
  19792. * Instantiates a particle system.
  19793. * 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.
  19794. * @param name The name of the particle system
  19795. */
  19796. constructor(name: string);
  19797. /**
  19798. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19799. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19800. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19801. * @returns the emitter
  19802. */
  19803. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19804. /**
  19805. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19806. * @param radius The radius of the hemisphere to emit from
  19807. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19808. * @returns the emitter
  19809. */
  19810. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  19811. /**
  19812. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19813. * @param radius The radius of the sphere to emit from
  19814. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19815. * @returns the emitter
  19816. */
  19817. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  19818. /**
  19819. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19820. * @param radius The radius of the sphere to emit from
  19821. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19822. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19823. * @returns the emitter
  19824. */
  19825. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  19826. /**
  19827. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19828. * @param radius The radius of the emission cylinder
  19829. * @param height The height of the emission cylinder
  19830. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19831. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19832. * @returns the emitter
  19833. */
  19834. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  19835. /**
  19836. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19837. * @param radius The radius of the cylinder to emit from
  19838. * @param height The height of the emission cylinder
  19839. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19840. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19841. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19842. * @returns the emitter
  19843. */
  19844. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  19845. /**
  19846. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19847. * @param radius The radius of the cone to emit from
  19848. * @param angle The base angle of the cone
  19849. * @returns the emitter
  19850. */
  19851. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  19852. /**
  19853. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19854. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19855. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19856. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19857. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19858. * @returns the emitter
  19859. */
  19860. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19861. }
  19862. }
  19863. declare module "babylonjs/Particles/subEmitter" {
  19864. import { Scene } from "babylonjs/scene";
  19865. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  19866. /**
  19867. * Type of sub emitter
  19868. */
  19869. export enum SubEmitterType {
  19870. /**
  19871. * Attached to the particle over it's lifetime
  19872. */
  19873. ATTACHED = 0,
  19874. /**
  19875. * Created when the particle dies
  19876. */
  19877. END = 1
  19878. }
  19879. /**
  19880. * Sub emitter class used to emit particles from an existing particle
  19881. */
  19882. export class SubEmitter {
  19883. /**
  19884. * the particle system to be used by the sub emitter
  19885. */
  19886. particleSystem: ParticleSystem;
  19887. /**
  19888. * Type of the submitter (Default: END)
  19889. */
  19890. type: SubEmitterType;
  19891. /**
  19892. * 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)
  19893. * Note: This only is supported when using an emitter of type Mesh
  19894. */
  19895. inheritDirection: boolean;
  19896. /**
  19897. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  19898. */
  19899. inheritedVelocityAmount: number;
  19900. /**
  19901. * Creates a sub emitter
  19902. * @param particleSystem the particle system to be used by the sub emitter
  19903. */
  19904. constructor(
  19905. /**
  19906. * the particle system to be used by the sub emitter
  19907. */
  19908. particleSystem: ParticleSystem);
  19909. /**
  19910. * Clones the sub emitter
  19911. * @returns the cloned sub emitter
  19912. */
  19913. clone(): SubEmitter;
  19914. /**
  19915. * Serialize current object to a JSON object
  19916. * @returns the serialized object
  19917. */
  19918. serialize(): any;
  19919. /** @hidden */
  19920. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  19921. /**
  19922. * Creates a new SubEmitter from a serialized JSON version
  19923. * @param serializationObject defines the JSON object to read from
  19924. * @param scene defines the hosting scene
  19925. * @param rootUrl defines the rootUrl for data loading
  19926. * @returns a new SubEmitter
  19927. */
  19928. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  19929. /** Release associated resources */
  19930. dispose(): void;
  19931. }
  19932. }
  19933. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  19934. /** @hidden */
  19935. export var imageProcessingDeclaration: {
  19936. name: string;
  19937. shader: string;
  19938. };
  19939. }
  19940. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  19941. /** @hidden */
  19942. export var imageProcessingFunctions: {
  19943. name: string;
  19944. shader: string;
  19945. };
  19946. }
  19947. declare module "babylonjs/Shaders/particles.fragment" {
  19948. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  19949. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  19950. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  19951. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  19952. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  19953. /** @hidden */
  19954. export var particlesPixelShader: {
  19955. name: string;
  19956. shader: string;
  19957. };
  19958. }
  19959. declare module "babylonjs/Shaders/particles.vertex" {
  19960. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  19961. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  19962. /** @hidden */
  19963. export var particlesVertexShader: {
  19964. name: string;
  19965. shader: string;
  19966. };
  19967. }
  19968. declare module "babylonjs/Particles/particleSystem" {
  19969. import { Nullable } from "babylonjs/types";
  19970. import { IAnimatable, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  19971. import { Observable } from "babylonjs/Misc/observable";
  19972. import { Color4, Color3, Vector3, Matrix } from "babylonjs/Maths/math";
  19973. import { Effect } from "babylonjs/Materials/effect";
  19974. import { Scene, IDisposable } from "babylonjs/scene";
  19975. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  19976. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  19977. import { Particle } from "babylonjs/Particles/particle";
  19978. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  19979. import "babylonjs/Shaders/particles.fragment";
  19980. import "babylonjs/Shaders/particles.vertex";
  19981. /**
  19982. * This represents a particle system in Babylon.
  19983. * 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.
  19984. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  19985. * @example https://doc.babylonjs.com/babylon101/particles
  19986. */
  19987. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  19988. /**
  19989. * Billboard mode will only apply to Y axis
  19990. */
  19991. static readonly BILLBOARDMODE_Y: number;
  19992. /**
  19993. * Billboard mode will apply to all axes
  19994. */
  19995. static readonly BILLBOARDMODE_ALL: number;
  19996. /**
  19997. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  19998. */
  19999. static readonly BILLBOARDMODE_STRETCHED: number;
  20000. /**
  20001. * This function can be defined to provide custom update for active particles.
  20002. * This function will be called instead of regular update (age, position, color, etc.).
  20003. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  20004. */
  20005. updateFunction: (particles: Particle[]) => void;
  20006. private _emitterWorldMatrix;
  20007. /**
  20008. * This function can be defined to specify initial direction for every new particle.
  20009. * It by default use the emitterType defined function
  20010. */
  20011. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  20012. /**
  20013. * This function can be defined to specify initial position for every new particle.
  20014. * It by default use the emitterType defined function
  20015. */
  20016. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  20017. /**
  20018. * @hidden
  20019. */
  20020. _inheritedVelocityOffset: Vector3;
  20021. /**
  20022. * An event triggered when the system is disposed
  20023. */
  20024. onDisposeObservable: Observable<ParticleSystem>;
  20025. private _onDisposeObserver;
  20026. /**
  20027. * Sets a callback that will be triggered when the system is disposed
  20028. */
  20029. onDispose: () => void;
  20030. private _particles;
  20031. private _epsilon;
  20032. private _capacity;
  20033. private _stockParticles;
  20034. private _newPartsExcess;
  20035. private _vertexData;
  20036. private _vertexBuffer;
  20037. private _vertexBuffers;
  20038. private _spriteBuffer;
  20039. private _indexBuffer;
  20040. private _effect;
  20041. private _customEffect;
  20042. private _cachedDefines;
  20043. private _scaledColorStep;
  20044. private _colorDiff;
  20045. private _scaledDirection;
  20046. private _scaledGravity;
  20047. private _currentRenderId;
  20048. private _alive;
  20049. private _useInstancing;
  20050. private _started;
  20051. private _stopped;
  20052. private _actualFrame;
  20053. private _scaledUpdateSpeed;
  20054. private _vertexBufferSize;
  20055. /** @hidden */
  20056. _currentEmitRateGradient: Nullable<FactorGradient>;
  20057. /** @hidden */
  20058. _currentEmitRate1: number;
  20059. /** @hidden */
  20060. _currentEmitRate2: number;
  20061. /** @hidden */
  20062. _currentStartSizeGradient: Nullable<FactorGradient>;
  20063. /** @hidden */
  20064. _currentStartSize1: number;
  20065. /** @hidden */
  20066. _currentStartSize2: number;
  20067. private readonly _rawTextureWidth;
  20068. private _rampGradientsTexture;
  20069. private _useRampGradients;
  20070. /** Gets or sets a boolean indicating that ramp gradients must be used
  20071. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  20072. */
  20073. useRampGradients: boolean;
  20074. /**
  20075. * 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.
  20076. * 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: [])
  20077. */
  20078. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  20079. private _subEmitters;
  20080. /**
  20081. * @hidden
  20082. * If the particle systems emitter should be disposed when the particle system is disposed
  20083. */
  20084. _disposeEmitterOnDispose: boolean;
  20085. /**
  20086. * The current active Sub-systems, this property is used by the root particle system only.
  20087. */
  20088. activeSubSystems: Array<ParticleSystem>;
  20089. private _rootParticleSystem;
  20090. /**
  20091. * Gets the current list of active particles
  20092. */
  20093. readonly particles: Particle[];
  20094. /**
  20095. * Returns the string "ParticleSystem"
  20096. * @returns a string containing the class name
  20097. */
  20098. getClassName(): string;
  20099. /**
  20100. * Instantiates a particle system.
  20101. * 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.
  20102. * @param name The name of the particle system
  20103. * @param capacity The max number of particles alive at the same time
  20104. * @param scene The scene the particle system belongs to
  20105. * @param customEffect a custom effect used to change the way particles are rendered by default
  20106. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  20107. * @param epsilon Offset used to render the particles
  20108. */
  20109. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  20110. private _addFactorGradient;
  20111. private _removeFactorGradient;
  20112. /**
  20113. * Adds a new life time gradient
  20114. * @param gradient defines the gradient to use (between 0 and 1)
  20115. * @param factor defines the life time factor to affect to the specified gradient
  20116. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20117. * @returns the current particle system
  20118. */
  20119. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20120. /**
  20121. * Remove a specific life time gradient
  20122. * @param gradient defines the gradient to remove
  20123. * @returns the current particle system
  20124. */
  20125. removeLifeTimeGradient(gradient: number): IParticleSystem;
  20126. /**
  20127. * Adds a new size gradient
  20128. * @param gradient defines the gradient to use (between 0 and 1)
  20129. * @param factor defines the size factor to affect to the specified gradient
  20130. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20131. * @returns the current particle system
  20132. */
  20133. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20134. /**
  20135. * Remove a specific size gradient
  20136. * @param gradient defines the gradient to remove
  20137. * @returns the current particle system
  20138. */
  20139. removeSizeGradient(gradient: number): IParticleSystem;
  20140. /**
  20141. * Adds a new color remap gradient
  20142. * @param gradient defines the gradient to use (between 0 and 1)
  20143. * @param min defines the color remap minimal range
  20144. * @param max defines the color remap maximal range
  20145. * @returns the current particle system
  20146. */
  20147. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  20148. /**
  20149. * Remove a specific color remap gradient
  20150. * @param gradient defines the gradient to remove
  20151. * @returns the current particle system
  20152. */
  20153. removeColorRemapGradient(gradient: number): IParticleSystem;
  20154. /**
  20155. * Adds a new alpha remap gradient
  20156. * @param gradient defines the gradient to use (between 0 and 1)
  20157. * @param min defines the alpha remap minimal range
  20158. * @param max defines the alpha remap maximal range
  20159. * @returns the current particle system
  20160. */
  20161. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  20162. /**
  20163. * Remove a specific alpha remap gradient
  20164. * @param gradient defines the gradient to remove
  20165. * @returns the current particle system
  20166. */
  20167. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  20168. /**
  20169. * Adds a new angular speed gradient
  20170. * @param gradient defines the gradient to use (between 0 and 1)
  20171. * @param factor defines the angular speed to affect to the specified gradient
  20172. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20173. * @returns the current particle system
  20174. */
  20175. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20176. /**
  20177. * Remove a specific angular speed gradient
  20178. * @param gradient defines the gradient to remove
  20179. * @returns the current particle system
  20180. */
  20181. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  20182. /**
  20183. * Adds a new velocity gradient
  20184. * @param gradient defines the gradient to use (between 0 and 1)
  20185. * @param factor defines the velocity to affect to the specified gradient
  20186. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20187. * @returns the current particle system
  20188. */
  20189. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20190. /**
  20191. * Remove a specific velocity gradient
  20192. * @param gradient defines the gradient to remove
  20193. * @returns the current particle system
  20194. */
  20195. removeVelocityGradient(gradient: number): IParticleSystem;
  20196. /**
  20197. * Adds a new limit velocity gradient
  20198. * @param gradient defines the gradient to use (between 0 and 1)
  20199. * @param factor defines the limit velocity value to affect to the specified gradient
  20200. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20201. * @returns the current particle system
  20202. */
  20203. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20204. /**
  20205. * Remove a specific limit velocity gradient
  20206. * @param gradient defines the gradient to remove
  20207. * @returns the current particle system
  20208. */
  20209. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  20210. /**
  20211. * Adds a new drag gradient
  20212. * @param gradient defines the gradient to use (between 0 and 1)
  20213. * @param factor defines the drag value to affect to the specified gradient
  20214. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20215. * @returns the current particle system
  20216. */
  20217. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20218. /**
  20219. * Remove a specific drag gradient
  20220. * @param gradient defines the gradient to remove
  20221. * @returns the current particle system
  20222. */
  20223. removeDragGradient(gradient: number): IParticleSystem;
  20224. /**
  20225. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  20226. * @param gradient defines the gradient to use (between 0 and 1)
  20227. * @param factor defines the emit rate value to affect to the specified gradient
  20228. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20229. * @returns the current particle system
  20230. */
  20231. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20232. /**
  20233. * Remove a specific emit rate gradient
  20234. * @param gradient defines the gradient to remove
  20235. * @returns the current particle system
  20236. */
  20237. removeEmitRateGradient(gradient: number): IParticleSystem;
  20238. /**
  20239. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  20240. * @param gradient defines the gradient to use (between 0 and 1)
  20241. * @param factor defines the start size value to affect to the specified gradient
  20242. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20243. * @returns the current particle system
  20244. */
  20245. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20246. /**
  20247. * Remove a specific start size gradient
  20248. * @param gradient defines the gradient to remove
  20249. * @returns the current particle system
  20250. */
  20251. removeStartSizeGradient(gradient: number): IParticleSystem;
  20252. private _createRampGradientTexture;
  20253. /**
  20254. * Gets the current list of ramp gradients.
  20255. * You must use addRampGradient and removeRampGradient to udpate this list
  20256. * @returns the list of ramp gradients
  20257. */
  20258. getRampGradients(): Nullable<Array<Color3Gradient>>;
  20259. /**
  20260. * Adds a new ramp gradient used to remap particle colors
  20261. * @param gradient defines the gradient to use (between 0 and 1)
  20262. * @param color defines the color to affect to the specified gradient
  20263. * @returns the current particle system
  20264. */
  20265. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  20266. /**
  20267. * Remove a specific ramp gradient
  20268. * @param gradient defines the gradient to remove
  20269. * @returns the current particle system
  20270. */
  20271. removeRampGradient(gradient: number): ParticleSystem;
  20272. /**
  20273. * Adds a new color gradient
  20274. * @param gradient defines the gradient to use (between 0 and 1)
  20275. * @param color1 defines the color to affect to the specified gradient
  20276. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  20277. * @returns this particle system
  20278. */
  20279. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  20280. /**
  20281. * Remove a specific color gradient
  20282. * @param gradient defines the gradient to remove
  20283. * @returns this particle system
  20284. */
  20285. removeColorGradient(gradient: number): IParticleSystem;
  20286. private _fetchR;
  20287. protected _reset(): void;
  20288. private _resetEffect;
  20289. private _createVertexBuffers;
  20290. private _createIndexBuffer;
  20291. /**
  20292. * Gets the maximum number of particles active at the same time.
  20293. * @returns The max number of active particles.
  20294. */
  20295. getCapacity(): number;
  20296. /**
  20297. * Gets whether there are still active particles in the system.
  20298. * @returns True if it is alive, otherwise false.
  20299. */
  20300. isAlive(): boolean;
  20301. /**
  20302. * Gets if the system has been started. (Note: this will still be true after stop is called)
  20303. * @returns True if it has been started, otherwise false.
  20304. */
  20305. isStarted(): boolean;
  20306. private _prepareSubEmitterInternalArray;
  20307. /**
  20308. * Starts the particle system and begins to emit
  20309. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  20310. */
  20311. start(delay?: number): void;
  20312. /**
  20313. * Stops the particle system.
  20314. * @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.
  20315. */
  20316. stop(stopSubEmitters?: boolean): void;
  20317. /**
  20318. * Remove all active particles
  20319. */
  20320. reset(): void;
  20321. /**
  20322. * @hidden (for internal use only)
  20323. */
  20324. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  20325. /**
  20326. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  20327. * Its lifetime will start back at 0.
  20328. */
  20329. recycleParticle: (particle: Particle) => void;
  20330. private _stopSubEmitters;
  20331. private _createParticle;
  20332. private _removeFromRoot;
  20333. private _emitFromParticle;
  20334. private _update;
  20335. /** @hidden */
  20336. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  20337. /** @hidden */
  20338. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  20339. /** @hidden */
  20340. private _getEffect;
  20341. /**
  20342. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  20343. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  20344. */
  20345. animate(preWarmOnly?: boolean): void;
  20346. private _appendParticleVertices;
  20347. /**
  20348. * Rebuilds the particle system.
  20349. */
  20350. rebuild(): void;
  20351. /**
  20352. * Is this system ready to be used/rendered
  20353. * @return true if the system is ready
  20354. */
  20355. isReady(): boolean;
  20356. private _render;
  20357. /**
  20358. * Renders the particle system in its current state.
  20359. * @returns the current number of particles
  20360. */
  20361. render(): number;
  20362. /**
  20363. * Disposes the particle system and free the associated resources
  20364. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  20365. */
  20366. dispose(disposeTexture?: boolean): void;
  20367. /**
  20368. * Clones the particle system.
  20369. * @param name The name of the cloned object
  20370. * @param newEmitter The new emitter to use
  20371. * @returns the cloned particle system
  20372. */
  20373. clone(name: string, newEmitter: any): ParticleSystem;
  20374. /**
  20375. * Serializes the particle system to a JSON object.
  20376. * @returns the JSON object
  20377. */
  20378. serialize(): any;
  20379. /** @hidden */
  20380. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  20381. /** @hidden */
  20382. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  20383. /**
  20384. * Parses a JSON object to create a particle system.
  20385. * @param parsedParticleSystem The JSON object to parse
  20386. * @param scene The scene to create the particle system in
  20387. * @param rootUrl The root url to use to load external dependencies like texture
  20388. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  20389. * @returns the Parsed particle system
  20390. */
  20391. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  20392. }
  20393. }
  20394. declare module "babylonjs/Particles/particle" {
  20395. import { Nullable } from "babylonjs/types";
  20396. import { Color4, Vector2, Vector3, Vector4 } from "babylonjs/Maths/math";
  20397. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  20398. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  20399. import { ColorGradient, FactorGradient } from "babylonjs/Misc/tools";
  20400. /**
  20401. * A particle represents one of the element emitted by a particle system.
  20402. * This is mainly define by its coordinates, direction, velocity and age.
  20403. */
  20404. export class Particle {
  20405. /**
  20406. * The particle system the particle belongs to.
  20407. */
  20408. particleSystem: ParticleSystem;
  20409. private static _Count;
  20410. /**
  20411. * Unique ID of the particle
  20412. */
  20413. id: number;
  20414. /**
  20415. * The world position of the particle in the scene.
  20416. */
  20417. position: Vector3;
  20418. /**
  20419. * The world direction of the particle in the scene.
  20420. */
  20421. direction: Vector3;
  20422. /**
  20423. * The color of the particle.
  20424. */
  20425. color: Color4;
  20426. /**
  20427. * The color change of the particle per step.
  20428. */
  20429. colorStep: Color4;
  20430. /**
  20431. * Defines how long will the life of the particle be.
  20432. */
  20433. lifeTime: number;
  20434. /**
  20435. * The current age of the particle.
  20436. */
  20437. age: number;
  20438. /**
  20439. * The current size of the particle.
  20440. */
  20441. size: number;
  20442. /**
  20443. * The current scale of the particle.
  20444. */
  20445. scale: Vector2;
  20446. /**
  20447. * The current angle of the particle.
  20448. */
  20449. angle: number;
  20450. /**
  20451. * Defines how fast is the angle changing.
  20452. */
  20453. angularSpeed: number;
  20454. /**
  20455. * Defines the cell index used by the particle to be rendered from a sprite.
  20456. */
  20457. cellIndex: number;
  20458. /**
  20459. * The information required to support color remapping
  20460. */
  20461. remapData: Vector4;
  20462. /** @hidden */
  20463. _randomCellOffset?: number;
  20464. /** @hidden */
  20465. _initialDirection: Nullable<Vector3>;
  20466. /** @hidden */
  20467. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  20468. /** @hidden */
  20469. _initialStartSpriteCellID: number;
  20470. /** @hidden */
  20471. _initialEndSpriteCellID: number;
  20472. /** @hidden */
  20473. _currentColorGradient: Nullable<ColorGradient>;
  20474. /** @hidden */
  20475. _currentColor1: Color4;
  20476. /** @hidden */
  20477. _currentColor2: Color4;
  20478. /** @hidden */
  20479. _currentSizeGradient: Nullable<FactorGradient>;
  20480. /** @hidden */
  20481. _currentSize1: number;
  20482. /** @hidden */
  20483. _currentSize2: number;
  20484. /** @hidden */
  20485. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  20486. /** @hidden */
  20487. _currentAngularSpeed1: number;
  20488. /** @hidden */
  20489. _currentAngularSpeed2: number;
  20490. /** @hidden */
  20491. _currentVelocityGradient: Nullable<FactorGradient>;
  20492. /** @hidden */
  20493. _currentVelocity1: number;
  20494. /** @hidden */
  20495. _currentVelocity2: number;
  20496. /** @hidden */
  20497. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  20498. /** @hidden */
  20499. _currentLimitVelocity1: number;
  20500. /** @hidden */
  20501. _currentLimitVelocity2: number;
  20502. /** @hidden */
  20503. _currentDragGradient: Nullable<FactorGradient>;
  20504. /** @hidden */
  20505. _currentDrag1: number;
  20506. /** @hidden */
  20507. _currentDrag2: number;
  20508. /** @hidden */
  20509. _randomNoiseCoordinates1: Vector3;
  20510. /** @hidden */
  20511. _randomNoiseCoordinates2: Vector3;
  20512. /**
  20513. * Creates a new instance Particle
  20514. * @param particleSystem the particle system the particle belongs to
  20515. */
  20516. constructor(
  20517. /**
  20518. * The particle system the particle belongs to.
  20519. */
  20520. particleSystem: ParticleSystem);
  20521. private updateCellInfoFromSystem;
  20522. /**
  20523. * Defines how the sprite cell index is updated for the particle
  20524. */
  20525. updateCellIndex(): void;
  20526. /** @hidden */
  20527. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  20528. /** @hidden */
  20529. _inheritParticleInfoToSubEmitters(): void;
  20530. /** @hidden */
  20531. _reset(): void;
  20532. /**
  20533. * Copy the properties of particle to another one.
  20534. * @param other the particle to copy the information to.
  20535. */
  20536. copyTo(other: Particle): void;
  20537. }
  20538. }
  20539. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  20540. import { Vector3, Matrix } from "babylonjs/Maths/math";
  20541. import { Effect } from "babylonjs/Materials/effect";
  20542. import { Particle } from "babylonjs/Particles/particle";
  20543. /**
  20544. * Particle emitter represents a volume emitting particles.
  20545. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  20546. */
  20547. export interface IParticleEmitterType {
  20548. /**
  20549. * Called by the particle System when the direction is computed for the created particle.
  20550. * @param worldMatrix is the world matrix of the particle system
  20551. * @param directionToUpdate is the direction vector to update with the result
  20552. * @param particle is the particle we are computed the direction for
  20553. */
  20554. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20555. /**
  20556. * Called by the particle System when the position is computed for the created particle.
  20557. * @param worldMatrix is the world matrix of the particle system
  20558. * @param positionToUpdate is the position vector to update with the result
  20559. * @param particle is the particle we are computed the position for
  20560. */
  20561. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20562. /**
  20563. * Clones the current emitter and returns a copy of it
  20564. * @returns the new emitter
  20565. */
  20566. clone(): IParticleEmitterType;
  20567. /**
  20568. * Called by the GPUParticleSystem to setup the update shader
  20569. * @param effect defines the update shader
  20570. */
  20571. applyToShader(effect: Effect): void;
  20572. /**
  20573. * Returns a string to use to update the GPU particles update shader
  20574. * @returns the effect defines string
  20575. */
  20576. getEffectDefines(): string;
  20577. /**
  20578. * Returns a string representing the class name
  20579. * @returns a string containing the class name
  20580. */
  20581. getClassName(): string;
  20582. /**
  20583. * Serializes the particle system to a JSON object.
  20584. * @returns the JSON object
  20585. */
  20586. serialize(): any;
  20587. /**
  20588. * Parse properties from a JSON object
  20589. * @param serializationObject defines the JSON object
  20590. */
  20591. parse(serializationObject: any): void;
  20592. }
  20593. }
  20594. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  20595. import { Vector3, Matrix } from "babylonjs/Maths/math";
  20596. import { Effect } from "babylonjs/Materials/effect";
  20597. import { Particle } from "babylonjs/Particles/particle";
  20598. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  20599. /**
  20600. * Particle emitter emitting particles from the inside of a box.
  20601. * It emits the particles randomly between 2 given directions.
  20602. */
  20603. export class BoxParticleEmitter implements IParticleEmitterType {
  20604. /**
  20605. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  20606. */
  20607. direction1: Vector3;
  20608. /**
  20609. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  20610. */
  20611. direction2: Vector3;
  20612. /**
  20613. * 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.
  20614. */
  20615. minEmitBox: Vector3;
  20616. /**
  20617. * 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.
  20618. */
  20619. maxEmitBox: Vector3;
  20620. /**
  20621. * Creates a new instance BoxParticleEmitter
  20622. */
  20623. constructor();
  20624. /**
  20625. * Called by the particle System when the direction is computed for the created particle.
  20626. * @param worldMatrix is the world matrix of the particle system
  20627. * @param directionToUpdate is the direction vector to update with the result
  20628. * @param particle is the particle we are computed the direction for
  20629. */
  20630. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20631. /**
  20632. * Called by the particle System when the position is computed for the created particle.
  20633. * @param worldMatrix is the world matrix of the particle system
  20634. * @param positionToUpdate is the position vector to update with the result
  20635. * @param particle is the particle we are computed the position for
  20636. */
  20637. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20638. /**
  20639. * Clones the current emitter and returns a copy of it
  20640. * @returns the new emitter
  20641. */
  20642. clone(): BoxParticleEmitter;
  20643. /**
  20644. * Called by the GPUParticleSystem to setup the update shader
  20645. * @param effect defines the update shader
  20646. */
  20647. applyToShader(effect: Effect): void;
  20648. /**
  20649. * Returns a string to use to update the GPU particles update shader
  20650. * @returns a string containng the defines string
  20651. */
  20652. getEffectDefines(): string;
  20653. /**
  20654. * Returns the string "BoxParticleEmitter"
  20655. * @returns a string containing the class name
  20656. */
  20657. getClassName(): string;
  20658. /**
  20659. * Serializes the particle system to a JSON object.
  20660. * @returns the JSON object
  20661. */
  20662. serialize(): any;
  20663. /**
  20664. * Parse properties from a JSON object
  20665. * @param serializationObject defines the JSON object
  20666. */
  20667. parse(serializationObject: any): void;
  20668. }
  20669. }
  20670. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  20671. import { Vector3, Matrix } from "babylonjs/Maths/math";
  20672. import { Effect } from "babylonjs/Materials/effect";
  20673. import { Particle } from "babylonjs/Particles/particle";
  20674. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  20675. /**
  20676. * Particle emitter emitting particles from the inside of a cone.
  20677. * It emits the particles alongside the cone volume from the base to the particle.
  20678. * The emission direction might be randomized.
  20679. */
  20680. export class ConeParticleEmitter implements IParticleEmitterType {
  20681. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  20682. directionRandomizer: number;
  20683. private _radius;
  20684. private _angle;
  20685. private _height;
  20686. /**
  20687. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  20688. */
  20689. radiusRange: number;
  20690. /**
  20691. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  20692. */
  20693. heightRange: number;
  20694. /**
  20695. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  20696. */
  20697. emitFromSpawnPointOnly: boolean;
  20698. /**
  20699. * Gets or sets the radius of the emission cone
  20700. */
  20701. radius: number;
  20702. /**
  20703. * Gets or sets the angle of the emission cone
  20704. */
  20705. angle: number;
  20706. private _buildHeight;
  20707. /**
  20708. * Creates a new instance ConeParticleEmitter
  20709. * @param radius the radius of the emission cone (1 by default)
  20710. * @param angle the cone base angle (PI by default)
  20711. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  20712. */
  20713. constructor(radius?: number, angle?: number,
  20714. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  20715. directionRandomizer?: number);
  20716. /**
  20717. * Called by the particle System when the direction is computed for the created particle.
  20718. * @param worldMatrix is the world matrix of the particle system
  20719. * @param directionToUpdate is the direction vector to update with the result
  20720. * @param particle is the particle we are computed the direction for
  20721. */
  20722. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20723. /**
  20724. * Called by the particle System when the position is computed for the created particle.
  20725. * @param worldMatrix is the world matrix of the particle system
  20726. * @param positionToUpdate is the position vector to update with the result
  20727. * @param particle is the particle we are computed the position for
  20728. */
  20729. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20730. /**
  20731. * Clones the current emitter and returns a copy of it
  20732. * @returns the new emitter
  20733. */
  20734. clone(): ConeParticleEmitter;
  20735. /**
  20736. * Called by the GPUParticleSystem to setup the update shader
  20737. * @param effect defines the update shader
  20738. */
  20739. applyToShader(effect: Effect): void;
  20740. /**
  20741. * Returns a string to use to update the GPU particles update shader
  20742. * @returns a string containng the defines string
  20743. */
  20744. getEffectDefines(): string;
  20745. /**
  20746. * Returns the string "ConeParticleEmitter"
  20747. * @returns a string containing the class name
  20748. */
  20749. getClassName(): string;
  20750. /**
  20751. * Serializes the particle system to a JSON object.
  20752. * @returns the JSON object
  20753. */
  20754. serialize(): any;
  20755. /**
  20756. * Parse properties from a JSON object
  20757. * @param serializationObject defines the JSON object
  20758. */
  20759. parse(serializationObject: any): void;
  20760. }
  20761. }
  20762. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  20763. import { Vector3, Matrix } from "babylonjs/Maths/math";
  20764. import { Effect } from "babylonjs/Materials/effect";
  20765. import { Particle } from "babylonjs/Particles/particle";
  20766. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  20767. /**
  20768. * Particle emitter emitting particles from the inside of a cylinder.
  20769. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  20770. */
  20771. export class CylinderParticleEmitter implements IParticleEmitterType {
  20772. /**
  20773. * The radius of the emission cylinder.
  20774. */
  20775. radius: number;
  20776. /**
  20777. * The height of the emission cylinder.
  20778. */
  20779. height: number;
  20780. /**
  20781. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20782. */
  20783. radiusRange: number;
  20784. /**
  20785. * How much to randomize the particle direction [0-1].
  20786. */
  20787. directionRandomizer: number;
  20788. /**
  20789. * Creates a new instance CylinderParticleEmitter
  20790. * @param radius the radius of the emission cylinder (1 by default)
  20791. * @param height the height of the emission cylinder (1 by default)
  20792. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  20793. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  20794. */
  20795. constructor(
  20796. /**
  20797. * The radius of the emission cylinder.
  20798. */
  20799. radius?: number,
  20800. /**
  20801. * The height of the emission cylinder.
  20802. */
  20803. height?: number,
  20804. /**
  20805. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20806. */
  20807. radiusRange?: number,
  20808. /**
  20809. * How much to randomize the particle direction [0-1].
  20810. */
  20811. directionRandomizer?: number);
  20812. /**
  20813. * Called by the particle System when the direction is computed for the created particle.
  20814. * @param worldMatrix is the world matrix of the particle system
  20815. * @param directionToUpdate is the direction vector to update with the result
  20816. * @param particle is the particle we are computed the direction for
  20817. */
  20818. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20819. /**
  20820. * Called by the particle System when the position is computed for the created particle.
  20821. * @param worldMatrix is the world matrix of the particle system
  20822. * @param positionToUpdate is the position vector to update with the result
  20823. * @param particle is the particle we are computed the position for
  20824. */
  20825. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20826. /**
  20827. * Clones the current emitter and returns a copy of it
  20828. * @returns the new emitter
  20829. */
  20830. clone(): CylinderParticleEmitter;
  20831. /**
  20832. * Called by the GPUParticleSystem to setup the update shader
  20833. * @param effect defines the update shader
  20834. */
  20835. applyToShader(effect: Effect): void;
  20836. /**
  20837. * Returns a string to use to update the GPU particles update shader
  20838. * @returns a string containng the defines string
  20839. */
  20840. getEffectDefines(): string;
  20841. /**
  20842. * Returns the string "CylinderParticleEmitter"
  20843. * @returns a string containing the class name
  20844. */
  20845. getClassName(): string;
  20846. /**
  20847. * Serializes the particle system to a JSON object.
  20848. * @returns the JSON object
  20849. */
  20850. serialize(): any;
  20851. /**
  20852. * Parse properties from a JSON object
  20853. * @param serializationObject defines the JSON object
  20854. */
  20855. parse(serializationObject: any): void;
  20856. }
  20857. /**
  20858. * Particle emitter emitting particles from the inside of a cylinder.
  20859. * It emits the particles randomly between two vectors.
  20860. */
  20861. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  20862. /**
  20863. * The min limit of the emission direction.
  20864. */
  20865. direction1: Vector3;
  20866. /**
  20867. * The max limit of the emission direction.
  20868. */
  20869. direction2: Vector3;
  20870. /**
  20871. * Creates a new instance CylinderDirectedParticleEmitter
  20872. * @param radius the radius of the emission cylinder (1 by default)
  20873. * @param height the height of the emission cylinder (1 by default)
  20874. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  20875. * @param direction1 the min limit of the emission direction (up vector by default)
  20876. * @param direction2 the max limit of the emission direction (up vector by default)
  20877. */
  20878. constructor(radius?: number, height?: number, radiusRange?: number,
  20879. /**
  20880. * The min limit of the emission direction.
  20881. */
  20882. direction1?: Vector3,
  20883. /**
  20884. * The max limit of the emission direction.
  20885. */
  20886. direction2?: Vector3);
  20887. /**
  20888. * Called by the particle System when the direction is computed for the created particle.
  20889. * @param worldMatrix is the world matrix of the particle system
  20890. * @param directionToUpdate is the direction vector to update with the result
  20891. * @param particle is the particle we are computed the direction for
  20892. */
  20893. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20894. /**
  20895. * Clones the current emitter and returns a copy of it
  20896. * @returns the new emitter
  20897. */
  20898. clone(): CylinderDirectedParticleEmitter;
  20899. /**
  20900. * Called by the GPUParticleSystem to setup the update shader
  20901. * @param effect defines the update shader
  20902. */
  20903. applyToShader(effect: Effect): void;
  20904. /**
  20905. * Returns a string to use to update the GPU particles update shader
  20906. * @returns a string containng the defines string
  20907. */
  20908. getEffectDefines(): string;
  20909. /**
  20910. * Returns the string "CylinderDirectedParticleEmitter"
  20911. * @returns a string containing the class name
  20912. */
  20913. getClassName(): string;
  20914. /**
  20915. * Serializes the particle system to a JSON object.
  20916. * @returns the JSON object
  20917. */
  20918. serialize(): any;
  20919. /**
  20920. * Parse properties from a JSON object
  20921. * @param serializationObject defines the JSON object
  20922. */
  20923. parse(serializationObject: any): void;
  20924. }
  20925. }
  20926. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  20927. import { Vector3, Matrix } from "babylonjs/Maths/math";
  20928. import { Effect } from "babylonjs/Materials/effect";
  20929. import { Particle } from "babylonjs/Particles/particle";
  20930. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  20931. /**
  20932. * Particle emitter emitting particles from the inside of a hemisphere.
  20933. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  20934. */
  20935. export class HemisphericParticleEmitter implements IParticleEmitterType {
  20936. /**
  20937. * The radius of the emission hemisphere.
  20938. */
  20939. radius: number;
  20940. /**
  20941. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20942. */
  20943. radiusRange: number;
  20944. /**
  20945. * How much to randomize the particle direction [0-1].
  20946. */
  20947. directionRandomizer: number;
  20948. /**
  20949. * Creates a new instance HemisphericParticleEmitter
  20950. * @param radius the radius of the emission hemisphere (1 by default)
  20951. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  20952. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  20953. */
  20954. constructor(
  20955. /**
  20956. * The radius of the emission hemisphere.
  20957. */
  20958. radius?: number,
  20959. /**
  20960. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20961. */
  20962. radiusRange?: number,
  20963. /**
  20964. * How much to randomize the particle direction [0-1].
  20965. */
  20966. directionRandomizer?: number);
  20967. /**
  20968. * Called by the particle System when the direction is computed for the created particle.
  20969. * @param worldMatrix is the world matrix of the particle system
  20970. * @param directionToUpdate is the direction vector to update with the result
  20971. * @param particle is the particle we are computed the direction for
  20972. */
  20973. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20974. /**
  20975. * Called by the particle System when the position is computed for the created particle.
  20976. * @param worldMatrix is the world matrix of the particle system
  20977. * @param positionToUpdate is the position vector to update with the result
  20978. * @param particle is the particle we are computed the position for
  20979. */
  20980. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20981. /**
  20982. * Clones the current emitter and returns a copy of it
  20983. * @returns the new emitter
  20984. */
  20985. clone(): HemisphericParticleEmitter;
  20986. /**
  20987. * Called by the GPUParticleSystem to setup the update shader
  20988. * @param effect defines the update shader
  20989. */
  20990. applyToShader(effect: Effect): void;
  20991. /**
  20992. * Returns a string to use to update the GPU particles update shader
  20993. * @returns a string containng the defines string
  20994. */
  20995. getEffectDefines(): string;
  20996. /**
  20997. * Returns the string "HemisphericParticleEmitter"
  20998. * @returns a string containing the class name
  20999. */
  21000. getClassName(): string;
  21001. /**
  21002. * Serializes the particle system to a JSON object.
  21003. * @returns the JSON object
  21004. */
  21005. serialize(): any;
  21006. /**
  21007. * Parse properties from a JSON object
  21008. * @param serializationObject defines the JSON object
  21009. */
  21010. parse(serializationObject: any): void;
  21011. }
  21012. }
  21013. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  21014. import { Vector3, Matrix } from "babylonjs/Maths/math";
  21015. import { Effect } from "babylonjs/Materials/effect";
  21016. import { Particle } from "babylonjs/Particles/particle";
  21017. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  21018. /**
  21019. * Particle emitter emitting particles from a point.
  21020. * It emits the particles randomly between 2 given directions.
  21021. */
  21022. export class PointParticleEmitter implements IParticleEmitterType {
  21023. /**
  21024. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  21025. */
  21026. direction1: Vector3;
  21027. /**
  21028. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  21029. */
  21030. direction2: Vector3;
  21031. /**
  21032. * Creates a new instance PointParticleEmitter
  21033. */
  21034. constructor();
  21035. /**
  21036. * Called by the particle System when the direction is computed for the created particle.
  21037. * @param worldMatrix is the world matrix of the particle system
  21038. * @param directionToUpdate is the direction vector to update with the result
  21039. * @param particle is the particle we are computed the direction for
  21040. */
  21041. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  21042. /**
  21043. * Called by the particle System when the position is computed for the created particle.
  21044. * @param worldMatrix is the world matrix of the particle system
  21045. * @param positionToUpdate is the position vector to update with the result
  21046. * @param particle is the particle we are computed the position for
  21047. */
  21048. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  21049. /**
  21050. * Clones the current emitter and returns a copy of it
  21051. * @returns the new emitter
  21052. */
  21053. clone(): PointParticleEmitter;
  21054. /**
  21055. * Called by the GPUParticleSystem to setup the update shader
  21056. * @param effect defines the update shader
  21057. */
  21058. applyToShader(effect: Effect): void;
  21059. /**
  21060. * Returns a string to use to update the GPU particles update shader
  21061. * @returns a string containng the defines string
  21062. */
  21063. getEffectDefines(): string;
  21064. /**
  21065. * Returns the string "PointParticleEmitter"
  21066. * @returns a string containing the class name
  21067. */
  21068. getClassName(): string;
  21069. /**
  21070. * Serializes the particle system to a JSON object.
  21071. * @returns the JSON object
  21072. */
  21073. serialize(): any;
  21074. /**
  21075. * Parse properties from a JSON object
  21076. * @param serializationObject defines the JSON object
  21077. */
  21078. parse(serializationObject: any): void;
  21079. }
  21080. }
  21081. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  21082. import { Vector3, Matrix } from "babylonjs/Maths/math";
  21083. import { Effect } from "babylonjs/Materials/effect";
  21084. import { Particle } from "babylonjs/Particles/particle";
  21085. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  21086. /**
  21087. * Particle emitter emitting particles from the inside of a sphere.
  21088. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  21089. */
  21090. export class SphereParticleEmitter implements IParticleEmitterType {
  21091. /**
  21092. * The radius of the emission sphere.
  21093. */
  21094. radius: number;
  21095. /**
  21096. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  21097. */
  21098. radiusRange: number;
  21099. /**
  21100. * How much to randomize the particle direction [0-1].
  21101. */
  21102. directionRandomizer: number;
  21103. /**
  21104. * Creates a new instance SphereParticleEmitter
  21105. * @param radius the radius of the emission sphere (1 by default)
  21106. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  21107. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  21108. */
  21109. constructor(
  21110. /**
  21111. * The radius of the emission sphere.
  21112. */
  21113. radius?: number,
  21114. /**
  21115. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  21116. */
  21117. radiusRange?: number,
  21118. /**
  21119. * How much to randomize the particle direction [0-1].
  21120. */
  21121. directionRandomizer?: number);
  21122. /**
  21123. * Called by the particle System when the direction is computed for the created particle.
  21124. * @param worldMatrix is the world matrix of the particle system
  21125. * @param directionToUpdate is the direction vector to update with the result
  21126. * @param particle is the particle we are computed the direction for
  21127. */
  21128. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  21129. /**
  21130. * Called by the particle System when the position is computed for the created particle.
  21131. * @param worldMatrix is the world matrix of the particle system
  21132. * @param positionToUpdate is the position vector to update with the result
  21133. * @param particle is the particle we are computed the position for
  21134. */
  21135. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  21136. /**
  21137. * Clones the current emitter and returns a copy of it
  21138. * @returns the new emitter
  21139. */
  21140. clone(): SphereParticleEmitter;
  21141. /**
  21142. * Called by the GPUParticleSystem to setup the update shader
  21143. * @param effect defines the update shader
  21144. */
  21145. applyToShader(effect: Effect): void;
  21146. /**
  21147. * Returns a string to use to update the GPU particles update shader
  21148. * @returns a string containng the defines string
  21149. */
  21150. getEffectDefines(): string;
  21151. /**
  21152. * Returns the string "SphereParticleEmitter"
  21153. * @returns a string containing the class name
  21154. */
  21155. getClassName(): string;
  21156. /**
  21157. * Serializes the particle system to a JSON object.
  21158. * @returns the JSON object
  21159. */
  21160. serialize(): any;
  21161. /**
  21162. * Parse properties from a JSON object
  21163. * @param serializationObject defines the JSON object
  21164. */
  21165. parse(serializationObject: any): void;
  21166. }
  21167. /**
  21168. * Particle emitter emitting particles from the inside of a sphere.
  21169. * It emits the particles randomly between two vectors.
  21170. */
  21171. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  21172. /**
  21173. * The min limit of the emission direction.
  21174. */
  21175. direction1: Vector3;
  21176. /**
  21177. * The max limit of the emission direction.
  21178. */
  21179. direction2: Vector3;
  21180. /**
  21181. * Creates a new instance SphereDirectedParticleEmitter
  21182. * @param radius the radius of the emission sphere (1 by default)
  21183. * @param direction1 the min limit of the emission direction (up vector by default)
  21184. * @param direction2 the max limit of the emission direction (up vector by default)
  21185. */
  21186. constructor(radius?: number,
  21187. /**
  21188. * The min limit of the emission direction.
  21189. */
  21190. direction1?: Vector3,
  21191. /**
  21192. * The max limit of the emission direction.
  21193. */
  21194. direction2?: Vector3);
  21195. /**
  21196. * Called by the particle System when the direction is computed for the created particle.
  21197. * @param worldMatrix is the world matrix of the particle system
  21198. * @param directionToUpdate is the direction vector to update with the result
  21199. * @param particle is the particle we are computed the direction for
  21200. */
  21201. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  21202. /**
  21203. * Clones the current emitter and returns a copy of it
  21204. * @returns the new emitter
  21205. */
  21206. clone(): SphereDirectedParticleEmitter;
  21207. /**
  21208. * Called by the GPUParticleSystem to setup the update shader
  21209. * @param effect defines the update shader
  21210. */
  21211. applyToShader(effect: Effect): void;
  21212. /**
  21213. * Returns a string to use to update the GPU particles update shader
  21214. * @returns a string containng the defines string
  21215. */
  21216. getEffectDefines(): string;
  21217. /**
  21218. * Returns the string "SphereDirectedParticleEmitter"
  21219. * @returns a string containing the class name
  21220. */
  21221. getClassName(): string;
  21222. /**
  21223. * Serializes the particle system to a JSON object.
  21224. * @returns the JSON object
  21225. */
  21226. serialize(): any;
  21227. /**
  21228. * Parse properties from a JSON object
  21229. * @param serializationObject defines the JSON object
  21230. */
  21231. parse(serializationObject: any): void;
  21232. }
  21233. }
  21234. declare module "babylonjs/Particles/EmitterTypes/index" {
  21235. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  21236. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  21237. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  21238. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  21239. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  21240. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  21241. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  21242. }
  21243. declare module "babylonjs/Particles/IParticleSystem" {
  21244. import { Nullable } from "babylonjs/types";
  21245. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  21246. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21247. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21248. import { Texture } from "babylonjs/Materials/Textures/texture";
  21249. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  21250. import { Scene } from "babylonjs/scene";
  21251. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  21252. import { Animation } from "babylonjs/Animations/animation";
  21253. /**
  21254. * Interface representing a particle system in Babylon.js.
  21255. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  21256. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  21257. */
  21258. export interface IParticleSystem {
  21259. /**
  21260. * List of animations used by the particle system.
  21261. */
  21262. animations: Animation[];
  21263. /**
  21264. * The id of the Particle system.
  21265. */
  21266. id: string;
  21267. /**
  21268. * The name of the Particle system.
  21269. */
  21270. name: string;
  21271. /**
  21272. * The emitter represents the Mesh or position we are attaching the particle system to.
  21273. */
  21274. emitter: Nullable<AbstractMesh | Vector3>;
  21275. /**
  21276. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  21277. */
  21278. isBillboardBased: boolean;
  21279. /**
  21280. * The rendering group used by the Particle system to chose when to render.
  21281. */
  21282. renderingGroupId: number;
  21283. /**
  21284. * The layer mask we are rendering the particles through.
  21285. */
  21286. layerMask: number;
  21287. /**
  21288. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  21289. */
  21290. updateSpeed: number;
  21291. /**
  21292. * The amount of time the particle system is running (depends of the overall update speed).
  21293. */
  21294. targetStopDuration: number;
  21295. /**
  21296. * The texture used to render each particle. (this can be a spritesheet)
  21297. */
  21298. particleTexture: Nullable<Texture>;
  21299. /**
  21300. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  21301. */
  21302. blendMode: number;
  21303. /**
  21304. * Minimum life time of emitting particles.
  21305. */
  21306. minLifeTime: number;
  21307. /**
  21308. * Maximum life time of emitting particles.
  21309. */
  21310. maxLifeTime: number;
  21311. /**
  21312. * Minimum Size of emitting particles.
  21313. */
  21314. minSize: number;
  21315. /**
  21316. * Maximum Size of emitting particles.
  21317. */
  21318. maxSize: number;
  21319. /**
  21320. * Minimum scale of emitting particles on X axis.
  21321. */
  21322. minScaleX: number;
  21323. /**
  21324. * Maximum scale of emitting particles on X axis.
  21325. */
  21326. maxScaleX: number;
  21327. /**
  21328. * Minimum scale of emitting particles on Y axis.
  21329. */
  21330. minScaleY: number;
  21331. /**
  21332. * Maximum scale of emitting particles on Y axis.
  21333. */
  21334. maxScaleY: number;
  21335. /**
  21336. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  21337. */
  21338. color1: Color4;
  21339. /**
  21340. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  21341. */
  21342. color2: Color4;
  21343. /**
  21344. * Color the particle will have at the end of its lifetime.
  21345. */
  21346. colorDead: Color4;
  21347. /**
  21348. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  21349. */
  21350. emitRate: number;
  21351. /**
  21352. * You can use gravity if you want to give an orientation to your particles.
  21353. */
  21354. gravity: Vector3;
  21355. /**
  21356. * Minimum power of emitting particles.
  21357. */
  21358. minEmitPower: number;
  21359. /**
  21360. * Maximum power of emitting particles.
  21361. */
  21362. maxEmitPower: number;
  21363. /**
  21364. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  21365. */
  21366. minAngularSpeed: number;
  21367. /**
  21368. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  21369. */
  21370. maxAngularSpeed: number;
  21371. /**
  21372. * Gets or sets the minimal initial rotation in radians.
  21373. */
  21374. minInitialRotation: number;
  21375. /**
  21376. * Gets or sets the maximal initial rotation in radians.
  21377. */
  21378. maxInitialRotation: number;
  21379. /**
  21380. * The particle emitter type defines the emitter used by the particle system.
  21381. * It can be for example box, sphere, or cone...
  21382. */
  21383. particleEmitterType: Nullable<IParticleEmitterType>;
  21384. /**
  21385. * Defines the delay in milliseconds before starting the system (0 by default)
  21386. */
  21387. startDelay: number;
  21388. /**
  21389. * 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
  21390. */
  21391. preWarmCycles: number;
  21392. /**
  21393. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  21394. */
  21395. preWarmStepOffset: number;
  21396. /**
  21397. * 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)
  21398. */
  21399. spriteCellChangeSpeed: number;
  21400. /**
  21401. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  21402. */
  21403. startSpriteCellID: number;
  21404. /**
  21405. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  21406. */
  21407. endSpriteCellID: number;
  21408. /**
  21409. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  21410. */
  21411. spriteCellWidth: number;
  21412. /**
  21413. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  21414. */
  21415. spriteCellHeight: number;
  21416. /**
  21417. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  21418. */
  21419. spriteRandomStartCell: boolean;
  21420. /**
  21421. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  21422. */
  21423. isAnimationSheetEnabled: boolean;
  21424. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  21425. translationPivot: Vector2;
  21426. /**
  21427. * Gets or sets a texture used to add random noise to particle positions
  21428. */
  21429. noiseTexture: Nullable<BaseTexture>;
  21430. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  21431. noiseStrength: Vector3;
  21432. /**
  21433. * Gets or sets the billboard mode to use when isBillboardBased = true.
  21434. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  21435. */
  21436. billboardMode: number;
  21437. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  21438. limitVelocityDamping: number;
  21439. /**
  21440. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  21441. */
  21442. beginAnimationOnStart: boolean;
  21443. /**
  21444. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  21445. */
  21446. beginAnimationFrom: number;
  21447. /**
  21448. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  21449. */
  21450. beginAnimationTo: number;
  21451. /**
  21452. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  21453. */
  21454. beginAnimationLoop: boolean;
  21455. /**
  21456. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  21457. */
  21458. disposeOnStop: boolean;
  21459. /**
  21460. * Gets the maximum number of particles active at the same time.
  21461. * @returns The max number of active particles.
  21462. */
  21463. getCapacity(): number;
  21464. /**
  21465. * Gets if the system has been started. (Note: this will still be true after stop is called)
  21466. * @returns True if it has been started, otherwise false.
  21467. */
  21468. isStarted(): boolean;
  21469. /**
  21470. * Animates the particle system for this frame.
  21471. */
  21472. animate(): void;
  21473. /**
  21474. * Renders the particle system in its current state.
  21475. * @returns the current number of particles
  21476. */
  21477. render(): number;
  21478. /**
  21479. * Dispose the particle system and frees its associated resources.
  21480. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  21481. */
  21482. dispose(disposeTexture?: boolean): void;
  21483. /**
  21484. * Clones the particle system.
  21485. * @param name The name of the cloned object
  21486. * @param newEmitter The new emitter to use
  21487. * @returns the cloned particle system
  21488. */
  21489. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  21490. /**
  21491. * Serializes the particle system to a JSON object.
  21492. * @returns the JSON object
  21493. */
  21494. serialize(): any;
  21495. /**
  21496. * Rebuild the particle system
  21497. */
  21498. rebuild(): void;
  21499. /**
  21500. * Starts the particle system and begins to emit
  21501. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  21502. */
  21503. start(delay?: number): void;
  21504. /**
  21505. * Stops the particle system.
  21506. */
  21507. stop(): void;
  21508. /**
  21509. * Remove all active particles
  21510. */
  21511. reset(): void;
  21512. /**
  21513. * Is this system ready to be used/rendered
  21514. * @return true if the system is ready
  21515. */
  21516. isReady(): boolean;
  21517. /**
  21518. * Adds a new color gradient
  21519. * @param gradient defines the gradient to use (between 0 and 1)
  21520. * @param color1 defines the color to affect to the specified gradient
  21521. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  21522. * @returns the current particle system
  21523. */
  21524. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  21525. /**
  21526. * Remove a specific color gradient
  21527. * @param gradient defines the gradient to remove
  21528. * @returns the current particle system
  21529. */
  21530. removeColorGradient(gradient: number): IParticleSystem;
  21531. /**
  21532. * Adds a new size gradient
  21533. * @param gradient defines the gradient to use (between 0 and 1)
  21534. * @param factor defines the size factor to affect to the specified gradient
  21535. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21536. * @returns the current particle system
  21537. */
  21538. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21539. /**
  21540. * Remove a specific size gradient
  21541. * @param gradient defines the gradient to remove
  21542. * @returns the current particle system
  21543. */
  21544. removeSizeGradient(gradient: number): IParticleSystem;
  21545. /**
  21546. * Gets the current list of color gradients.
  21547. * You must use addColorGradient and removeColorGradient to udpate this list
  21548. * @returns the list of color gradients
  21549. */
  21550. getColorGradients(): Nullable<Array<ColorGradient>>;
  21551. /**
  21552. * Gets the current list of size gradients.
  21553. * You must use addSizeGradient and removeSizeGradient to udpate this list
  21554. * @returns the list of size gradients
  21555. */
  21556. getSizeGradients(): Nullable<Array<FactorGradient>>;
  21557. /**
  21558. * Gets the current list of angular speed gradients.
  21559. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  21560. * @returns the list of angular speed gradients
  21561. */
  21562. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  21563. /**
  21564. * Adds a new angular speed gradient
  21565. * @param gradient defines the gradient to use (between 0 and 1)
  21566. * @param factor defines the angular speed to affect to the specified gradient
  21567. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21568. * @returns the current particle system
  21569. */
  21570. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21571. /**
  21572. * Remove a specific angular speed gradient
  21573. * @param gradient defines the gradient to remove
  21574. * @returns the current particle system
  21575. */
  21576. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  21577. /**
  21578. * Gets the current list of velocity gradients.
  21579. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  21580. * @returns the list of velocity gradients
  21581. */
  21582. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  21583. /**
  21584. * Adds a new velocity gradient
  21585. * @param gradient defines the gradient to use (between 0 and 1)
  21586. * @param factor defines the velocity to affect to the specified gradient
  21587. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21588. * @returns the current particle system
  21589. */
  21590. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21591. /**
  21592. * Remove a specific velocity gradient
  21593. * @param gradient defines the gradient to remove
  21594. * @returns the current particle system
  21595. */
  21596. removeVelocityGradient(gradient: number): IParticleSystem;
  21597. /**
  21598. * Gets the current list of limit velocity gradients.
  21599. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  21600. * @returns the list of limit velocity gradients
  21601. */
  21602. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  21603. /**
  21604. * Adds a new limit velocity gradient
  21605. * @param gradient defines the gradient to use (between 0 and 1)
  21606. * @param factor defines the limit velocity to affect to the specified gradient
  21607. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21608. * @returns the current particle system
  21609. */
  21610. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21611. /**
  21612. * Remove a specific limit velocity gradient
  21613. * @param gradient defines the gradient to remove
  21614. * @returns the current particle system
  21615. */
  21616. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  21617. /**
  21618. * Adds a new drag gradient
  21619. * @param gradient defines the gradient to use (between 0 and 1)
  21620. * @param factor defines the drag to affect to the specified gradient
  21621. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21622. * @returns the current particle system
  21623. */
  21624. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21625. /**
  21626. * Remove a specific drag gradient
  21627. * @param gradient defines the gradient to remove
  21628. * @returns the current particle system
  21629. */
  21630. removeDragGradient(gradient: number): IParticleSystem;
  21631. /**
  21632. * Gets the current list of drag gradients.
  21633. * You must use addDragGradient and removeDragGradient to udpate this list
  21634. * @returns the list of drag gradients
  21635. */
  21636. getDragGradients(): Nullable<Array<FactorGradient>>;
  21637. /**
  21638. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  21639. * @param gradient defines the gradient to use (between 0 and 1)
  21640. * @param factor defines the emit rate to affect to the specified gradient
  21641. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21642. * @returns the current particle system
  21643. */
  21644. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21645. /**
  21646. * Remove a specific emit rate gradient
  21647. * @param gradient defines the gradient to remove
  21648. * @returns the current particle system
  21649. */
  21650. removeEmitRateGradient(gradient: number): IParticleSystem;
  21651. /**
  21652. * Gets the current list of emit rate gradients.
  21653. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  21654. * @returns the list of emit rate gradients
  21655. */
  21656. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  21657. /**
  21658. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  21659. * @param gradient defines the gradient to use (between 0 and 1)
  21660. * @param factor defines the start size to affect to the specified gradient
  21661. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21662. * @returns the current particle system
  21663. */
  21664. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21665. /**
  21666. * Remove a specific start size gradient
  21667. * @param gradient defines the gradient to remove
  21668. * @returns the current particle system
  21669. */
  21670. removeStartSizeGradient(gradient: number): IParticleSystem;
  21671. /**
  21672. * Gets the current list of start size gradients.
  21673. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  21674. * @returns the list of start size gradients
  21675. */
  21676. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  21677. /**
  21678. * Adds a new life time gradient
  21679. * @param gradient defines the gradient to use (between 0 and 1)
  21680. * @param factor defines the life time factor to affect to the specified gradient
  21681. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21682. * @returns the current particle system
  21683. */
  21684. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21685. /**
  21686. * Remove a specific life time gradient
  21687. * @param gradient defines the gradient to remove
  21688. * @returns the current particle system
  21689. */
  21690. removeLifeTimeGradient(gradient: number): IParticleSystem;
  21691. /**
  21692. * Gets the current list of life time gradients.
  21693. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  21694. * @returns the list of life time gradients
  21695. */
  21696. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  21697. /**
  21698. * Gets the current list of color gradients.
  21699. * You must use addColorGradient and removeColorGradient to udpate this list
  21700. * @returns the list of color gradients
  21701. */
  21702. getColorGradients(): Nullable<Array<ColorGradient>>;
  21703. /**
  21704. * Adds a new ramp gradient used to remap particle colors
  21705. * @param gradient defines the gradient to use (between 0 and 1)
  21706. * @param color defines the color to affect to the specified gradient
  21707. * @returns the current particle system
  21708. */
  21709. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  21710. /**
  21711. * Gets the current list of ramp gradients.
  21712. * You must use addRampGradient and removeRampGradient to udpate this list
  21713. * @returns the list of ramp gradients
  21714. */
  21715. getRampGradients(): Nullable<Array<Color3Gradient>>;
  21716. /** Gets or sets a boolean indicating that ramp gradients must be used
  21717. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  21718. */
  21719. useRampGradients: boolean;
  21720. /**
  21721. * Adds a new color remap gradient
  21722. * @param gradient defines the gradient to use (between 0 and 1)
  21723. * @param min defines the color remap minimal range
  21724. * @param max defines the color remap maximal range
  21725. * @returns the current particle system
  21726. */
  21727. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  21728. /**
  21729. * Gets the current list of color remap gradients.
  21730. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  21731. * @returns the list of color remap gradients
  21732. */
  21733. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  21734. /**
  21735. * Adds a new alpha remap gradient
  21736. * @param gradient defines the gradient to use (between 0 and 1)
  21737. * @param min defines the alpha remap minimal range
  21738. * @param max defines the alpha remap maximal range
  21739. * @returns the current particle system
  21740. */
  21741. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  21742. /**
  21743. * Gets the current list of alpha remap gradients.
  21744. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  21745. * @returns the list of alpha remap gradients
  21746. */
  21747. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  21748. /**
  21749. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  21750. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  21751. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  21752. * @returns the emitter
  21753. */
  21754. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  21755. /**
  21756. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  21757. * @param radius The radius of the hemisphere to emit from
  21758. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  21759. * @returns the emitter
  21760. */
  21761. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  21762. /**
  21763. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  21764. * @param radius The radius of the sphere to emit from
  21765. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  21766. * @returns the emitter
  21767. */
  21768. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  21769. /**
  21770. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  21771. * @param radius The radius of the sphere to emit from
  21772. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  21773. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  21774. * @returns the emitter
  21775. */
  21776. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  21777. /**
  21778. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  21779. * @param radius The radius of the emission cylinder
  21780. * @param height The height of the emission cylinder
  21781. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  21782. * @param directionRandomizer How much to randomize the particle direction [0-1]
  21783. * @returns the emitter
  21784. */
  21785. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  21786. /**
  21787. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  21788. * @param radius The radius of the cylinder to emit from
  21789. * @param height The height of the emission cylinder
  21790. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  21791. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  21792. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  21793. * @returns the emitter
  21794. */
  21795. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  21796. /**
  21797. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  21798. * @param radius The radius of the cone to emit from
  21799. * @param angle The base angle of the cone
  21800. * @returns the emitter
  21801. */
  21802. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  21803. /**
  21804. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  21805. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  21806. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  21807. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  21808. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  21809. * @returns the emitter
  21810. */
  21811. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  21812. /**
  21813. * Get hosting scene
  21814. * @returns the scene
  21815. */
  21816. getScene(): Scene;
  21817. }
  21818. }
  21819. declare module "babylonjs/Shaders/line.fragment" {
  21820. /** @hidden */
  21821. export var linePixelShader: {
  21822. name: string;
  21823. shader: string;
  21824. };
  21825. }
  21826. declare module "babylonjs/Shaders/line.vertex" {
  21827. /** @hidden */
  21828. export var lineVertexShader: {
  21829. name: string;
  21830. shader: string;
  21831. };
  21832. }
  21833. declare module "babylonjs/Rendering/edgesRenderer" {
  21834. import { Nullable } from "babylonjs/types";
  21835. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21836. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21837. import { Vector3 } from "babylonjs/Maths/math";
  21838. import { IDisposable } from "babylonjs/scene";
  21839. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  21840. import "babylonjs/Shaders/line.fragment";
  21841. import "babylonjs/Shaders/line.vertex";
  21842. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21843. module "babylonjs/Meshes/abstractMesh" {
  21844. interface AbstractMesh {
  21845. /**
  21846. * Gets the edgesRenderer associated with the mesh
  21847. */
  21848. edgesRenderer: Nullable<EdgesRenderer>;
  21849. }
  21850. }
  21851. module "babylonjs/Meshes/linesMesh" {
  21852. interface LinesMesh {
  21853. /**
  21854. * Enables the edge rendering mode on the mesh.
  21855. * This mode makes the mesh edges visible
  21856. * @param epsilon defines the maximal distance between two angles to detect a face
  21857. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  21858. * @returns the currentAbstractMesh
  21859. * @see https://www.babylonjs-playground.com/#19O9TU#0
  21860. */
  21861. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  21862. }
  21863. }
  21864. module "babylonjs/Meshes/linesMesh" {
  21865. interface InstancedLinesMesh {
  21866. /**
  21867. * Enables the edge rendering mode on the mesh.
  21868. * This mode makes the mesh edges visible
  21869. * @param epsilon defines the maximal distance between two angles to detect a face
  21870. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  21871. * @returns the current InstancedLinesMesh
  21872. * @see https://www.babylonjs-playground.com/#19O9TU#0
  21873. */
  21874. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  21875. }
  21876. }
  21877. /**
  21878. * Defines the minimum contract an Edges renderer should follow.
  21879. */
  21880. export interface IEdgesRenderer extends IDisposable {
  21881. /**
  21882. * Gets or sets a boolean indicating if the edgesRenderer is active
  21883. */
  21884. isEnabled: boolean;
  21885. /**
  21886. * Renders the edges of the attached mesh,
  21887. */
  21888. render(): void;
  21889. /**
  21890. * Checks wether or not the edges renderer is ready to render.
  21891. * @return true if ready, otherwise false.
  21892. */
  21893. isReady(): boolean;
  21894. }
  21895. /**
  21896. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  21897. */
  21898. export class EdgesRenderer implements IEdgesRenderer {
  21899. /**
  21900. * Define the size of the edges with an orthographic camera
  21901. */
  21902. edgesWidthScalerForOrthographic: number;
  21903. /**
  21904. * Define the size of the edges with a perspective camera
  21905. */
  21906. edgesWidthScalerForPerspective: number;
  21907. protected _source: AbstractMesh;
  21908. protected _linesPositions: number[];
  21909. protected _linesNormals: number[];
  21910. protected _linesIndices: number[];
  21911. protected _epsilon: number;
  21912. protected _indicesCount: number;
  21913. protected _lineShader: ShaderMaterial;
  21914. protected _ib: DataBuffer;
  21915. protected _buffers: {
  21916. [key: string]: Nullable<VertexBuffer>;
  21917. };
  21918. protected _checkVerticesInsteadOfIndices: boolean;
  21919. private _meshRebuildObserver;
  21920. private _meshDisposeObserver;
  21921. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  21922. isEnabled: boolean;
  21923. /**
  21924. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  21925. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  21926. * @param source Mesh used to create edges
  21927. * @param epsilon sum of angles in adjacency to check for edge
  21928. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  21929. * @param generateEdgesLines - should generate Lines or only prepare resources.
  21930. */
  21931. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  21932. protected _prepareRessources(): void;
  21933. /** @hidden */
  21934. _rebuild(): void;
  21935. /**
  21936. * Releases the required resources for the edges renderer
  21937. */
  21938. dispose(): void;
  21939. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  21940. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  21941. /**
  21942. * Checks if the pair of p0 and p1 is en edge
  21943. * @param faceIndex
  21944. * @param edge
  21945. * @param faceNormals
  21946. * @param p0
  21947. * @param p1
  21948. * @private
  21949. */
  21950. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  21951. /**
  21952. * push line into the position, normal and index buffer
  21953. * @protected
  21954. */
  21955. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  21956. /**
  21957. * Generates lines edges from adjacencjes
  21958. * @private
  21959. */
  21960. _generateEdgesLines(): void;
  21961. /**
  21962. * Checks wether or not the edges renderer is ready to render.
  21963. * @return true if ready, otherwise false.
  21964. */
  21965. isReady(): boolean;
  21966. /**
  21967. * Renders the edges of the attached mesh,
  21968. */
  21969. render(): void;
  21970. }
  21971. /**
  21972. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  21973. */
  21974. export class LineEdgesRenderer extends EdgesRenderer {
  21975. /**
  21976. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  21977. * @param source LineMesh used to generate edges
  21978. * @param epsilon not important (specified angle for edge detection)
  21979. * @param checkVerticesInsteadOfIndices not important for LineMesh
  21980. */
  21981. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  21982. /**
  21983. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  21984. */
  21985. _generateEdgesLines(): void;
  21986. }
  21987. }
  21988. declare module "babylonjs/Rendering/renderingGroup" {
  21989. import { SmartArray } from "babylonjs/Misc/smartArray";
  21990. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21991. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21992. import { Nullable } from "babylonjs/types";
  21993. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  21994. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  21995. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  21996. import { Material } from "babylonjs/Materials/material";
  21997. import { Scene } from "babylonjs/scene";
  21998. /**
  21999. * This represents the object necessary to create a rendering group.
  22000. * This is exclusively used and created by the rendering manager.
  22001. * To modify the behavior, you use the available helpers in your scene or meshes.
  22002. * @hidden
  22003. */
  22004. export class RenderingGroup {
  22005. index: number;
  22006. private static _zeroVector;
  22007. private _scene;
  22008. private _opaqueSubMeshes;
  22009. private _transparentSubMeshes;
  22010. private _alphaTestSubMeshes;
  22011. private _depthOnlySubMeshes;
  22012. private _particleSystems;
  22013. private _spriteManagers;
  22014. private _opaqueSortCompareFn;
  22015. private _alphaTestSortCompareFn;
  22016. private _transparentSortCompareFn;
  22017. private _renderOpaque;
  22018. private _renderAlphaTest;
  22019. private _renderTransparent;
  22020. /** @hidden */
  22021. _edgesRenderers: SmartArray<IEdgesRenderer>;
  22022. onBeforeTransparentRendering: () => void;
  22023. /**
  22024. * Set the opaque sort comparison function.
  22025. * If null the sub meshes will be render in the order they were created
  22026. */
  22027. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  22028. /**
  22029. * Set the alpha test sort comparison function.
  22030. * If null the sub meshes will be render in the order they were created
  22031. */
  22032. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  22033. /**
  22034. * Set the transparent sort comparison function.
  22035. * If null the sub meshes will be render in the order they were created
  22036. */
  22037. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  22038. /**
  22039. * Creates a new rendering group.
  22040. * @param index The rendering group index
  22041. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  22042. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  22043. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  22044. */
  22045. 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>);
  22046. /**
  22047. * Render all the sub meshes contained in the group.
  22048. * @param customRenderFunction Used to override the default render behaviour of the group.
  22049. * @returns true if rendered some submeshes.
  22050. */
  22051. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  22052. /**
  22053. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  22054. * @param subMeshes The submeshes to render
  22055. */
  22056. private renderOpaqueSorted;
  22057. /**
  22058. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  22059. * @param subMeshes The submeshes to render
  22060. */
  22061. private renderAlphaTestSorted;
  22062. /**
  22063. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  22064. * @param subMeshes The submeshes to render
  22065. */
  22066. private renderTransparentSorted;
  22067. /**
  22068. * Renders the submeshes in a specified order.
  22069. * @param subMeshes The submeshes to sort before render
  22070. * @param sortCompareFn The comparison function use to sort
  22071. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  22072. * @param transparent Specifies to activate blending if true
  22073. */
  22074. private static renderSorted;
  22075. /**
  22076. * Renders the submeshes in the order they were dispatched (no sort applied).
  22077. * @param subMeshes The submeshes to render
  22078. */
  22079. private static renderUnsorted;
  22080. /**
  22081. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  22082. * are rendered back to front if in the same alpha index.
  22083. *
  22084. * @param a The first submesh
  22085. * @param b The second submesh
  22086. * @returns The result of the comparison
  22087. */
  22088. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  22089. /**
  22090. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  22091. * are rendered back to front.
  22092. *
  22093. * @param a The first submesh
  22094. * @param b The second submesh
  22095. * @returns The result of the comparison
  22096. */
  22097. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  22098. /**
  22099. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  22100. * are rendered front to back (prevent overdraw).
  22101. *
  22102. * @param a The first submesh
  22103. * @param b The second submesh
  22104. * @returns The result of the comparison
  22105. */
  22106. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  22107. /**
  22108. * Resets the different lists of submeshes to prepare a new frame.
  22109. */
  22110. prepare(): void;
  22111. dispose(): void;
  22112. /**
  22113. * Inserts the submesh in its correct queue depending on its material.
  22114. * @param subMesh The submesh to dispatch
  22115. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  22116. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  22117. */
  22118. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  22119. dispatchSprites(spriteManager: ISpriteManager): void;
  22120. dispatchParticles(particleSystem: IParticleSystem): void;
  22121. private _renderParticles;
  22122. private _renderSprites;
  22123. }
  22124. }
  22125. declare module "babylonjs/Rendering/renderingManager" {
  22126. import { Nullable } from "babylonjs/types";
  22127. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22128. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22129. import { SmartArray } from "babylonjs/Misc/smartArray";
  22130. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  22131. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  22132. import { Material } from "babylonjs/Materials/material";
  22133. import { Scene } from "babylonjs/scene";
  22134. import { Camera } from "babylonjs/Cameras/camera";
  22135. /**
  22136. * Interface describing the different options available in the rendering manager
  22137. * regarding Auto Clear between groups.
  22138. */
  22139. export interface IRenderingManagerAutoClearSetup {
  22140. /**
  22141. * Defines whether or not autoclear is enable.
  22142. */
  22143. autoClear: boolean;
  22144. /**
  22145. * Defines whether or not to autoclear the depth buffer.
  22146. */
  22147. depth: boolean;
  22148. /**
  22149. * Defines whether or not to autoclear the stencil buffer.
  22150. */
  22151. stencil: boolean;
  22152. }
  22153. /**
  22154. * This class is used by the onRenderingGroupObservable
  22155. */
  22156. export class RenderingGroupInfo {
  22157. /**
  22158. * The Scene that being rendered
  22159. */
  22160. scene: Scene;
  22161. /**
  22162. * The camera currently used for the rendering pass
  22163. */
  22164. camera: Nullable<Camera>;
  22165. /**
  22166. * The ID of the renderingGroup being processed
  22167. */
  22168. renderingGroupId: number;
  22169. }
  22170. /**
  22171. * This is the manager responsible of all the rendering for meshes sprites and particles.
  22172. * It is enable to manage the different groups as well as the different necessary sort functions.
  22173. * This should not be used directly aside of the few static configurations
  22174. */
  22175. export class RenderingManager {
  22176. /**
  22177. * The max id used for rendering groups (not included)
  22178. */
  22179. static MAX_RENDERINGGROUPS: number;
  22180. /**
  22181. * The min id used for rendering groups (included)
  22182. */
  22183. static MIN_RENDERINGGROUPS: number;
  22184. /**
  22185. * Used to globally prevent autoclearing scenes.
  22186. */
  22187. static AUTOCLEAR: boolean;
  22188. /**
  22189. * @hidden
  22190. */
  22191. _useSceneAutoClearSetup: boolean;
  22192. private _scene;
  22193. private _renderingGroups;
  22194. private _depthStencilBufferAlreadyCleaned;
  22195. private _autoClearDepthStencil;
  22196. private _customOpaqueSortCompareFn;
  22197. private _customAlphaTestSortCompareFn;
  22198. private _customTransparentSortCompareFn;
  22199. private _renderingGroupInfo;
  22200. /**
  22201. * Instantiates a new rendering group for a particular scene
  22202. * @param scene Defines the scene the groups belongs to
  22203. */
  22204. constructor(scene: Scene);
  22205. private _clearDepthStencilBuffer;
  22206. /**
  22207. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  22208. * @hidden
  22209. */
  22210. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  22211. /**
  22212. * Resets the different information of the group to prepare a new frame
  22213. * @hidden
  22214. */
  22215. reset(): void;
  22216. /**
  22217. * Dispose and release the group and its associated resources.
  22218. * @hidden
  22219. */
  22220. dispose(): void;
  22221. /**
  22222. * Clear the info related to rendering groups preventing retention points during dispose.
  22223. */
  22224. freeRenderingGroups(): void;
  22225. private _prepareRenderingGroup;
  22226. /**
  22227. * Add a sprite manager to the rendering manager in order to render it this frame.
  22228. * @param spriteManager Define the sprite manager to render
  22229. */
  22230. dispatchSprites(spriteManager: ISpriteManager): void;
  22231. /**
  22232. * Add a particle system to the rendering manager in order to render it this frame.
  22233. * @param particleSystem Define the particle system to render
  22234. */
  22235. dispatchParticles(particleSystem: IParticleSystem): void;
  22236. /**
  22237. * Add a submesh to the manager in order to render it this frame
  22238. * @param subMesh The submesh to dispatch
  22239. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  22240. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  22241. */
  22242. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  22243. /**
  22244. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  22245. * This allowed control for front to back rendering or reversly depending of the special needs.
  22246. *
  22247. * @param renderingGroupId The rendering group id corresponding to its index
  22248. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  22249. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  22250. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  22251. */
  22252. 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;
  22253. /**
  22254. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  22255. *
  22256. * @param renderingGroupId The rendering group id corresponding to its index
  22257. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  22258. * @param depth Automatically clears depth between groups if true and autoClear is true.
  22259. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  22260. */
  22261. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  22262. /**
  22263. * Gets the current auto clear configuration for one rendering group of the rendering
  22264. * manager.
  22265. * @param index the rendering group index to get the information for
  22266. * @returns The auto clear setup for the requested rendering group
  22267. */
  22268. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  22269. }
  22270. }
  22271. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  22272. import { Observable } from "babylonjs/Misc/observable";
  22273. import { SmartArray } from "babylonjs/Misc/smartArray";
  22274. import { Nullable } from "babylonjs/types";
  22275. import { Camera } from "babylonjs/Cameras/camera";
  22276. import { Scene } from "babylonjs/scene";
  22277. import { Matrix, Vector3, Color4 } from "babylonjs/Maths/math";
  22278. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  22279. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22280. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22281. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  22282. import { Texture } from "babylonjs/Materials/Textures/texture";
  22283. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  22284. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  22285. import "babylonjs/Engines/Extensions/engine.renderTarget";
  22286. import { Engine } from "babylonjs/Engines/engine";
  22287. /**
  22288. * This Helps creating a texture that will be created from a camera in your scene.
  22289. * It is basically a dynamic texture that could be used to create special effects for instance.
  22290. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  22291. */
  22292. export class RenderTargetTexture extends Texture {
  22293. isCube: boolean;
  22294. /**
  22295. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  22296. */
  22297. static readonly REFRESHRATE_RENDER_ONCE: number;
  22298. /**
  22299. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  22300. */
  22301. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  22302. /**
  22303. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  22304. * the central point of your effect and can save a lot of performances.
  22305. */
  22306. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  22307. /**
  22308. * Use this predicate to dynamically define the list of mesh you want to render.
  22309. * If set, the renderList property will be overwritten.
  22310. */
  22311. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  22312. private _renderList;
  22313. /**
  22314. * Use this list to define the list of mesh you want to render.
  22315. */
  22316. renderList: Nullable<Array<AbstractMesh>>;
  22317. private _hookArray;
  22318. /**
  22319. * Define if particles should be rendered in your texture.
  22320. */
  22321. renderParticles: boolean;
  22322. /**
  22323. * Define if sprites should be rendered in your texture.
  22324. */
  22325. renderSprites: boolean;
  22326. /**
  22327. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  22328. */
  22329. coordinatesMode: number;
  22330. /**
  22331. * Define the camera used to render the texture.
  22332. */
  22333. activeCamera: Nullable<Camera>;
  22334. /**
  22335. * Override the render function of the texture with your own one.
  22336. */
  22337. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  22338. /**
  22339. * Define if camera post processes should be use while rendering the texture.
  22340. */
  22341. useCameraPostProcesses: boolean;
  22342. /**
  22343. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  22344. */
  22345. ignoreCameraViewport: boolean;
  22346. private _postProcessManager;
  22347. private _postProcesses;
  22348. private _resizeObserver;
  22349. /**
  22350. * An event triggered when the texture is unbind.
  22351. */
  22352. onBeforeBindObservable: Observable<RenderTargetTexture>;
  22353. /**
  22354. * An event triggered when the texture is unbind.
  22355. */
  22356. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  22357. private _onAfterUnbindObserver;
  22358. /**
  22359. * Set a after unbind callback in the texture.
  22360. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  22361. */
  22362. onAfterUnbind: () => void;
  22363. /**
  22364. * An event triggered before rendering the texture
  22365. */
  22366. onBeforeRenderObservable: Observable<number>;
  22367. private _onBeforeRenderObserver;
  22368. /**
  22369. * Set a before render callback in the texture.
  22370. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  22371. */
  22372. onBeforeRender: (faceIndex: number) => void;
  22373. /**
  22374. * An event triggered after rendering the texture
  22375. */
  22376. onAfterRenderObservable: Observable<number>;
  22377. private _onAfterRenderObserver;
  22378. /**
  22379. * Set a after render callback in the texture.
  22380. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  22381. */
  22382. onAfterRender: (faceIndex: number) => void;
  22383. /**
  22384. * An event triggered after the texture clear
  22385. */
  22386. onClearObservable: Observable<import("babylonjs/Engines/engine").Engine>;
  22387. private _onClearObserver;
  22388. /**
  22389. * Set a clear callback in the texture.
  22390. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  22391. */
  22392. onClear: (Engine: Engine) => void;
  22393. /**
  22394. * Define the clear color of the Render Target if it should be different from the scene.
  22395. */
  22396. clearColor: Color4;
  22397. protected _size: number | {
  22398. width: number;
  22399. height: number;
  22400. };
  22401. protected _initialSizeParameter: number | {
  22402. width: number;
  22403. height: number;
  22404. } | {
  22405. ratio: number;
  22406. };
  22407. protected _sizeRatio: Nullable<number>;
  22408. /** @hidden */
  22409. _generateMipMaps: boolean;
  22410. protected _renderingManager: RenderingManager;
  22411. /** @hidden */
  22412. _waitingRenderList: string[];
  22413. protected _doNotChangeAspectRatio: boolean;
  22414. protected _currentRefreshId: number;
  22415. protected _refreshRate: number;
  22416. protected _textureMatrix: Matrix;
  22417. protected _samples: number;
  22418. protected _renderTargetOptions: RenderTargetCreationOptions;
  22419. /**
  22420. * Gets render target creation options that were used.
  22421. */
  22422. readonly renderTargetOptions: RenderTargetCreationOptions;
  22423. protected _engine: Engine;
  22424. protected _onRatioRescale(): void;
  22425. /**
  22426. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  22427. * It must define where the camera used to render the texture is set
  22428. */
  22429. boundingBoxPosition: Vector3;
  22430. private _boundingBoxSize;
  22431. /**
  22432. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  22433. * When defined, the cubemap will switch to local mode
  22434. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  22435. * @example https://www.babylonjs-playground.com/#RNASML
  22436. */
  22437. boundingBoxSize: Vector3;
  22438. /**
  22439. * In case the RTT has been created with a depth texture, get the associated
  22440. * depth texture.
  22441. * Otherwise, return null.
  22442. */
  22443. depthStencilTexture: Nullable<InternalTexture>;
  22444. /**
  22445. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  22446. * or used a shadow, depth texture...
  22447. * @param name The friendly name of the texture
  22448. * @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)
  22449. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  22450. * @param generateMipMaps True if mip maps need to be generated after render.
  22451. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  22452. * @param type The type of the buffer in the RTT (int, half float, float...)
  22453. * @param isCube True if a cube texture needs to be created
  22454. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  22455. * @param generateDepthBuffer True to generate a depth buffer
  22456. * @param generateStencilBuffer True to generate a stencil buffer
  22457. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  22458. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  22459. * @param delayAllocation if the texture allocation should be delayed (default: false)
  22460. */
  22461. constructor(name: string, size: number | {
  22462. width: number;
  22463. height: number;
  22464. } | {
  22465. ratio: number;
  22466. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  22467. /**
  22468. * Creates a depth stencil texture.
  22469. * This is only available in WebGL 2 or with the depth texture extension available.
  22470. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  22471. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  22472. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  22473. */
  22474. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  22475. private _processSizeParameter;
  22476. /**
  22477. * Define the number of samples to use in case of MSAA.
  22478. * It defaults to one meaning no MSAA has been enabled.
  22479. */
  22480. samples: number;
  22481. /**
  22482. * Resets the refresh counter of the texture and start bak from scratch.
  22483. * Could be useful to regenerate the texture if it is setup to render only once.
  22484. */
  22485. resetRefreshCounter(): void;
  22486. /**
  22487. * Define the refresh rate of the texture or the rendering frequency.
  22488. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  22489. */
  22490. refreshRate: number;
  22491. /**
  22492. * Adds a post process to the render target rendering passes.
  22493. * @param postProcess define the post process to add
  22494. */
  22495. addPostProcess(postProcess: PostProcess): void;
  22496. /**
  22497. * Clear all the post processes attached to the render target
  22498. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  22499. */
  22500. clearPostProcesses(dispose?: boolean): void;
  22501. /**
  22502. * Remove one of the post process from the list of attached post processes to the texture
  22503. * @param postProcess define the post process to remove from the list
  22504. */
  22505. removePostProcess(postProcess: PostProcess): void;
  22506. /** @hidden */
  22507. _shouldRender(): boolean;
  22508. /**
  22509. * Gets the actual render size of the texture.
  22510. * @returns the width of the render size
  22511. */
  22512. getRenderSize(): number;
  22513. /**
  22514. * Gets the actual render width of the texture.
  22515. * @returns the width of the render size
  22516. */
  22517. getRenderWidth(): number;
  22518. /**
  22519. * Gets the actual render height of the texture.
  22520. * @returns the height of the render size
  22521. */
  22522. getRenderHeight(): number;
  22523. /**
  22524. * Get if the texture can be rescaled or not.
  22525. */
  22526. readonly canRescale: boolean;
  22527. /**
  22528. * Resize the texture using a ratio.
  22529. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  22530. */
  22531. scale(ratio: number): void;
  22532. /**
  22533. * Get the texture reflection matrix used to rotate/transform the reflection.
  22534. * @returns the reflection matrix
  22535. */
  22536. getReflectionTextureMatrix(): Matrix;
  22537. /**
  22538. * Resize the texture to a new desired size.
  22539. * Be carrefull as it will recreate all the data in the new texture.
  22540. * @param size Define the new size. It can be:
  22541. * - a number for squared texture,
  22542. * - an object containing { width: number, height: number }
  22543. * - or an object containing a ratio { ratio: number }
  22544. */
  22545. resize(size: number | {
  22546. width: number;
  22547. height: number;
  22548. } | {
  22549. ratio: number;
  22550. }): void;
  22551. /**
  22552. * Renders all the objects from the render list into the texture.
  22553. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  22554. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  22555. */
  22556. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  22557. private _bestReflectionRenderTargetDimension;
  22558. /**
  22559. * @hidden
  22560. * @param faceIndex face index to bind to if this is a cubetexture
  22561. */
  22562. _bindFrameBuffer(faceIndex?: number): void;
  22563. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  22564. private renderToTarget;
  22565. /**
  22566. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  22567. * This allowed control for front to back rendering or reversly depending of the special needs.
  22568. *
  22569. * @param renderingGroupId The rendering group id corresponding to its index
  22570. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  22571. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  22572. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  22573. */
  22574. 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;
  22575. /**
  22576. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  22577. *
  22578. * @param renderingGroupId The rendering group id corresponding to its index
  22579. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  22580. */
  22581. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  22582. /**
  22583. * Clones the texture.
  22584. * @returns the cloned texture
  22585. */
  22586. clone(): RenderTargetTexture;
  22587. /**
  22588. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  22589. * @returns The JSON representation of the texture
  22590. */
  22591. serialize(): any;
  22592. /**
  22593. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  22594. */
  22595. disposeFramebufferObjects(): void;
  22596. /**
  22597. * Dispose the texture and release its associated resources.
  22598. */
  22599. dispose(): void;
  22600. /** @hidden */
  22601. _rebuild(): void;
  22602. /**
  22603. * Clear the info related to rendering groups preventing retention point in material dispose.
  22604. */
  22605. freeRenderingGroups(): void;
  22606. /**
  22607. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  22608. * @returns the view count
  22609. */
  22610. getViewCount(): number;
  22611. }
  22612. }
  22613. declare module "babylonjs/Materials/material" {
  22614. import { IAnimatable } from "babylonjs/Misc/tools";
  22615. import { SmartArray } from "babylonjs/Misc/smartArray";
  22616. import { Observable } from "babylonjs/Misc/observable";
  22617. import { Nullable } from "babylonjs/types";
  22618. import { Scene } from "babylonjs/scene";
  22619. import { Matrix } from "babylonjs/Maths/math";
  22620. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  22621. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22622. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  22623. import { Effect } from "babylonjs/Materials/effect";
  22624. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22625. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  22626. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22627. import { IInspectable } from "babylonjs/Misc/iInspectable";
  22628. import { Mesh } from "babylonjs/Meshes/mesh";
  22629. import { Animation } from "babylonjs/Animations/animation";
  22630. /**
  22631. * Base class for the main features of a material in Babylon.js
  22632. */
  22633. export class Material implements IAnimatable {
  22634. /**
  22635. * Returns the triangle fill mode
  22636. */
  22637. static readonly TriangleFillMode: number;
  22638. /**
  22639. * Returns the wireframe mode
  22640. */
  22641. static readonly WireFrameFillMode: number;
  22642. /**
  22643. * Returns the point fill mode
  22644. */
  22645. static readonly PointFillMode: number;
  22646. /**
  22647. * Returns the point list draw mode
  22648. */
  22649. static readonly PointListDrawMode: number;
  22650. /**
  22651. * Returns the line list draw mode
  22652. */
  22653. static readonly LineListDrawMode: number;
  22654. /**
  22655. * Returns the line loop draw mode
  22656. */
  22657. static readonly LineLoopDrawMode: number;
  22658. /**
  22659. * Returns the line strip draw mode
  22660. */
  22661. static readonly LineStripDrawMode: number;
  22662. /**
  22663. * Returns the triangle strip draw mode
  22664. */
  22665. static readonly TriangleStripDrawMode: number;
  22666. /**
  22667. * Returns the triangle fan draw mode
  22668. */
  22669. static readonly TriangleFanDrawMode: number;
  22670. /**
  22671. * Stores the clock-wise side orientation
  22672. */
  22673. static readonly ClockWiseSideOrientation: number;
  22674. /**
  22675. * Stores the counter clock-wise side orientation
  22676. */
  22677. static readonly CounterClockWiseSideOrientation: number;
  22678. /**
  22679. * The dirty texture flag value
  22680. */
  22681. static readonly TextureDirtyFlag: number;
  22682. /**
  22683. * The dirty light flag value
  22684. */
  22685. static readonly LightDirtyFlag: number;
  22686. /**
  22687. * The dirty fresnel flag value
  22688. */
  22689. static readonly FresnelDirtyFlag: number;
  22690. /**
  22691. * The dirty attribute flag value
  22692. */
  22693. static readonly AttributesDirtyFlag: number;
  22694. /**
  22695. * The dirty misc flag value
  22696. */
  22697. static readonly MiscDirtyFlag: number;
  22698. /**
  22699. * The all dirty flag value
  22700. */
  22701. static readonly AllDirtyFlag: number;
  22702. /**
  22703. * The ID of the material
  22704. */
  22705. id: string;
  22706. /**
  22707. * Gets or sets the unique id of the material
  22708. */
  22709. uniqueId: number;
  22710. /**
  22711. * The name of the material
  22712. */
  22713. name: string;
  22714. /**
  22715. * Gets or sets user defined metadata
  22716. */
  22717. metadata: any;
  22718. /**
  22719. * For internal use only. Please do not use.
  22720. */
  22721. reservedDataStore: any;
  22722. /**
  22723. * Specifies if the ready state should be checked on each call
  22724. */
  22725. checkReadyOnEveryCall: boolean;
  22726. /**
  22727. * Specifies if the ready state should be checked once
  22728. */
  22729. checkReadyOnlyOnce: boolean;
  22730. /**
  22731. * The state of the material
  22732. */
  22733. state: string;
  22734. /**
  22735. * The alpha value of the material
  22736. */
  22737. protected _alpha: number;
  22738. /**
  22739. * List of inspectable custom properties (used by the Inspector)
  22740. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22741. */
  22742. inspectableCustomProperties: IInspectable[];
  22743. /**
  22744. * Sets the alpha value of the material
  22745. */
  22746. /**
  22747. * Gets the alpha value of the material
  22748. */
  22749. alpha: number;
  22750. /**
  22751. * Specifies if back face culling is enabled
  22752. */
  22753. protected _backFaceCulling: boolean;
  22754. /**
  22755. * Sets the back-face culling state
  22756. */
  22757. /**
  22758. * Gets the back-face culling state
  22759. */
  22760. backFaceCulling: boolean;
  22761. /**
  22762. * Stores the value for side orientation
  22763. */
  22764. sideOrientation: number;
  22765. /**
  22766. * Callback triggered when the material is compiled
  22767. */
  22768. onCompiled: Nullable<(effect: Effect) => void>;
  22769. /**
  22770. * Callback triggered when an error occurs
  22771. */
  22772. onError: Nullable<(effect: Effect, errors: string) => void>;
  22773. /**
  22774. * Callback triggered to get the render target textures
  22775. */
  22776. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  22777. /**
  22778. * Gets a boolean indicating that current material needs to register RTT
  22779. */
  22780. readonly hasRenderTargetTextures: boolean;
  22781. /**
  22782. * Specifies if the material should be serialized
  22783. */
  22784. doNotSerialize: boolean;
  22785. /**
  22786. * @hidden
  22787. */
  22788. _storeEffectOnSubMeshes: boolean;
  22789. /**
  22790. * Stores the animations for the material
  22791. */
  22792. animations: Nullable<Array<Animation>>;
  22793. /**
  22794. * An event triggered when the material is disposed
  22795. */
  22796. onDisposeObservable: Observable<Material>;
  22797. /**
  22798. * An observer which watches for dispose events
  22799. */
  22800. private _onDisposeObserver;
  22801. private _onUnBindObservable;
  22802. /**
  22803. * Called during a dispose event
  22804. */
  22805. onDispose: () => void;
  22806. private _onBindObservable;
  22807. /**
  22808. * An event triggered when the material is bound
  22809. */
  22810. readonly onBindObservable: Observable<AbstractMesh>;
  22811. /**
  22812. * An observer which watches for bind events
  22813. */
  22814. private _onBindObserver;
  22815. /**
  22816. * Called during a bind event
  22817. */
  22818. onBind: (Mesh: AbstractMesh) => void;
  22819. /**
  22820. * An event triggered when the material is unbound
  22821. */
  22822. readonly onUnBindObservable: Observable<Material>;
  22823. /**
  22824. * Stores the value of the alpha mode
  22825. */
  22826. private _alphaMode;
  22827. /**
  22828. * Sets the value of the alpha mode.
  22829. *
  22830. * | Value | Type | Description |
  22831. * | --- | --- | --- |
  22832. * | 0 | ALPHA_DISABLE | |
  22833. * | 1 | ALPHA_ADD | |
  22834. * | 2 | ALPHA_COMBINE | |
  22835. * | 3 | ALPHA_SUBTRACT | |
  22836. * | 4 | ALPHA_MULTIPLY | |
  22837. * | 5 | ALPHA_MAXIMIZED | |
  22838. * | 6 | ALPHA_ONEONE | |
  22839. * | 7 | ALPHA_PREMULTIPLIED | |
  22840. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  22841. * | 9 | ALPHA_INTERPOLATE | |
  22842. * | 10 | ALPHA_SCREENMODE | |
  22843. *
  22844. */
  22845. /**
  22846. * Gets the value of the alpha mode
  22847. */
  22848. alphaMode: number;
  22849. /**
  22850. * Stores the state of the need depth pre-pass value
  22851. */
  22852. private _needDepthPrePass;
  22853. /**
  22854. * Sets the need depth pre-pass value
  22855. */
  22856. /**
  22857. * Gets the depth pre-pass value
  22858. */
  22859. needDepthPrePass: boolean;
  22860. /**
  22861. * Specifies if depth writing should be disabled
  22862. */
  22863. disableDepthWrite: boolean;
  22864. /**
  22865. * Specifies if depth writing should be forced
  22866. */
  22867. forceDepthWrite: boolean;
  22868. /**
  22869. * Specifies if there should be a separate pass for culling
  22870. */
  22871. separateCullingPass: boolean;
  22872. /**
  22873. * Stores the state specifing if fog should be enabled
  22874. */
  22875. private _fogEnabled;
  22876. /**
  22877. * Sets the state for enabling fog
  22878. */
  22879. /**
  22880. * Gets the value of the fog enabled state
  22881. */
  22882. fogEnabled: boolean;
  22883. /**
  22884. * Stores the size of points
  22885. */
  22886. pointSize: number;
  22887. /**
  22888. * Stores the z offset value
  22889. */
  22890. zOffset: number;
  22891. /**
  22892. * Gets a value specifying if wireframe mode is enabled
  22893. */
  22894. /**
  22895. * Sets the state of wireframe mode
  22896. */
  22897. wireframe: boolean;
  22898. /**
  22899. * Gets the value specifying if point clouds are enabled
  22900. */
  22901. /**
  22902. * Sets the state of point cloud mode
  22903. */
  22904. pointsCloud: boolean;
  22905. /**
  22906. * Gets the material fill mode
  22907. */
  22908. /**
  22909. * Sets the material fill mode
  22910. */
  22911. fillMode: number;
  22912. /**
  22913. * @hidden
  22914. * Stores the effects for the material
  22915. */
  22916. _effect: Nullable<Effect>;
  22917. /**
  22918. * @hidden
  22919. * Specifies if the material was previously ready
  22920. */
  22921. _wasPreviouslyReady: boolean;
  22922. /**
  22923. * Specifies if uniform buffers should be used
  22924. */
  22925. private _useUBO;
  22926. /**
  22927. * Stores a reference to the scene
  22928. */
  22929. private _scene;
  22930. /**
  22931. * Stores the fill mode state
  22932. */
  22933. private _fillMode;
  22934. /**
  22935. * Specifies if the depth write state should be cached
  22936. */
  22937. private _cachedDepthWriteState;
  22938. /**
  22939. * Stores the uniform buffer
  22940. */
  22941. protected _uniformBuffer: UniformBuffer;
  22942. /** @hidden */
  22943. _indexInSceneMaterialArray: number;
  22944. /** @hidden */
  22945. meshMap: Nullable<{
  22946. [id: string]: AbstractMesh | undefined;
  22947. }>;
  22948. /**
  22949. * Creates a material instance
  22950. * @param name defines the name of the material
  22951. * @param scene defines the scene to reference
  22952. * @param doNotAdd specifies if the material should be added to the scene
  22953. */
  22954. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  22955. /**
  22956. * Returns a string representation of the current material
  22957. * @param fullDetails defines a boolean indicating which levels of logging is desired
  22958. * @returns a string with material information
  22959. */
  22960. toString(fullDetails?: boolean): string;
  22961. /**
  22962. * Gets the class name of the material
  22963. * @returns a string with the class name of the material
  22964. */
  22965. getClassName(): string;
  22966. /**
  22967. * Specifies if updates for the material been locked
  22968. */
  22969. readonly isFrozen: boolean;
  22970. /**
  22971. * Locks updates for the material
  22972. */
  22973. freeze(): void;
  22974. /**
  22975. * Unlocks updates for the material
  22976. */
  22977. unfreeze(): void;
  22978. /**
  22979. * Specifies if the material is ready to be used
  22980. * @param mesh defines the mesh to check
  22981. * @param useInstances specifies if instances should be used
  22982. * @returns a boolean indicating if the material is ready to be used
  22983. */
  22984. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22985. /**
  22986. * Specifies that the submesh is ready to be used
  22987. * @param mesh defines the mesh to check
  22988. * @param subMesh defines which submesh to check
  22989. * @param useInstances specifies that instances should be used
  22990. * @returns a boolean indicating that the submesh is ready or not
  22991. */
  22992. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22993. /**
  22994. * Returns the material effect
  22995. * @returns the effect associated with the material
  22996. */
  22997. getEffect(): Nullable<Effect>;
  22998. /**
  22999. * Returns the current scene
  23000. * @returns a Scene
  23001. */
  23002. getScene(): Scene;
  23003. /**
  23004. * Specifies if the material will require alpha blending
  23005. * @returns a boolean specifying if alpha blending is needed
  23006. */
  23007. needAlphaBlending(): boolean;
  23008. /**
  23009. * Specifies if the mesh will require alpha blending
  23010. * @param mesh defines the mesh to check
  23011. * @returns a boolean specifying if alpha blending is needed for the mesh
  23012. */
  23013. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  23014. /**
  23015. * Specifies if this material should be rendered in alpha test mode
  23016. * @returns a boolean specifying if an alpha test is needed.
  23017. */
  23018. needAlphaTesting(): boolean;
  23019. /**
  23020. * Gets the texture used for the alpha test
  23021. * @returns the texture to use for alpha testing
  23022. */
  23023. getAlphaTestTexture(): Nullable<BaseTexture>;
  23024. /**
  23025. * Marks the material to indicate that it needs to be re-calculated
  23026. */
  23027. markDirty(): void;
  23028. /** @hidden */
  23029. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  23030. /**
  23031. * Binds the material to the mesh
  23032. * @param world defines the world transformation matrix
  23033. * @param mesh defines the mesh to bind the material to
  23034. */
  23035. bind(world: Matrix, mesh?: Mesh): void;
  23036. /**
  23037. * Binds the submesh to the material
  23038. * @param world defines the world transformation matrix
  23039. * @param mesh defines the mesh containing the submesh
  23040. * @param subMesh defines the submesh to bind the material to
  23041. */
  23042. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  23043. /**
  23044. * Binds the world matrix to the material
  23045. * @param world defines the world transformation matrix
  23046. */
  23047. bindOnlyWorldMatrix(world: Matrix): void;
  23048. /**
  23049. * Binds the scene's uniform buffer to the effect.
  23050. * @param effect defines the effect to bind to the scene uniform buffer
  23051. * @param sceneUbo defines the uniform buffer storing scene data
  23052. */
  23053. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  23054. /**
  23055. * Binds the view matrix to the effect
  23056. * @param effect defines the effect to bind the view matrix to
  23057. */
  23058. bindView(effect: Effect): void;
  23059. /**
  23060. * Binds the view projection matrix to the effect
  23061. * @param effect defines the effect to bind the view projection matrix to
  23062. */
  23063. bindViewProjection(effect: Effect): void;
  23064. /**
  23065. * Specifies if material alpha testing should be turned on for the mesh
  23066. * @param mesh defines the mesh to check
  23067. */
  23068. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  23069. /**
  23070. * Processes to execute after binding the material to a mesh
  23071. * @param mesh defines the rendered mesh
  23072. */
  23073. protected _afterBind(mesh?: Mesh): void;
  23074. /**
  23075. * Unbinds the material from the mesh
  23076. */
  23077. unbind(): void;
  23078. /**
  23079. * Gets the active textures from the material
  23080. * @returns an array of textures
  23081. */
  23082. getActiveTextures(): BaseTexture[];
  23083. /**
  23084. * Specifies if the material uses a texture
  23085. * @param texture defines the texture to check against the material
  23086. * @returns a boolean specifying if the material uses the texture
  23087. */
  23088. hasTexture(texture: BaseTexture): boolean;
  23089. /**
  23090. * Makes a duplicate of the material, and gives it a new name
  23091. * @param name defines the new name for the duplicated material
  23092. * @returns the cloned material
  23093. */
  23094. clone(name: string): Nullable<Material>;
  23095. /**
  23096. * Gets the meshes bound to the material
  23097. * @returns an array of meshes bound to the material
  23098. */
  23099. getBindedMeshes(): AbstractMesh[];
  23100. /**
  23101. * Force shader compilation
  23102. * @param mesh defines the mesh associated with this material
  23103. * @param onCompiled defines a function to execute once the material is compiled
  23104. * @param options defines the options to configure the compilation
  23105. */
  23106. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  23107. clipPlane: boolean;
  23108. }>): void;
  23109. /**
  23110. * Force shader compilation
  23111. * @param mesh defines the mesh that will use this material
  23112. * @param options defines additional options for compiling the shaders
  23113. * @returns a promise that resolves when the compilation completes
  23114. */
  23115. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  23116. clipPlane: boolean;
  23117. }>): Promise<void>;
  23118. private static readonly _AllDirtyCallBack;
  23119. private static readonly _ImageProcessingDirtyCallBack;
  23120. private static readonly _TextureDirtyCallBack;
  23121. private static readonly _FresnelDirtyCallBack;
  23122. private static readonly _MiscDirtyCallBack;
  23123. private static readonly _LightsDirtyCallBack;
  23124. private static readonly _AttributeDirtyCallBack;
  23125. private static _FresnelAndMiscDirtyCallBack;
  23126. private static _TextureAndMiscDirtyCallBack;
  23127. private static readonly _DirtyCallbackArray;
  23128. private static readonly _RunDirtyCallBacks;
  23129. /**
  23130. * Marks a define in the material to indicate that it needs to be re-computed
  23131. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  23132. */
  23133. markAsDirty(flag: number): void;
  23134. /**
  23135. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  23136. * @param func defines a function which checks material defines against the submeshes
  23137. */
  23138. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  23139. /**
  23140. * Indicates that we need to re-calculated for all submeshes
  23141. */
  23142. protected _markAllSubMeshesAsAllDirty(): void;
  23143. /**
  23144. * Indicates that image processing needs to be re-calculated for all submeshes
  23145. */
  23146. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  23147. /**
  23148. * Indicates that textures need to be re-calculated for all submeshes
  23149. */
  23150. protected _markAllSubMeshesAsTexturesDirty(): void;
  23151. /**
  23152. * Indicates that fresnel needs to be re-calculated for all submeshes
  23153. */
  23154. protected _markAllSubMeshesAsFresnelDirty(): void;
  23155. /**
  23156. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  23157. */
  23158. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  23159. /**
  23160. * Indicates that lights need to be re-calculated for all submeshes
  23161. */
  23162. protected _markAllSubMeshesAsLightsDirty(): void;
  23163. /**
  23164. * Indicates that attributes need to be re-calculated for all submeshes
  23165. */
  23166. protected _markAllSubMeshesAsAttributesDirty(): void;
  23167. /**
  23168. * Indicates that misc needs to be re-calculated for all submeshes
  23169. */
  23170. protected _markAllSubMeshesAsMiscDirty(): void;
  23171. /**
  23172. * Indicates that textures and misc need to be re-calculated for all submeshes
  23173. */
  23174. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  23175. /**
  23176. * Disposes the material
  23177. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23178. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23179. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23180. */
  23181. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23182. /** @hidden */
  23183. private releaseVertexArrayObject;
  23184. /**
  23185. * Serializes this material
  23186. * @returns the serialized material object
  23187. */
  23188. serialize(): any;
  23189. /**
  23190. * Creates a material from parsed material data
  23191. * @param parsedMaterial defines parsed material data
  23192. * @param scene defines the hosting scene
  23193. * @param rootUrl defines the root URL to use to load textures
  23194. * @returns a new material
  23195. */
  23196. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  23197. }
  23198. }
  23199. declare module "babylonjs/Meshes/subMesh" {
  23200. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  23201. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  23202. import { Engine } from "babylonjs/Engines/engine";
  23203. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  23204. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23205. import { Effect } from "babylonjs/Materials/effect";
  23206. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  23207. import { Collider } from "babylonjs/Collisions/collider";
  23208. import { Material } from "babylonjs/Materials/material";
  23209. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  23210. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23211. import { Mesh } from "babylonjs/Meshes/mesh";
  23212. import { Ray } from "babylonjs/Culling/ray";
  23213. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  23214. /**
  23215. * Base class for submeshes
  23216. */
  23217. export class BaseSubMesh {
  23218. /** @hidden */
  23219. _materialDefines: Nullable<MaterialDefines>;
  23220. /** @hidden */
  23221. _materialEffect: Nullable<Effect>;
  23222. /**
  23223. * Gets associated effect
  23224. */
  23225. readonly effect: Nullable<Effect>;
  23226. /**
  23227. * Sets associated effect (effect used to render this submesh)
  23228. * @param effect defines the effect to associate with
  23229. * @param defines defines the set of defines used to compile this effect
  23230. */
  23231. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  23232. }
  23233. /**
  23234. * Defines a subdivision inside a mesh
  23235. */
  23236. export class SubMesh extends BaseSubMesh implements ICullable {
  23237. /** the material index to use */
  23238. materialIndex: number;
  23239. /** vertex index start */
  23240. verticesStart: number;
  23241. /** vertices count */
  23242. verticesCount: number;
  23243. /** index start */
  23244. indexStart: number;
  23245. /** indices count */
  23246. indexCount: number;
  23247. /** @hidden */
  23248. _linesIndexCount: number;
  23249. private _mesh;
  23250. private _renderingMesh;
  23251. private _boundingInfo;
  23252. private _linesIndexBuffer;
  23253. /** @hidden */
  23254. _lastColliderWorldVertices: Nullable<Vector3[]>;
  23255. /** @hidden */
  23256. _trianglePlanes: Plane[];
  23257. /** @hidden */
  23258. _lastColliderTransformMatrix: Nullable<Matrix>;
  23259. /** @hidden */
  23260. _renderId: number;
  23261. /** @hidden */
  23262. _alphaIndex: number;
  23263. /** @hidden */
  23264. _distanceToCamera: number;
  23265. /** @hidden */
  23266. _id: number;
  23267. private _currentMaterial;
  23268. /**
  23269. * Add a new submesh to a mesh
  23270. * @param materialIndex defines the material index to use
  23271. * @param verticesStart defines vertex index start
  23272. * @param verticesCount defines vertices count
  23273. * @param indexStart defines index start
  23274. * @param indexCount defines indices count
  23275. * @param mesh defines the parent mesh
  23276. * @param renderingMesh defines an optional rendering mesh
  23277. * @param createBoundingBox defines if bounding box should be created for this submesh
  23278. * @returns the new submesh
  23279. */
  23280. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  23281. /**
  23282. * Creates a new submesh
  23283. * @param materialIndex defines the material index to use
  23284. * @param verticesStart defines vertex index start
  23285. * @param verticesCount defines vertices count
  23286. * @param indexStart defines index start
  23287. * @param indexCount defines indices count
  23288. * @param mesh defines the parent mesh
  23289. * @param renderingMesh defines an optional rendering mesh
  23290. * @param createBoundingBox defines if bounding box should be created for this submesh
  23291. */
  23292. constructor(
  23293. /** the material index to use */
  23294. materialIndex: number,
  23295. /** vertex index start */
  23296. verticesStart: number,
  23297. /** vertices count */
  23298. verticesCount: number,
  23299. /** index start */
  23300. indexStart: number,
  23301. /** indices count */
  23302. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  23303. /**
  23304. * Returns true if this submesh covers the entire parent mesh
  23305. * @ignorenaming
  23306. */
  23307. readonly IsGlobal: boolean;
  23308. /**
  23309. * Returns the submesh BoudingInfo object
  23310. * @returns current bounding info (or mesh's one if the submesh is global)
  23311. */
  23312. getBoundingInfo(): BoundingInfo;
  23313. /**
  23314. * Sets the submesh BoundingInfo
  23315. * @param boundingInfo defines the new bounding info to use
  23316. * @returns the SubMesh
  23317. */
  23318. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  23319. /**
  23320. * Returns the mesh of the current submesh
  23321. * @return the parent mesh
  23322. */
  23323. getMesh(): AbstractMesh;
  23324. /**
  23325. * Returns the rendering mesh of the submesh
  23326. * @returns the rendering mesh (could be different from parent mesh)
  23327. */
  23328. getRenderingMesh(): Mesh;
  23329. /**
  23330. * Returns the submesh material
  23331. * @returns null or the current material
  23332. */
  23333. getMaterial(): Nullable<Material>;
  23334. /**
  23335. * Sets a new updated BoundingInfo object to the submesh
  23336. * @param data defines an optional position array to use to determine the bounding info
  23337. * @returns the SubMesh
  23338. */
  23339. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  23340. /** @hidden */
  23341. _checkCollision(collider: Collider): boolean;
  23342. /**
  23343. * Updates the submesh BoundingInfo
  23344. * @param world defines the world matrix to use to update the bounding info
  23345. * @returns the submesh
  23346. */
  23347. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  23348. /**
  23349. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  23350. * @param frustumPlanes defines the frustum planes
  23351. * @returns true if the submesh is intersecting with the frustum
  23352. */
  23353. isInFrustum(frustumPlanes: Plane[]): boolean;
  23354. /**
  23355. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  23356. * @param frustumPlanes defines the frustum planes
  23357. * @returns true if the submesh is inside the frustum
  23358. */
  23359. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  23360. /**
  23361. * Renders the submesh
  23362. * @param enableAlphaMode defines if alpha needs to be used
  23363. * @returns the submesh
  23364. */
  23365. render(enableAlphaMode: boolean): SubMesh;
  23366. /**
  23367. * @hidden
  23368. */
  23369. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  23370. /**
  23371. * Checks if the submesh intersects with a ray
  23372. * @param ray defines the ray to test
  23373. * @returns true is the passed ray intersects the submesh bounding box
  23374. */
  23375. canIntersects(ray: Ray): boolean;
  23376. /**
  23377. * Intersects current submesh with a ray
  23378. * @param ray defines the ray to test
  23379. * @param positions defines mesh's positions array
  23380. * @param indices defines mesh's indices array
  23381. * @param fastCheck defines if only bounding info should be used
  23382. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  23383. * @returns intersection info or null if no intersection
  23384. */
  23385. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  23386. /** @hidden */
  23387. private _intersectLines;
  23388. /** @hidden */
  23389. private _intersectUnIndexedLines;
  23390. /** @hidden */
  23391. private _intersectTriangles;
  23392. /** @hidden */
  23393. private _intersectUnIndexedTriangles;
  23394. /** @hidden */
  23395. _rebuild(): void;
  23396. /**
  23397. * Creates a new submesh from the passed mesh
  23398. * @param newMesh defines the new hosting mesh
  23399. * @param newRenderingMesh defines an optional rendering mesh
  23400. * @returns the new submesh
  23401. */
  23402. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  23403. /**
  23404. * Release associated resources
  23405. */
  23406. dispose(): void;
  23407. /**
  23408. * Gets the class name
  23409. * @returns the string "SubMesh".
  23410. */
  23411. getClassName(): string;
  23412. /**
  23413. * Creates a new submesh from indices data
  23414. * @param materialIndex the index of the main mesh material
  23415. * @param startIndex the index where to start the copy in the mesh indices array
  23416. * @param indexCount the number of indices to copy then from the startIndex
  23417. * @param mesh the main mesh to create the submesh from
  23418. * @param renderingMesh the optional rendering mesh
  23419. * @returns a new submesh
  23420. */
  23421. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  23422. }
  23423. }
  23424. declare module "babylonjs/Meshes/geometry" {
  23425. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  23426. import { Scene } from "babylonjs/scene";
  23427. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  23428. import { Engine } from "babylonjs/Engines/engine";
  23429. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  23430. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  23431. import { Effect } from "babylonjs/Materials/effect";
  23432. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23433. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  23434. import { Mesh } from "babylonjs/Meshes/mesh";
  23435. /**
  23436. * Class used to store geometry data (vertex buffers + index buffer)
  23437. */
  23438. export class Geometry implements IGetSetVerticesData {
  23439. /**
  23440. * Gets or sets the ID of the geometry
  23441. */
  23442. id: string;
  23443. /**
  23444. * Gets or sets the unique ID of the geometry
  23445. */
  23446. uniqueId: number;
  23447. /**
  23448. * Gets the delay loading state of the geometry (none by default which means not delayed)
  23449. */
  23450. delayLoadState: number;
  23451. /**
  23452. * Gets the file containing the data to load when running in delay load state
  23453. */
  23454. delayLoadingFile: Nullable<string>;
  23455. /**
  23456. * Callback called when the geometry is updated
  23457. */
  23458. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  23459. private _scene;
  23460. private _engine;
  23461. private _meshes;
  23462. private _totalVertices;
  23463. /** @hidden */
  23464. _indices: IndicesArray;
  23465. /** @hidden */
  23466. _vertexBuffers: {
  23467. [key: string]: VertexBuffer;
  23468. };
  23469. private _isDisposed;
  23470. private _extend;
  23471. private _boundingBias;
  23472. /** @hidden */
  23473. _delayInfo: Array<string>;
  23474. private _indexBuffer;
  23475. private _indexBufferIsUpdatable;
  23476. /** @hidden */
  23477. _boundingInfo: Nullable<BoundingInfo>;
  23478. /** @hidden */
  23479. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  23480. /** @hidden */
  23481. _softwareSkinningFrameId: number;
  23482. private _vertexArrayObjects;
  23483. private _updatable;
  23484. /** @hidden */
  23485. _positions: Nullable<Vector3[]>;
  23486. /**
  23487. * 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
  23488. */
  23489. /**
  23490. * 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
  23491. */
  23492. boundingBias: Vector2;
  23493. /**
  23494. * Static function used to attach a new empty geometry to a mesh
  23495. * @param mesh defines the mesh to attach the geometry to
  23496. * @returns the new Geometry
  23497. */
  23498. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  23499. /**
  23500. * Creates a new geometry
  23501. * @param id defines the unique ID
  23502. * @param scene defines the hosting scene
  23503. * @param vertexData defines the VertexData used to get geometry data
  23504. * @param updatable defines if geometry must be updatable (false by default)
  23505. * @param mesh defines the mesh that will be associated with the geometry
  23506. */
  23507. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  23508. /**
  23509. * Gets the current extend of the geometry
  23510. */
  23511. readonly extend: {
  23512. minimum: Vector3;
  23513. maximum: Vector3;
  23514. };
  23515. /**
  23516. * Gets the hosting scene
  23517. * @returns the hosting Scene
  23518. */
  23519. getScene(): Scene;
  23520. /**
  23521. * Gets the hosting engine
  23522. * @returns the hosting Engine
  23523. */
  23524. getEngine(): Engine;
  23525. /**
  23526. * Defines if the geometry is ready to use
  23527. * @returns true if the geometry is ready to be used
  23528. */
  23529. isReady(): boolean;
  23530. /**
  23531. * Gets a value indicating that the geometry should not be serialized
  23532. */
  23533. readonly doNotSerialize: boolean;
  23534. /** @hidden */
  23535. _rebuild(): void;
  23536. /**
  23537. * Affects all geometry data in one call
  23538. * @param vertexData defines the geometry data
  23539. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  23540. */
  23541. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  23542. /**
  23543. * Set specific vertex data
  23544. * @param kind defines the data kind (Position, normal, etc...)
  23545. * @param data defines the vertex data to use
  23546. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23547. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23548. */
  23549. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  23550. /**
  23551. * Removes a specific vertex data
  23552. * @param kind defines the data kind (Position, normal, etc...)
  23553. */
  23554. removeVerticesData(kind: string): void;
  23555. /**
  23556. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  23557. * @param buffer defines the vertex buffer to use
  23558. * @param totalVertices defines the total number of vertices for position kind (could be null)
  23559. */
  23560. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  23561. /**
  23562. * Update a specific vertex buffer
  23563. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  23564. * It will do nothing if the buffer is not updatable
  23565. * @param kind defines the data kind (Position, normal, etc...)
  23566. * @param data defines the data to use
  23567. * @param offset defines the offset in the target buffer where to store the data
  23568. * @param useBytes set to true if the offset is in bytes
  23569. */
  23570. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  23571. /**
  23572. * Update a specific vertex buffer
  23573. * This function will create a new buffer if the current one is not updatable
  23574. * @param kind defines the data kind (Position, normal, etc...)
  23575. * @param data defines the data to use
  23576. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  23577. */
  23578. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  23579. private _updateBoundingInfo;
  23580. /** @hidden */
  23581. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  23582. /**
  23583. * Gets total number of vertices
  23584. * @returns the total number of vertices
  23585. */
  23586. getTotalVertices(): number;
  23587. /**
  23588. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23589. * @param kind defines the data kind (Position, normal, etc...)
  23590. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23591. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23592. * @returns a float array containing vertex data
  23593. */
  23594. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23595. /**
  23596. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  23597. * @param kind defines the data kind (Position, normal, etc...)
  23598. * @returns true if the vertex buffer with the specified kind is updatable
  23599. */
  23600. isVertexBufferUpdatable(kind: string): boolean;
  23601. /**
  23602. * Gets a specific vertex buffer
  23603. * @param kind defines the data kind (Position, normal, etc...)
  23604. * @returns a VertexBuffer
  23605. */
  23606. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23607. /**
  23608. * Returns all vertex buffers
  23609. * @return an object holding all vertex buffers indexed by kind
  23610. */
  23611. getVertexBuffers(): Nullable<{
  23612. [key: string]: VertexBuffer;
  23613. }>;
  23614. /**
  23615. * Gets a boolean indicating if specific vertex buffer is present
  23616. * @param kind defines the data kind (Position, normal, etc...)
  23617. * @returns true if data is present
  23618. */
  23619. isVerticesDataPresent(kind: string): boolean;
  23620. /**
  23621. * Gets a list of all attached data kinds (Position, normal, etc...)
  23622. * @returns a list of string containing all kinds
  23623. */
  23624. getVerticesDataKinds(): string[];
  23625. /**
  23626. * Update index buffer
  23627. * @param indices defines the indices to store in the index buffer
  23628. * @param offset defines the offset in the target buffer where to store the data
  23629. * @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)
  23630. */
  23631. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  23632. /**
  23633. * Creates a new index buffer
  23634. * @param indices defines the indices to store in the index buffer
  23635. * @param totalVertices defines the total number of vertices (could be null)
  23636. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23637. */
  23638. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  23639. /**
  23640. * Return the total number of indices
  23641. * @returns the total number of indices
  23642. */
  23643. getTotalIndices(): number;
  23644. /**
  23645. * Gets the index buffer array
  23646. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23647. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23648. * @returns the index buffer array
  23649. */
  23650. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23651. /**
  23652. * Gets the index buffer
  23653. * @return the index buffer
  23654. */
  23655. getIndexBuffer(): Nullable<DataBuffer>;
  23656. /** @hidden */
  23657. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  23658. /**
  23659. * Release the associated resources for a specific mesh
  23660. * @param mesh defines the source mesh
  23661. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  23662. */
  23663. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  23664. /**
  23665. * Apply current geometry to a given mesh
  23666. * @param mesh defines the mesh to apply geometry to
  23667. */
  23668. applyToMesh(mesh: Mesh): void;
  23669. private _updateExtend;
  23670. private _applyToMesh;
  23671. private notifyUpdate;
  23672. /**
  23673. * Load the geometry if it was flagged as delay loaded
  23674. * @param scene defines the hosting scene
  23675. * @param onLoaded defines a callback called when the geometry is loaded
  23676. */
  23677. load(scene: Scene, onLoaded?: () => void): void;
  23678. private _queueLoad;
  23679. /**
  23680. * Invert the geometry to move from a right handed system to a left handed one.
  23681. */
  23682. toLeftHanded(): void;
  23683. /** @hidden */
  23684. _resetPointsArrayCache(): void;
  23685. /** @hidden */
  23686. _generatePointsArray(): boolean;
  23687. /**
  23688. * Gets a value indicating if the geometry is disposed
  23689. * @returns true if the geometry was disposed
  23690. */
  23691. isDisposed(): boolean;
  23692. private _disposeVertexArrayObjects;
  23693. /**
  23694. * Free all associated resources
  23695. */
  23696. dispose(): void;
  23697. /**
  23698. * Clone the current geometry into a new geometry
  23699. * @param id defines the unique ID of the new geometry
  23700. * @returns a new geometry object
  23701. */
  23702. copy(id: string): Geometry;
  23703. /**
  23704. * Serialize the current geometry info (and not the vertices data) into a JSON object
  23705. * @return a JSON representation of the current geometry data (without the vertices data)
  23706. */
  23707. serialize(): any;
  23708. private toNumberArray;
  23709. /**
  23710. * Serialize all vertices data into a JSON oject
  23711. * @returns a JSON representation of the current geometry data
  23712. */
  23713. serializeVerticeData(): any;
  23714. /**
  23715. * Extracts a clone of a mesh geometry
  23716. * @param mesh defines the source mesh
  23717. * @param id defines the unique ID of the new geometry object
  23718. * @returns the new geometry object
  23719. */
  23720. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  23721. /**
  23722. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  23723. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23724. * Be aware Math.random() could cause collisions, but:
  23725. * "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"
  23726. * @returns a string containing a new GUID
  23727. */
  23728. static RandomId(): string;
  23729. /** @hidden */
  23730. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  23731. private static _CleanMatricesWeights;
  23732. /**
  23733. * Create a new geometry from persisted data (Using .babylon file format)
  23734. * @param parsedVertexData defines the persisted data
  23735. * @param scene defines the hosting scene
  23736. * @param rootUrl defines the root url to use to load assets (like delayed data)
  23737. * @returns the new geometry object
  23738. */
  23739. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  23740. }
  23741. }
  23742. declare module "babylonjs/Meshes/mesh.vertexData" {
  23743. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  23744. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  23745. import { Geometry } from "babylonjs/Meshes/geometry";
  23746. import { Mesh } from "babylonjs/Meshes/mesh";
  23747. /**
  23748. * Define an interface for all classes that will get and set the data on vertices
  23749. */
  23750. export interface IGetSetVerticesData {
  23751. /**
  23752. * Gets a boolean indicating if specific vertex data is present
  23753. * @param kind defines the vertex data kind to use
  23754. * @returns true is data kind is present
  23755. */
  23756. isVerticesDataPresent(kind: string): boolean;
  23757. /**
  23758. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23759. * @param kind defines the data kind (Position, normal, etc...)
  23760. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23761. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23762. * @returns a float array containing vertex data
  23763. */
  23764. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23765. /**
  23766. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23767. * @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.
  23768. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23769. * @returns the indices array or an empty array if the mesh has no geometry
  23770. */
  23771. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23772. /**
  23773. * Set specific vertex data
  23774. * @param kind defines the data kind (Position, normal, etc...)
  23775. * @param data defines the vertex data to use
  23776. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23777. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23778. */
  23779. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  23780. /**
  23781. * Update a specific associated vertex buffer
  23782. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23783. * - VertexBuffer.PositionKind
  23784. * - VertexBuffer.UVKind
  23785. * - VertexBuffer.UV2Kind
  23786. * - VertexBuffer.UV3Kind
  23787. * - VertexBuffer.UV4Kind
  23788. * - VertexBuffer.UV5Kind
  23789. * - VertexBuffer.UV6Kind
  23790. * - VertexBuffer.ColorKind
  23791. * - VertexBuffer.MatricesIndicesKind
  23792. * - VertexBuffer.MatricesIndicesExtraKind
  23793. * - VertexBuffer.MatricesWeightsKind
  23794. * - VertexBuffer.MatricesWeightsExtraKind
  23795. * @param data defines the data source
  23796. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23797. * @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)
  23798. */
  23799. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  23800. /**
  23801. * Creates a new index buffer
  23802. * @param indices defines the indices to store in the index buffer
  23803. * @param totalVertices defines the total number of vertices (could be null)
  23804. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23805. */
  23806. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  23807. }
  23808. /**
  23809. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  23810. */
  23811. export class VertexData {
  23812. /**
  23813. * Mesh side orientation : usually the external or front surface
  23814. */
  23815. static readonly FRONTSIDE: number;
  23816. /**
  23817. * Mesh side orientation : usually the internal or back surface
  23818. */
  23819. static readonly BACKSIDE: number;
  23820. /**
  23821. * Mesh side orientation : both internal and external or front and back surfaces
  23822. */
  23823. static readonly DOUBLESIDE: number;
  23824. /**
  23825. * Mesh side orientation : by default, `FRONTSIDE`
  23826. */
  23827. static readonly DEFAULTSIDE: number;
  23828. /**
  23829. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  23830. */
  23831. positions: Nullable<FloatArray>;
  23832. /**
  23833. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  23834. */
  23835. normals: Nullable<FloatArray>;
  23836. /**
  23837. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  23838. */
  23839. tangents: Nullable<FloatArray>;
  23840. /**
  23841. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23842. */
  23843. uvs: Nullable<FloatArray>;
  23844. /**
  23845. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23846. */
  23847. uvs2: Nullable<FloatArray>;
  23848. /**
  23849. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23850. */
  23851. uvs3: Nullable<FloatArray>;
  23852. /**
  23853. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23854. */
  23855. uvs4: Nullable<FloatArray>;
  23856. /**
  23857. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23858. */
  23859. uvs5: Nullable<FloatArray>;
  23860. /**
  23861. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23862. */
  23863. uvs6: Nullable<FloatArray>;
  23864. /**
  23865. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  23866. */
  23867. colors: Nullable<FloatArray>;
  23868. /**
  23869. * 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).
  23870. */
  23871. matricesIndices: Nullable<FloatArray>;
  23872. /**
  23873. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  23874. */
  23875. matricesWeights: Nullable<FloatArray>;
  23876. /**
  23877. * An array extending the number of possible indices
  23878. */
  23879. matricesIndicesExtra: Nullable<FloatArray>;
  23880. /**
  23881. * An array extending the number of possible weights when the number of indices is extended
  23882. */
  23883. matricesWeightsExtra: Nullable<FloatArray>;
  23884. /**
  23885. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  23886. */
  23887. indices: Nullable<IndicesArray>;
  23888. /**
  23889. * Uses the passed data array to set the set the values for the specified kind of data
  23890. * @param data a linear array of floating numbers
  23891. * @param kind the type of data that is being set, eg positions, colors etc
  23892. */
  23893. set(data: FloatArray, kind: string): void;
  23894. /**
  23895. * Associates the vertexData to the passed Mesh.
  23896. * Sets it as updatable or not (default `false`)
  23897. * @param mesh the mesh the vertexData is applied to
  23898. * @param updatable when used and having the value true allows new data to update the vertexData
  23899. * @returns the VertexData
  23900. */
  23901. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  23902. /**
  23903. * Associates the vertexData to the passed Geometry.
  23904. * Sets it as updatable or not (default `false`)
  23905. * @param geometry the geometry the vertexData is applied to
  23906. * @param updatable when used and having the value true allows new data to update the vertexData
  23907. * @returns VertexData
  23908. */
  23909. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  23910. /**
  23911. * Updates the associated mesh
  23912. * @param mesh the mesh to be updated
  23913. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23914. * @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
  23915. * @returns VertexData
  23916. */
  23917. updateMesh(mesh: Mesh): VertexData;
  23918. /**
  23919. * Updates the associated geometry
  23920. * @param geometry the geometry to be updated
  23921. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23922. * @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
  23923. * @returns VertexData.
  23924. */
  23925. updateGeometry(geometry: Geometry): VertexData;
  23926. private _applyTo;
  23927. private _update;
  23928. /**
  23929. * Transforms each position and each normal of the vertexData according to the passed Matrix
  23930. * @param matrix the transforming matrix
  23931. * @returns the VertexData
  23932. */
  23933. transform(matrix: Matrix): VertexData;
  23934. /**
  23935. * Merges the passed VertexData into the current one
  23936. * @param other the VertexData to be merged into the current one
  23937. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  23938. * @returns the modified VertexData
  23939. */
  23940. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  23941. private _mergeElement;
  23942. private _validate;
  23943. /**
  23944. * Serializes the VertexData
  23945. * @returns a serialized object
  23946. */
  23947. serialize(): any;
  23948. /**
  23949. * Extracts the vertexData from a mesh
  23950. * @param mesh the mesh from which to extract the VertexData
  23951. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  23952. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23953. * @returns the object VertexData associated to the passed mesh
  23954. */
  23955. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23956. /**
  23957. * Extracts the vertexData from the geometry
  23958. * @param geometry the geometry from which to extract the VertexData
  23959. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  23960. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23961. * @returns the object VertexData associated to the passed mesh
  23962. */
  23963. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23964. private static _ExtractFrom;
  23965. /**
  23966. * Creates the VertexData for a Ribbon
  23967. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  23968. * * pathArray array of paths, each of which an array of successive Vector3
  23969. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  23970. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  23971. * * 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
  23972. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23973. * * 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)
  23974. * * 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)
  23975. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  23976. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  23977. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  23978. * @returns the VertexData of the ribbon
  23979. */
  23980. static CreateRibbon(options: {
  23981. pathArray: Vector3[][];
  23982. closeArray?: boolean;
  23983. closePath?: boolean;
  23984. offset?: number;
  23985. sideOrientation?: number;
  23986. frontUVs?: Vector4;
  23987. backUVs?: Vector4;
  23988. invertUV?: boolean;
  23989. uvs?: Vector2[];
  23990. colors?: Color4[];
  23991. }): VertexData;
  23992. /**
  23993. * Creates the VertexData for a box
  23994. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23995. * * size sets the width, height and depth of the box to the value of size, optional default 1
  23996. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  23997. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  23998. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  23999. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  24000. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  24001. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24002. * * 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)
  24003. * * 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)
  24004. * @returns the VertexData of the box
  24005. */
  24006. static CreateBox(options: {
  24007. size?: number;
  24008. width?: number;
  24009. height?: number;
  24010. depth?: number;
  24011. faceUV?: Vector4[];
  24012. faceColors?: Color4[];
  24013. sideOrientation?: number;
  24014. frontUVs?: Vector4;
  24015. backUVs?: Vector4;
  24016. }): VertexData;
  24017. /**
  24018. * Creates the VertexData for a tiled box
  24019. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24020. * * faceTiles sets the pattern, tile size and number of tiles for a face
  24021. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  24022. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  24023. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24024. * @returns the VertexData of the box
  24025. */
  24026. static CreateTiledBox(options: {
  24027. pattern?: number;
  24028. width?: number;
  24029. height?: number;
  24030. depth?: number;
  24031. tileSize?: number;
  24032. tileWidth?: number;
  24033. tileHeight?: number;
  24034. alignHorizontal?: number;
  24035. alignVertical?: number;
  24036. faceUV?: Vector4[];
  24037. faceColors?: Color4[];
  24038. sideOrientation?: number;
  24039. }): VertexData;
  24040. /**
  24041. * Creates the VertexData for a tiled plane
  24042. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24043. * * pattern a limited pattern arrangement depending on the number
  24044. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  24045. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  24046. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  24047. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24048. * * 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)
  24049. * * 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)
  24050. * @returns the VertexData of the tiled plane
  24051. */
  24052. static CreateTiledPlane(options: {
  24053. pattern?: number;
  24054. tileSize?: number;
  24055. tileWidth?: number;
  24056. tileHeight?: number;
  24057. size?: number;
  24058. width?: number;
  24059. height?: number;
  24060. alignHorizontal?: number;
  24061. alignVertical?: number;
  24062. sideOrientation?: number;
  24063. frontUVs?: Vector4;
  24064. backUVs?: Vector4;
  24065. }): VertexData;
  24066. /**
  24067. * Creates the VertexData for an ellipsoid, defaults to a sphere
  24068. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24069. * * segments sets the number of horizontal strips optional, default 32
  24070. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  24071. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  24072. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  24073. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  24074. * * 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
  24075. * * 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
  24076. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24077. * * 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)
  24078. * * 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)
  24079. * @returns the VertexData of the ellipsoid
  24080. */
  24081. static CreateSphere(options: {
  24082. segments?: number;
  24083. diameter?: number;
  24084. diameterX?: number;
  24085. diameterY?: number;
  24086. diameterZ?: number;
  24087. arc?: number;
  24088. slice?: number;
  24089. sideOrientation?: number;
  24090. frontUVs?: Vector4;
  24091. backUVs?: Vector4;
  24092. }): VertexData;
  24093. /**
  24094. * Creates the VertexData for a cylinder, cone or prism
  24095. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24096. * * height sets the height (y direction) of the cylinder, optional, default 2
  24097. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  24098. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  24099. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  24100. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  24101. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  24102. * * 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
  24103. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  24104. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  24105. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  24106. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  24107. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24108. * * 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)
  24109. * * 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)
  24110. * @returns the VertexData of the cylinder, cone or prism
  24111. */
  24112. static CreateCylinder(options: {
  24113. height?: number;
  24114. diameterTop?: number;
  24115. diameterBottom?: number;
  24116. diameter?: number;
  24117. tessellation?: number;
  24118. subdivisions?: number;
  24119. arc?: number;
  24120. faceColors?: Color4[];
  24121. faceUV?: Vector4[];
  24122. hasRings?: boolean;
  24123. enclose?: boolean;
  24124. sideOrientation?: number;
  24125. frontUVs?: Vector4;
  24126. backUVs?: Vector4;
  24127. }): VertexData;
  24128. /**
  24129. * Creates the VertexData for a torus
  24130. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24131. * * diameter the diameter of the torus, optional default 1
  24132. * * thickness the diameter of the tube forming the torus, optional default 0.5
  24133. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  24134. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24135. * * 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)
  24136. * * 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)
  24137. * @returns the VertexData of the torus
  24138. */
  24139. static CreateTorus(options: {
  24140. diameter?: number;
  24141. thickness?: number;
  24142. tessellation?: number;
  24143. sideOrientation?: number;
  24144. frontUVs?: Vector4;
  24145. backUVs?: Vector4;
  24146. }): VertexData;
  24147. /**
  24148. * Creates the VertexData of the LineSystem
  24149. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  24150. * - lines an array of lines, each line being an array of successive Vector3
  24151. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  24152. * @returns the VertexData of the LineSystem
  24153. */
  24154. static CreateLineSystem(options: {
  24155. lines: Vector3[][];
  24156. colors?: Nullable<Color4[][]>;
  24157. }): VertexData;
  24158. /**
  24159. * Create the VertexData for a DashedLines
  24160. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  24161. * - points an array successive Vector3
  24162. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  24163. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  24164. * - dashNb the intended total number of dashes, optional, default 200
  24165. * @returns the VertexData for the DashedLines
  24166. */
  24167. static CreateDashedLines(options: {
  24168. points: Vector3[];
  24169. dashSize?: number;
  24170. gapSize?: number;
  24171. dashNb?: number;
  24172. }): VertexData;
  24173. /**
  24174. * Creates the VertexData for a Ground
  24175. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  24176. * - width the width (x direction) of the ground, optional, default 1
  24177. * - height the height (z direction) of the ground, optional, default 1
  24178. * - subdivisions the number of subdivisions per side, optional, default 1
  24179. * @returns the VertexData of the Ground
  24180. */
  24181. static CreateGround(options: {
  24182. width?: number;
  24183. height?: number;
  24184. subdivisions?: number;
  24185. subdivisionsX?: number;
  24186. subdivisionsY?: number;
  24187. }): VertexData;
  24188. /**
  24189. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  24190. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  24191. * * xmin the ground minimum X coordinate, optional, default -1
  24192. * * zmin the ground minimum Z coordinate, optional, default -1
  24193. * * xmax the ground maximum X coordinate, optional, default 1
  24194. * * zmax the ground maximum Z coordinate, optional, default 1
  24195. * * 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}
  24196. * * 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}
  24197. * @returns the VertexData of the TiledGround
  24198. */
  24199. static CreateTiledGround(options: {
  24200. xmin: number;
  24201. zmin: number;
  24202. xmax: number;
  24203. zmax: number;
  24204. subdivisions?: {
  24205. w: number;
  24206. h: number;
  24207. };
  24208. precision?: {
  24209. w: number;
  24210. h: number;
  24211. };
  24212. }): VertexData;
  24213. /**
  24214. * Creates the VertexData of the Ground designed from a heightmap
  24215. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  24216. * * width the width (x direction) of the ground
  24217. * * height the height (z direction) of the ground
  24218. * * subdivisions the number of subdivisions per side
  24219. * * minHeight the minimum altitude on the ground, optional, default 0
  24220. * * maxHeight the maximum altitude on the ground, optional default 1
  24221. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  24222. * * buffer the array holding the image color data
  24223. * * bufferWidth the width of image
  24224. * * bufferHeight the height of image
  24225. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  24226. * @returns the VertexData of the Ground designed from a heightmap
  24227. */
  24228. static CreateGroundFromHeightMap(options: {
  24229. width: number;
  24230. height: number;
  24231. subdivisions: number;
  24232. minHeight: number;
  24233. maxHeight: number;
  24234. colorFilter: Color3;
  24235. buffer: Uint8Array;
  24236. bufferWidth: number;
  24237. bufferHeight: number;
  24238. alphaFilter: number;
  24239. }): VertexData;
  24240. /**
  24241. * Creates the VertexData for a Plane
  24242. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  24243. * * size sets the width and height of the plane to the value of size, optional default 1
  24244. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  24245. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  24246. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24247. * * 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)
  24248. * * 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)
  24249. * @returns the VertexData of the box
  24250. */
  24251. static CreatePlane(options: {
  24252. size?: number;
  24253. width?: number;
  24254. height?: number;
  24255. sideOrientation?: number;
  24256. frontUVs?: Vector4;
  24257. backUVs?: Vector4;
  24258. }): VertexData;
  24259. /**
  24260. * Creates the VertexData of the Disc or regular Polygon
  24261. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  24262. * * radius the radius of the disc, optional default 0.5
  24263. * * tessellation the number of polygon sides, optional, default 64
  24264. * * 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
  24265. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24266. * * 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)
  24267. * * 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)
  24268. * @returns the VertexData of the box
  24269. */
  24270. static CreateDisc(options: {
  24271. radius?: number;
  24272. tessellation?: number;
  24273. arc?: number;
  24274. sideOrientation?: number;
  24275. frontUVs?: Vector4;
  24276. backUVs?: Vector4;
  24277. }): VertexData;
  24278. /**
  24279. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  24280. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  24281. * @param polygon a mesh built from polygonTriangulation.build()
  24282. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24283. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  24284. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  24285. * @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)
  24286. * @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)
  24287. * @returns the VertexData of the Polygon
  24288. */
  24289. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  24290. /**
  24291. * Creates the VertexData of the IcoSphere
  24292. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  24293. * * radius the radius of the IcoSphere, optional default 1
  24294. * * radiusX allows stretching in the x direction, optional, default radius
  24295. * * radiusY allows stretching in the y direction, optional, default radius
  24296. * * radiusZ allows stretching in the z direction, optional, default radius
  24297. * * flat when true creates a flat shaded mesh, optional, default true
  24298. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  24299. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24300. * * 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)
  24301. * * 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)
  24302. * @returns the VertexData of the IcoSphere
  24303. */
  24304. static CreateIcoSphere(options: {
  24305. radius?: number;
  24306. radiusX?: number;
  24307. radiusY?: number;
  24308. radiusZ?: number;
  24309. flat?: boolean;
  24310. subdivisions?: number;
  24311. sideOrientation?: number;
  24312. frontUVs?: Vector4;
  24313. backUVs?: Vector4;
  24314. }): VertexData;
  24315. /**
  24316. * Creates the VertexData for a Polyhedron
  24317. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  24318. * * type provided types are:
  24319. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  24320. * * 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)
  24321. * * size the size of the IcoSphere, optional default 1
  24322. * * sizeX allows stretching in the x direction, optional, default size
  24323. * * sizeY allows stretching in the y direction, optional, default size
  24324. * * sizeZ allows stretching in the z direction, optional, default size
  24325. * * 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
  24326. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  24327. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  24328. * * flat when true creates a flat shaded mesh, optional, default true
  24329. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  24330. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24331. * * 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)
  24332. * * 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)
  24333. * @returns the VertexData of the Polyhedron
  24334. */
  24335. static CreatePolyhedron(options: {
  24336. type?: number;
  24337. size?: number;
  24338. sizeX?: number;
  24339. sizeY?: number;
  24340. sizeZ?: number;
  24341. custom?: any;
  24342. faceUV?: Vector4[];
  24343. faceColors?: Color4[];
  24344. flat?: boolean;
  24345. sideOrientation?: number;
  24346. frontUVs?: Vector4;
  24347. backUVs?: Vector4;
  24348. }): VertexData;
  24349. /**
  24350. * Creates the VertexData for a TorusKnot
  24351. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  24352. * * radius the radius of the torus knot, optional, default 2
  24353. * * tube the thickness of the tube, optional, default 0.5
  24354. * * radialSegments the number of sides on each tube segments, optional, default 32
  24355. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  24356. * * p the number of windings around the z axis, optional, default 2
  24357. * * q the number of windings around the x axis, optional, default 3
  24358. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24359. * * 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)
  24360. * * 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)
  24361. * @returns the VertexData of the Torus Knot
  24362. */
  24363. static CreateTorusKnot(options: {
  24364. radius?: number;
  24365. tube?: number;
  24366. radialSegments?: number;
  24367. tubularSegments?: number;
  24368. p?: number;
  24369. q?: number;
  24370. sideOrientation?: number;
  24371. frontUVs?: Vector4;
  24372. backUVs?: Vector4;
  24373. }): VertexData;
  24374. /**
  24375. * Compute normals for given positions and indices
  24376. * @param positions an array of vertex positions, [...., x, y, z, ......]
  24377. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  24378. * @param normals an array of vertex normals, [...., x, y, z, ......]
  24379. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  24380. * * facetNormals : optional array of facet normals (vector3)
  24381. * * facetPositions : optional array of facet positions (vector3)
  24382. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  24383. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  24384. * * bInfo : optional bounding info, required for facetPartitioning computation
  24385. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  24386. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  24387. * * useRightHandedSystem: optional boolean to for right handed system computation
  24388. * * depthSort : optional boolean to enable the facet depth sort computation
  24389. * * distanceTo : optional Vector3 to compute the facet depth from this location
  24390. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  24391. */
  24392. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  24393. facetNormals?: any;
  24394. facetPositions?: any;
  24395. facetPartitioning?: any;
  24396. ratio?: number;
  24397. bInfo?: any;
  24398. bbSize?: Vector3;
  24399. subDiv?: any;
  24400. useRightHandedSystem?: boolean;
  24401. depthSort?: boolean;
  24402. distanceTo?: Vector3;
  24403. depthSortedFacets?: any;
  24404. }): void;
  24405. /** @hidden */
  24406. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  24407. /**
  24408. * Applies VertexData created from the imported parameters to the geometry
  24409. * @param parsedVertexData the parsed data from an imported file
  24410. * @param geometry the geometry to apply the VertexData to
  24411. */
  24412. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  24413. }
  24414. }
  24415. declare module "babylonjs/Meshes/Builders/discBuilder" {
  24416. import { Nullable } from "babylonjs/types";
  24417. import { Scene } from "babylonjs/scene";
  24418. import { Vector4 } from "babylonjs/Maths/math";
  24419. import { Mesh } from "babylonjs/Meshes/mesh";
  24420. /**
  24421. * Class containing static functions to help procedurally build meshes
  24422. */
  24423. export class DiscBuilder {
  24424. /**
  24425. * Creates a plane polygonal mesh. By default, this is a disc
  24426. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  24427. * * 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
  24428. * * 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
  24429. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24430. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  24431. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24432. * @param name defines the name of the mesh
  24433. * @param options defines the options used to create the mesh
  24434. * @param scene defines the hosting scene
  24435. * @returns the plane polygonal mesh
  24436. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  24437. */
  24438. static CreateDisc(name: string, options: {
  24439. radius?: number;
  24440. tessellation?: number;
  24441. arc?: number;
  24442. updatable?: boolean;
  24443. sideOrientation?: number;
  24444. frontUVs?: Vector4;
  24445. backUVs?: Vector4;
  24446. }, scene?: Nullable<Scene>): Mesh;
  24447. }
  24448. }
  24449. declare module "babylonjs/Particles/solidParticleSystem" {
  24450. import { Vector3 } from "babylonjs/Maths/math";
  24451. import { Mesh } from "babylonjs/Meshes/mesh";
  24452. import { Scene, IDisposable } from "babylonjs/scene";
  24453. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  24454. /**
  24455. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  24456. *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.
  24457. * The SPS is also a particle system. It provides some methods to manage the particles.
  24458. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  24459. *
  24460. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  24461. */
  24462. export class SolidParticleSystem implements IDisposable {
  24463. /**
  24464. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  24465. * Example : var p = SPS.particles[i];
  24466. */
  24467. particles: SolidParticle[];
  24468. /**
  24469. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  24470. */
  24471. nbParticles: number;
  24472. /**
  24473. * If the particles must ever face the camera (default false). Useful for planar particles.
  24474. */
  24475. billboard: boolean;
  24476. /**
  24477. * Recompute normals when adding a shape
  24478. */
  24479. recomputeNormals: boolean;
  24480. /**
  24481. * This a counter ofr your own usage. It's not set by any SPS functions.
  24482. */
  24483. counter: number;
  24484. /**
  24485. * The SPS name. This name is also given to the underlying mesh.
  24486. */
  24487. name: string;
  24488. /**
  24489. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  24490. */
  24491. mesh: Mesh;
  24492. /**
  24493. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  24494. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  24495. */
  24496. vars: any;
  24497. /**
  24498. * This array is populated when the SPS is set as 'pickable'.
  24499. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  24500. * Each element of this array is an object `{idx: int, faceId: int}`.
  24501. * `idx` is the picked particle index in the `SPS.particles` array
  24502. * `faceId` is the picked face index counted within this particle.
  24503. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  24504. */
  24505. pickedParticles: {
  24506. idx: number;
  24507. faceId: number;
  24508. }[];
  24509. /**
  24510. * This array is populated when `enableDepthSort` is set to true.
  24511. * Each element of this array is an instance of the class DepthSortedParticle.
  24512. */
  24513. depthSortedParticles: DepthSortedParticle[];
  24514. /**
  24515. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  24516. * @hidden
  24517. */
  24518. _bSphereOnly: boolean;
  24519. /**
  24520. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  24521. * @hidden
  24522. */
  24523. _bSphereRadiusFactor: number;
  24524. private _scene;
  24525. private _positions;
  24526. private _indices;
  24527. private _normals;
  24528. private _colors;
  24529. private _uvs;
  24530. private _indices32;
  24531. private _positions32;
  24532. private _normals32;
  24533. private _fixedNormal32;
  24534. private _colors32;
  24535. private _uvs32;
  24536. private _index;
  24537. private _updatable;
  24538. private _pickable;
  24539. private _isVisibilityBoxLocked;
  24540. private _alwaysVisible;
  24541. private _depthSort;
  24542. private _shapeCounter;
  24543. private _copy;
  24544. private _color;
  24545. private _computeParticleColor;
  24546. private _computeParticleTexture;
  24547. private _computeParticleRotation;
  24548. private _computeParticleVertex;
  24549. private _computeBoundingBox;
  24550. private _depthSortParticles;
  24551. private _camera;
  24552. private _mustUnrotateFixedNormals;
  24553. private _particlesIntersect;
  24554. private _needs32Bits;
  24555. /**
  24556. * Creates a SPS (Solid Particle System) object.
  24557. * @param name (String) is the SPS name, this will be the underlying mesh name.
  24558. * @param scene (Scene) is the scene in which the SPS is added.
  24559. * @param options defines the options of the sps e.g.
  24560. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  24561. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  24562. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  24563. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  24564. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  24565. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  24566. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  24567. */
  24568. constructor(name: string, scene: Scene, options?: {
  24569. updatable?: boolean;
  24570. isPickable?: boolean;
  24571. enableDepthSort?: boolean;
  24572. particleIntersection?: boolean;
  24573. boundingSphereOnly?: boolean;
  24574. bSphereRadiusFactor?: number;
  24575. });
  24576. /**
  24577. * Builds the SPS underlying mesh. Returns a standard Mesh.
  24578. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  24579. * @returns the created mesh
  24580. */
  24581. buildMesh(): Mesh;
  24582. /**
  24583. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  24584. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  24585. * Thus the particles generated from `digest()` have their property `position` set yet.
  24586. * @param mesh ( Mesh ) is the mesh to be digested
  24587. * @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
  24588. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  24589. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  24590. * @returns the current SPS
  24591. */
  24592. digest(mesh: Mesh, options?: {
  24593. facetNb?: number;
  24594. number?: number;
  24595. delta?: number;
  24596. }): SolidParticleSystem;
  24597. private _unrotateFixedNormals;
  24598. private _resetCopy;
  24599. private _meshBuilder;
  24600. private _posToShape;
  24601. private _uvsToShapeUV;
  24602. private _addParticle;
  24603. /**
  24604. * Adds some particles to the SPS from the model shape. Returns the shape id.
  24605. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  24606. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  24607. * @param nb (positive integer) the number of particles to be created from this model
  24608. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  24609. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  24610. * @returns the number of shapes in the system
  24611. */
  24612. addShape(mesh: Mesh, nb: number, options?: {
  24613. positionFunction?: any;
  24614. vertexFunction?: any;
  24615. }): number;
  24616. private _rebuildParticle;
  24617. /**
  24618. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  24619. * @returns the SPS.
  24620. */
  24621. rebuildMesh(): SolidParticleSystem;
  24622. /**
  24623. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  24624. * This method calls `updateParticle()` for each particle of the SPS.
  24625. * For an animated SPS, it is usually called within the render loop.
  24626. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  24627. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  24628. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  24629. * @returns the SPS.
  24630. */
  24631. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  24632. /**
  24633. * Disposes the SPS.
  24634. */
  24635. dispose(): void;
  24636. /**
  24637. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  24638. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24639. * @returns the SPS.
  24640. */
  24641. refreshVisibleSize(): SolidParticleSystem;
  24642. /**
  24643. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  24644. * @param size the size (float) of the visibility box
  24645. * note : this doesn't lock the SPS mesh bounding box.
  24646. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24647. */
  24648. setVisibilityBox(size: number): void;
  24649. /**
  24650. * Gets whether the SPS as always visible or not
  24651. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24652. */
  24653. /**
  24654. * Sets the SPS as always visible or not
  24655. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24656. */
  24657. isAlwaysVisible: boolean;
  24658. /**
  24659. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24660. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24661. */
  24662. /**
  24663. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24664. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24665. */
  24666. isVisibilityBoxLocked: boolean;
  24667. /**
  24668. * Tells to `setParticles()` to compute the particle rotations or not.
  24669. * Default value : true. The SPS is faster when it's set to false.
  24670. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24671. */
  24672. /**
  24673. * Gets if `setParticles()` computes the particle rotations or not.
  24674. * Default value : true. The SPS is faster when it's set to false.
  24675. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24676. */
  24677. computeParticleRotation: boolean;
  24678. /**
  24679. * Tells to `setParticles()` to compute the particle colors or not.
  24680. * Default value : true. The SPS is faster when it's set to false.
  24681. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24682. */
  24683. /**
  24684. * Gets if `setParticles()` computes the particle colors or not.
  24685. * Default value : true. The SPS is faster when it's set to false.
  24686. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24687. */
  24688. computeParticleColor: boolean;
  24689. /**
  24690. * Gets if `setParticles()` computes the particle textures or not.
  24691. * Default value : true. The SPS is faster when it's set to false.
  24692. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  24693. */
  24694. computeParticleTexture: boolean;
  24695. /**
  24696. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  24697. * Default value : false. The SPS is faster when it's set to false.
  24698. * Note : the particle custom vertex positions aren't stored values.
  24699. */
  24700. /**
  24701. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  24702. * Default value : false. The SPS is faster when it's set to false.
  24703. * Note : the particle custom vertex positions aren't stored values.
  24704. */
  24705. computeParticleVertex: boolean;
  24706. /**
  24707. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  24708. */
  24709. /**
  24710. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  24711. */
  24712. computeBoundingBox: boolean;
  24713. /**
  24714. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  24715. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24716. * Default : `true`
  24717. */
  24718. /**
  24719. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  24720. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24721. * Default : `true`
  24722. */
  24723. depthSortParticles: boolean;
  24724. /**
  24725. * This function does nothing. It may be overwritten to set all the particle first values.
  24726. * The SPS doesn't call this function, you may have to call it by your own.
  24727. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24728. */
  24729. initParticles(): void;
  24730. /**
  24731. * This function does nothing. It may be overwritten to recycle a particle.
  24732. * The SPS doesn't call this function, you may have to call it by your own.
  24733. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24734. * @param particle The particle to recycle
  24735. * @returns the recycled particle
  24736. */
  24737. recycleParticle(particle: SolidParticle): SolidParticle;
  24738. /**
  24739. * Updates a particle : this function should be overwritten by the user.
  24740. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  24741. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24742. * @example : just set a particle position or velocity and recycle conditions
  24743. * @param particle The particle to update
  24744. * @returns the updated particle
  24745. */
  24746. updateParticle(particle: SolidParticle): SolidParticle;
  24747. /**
  24748. * Updates a vertex of a particle : it can be overwritten by the user.
  24749. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  24750. * @param particle the current particle
  24751. * @param vertex the current index of the current particle
  24752. * @param pt the index of the current vertex in the particle shape
  24753. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  24754. * @example : just set a vertex particle position
  24755. * @returns the updated vertex
  24756. */
  24757. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  24758. /**
  24759. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  24760. * This does nothing and may be overwritten by the user.
  24761. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24762. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24763. * @param update the boolean update value actually passed to setParticles()
  24764. */
  24765. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24766. /**
  24767. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  24768. * This will be passed three parameters.
  24769. * This does nothing and may be overwritten by the user.
  24770. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24771. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24772. * @param update the boolean update value actually passed to setParticles()
  24773. */
  24774. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24775. }
  24776. }
  24777. declare module "babylonjs/Particles/solidParticle" {
  24778. import { Nullable } from "babylonjs/types";
  24779. import { Color4, Vector3, Matrix, Quaternion, Vector4, Plane } from "babylonjs/Maths/math";
  24780. import { Mesh } from "babylonjs/Meshes/mesh";
  24781. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24782. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  24783. /**
  24784. * Represents one particle of a solid particle system.
  24785. */
  24786. export class SolidParticle {
  24787. /**
  24788. * particle global index
  24789. */
  24790. idx: number;
  24791. /**
  24792. * The color of the particle
  24793. */
  24794. color: Nullable<Color4>;
  24795. /**
  24796. * The world space position of the particle.
  24797. */
  24798. position: Vector3;
  24799. /**
  24800. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  24801. */
  24802. rotation: Vector3;
  24803. /**
  24804. * The world space rotation quaternion of the particle.
  24805. */
  24806. rotationQuaternion: Nullable<Quaternion>;
  24807. /**
  24808. * The scaling of the particle.
  24809. */
  24810. scaling: Vector3;
  24811. /**
  24812. * The uvs of the particle.
  24813. */
  24814. uvs: Vector4;
  24815. /**
  24816. * The current speed of the particle.
  24817. */
  24818. velocity: Vector3;
  24819. /**
  24820. * The pivot point in the particle local space.
  24821. */
  24822. pivot: Vector3;
  24823. /**
  24824. * Must the particle be translated from its pivot point in its local space ?
  24825. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  24826. * Default : false
  24827. */
  24828. translateFromPivot: boolean;
  24829. /**
  24830. * Is the particle active or not ?
  24831. */
  24832. alive: boolean;
  24833. /**
  24834. * Is the particle visible or not ?
  24835. */
  24836. isVisible: boolean;
  24837. /**
  24838. * Index of this particle in the global "positions" array (Internal use)
  24839. * @hidden
  24840. */
  24841. _pos: number;
  24842. /**
  24843. * @hidden Index of this particle in the global "indices" array (Internal use)
  24844. */
  24845. _ind: number;
  24846. /**
  24847. * @hidden ModelShape of this particle (Internal use)
  24848. */
  24849. _model: ModelShape;
  24850. /**
  24851. * ModelShape id of this particle
  24852. */
  24853. shapeId: number;
  24854. /**
  24855. * Index of the particle in its shape id (Internal use)
  24856. */
  24857. idxInShape: number;
  24858. /**
  24859. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  24860. */
  24861. _modelBoundingInfo: BoundingInfo;
  24862. /**
  24863. * @hidden Particle BoundingInfo object (Internal use)
  24864. */
  24865. _boundingInfo: BoundingInfo;
  24866. /**
  24867. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  24868. */
  24869. _sps: SolidParticleSystem;
  24870. /**
  24871. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  24872. */
  24873. _stillInvisible: boolean;
  24874. /**
  24875. * @hidden Last computed particle rotation matrix
  24876. */
  24877. _rotationMatrix: number[];
  24878. /**
  24879. * Parent particle Id, if any.
  24880. * Default null.
  24881. */
  24882. parentId: Nullable<number>;
  24883. /**
  24884. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  24885. * The possible values are :
  24886. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24887. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24888. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24889. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24890. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24891. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  24892. * */
  24893. cullingStrategy: number;
  24894. /**
  24895. * @hidden Internal global position in the SPS.
  24896. */
  24897. _globalPosition: Vector3;
  24898. /**
  24899. * Creates a Solid Particle object.
  24900. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  24901. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  24902. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  24903. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  24904. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  24905. * @param shapeId (integer) is the model shape identifier in the SPS.
  24906. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  24907. * @param sps defines the sps it is associated to
  24908. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  24909. */
  24910. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  24911. /**
  24912. * Legacy support, changed scale to scaling
  24913. */
  24914. /**
  24915. * Legacy support, changed scale to scaling
  24916. */
  24917. scale: Vector3;
  24918. /**
  24919. * Legacy support, changed quaternion to rotationQuaternion
  24920. */
  24921. /**
  24922. * Legacy support, changed quaternion to rotationQuaternion
  24923. */
  24924. quaternion: Nullable<Quaternion>;
  24925. /**
  24926. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  24927. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  24928. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  24929. * @returns true if it intersects
  24930. */
  24931. intersectsMesh(target: Mesh | SolidParticle): boolean;
  24932. /**
  24933. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  24934. * A particle is in the frustum if its bounding box intersects the frustum
  24935. * @param frustumPlanes defines the frustum to test
  24936. * @returns true if the particle is in the frustum planes
  24937. */
  24938. isInFrustum(frustumPlanes: Plane[]): boolean;
  24939. /**
  24940. * get the rotation matrix of the particle
  24941. * @hidden
  24942. */
  24943. getRotationMatrix(m: Matrix): void;
  24944. }
  24945. /**
  24946. * Represents the shape of the model used by one particle of a solid particle system.
  24947. * SPS internal tool, don't use it manually.
  24948. */
  24949. export class ModelShape {
  24950. /**
  24951. * The shape id
  24952. * @hidden
  24953. */
  24954. shapeID: number;
  24955. /**
  24956. * flat array of model positions (internal use)
  24957. * @hidden
  24958. */
  24959. _shape: Vector3[];
  24960. /**
  24961. * flat array of model UVs (internal use)
  24962. * @hidden
  24963. */
  24964. _shapeUV: number[];
  24965. /**
  24966. * length of the shape in the model indices array (internal use)
  24967. * @hidden
  24968. */
  24969. _indicesLength: number;
  24970. /**
  24971. * Custom position function (internal use)
  24972. * @hidden
  24973. */
  24974. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  24975. /**
  24976. * Custom vertex function (internal use)
  24977. * @hidden
  24978. */
  24979. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  24980. /**
  24981. * 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.
  24982. * SPS internal tool, don't use it manually.
  24983. * @hidden
  24984. */
  24985. 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>);
  24986. }
  24987. /**
  24988. * Represents a Depth Sorted Particle in the solid particle system.
  24989. */
  24990. export class DepthSortedParticle {
  24991. /**
  24992. * Index of the particle in the "indices" array
  24993. */
  24994. ind: number;
  24995. /**
  24996. * Length of the particle shape in the "indices" array
  24997. */
  24998. indicesLength: number;
  24999. /**
  25000. * Squared distance from the particle to the camera
  25001. */
  25002. sqDistance: number;
  25003. }
  25004. }
  25005. declare module "babylonjs/Collisions/meshCollisionData" {
  25006. import { Collider } from "babylonjs/Collisions/collider";
  25007. import { Vector3 } from "babylonjs/Maths/math";
  25008. import { Nullable } from "babylonjs/types";
  25009. import { Observer } from "babylonjs/Misc/observable";
  25010. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25011. /**
  25012. * @hidden
  25013. */
  25014. export class _MeshCollisionData {
  25015. _checkCollisions: boolean;
  25016. _collisionMask: number;
  25017. _collisionGroup: number;
  25018. _collider: Nullable<Collider>;
  25019. _oldPositionForCollisions: Vector3;
  25020. _diffPositionForCollisions: Vector3;
  25021. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  25022. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  25023. }
  25024. }
  25025. declare module "babylonjs/Meshes/abstractMesh" {
  25026. import { Observable } from "babylonjs/Misc/observable";
  25027. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  25028. import { Camera } from "babylonjs/Cameras/camera";
  25029. import { Scene, IDisposable } from "babylonjs/scene";
  25030. import { Matrix, Vector3, Color3, Color4, Plane, Vector2 } from "babylonjs/Maths/math";
  25031. import { Node } from "babylonjs/node";
  25032. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  25033. import { TransformNode } from "babylonjs/Meshes/transformNode";
  25034. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25035. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  25036. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  25037. import { Material } from "babylonjs/Materials/material";
  25038. import { Light } from "babylonjs/Lights/light";
  25039. import { Skeleton } from "babylonjs/Bones/skeleton";
  25040. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  25041. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  25042. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  25043. import { Ray } from "babylonjs/Culling/ray";
  25044. import { Collider } from "babylonjs/Collisions/collider";
  25045. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  25046. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  25047. /** @hidden */
  25048. class _FacetDataStorage {
  25049. facetPositions: Vector3[];
  25050. facetNormals: Vector3[];
  25051. facetPartitioning: number[][];
  25052. facetNb: number;
  25053. partitioningSubdivisions: number;
  25054. partitioningBBoxRatio: number;
  25055. facetDataEnabled: boolean;
  25056. facetParameters: any;
  25057. bbSize: Vector3;
  25058. subDiv: {
  25059. max: number;
  25060. X: number;
  25061. Y: number;
  25062. Z: number;
  25063. };
  25064. facetDepthSort: boolean;
  25065. facetDepthSortEnabled: boolean;
  25066. depthSortedIndices: IndicesArray;
  25067. depthSortedFacets: {
  25068. ind: number;
  25069. sqDistance: number;
  25070. }[];
  25071. facetDepthSortFunction: (f1: {
  25072. ind: number;
  25073. sqDistance: number;
  25074. }, f2: {
  25075. ind: number;
  25076. sqDistance: number;
  25077. }) => number;
  25078. facetDepthSortFrom: Vector3;
  25079. facetDepthSortOrigin: Vector3;
  25080. invertedMatrix: Matrix;
  25081. }
  25082. /**
  25083. * @hidden
  25084. **/
  25085. class _InternalAbstractMeshDataInfo {
  25086. _hasVertexAlpha: boolean;
  25087. _useVertexColors: boolean;
  25088. _numBoneInfluencers: number;
  25089. _applyFog: boolean;
  25090. _receiveShadows: boolean;
  25091. _facetData: _FacetDataStorage;
  25092. _visibility: number;
  25093. _skeleton: Nullable<Skeleton>;
  25094. _layerMask: number;
  25095. _computeBonesUsingShaders: boolean;
  25096. _isActive: boolean;
  25097. _onlyForInstances: boolean;
  25098. _isActiveIntermediate: boolean;
  25099. _onlyForInstancesIntermediate: boolean;
  25100. }
  25101. /**
  25102. * Class used to store all common mesh properties
  25103. */
  25104. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  25105. /** No occlusion */
  25106. static OCCLUSION_TYPE_NONE: number;
  25107. /** Occlusion set to optimisitic */
  25108. static OCCLUSION_TYPE_OPTIMISTIC: number;
  25109. /** Occlusion set to strict */
  25110. static OCCLUSION_TYPE_STRICT: number;
  25111. /** Use an accurante occlusion algorithm */
  25112. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  25113. /** Use a conservative occlusion algorithm */
  25114. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  25115. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  25116. * Test order :
  25117. * Is the bounding sphere outside the frustum ?
  25118. * If not, are the bounding box vertices outside the frustum ?
  25119. * It not, then the cullable object is in the frustum.
  25120. */
  25121. static readonly CULLINGSTRATEGY_STANDARD: number;
  25122. /** Culling strategy : Bounding Sphere Only.
  25123. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  25124. * It's also less accurate than the standard because some not visible objects can still be selected.
  25125. * Test : is the bounding sphere outside the frustum ?
  25126. * If not, then the cullable object is in the frustum.
  25127. */
  25128. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  25129. /** Culling strategy : Optimistic Inclusion.
  25130. * This in an inclusion test first, then the standard exclusion test.
  25131. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  25132. * 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.
  25133. * Anyway, it's as accurate as the standard strategy.
  25134. * Test :
  25135. * Is the cullable object bounding sphere center in the frustum ?
  25136. * If not, apply the default culling strategy.
  25137. */
  25138. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  25139. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  25140. * This in an inclusion test first, then the bounding sphere only exclusion test.
  25141. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  25142. * 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.
  25143. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  25144. * Test :
  25145. * Is the cullable object bounding sphere center in the frustum ?
  25146. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  25147. */
  25148. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  25149. /**
  25150. * No billboard
  25151. */
  25152. static readonly BILLBOARDMODE_NONE: number;
  25153. /** Billboard on X axis */
  25154. static readonly BILLBOARDMODE_X: number;
  25155. /** Billboard on Y axis */
  25156. static readonly BILLBOARDMODE_Y: number;
  25157. /** Billboard on Z axis */
  25158. static readonly BILLBOARDMODE_Z: number;
  25159. /** Billboard on all axes */
  25160. static readonly BILLBOARDMODE_ALL: number;
  25161. /** @hidden */
  25162. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  25163. /**
  25164. * The culling strategy to use to check whether the mesh must be rendered or not.
  25165. * This value can be changed at any time and will be used on the next render mesh selection.
  25166. * The possible values are :
  25167. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25168. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25169. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25170. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25171. * Please read each static variable documentation to get details about the culling process.
  25172. * */
  25173. cullingStrategy: number;
  25174. /**
  25175. * Gets the number of facets in the mesh
  25176. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25177. */
  25178. readonly facetNb: number;
  25179. /**
  25180. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  25181. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25182. */
  25183. partitioningSubdivisions: number;
  25184. /**
  25185. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  25186. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  25187. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25188. */
  25189. partitioningBBoxRatio: number;
  25190. /**
  25191. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  25192. * Works only for updatable meshes.
  25193. * Doesn't work with multi-materials
  25194. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25195. */
  25196. mustDepthSortFacets: boolean;
  25197. /**
  25198. * The location (Vector3) where the facet depth sort must be computed from.
  25199. * By default, the active camera position.
  25200. * Used only when facet depth sort is enabled
  25201. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25202. */
  25203. facetDepthSortFrom: Vector3;
  25204. /**
  25205. * gets a boolean indicating if facetData is enabled
  25206. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25207. */
  25208. readonly isFacetDataEnabled: boolean;
  25209. /** @hidden */
  25210. _updateNonUniformScalingState(value: boolean): boolean;
  25211. /**
  25212. * An event triggered when this mesh collides with another one
  25213. */
  25214. onCollideObservable: Observable<AbstractMesh>;
  25215. /** Set a function to call when this mesh collides with another one */
  25216. onCollide: () => void;
  25217. /**
  25218. * An event triggered when the collision's position changes
  25219. */
  25220. onCollisionPositionChangeObservable: Observable<Vector3>;
  25221. /** Set a function to call when the collision's position changes */
  25222. onCollisionPositionChange: () => void;
  25223. /**
  25224. * An event triggered when material is changed
  25225. */
  25226. onMaterialChangedObservable: Observable<AbstractMesh>;
  25227. /**
  25228. * Gets or sets the orientation for POV movement & rotation
  25229. */
  25230. definedFacingForward: boolean;
  25231. /** @hidden */
  25232. _occlusionQuery: Nullable<WebGLQuery>;
  25233. /** @hidden */
  25234. _renderingGroup: Nullable<RenderingGroup>;
  25235. /**
  25236. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25237. */
  25238. /**
  25239. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25240. */
  25241. visibility: number;
  25242. /** Gets or sets the alpha index used to sort transparent meshes
  25243. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  25244. */
  25245. alphaIndex: number;
  25246. /**
  25247. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  25248. */
  25249. isVisible: boolean;
  25250. /**
  25251. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  25252. */
  25253. isPickable: boolean;
  25254. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  25255. showSubMeshesBoundingBox: boolean;
  25256. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  25257. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  25258. */
  25259. isBlocker: boolean;
  25260. /**
  25261. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  25262. */
  25263. enablePointerMoveEvents: boolean;
  25264. /**
  25265. * Specifies the rendering group id for this mesh (0 by default)
  25266. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  25267. */
  25268. renderingGroupId: number;
  25269. private _material;
  25270. /** Gets or sets current material */
  25271. material: Nullable<Material>;
  25272. /**
  25273. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  25274. * @see http://doc.babylonjs.com/babylon101/shadows
  25275. */
  25276. receiveShadows: boolean;
  25277. /** Defines color to use when rendering outline */
  25278. outlineColor: Color3;
  25279. /** Define width to use when rendering outline */
  25280. outlineWidth: number;
  25281. /** Defines color to use when rendering overlay */
  25282. overlayColor: Color3;
  25283. /** Defines alpha to use when rendering overlay */
  25284. overlayAlpha: number;
  25285. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  25286. hasVertexAlpha: boolean;
  25287. /** 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) */
  25288. useVertexColors: boolean;
  25289. /**
  25290. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  25291. */
  25292. computeBonesUsingShaders: boolean;
  25293. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  25294. numBoneInfluencers: number;
  25295. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  25296. applyFog: boolean;
  25297. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  25298. useOctreeForRenderingSelection: boolean;
  25299. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  25300. useOctreeForPicking: boolean;
  25301. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  25302. useOctreeForCollisions: boolean;
  25303. /**
  25304. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  25305. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  25306. */
  25307. layerMask: number;
  25308. /**
  25309. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  25310. */
  25311. alwaysSelectAsActiveMesh: boolean;
  25312. /**
  25313. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  25314. */
  25315. doNotSyncBoundingInfo: boolean;
  25316. /**
  25317. * Gets or sets the current action manager
  25318. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25319. */
  25320. actionManager: Nullable<AbstractActionManager>;
  25321. private _meshCollisionData;
  25322. /**
  25323. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  25324. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25325. */
  25326. ellipsoid: Vector3;
  25327. /**
  25328. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  25329. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25330. */
  25331. ellipsoidOffset: Vector3;
  25332. /**
  25333. * Gets or sets a collision mask used to mask collisions (default is -1).
  25334. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25335. */
  25336. collisionMask: number;
  25337. /**
  25338. * Gets or sets the current collision group mask (-1 by default).
  25339. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25340. */
  25341. collisionGroup: number;
  25342. /**
  25343. * Defines edge width used when edgesRenderer is enabled
  25344. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25345. */
  25346. edgesWidth: number;
  25347. /**
  25348. * Defines edge color used when edgesRenderer is enabled
  25349. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25350. */
  25351. edgesColor: Color4;
  25352. /** @hidden */
  25353. _edgesRenderer: Nullable<IEdgesRenderer>;
  25354. /** @hidden */
  25355. _masterMesh: Nullable<AbstractMesh>;
  25356. /** @hidden */
  25357. _boundingInfo: Nullable<BoundingInfo>;
  25358. /** @hidden */
  25359. _renderId: number;
  25360. /**
  25361. * Gets or sets the list of subMeshes
  25362. * @see http://doc.babylonjs.com/how_to/multi_materials
  25363. */
  25364. subMeshes: SubMesh[];
  25365. /** @hidden */
  25366. _intersectionsInProgress: AbstractMesh[];
  25367. /** @hidden */
  25368. _unIndexed: boolean;
  25369. /** @hidden */
  25370. _lightSources: Light[];
  25371. /** Gets the list of lights affecting that mesh */
  25372. readonly lightSources: Light[];
  25373. /** @hidden */
  25374. readonly _positions: Nullable<Vector3[]>;
  25375. /** @hidden */
  25376. _waitingData: {
  25377. lods: Nullable<any>;
  25378. actions: Nullable<any>;
  25379. freezeWorldMatrix: Nullable<boolean>;
  25380. };
  25381. /** @hidden */
  25382. _bonesTransformMatrices: Nullable<Float32Array>;
  25383. /**
  25384. * Gets or sets a skeleton to apply skining transformations
  25385. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25386. */
  25387. skeleton: Nullable<Skeleton>;
  25388. /**
  25389. * An event triggered when the mesh is rebuilt.
  25390. */
  25391. onRebuildObservable: Observable<AbstractMesh>;
  25392. /**
  25393. * Creates a new AbstractMesh
  25394. * @param name defines the name of the mesh
  25395. * @param scene defines the hosting scene
  25396. */
  25397. constructor(name: string, scene?: Nullable<Scene>);
  25398. /**
  25399. * Returns the string "AbstractMesh"
  25400. * @returns "AbstractMesh"
  25401. */
  25402. getClassName(): string;
  25403. /**
  25404. * Gets a string representation of the current mesh
  25405. * @param fullDetails defines a boolean indicating if full details must be included
  25406. * @returns a string representation of the current mesh
  25407. */
  25408. toString(fullDetails?: boolean): string;
  25409. /**
  25410. * @hidden
  25411. */
  25412. protected _getEffectiveParent(): Nullable<Node>;
  25413. /** @hidden */
  25414. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25415. /** @hidden */
  25416. _rebuild(): void;
  25417. /** @hidden */
  25418. _resyncLightSources(): void;
  25419. /** @hidden */
  25420. _resyncLighSource(light: Light): void;
  25421. /** @hidden */
  25422. _unBindEffect(): void;
  25423. /** @hidden */
  25424. _removeLightSource(light: Light): void;
  25425. private _markSubMeshesAsDirty;
  25426. /** @hidden */
  25427. _markSubMeshesAsLightDirty(): void;
  25428. /** @hidden */
  25429. _markSubMeshesAsAttributesDirty(): void;
  25430. /** @hidden */
  25431. _markSubMeshesAsMiscDirty(): void;
  25432. /**
  25433. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  25434. */
  25435. scaling: Vector3;
  25436. /**
  25437. * Returns true if the mesh is blocked. Implemented by child classes
  25438. */
  25439. readonly isBlocked: boolean;
  25440. /**
  25441. * Returns the mesh itself by default. Implemented by child classes
  25442. * @param camera defines the camera to use to pick the right LOD level
  25443. * @returns the currentAbstractMesh
  25444. */
  25445. getLOD(camera: Camera): Nullable<AbstractMesh>;
  25446. /**
  25447. * Returns 0 by default. Implemented by child classes
  25448. * @returns an integer
  25449. */
  25450. getTotalVertices(): number;
  25451. /**
  25452. * Returns a positive integer : the total number of indices in this mesh geometry.
  25453. * @returns the numner of indices or zero if the mesh has no geometry.
  25454. */
  25455. getTotalIndices(): number;
  25456. /**
  25457. * Returns null by default. Implemented by child classes
  25458. * @returns null
  25459. */
  25460. getIndices(): Nullable<IndicesArray>;
  25461. /**
  25462. * Returns the array of the requested vertex data kind. Implemented by child classes
  25463. * @param kind defines the vertex data kind to use
  25464. * @returns null
  25465. */
  25466. getVerticesData(kind: string): Nullable<FloatArray>;
  25467. /**
  25468. * Sets the vertex data of the mesh geometry for the requested `kind`.
  25469. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  25470. * Note that a new underlying VertexBuffer object is created each call.
  25471. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  25472. * @param kind defines vertex data kind:
  25473. * * VertexBuffer.PositionKind
  25474. * * VertexBuffer.UVKind
  25475. * * VertexBuffer.UV2Kind
  25476. * * VertexBuffer.UV3Kind
  25477. * * VertexBuffer.UV4Kind
  25478. * * VertexBuffer.UV5Kind
  25479. * * VertexBuffer.UV6Kind
  25480. * * VertexBuffer.ColorKind
  25481. * * VertexBuffer.MatricesIndicesKind
  25482. * * VertexBuffer.MatricesIndicesExtraKind
  25483. * * VertexBuffer.MatricesWeightsKind
  25484. * * VertexBuffer.MatricesWeightsExtraKind
  25485. * @param data defines the data source
  25486. * @param updatable defines if the data must be flagged as updatable (or static)
  25487. * @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
  25488. * @returns the current mesh
  25489. */
  25490. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25491. /**
  25492. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  25493. * If the mesh has no geometry, it is simply returned as it is.
  25494. * @param kind defines vertex data kind:
  25495. * * VertexBuffer.PositionKind
  25496. * * VertexBuffer.UVKind
  25497. * * VertexBuffer.UV2Kind
  25498. * * VertexBuffer.UV3Kind
  25499. * * VertexBuffer.UV4Kind
  25500. * * VertexBuffer.UV5Kind
  25501. * * VertexBuffer.UV6Kind
  25502. * * VertexBuffer.ColorKind
  25503. * * VertexBuffer.MatricesIndicesKind
  25504. * * VertexBuffer.MatricesIndicesExtraKind
  25505. * * VertexBuffer.MatricesWeightsKind
  25506. * * VertexBuffer.MatricesWeightsExtraKind
  25507. * @param data defines the data source
  25508. * @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
  25509. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  25510. * @returns the current mesh
  25511. */
  25512. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25513. /**
  25514. * Sets the mesh indices,
  25515. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  25516. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  25517. * @param totalVertices Defines the total number of vertices
  25518. * @returns the current mesh
  25519. */
  25520. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  25521. /**
  25522. * Gets a boolean indicating if specific vertex data is present
  25523. * @param kind defines the vertex data kind to use
  25524. * @returns true is data kind is present
  25525. */
  25526. isVerticesDataPresent(kind: string): boolean;
  25527. /**
  25528. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  25529. * @returns a BoundingInfo
  25530. */
  25531. getBoundingInfo(): BoundingInfo;
  25532. /**
  25533. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  25534. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  25535. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  25536. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  25537. * @returns the current mesh
  25538. */
  25539. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  25540. /**
  25541. * Overwrite the current bounding info
  25542. * @param boundingInfo defines the new bounding info
  25543. * @returns the current mesh
  25544. */
  25545. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  25546. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  25547. readonly useBones: boolean;
  25548. /** @hidden */
  25549. _preActivate(): void;
  25550. /** @hidden */
  25551. _preActivateForIntermediateRendering(renderId: number): void;
  25552. /** @hidden */
  25553. _activate(renderId: number, intermediateRendering: boolean): boolean;
  25554. /** @hidden */
  25555. _postActivate(): void;
  25556. /** @hidden */
  25557. _freeze(): void;
  25558. /** @hidden */
  25559. _unFreeze(): void;
  25560. /**
  25561. * Gets the current world matrix
  25562. * @returns a Matrix
  25563. */
  25564. getWorldMatrix(): Matrix;
  25565. /** @hidden */
  25566. _getWorldMatrixDeterminant(): number;
  25567. /**
  25568. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  25569. */
  25570. readonly isAnInstance: boolean;
  25571. /**
  25572. * Perform relative position change from the point of view of behind the front of the mesh.
  25573. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25574. * Supports definition of mesh facing forward or backward
  25575. * @param amountRight defines the distance on the right axis
  25576. * @param amountUp defines the distance on the up axis
  25577. * @param amountForward defines the distance on the forward axis
  25578. * @returns the current mesh
  25579. */
  25580. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  25581. /**
  25582. * Calculate relative position change from the point of view of behind the front of the mesh.
  25583. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25584. * Supports definition of mesh facing forward or backward
  25585. * @param amountRight defines the distance on the right axis
  25586. * @param amountUp defines the distance on the up axis
  25587. * @param amountForward defines the distance on the forward axis
  25588. * @returns the new displacement vector
  25589. */
  25590. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  25591. /**
  25592. * Perform relative rotation change from the point of view of behind the front of the mesh.
  25593. * Supports definition of mesh facing forward or backward
  25594. * @param flipBack defines the flip
  25595. * @param twirlClockwise defines the twirl
  25596. * @param tiltRight defines the tilt
  25597. * @returns the current mesh
  25598. */
  25599. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  25600. /**
  25601. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  25602. * Supports definition of mesh facing forward or backward.
  25603. * @param flipBack defines the flip
  25604. * @param twirlClockwise defines the twirl
  25605. * @param tiltRight defines the tilt
  25606. * @returns the new rotation vector
  25607. */
  25608. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  25609. /**
  25610. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25611. * This means the mesh underlying bounding box and sphere are recomputed.
  25612. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25613. * @returns the current mesh
  25614. */
  25615. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  25616. /** @hidden */
  25617. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  25618. /** @hidden */
  25619. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  25620. /** @hidden */
  25621. _updateBoundingInfo(): AbstractMesh;
  25622. /** @hidden */
  25623. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  25624. /** @hidden */
  25625. protected _afterComputeWorldMatrix(): void;
  25626. /** @hidden */
  25627. readonly _effectiveMesh: AbstractMesh;
  25628. /**
  25629. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25630. * A mesh is in the frustum if its bounding box intersects the frustum
  25631. * @param frustumPlanes defines the frustum to test
  25632. * @returns true if the mesh is in the frustum planes
  25633. */
  25634. isInFrustum(frustumPlanes: Plane[]): boolean;
  25635. /**
  25636. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  25637. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  25638. * @param frustumPlanes defines the frustum to test
  25639. * @returns true if the mesh is completely in the frustum planes
  25640. */
  25641. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25642. /**
  25643. * True if the mesh intersects another mesh or a SolidParticle object
  25644. * @param mesh defines a target mesh or SolidParticle to test
  25645. * @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)
  25646. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  25647. * @returns true if there is an intersection
  25648. */
  25649. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  25650. /**
  25651. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  25652. * @param point defines the point to test
  25653. * @returns true if there is an intersection
  25654. */
  25655. intersectsPoint(point: Vector3): boolean;
  25656. /**
  25657. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  25658. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25659. */
  25660. checkCollisions: boolean;
  25661. /**
  25662. * Gets Collider object used to compute collisions (not physics)
  25663. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25664. */
  25665. readonly collider: Nullable<Collider>;
  25666. /**
  25667. * Move the mesh using collision engine
  25668. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25669. * @param displacement defines the requested displacement vector
  25670. * @returns the current mesh
  25671. */
  25672. moveWithCollisions(displacement: Vector3): AbstractMesh;
  25673. private _onCollisionPositionChange;
  25674. /** @hidden */
  25675. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  25676. /** @hidden */
  25677. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  25678. /** @hidden */
  25679. _checkCollision(collider: Collider): AbstractMesh;
  25680. /** @hidden */
  25681. _generatePointsArray(): boolean;
  25682. /**
  25683. * Checks if the passed Ray intersects with the mesh
  25684. * @param ray defines the ray to use
  25685. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  25686. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25687. * @returns the picking info
  25688. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  25689. */
  25690. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  25691. /**
  25692. * Clones the current mesh
  25693. * @param name defines the mesh name
  25694. * @param newParent defines the new mesh parent
  25695. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  25696. * @returns the new mesh
  25697. */
  25698. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  25699. /**
  25700. * Disposes all the submeshes of the current meshnp
  25701. * @returns the current mesh
  25702. */
  25703. releaseSubMeshes(): AbstractMesh;
  25704. /**
  25705. * Releases resources associated with this abstract mesh.
  25706. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25707. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25708. */
  25709. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25710. /**
  25711. * Adds the passed mesh as a child to the current mesh
  25712. * @param mesh defines the child mesh
  25713. * @returns the current mesh
  25714. */
  25715. addChild(mesh: AbstractMesh): AbstractMesh;
  25716. /**
  25717. * Removes the passed mesh from the current mesh children list
  25718. * @param mesh defines the child mesh
  25719. * @returns the current mesh
  25720. */
  25721. removeChild(mesh: AbstractMesh): AbstractMesh;
  25722. /** @hidden */
  25723. private _initFacetData;
  25724. /**
  25725. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  25726. * This method can be called within the render loop.
  25727. * 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
  25728. * @returns the current mesh
  25729. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25730. */
  25731. updateFacetData(): AbstractMesh;
  25732. /**
  25733. * Returns the facetLocalNormals array.
  25734. * The normals are expressed in the mesh local spac
  25735. * @returns an array of Vector3
  25736. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25737. */
  25738. getFacetLocalNormals(): Vector3[];
  25739. /**
  25740. * Returns the facetLocalPositions array.
  25741. * The facet positions are expressed in the mesh local space
  25742. * @returns an array of Vector3
  25743. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25744. */
  25745. getFacetLocalPositions(): Vector3[];
  25746. /**
  25747. * Returns the facetLocalPartioning array
  25748. * @returns an array of array of numbers
  25749. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25750. */
  25751. getFacetLocalPartitioning(): number[][];
  25752. /**
  25753. * Returns the i-th facet position in the world system.
  25754. * This method allocates a new Vector3 per call
  25755. * @param i defines the facet index
  25756. * @returns a new Vector3
  25757. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25758. */
  25759. getFacetPosition(i: number): Vector3;
  25760. /**
  25761. * Sets the reference Vector3 with the i-th facet position in the world system
  25762. * @param i defines the facet index
  25763. * @param ref defines the target vector
  25764. * @returns the current mesh
  25765. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25766. */
  25767. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  25768. /**
  25769. * Returns the i-th facet normal in the world system.
  25770. * This method allocates a new Vector3 per call
  25771. * @param i defines the facet index
  25772. * @returns a new Vector3
  25773. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25774. */
  25775. getFacetNormal(i: number): Vector3;
  25776. /**
  25777. * Sets the reference Vector3 with the i-th facet normal in the world system
  25778. * @param i defines the facet index
  25779. * @param ref defines the target vector
  25780. * @returns the current mesh
  25781. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25782. */
  25783. getFacetNormalToRef(i: number, ref: Vector3): this;
  25784. /**
  25785. * 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)
  25786. * @param x defines x coordinate
  25787. * @param y defines y coordinate
  25788. * @param z defines z coordinate
  25789. * @returns the array of facet indexes
  25790. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25791. */
  25792. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  25793. /**
  25794. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  25795. * @param projected sets as the (x,y,z) world projection on the facet
  25796. * @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
  25797. * @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
  25798. * @param x defines x coordinate
  25799. * @param y defines y coordinate
  25800. * @param z defines z coordinate
  25801. * @returns the face index if found (or null instead)
  25802. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25803. */
  25804. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25805. /**
  25806. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  25807. * @param projected sets as the (x,y,z) local projection on the facet
  25808. * @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
  25809. * @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
  25810. * @param x defines x coordinate
  25811. * @param y defines y coordinate
  25812. * @param z defines z coordinate
  25813. * @returns the face index if found (or null instead)
  25814. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25815. */
  25816. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25817. /**
  25818. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  25819. * @returns the parameters
  25820. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25821. */
  25822. getFacetDataParameters(): any;
  25823. /**
  25824. * Disables the feature FacetData and frees the related memory
  25825. * @returns the current mesh
  25826. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25827. */
  25828. disableFacetData(): AbstractMesh;
  25829. /**
  25830. * Updates the AbstractMesh indices array
  25831. * @param indices defines the data source
  25832. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25833. * @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)
  25834. * @returns the current mesh
  25835. */
  25836. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25837. /**
  25838. * Creates new normals data for the mesh
  25839. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  25840. * @returns the current mesh
  25841. */
  25842. createNormals(updatable: boolean): AbstractMesh;
  25843. /**
  25844. * Align the mesh with a normal
  25845. * @param normal defines the normal to use
  25846. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  25847. * @returns the current mesh
  25848. */
  25849. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  25850. /** @hidden */
  25851. _checkOcclusionQuery(): boolean;
  25852. /**
  25853. * Disables the mesh edge rendering mode
  25854. * @returns the currentAbstractMesh
  25855. */
  25856. disableEdgesRendering(): AbstractMesh;
  25857. /**
  25858. * Enables the edge rendering mode on the mesh.
  25859. * This mode makes the mesh edges visible
  25860. * @param epsilon defines the maximal distance between two angles to detect a face
  25861. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  25862. * @returns the currentAbstractMesh
  25863. * @see https://www.babylonjs-playground.com/#19O9TU#0
  25864. */
  25865. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  25866. }
  25867. }
  25868. declare module "babylonjs/Actions/actionEvent" {
  25869. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25870. import { Nullable } from "babylonjs/types";
  25871. import { Sprite } from "babylonjs/Sprites/sprite";
  25872. import { Scene } from "babylonjs/scene";
  25873. import { Vector2 } from "babylonjs/Maths/math";
  25874. /**
  25875. * Interface used to define ActionEvent
  25876. */
  25877. export interface IActionEvent {
  25878. /** The mesh or sprite that triggered the action */
  25879. source: any;
  25880. /** The X mouse cursor position at the time of the event */
  25881. pointerX: number;
  25882. /** The Y mouse cursor position at the time of the event */
  25883. pointerY: number;
  25884. /** The mesh that is currently pointed at (can be null) */
  25885. meshUnderPointer: Nullable<AbstractMesh>;
  25886. /** the original (browser) event that triggered the ActionEvent */
  25887. sourceEvent?: any;
  25888. /** additional data for the event */
  25889. additionalData?: any;
  25890. }
  25891. /**
  25892. * ActionEvent is the event being sent when an action is triggered.
  25893. */
  25894. export class ActionEvent implements IActionEvent {
  25895. /** The mesh or sprite that triggered the action */
  25896. source: any;
  25897. /** The X mouse cursor position at the time of the event */
  25898. pointerX: number;
  25899. /** The Y mouse cursor position at the time of the event */
  25900. pointerY: number;
  25901. /** The mesh that is currently pointed at (can be null) */
  25902. meshUnderPointer: Nullable<AbstractMesh>;
  25903. /** the original (browser) event that triggered the ActionEvent */
  25904. sourceEvent?: any;
  25905. /** additional data for the event */
  25906. additionalData?: any;
  25907. /**
  25908. * Creates a new ActionEvent
  25909. * @param source The mesh or sprite that triggered the action
  25910. * @param pointerX The X mouse cursor position at the time of the event
  25911. * @param pointerY The Y mouse cursor position at the time of the event
  25912. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  25913. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  25914. * @param additionalData additional data for the event
  25915. */
  25916. constructor(
  25917. /** The mesh or sprite that triggered the action */
  25918. source: any,
  25919. /** The X mouse cursor position at the time of the event */
  25920. pointerX: number,
  25921. /** The Y mouse cursor position at the time of the event */
  25922. pointerY: number,
  25923. /** The mesh that is currently pointed at (can be null) */
  25924. meshUnderPointer: Nullable<AbstractMesh>,
  25925. /** the original (browser) event that triggered the ActionEvent */
  25926. sourceEvent?: any,
  25927. /** additional data for the event */
  25928. additionalData?: any);
  25929. /**
  25930. * Helper function to auto-create an ActionEvent from a source mesh.
  25931. * @param source The source mesh that triggered the event
  25932. * @param evt The original (browser) event
  25933. * @param additionalData additional data for the event
  25934. * @returns the new ActionEvent
  25935. */
  25936. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  25937. /**
  25938. * Helper function to auto-create an ActionEvent from a source sprite
  25939. * @param source The source sprite that triggered the event
  25940. * @param scene Scene associated with the sprite
  25941. * @param evt The original (browser) event
  25942. * @param additionalData additional data for the event
  25943. * @returns the new ActionEvent
  25944. */
  25945. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  25946. /**
  25947. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  25948. * @param scene the scene where the event occurred
  25949. * @param evt The original (browser) event
  25950. * @returns the new ActionEvent
  25951. */
  25952. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  25953. /**
  25954. * Helper function to auto-create an ActionEvent from a primitive
  25955. * @param prim defines the target primitive
  25956. * @param pointerPos defines the pointer position
  25957. * @param evt The original (browser) event
  25958. * @param additionalData additional data for the event
  25959. * @returns the new ActionEvent
  25960. */
  25961. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  25962. }
  25963. }
  25964. declare module "babylonjs/Actions/abstractActionManager" {
  25965. import { IDisposable } from "babylonjs/scene";
  25966. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  25967. import { IAction } from "babylonjs/Actions/action";
  25968. import { Nullable } from "babylonjs/types";
  25969. /**
  25970. * Abstract class used to decouple action Manager from scene and meshes.
  25971. * Do not instantiate.
  25972. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25973. */
  25974. export abstract class AbstractActionManager implements IDisposable {
  25975. /** Gets the list of active triggers */
  25976. static Triggers: {
  25977. [key: string]: number;
  25978. };
  25979. /** Gets the cursor to use when hovering items */
  25980. hoverCursor: string;
  25981. /** Gets the list of actions */
  25982. actions: IAction[];
  25983. /**
  25984. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  25985. */
  25986. isRecursive: boolean;
  25987. /**
  25988. * Releases all associated resources
  25989. */
  25990. abstract dispose(): void;
  25991. /**
  25992. * Does this action manager has pointer triggers
  25993. */
  25994. abstract readonly hasPointerTriggers: boolean;
  25995. /**
  25996. * Does this action manager has pick triggers
  25997. */
  25998. abstract readonly hasPickTriggers: boolean;
  25999. /**
  26000. * Process a specific trigger
  26001. * @param trigger defines the trigger to process
  26002. * @param evt defines the event details to be processed
  26003. */
  26004. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  26005. /**
  26006. * Does this action manager handles actions of any of the given triggers
  26007. * @param triggers defines the triggers to be tested
  26008. * @return a boolean indicating whether one (or more) of the triggers is handled
  26009. */
  26010. abstract hasSpecificTriggers(triggers: number[]): boolean;
  26011. /**
  26012. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  26013. * speed.
  26014. * @param triggerA defines the trigger to be tested
  26015. * @param triggerB defines the trigger to be tested
  26016. * @return a boolean indicating whether one (or more) of the triggers is handled
  26017. */
  26018. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  26019. /**
  26020. * Does this action manager handles actions of a given trigger
  26021. * @param trigger defines the trigger to be tested
  26022. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  26023. * @return whether the trigger is handled
  26024. */
  26025. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  26026. /**
  26027. * Serialize this manager to a JSON object
  26028. * @param name defines the property name to store this manager
  26029. * @returns a JSON representation of this manager
  26030. */
  26031. abstract serialize(name: string): any;
  26032. /**
  26033. * Registers an action to this action manager
  26034. * @param action defines the action to be registered
  26035. * @return the action amended (prepared) after registration
  26036. */
  26037. abstract registerAction(action: IAction): Nullable<IAction>;
  26038. /**
  26039. * Unregisters an action to this action manager
  26040. * @param action defines the action to be unregistered
  26041. * @return a boolean indicating whether the action has been unregistered
  26042. */
  26043. abstract unregisterAction(action: IAction): Boolean;
  26044. /**
  26045. * Does exist one action manager with at least one trigger
  26046. **/
  26047. static readonly HasTriggers: boolean;
  26048. /**
  26049. * Does exist one action manager with at least one pick trigger
  26050. **/
  26051. static readonly HasPickTriggers: boolean;
  26052. /**
  26053. * Does exist one action manager that handles actions of a given trigger
  26054. * @param trigger defines the trigger to be tested
  26055. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  26056. **/
  26057. static HasSpecificTrigger(trigger: number): boolean;
  26058. }
  26059. }
  26060. declare module "babylonjs/node" {
  26061. import { Scene } from "babylonjs/scene";
  26062. import { Nullable } from "babylonjs/types";
  26063. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  26064. import { Engine } from "babylonjs/Engines/engine";
  26065. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  26066. import { Observable } from "babylonjs/Misc/observable";
  26067. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  26068. import { IInspectable } from "babylonjs/Misc/iInspectable";
  26069. import { Animatable } from "babylonjs/Animations/animatable";
  26070. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  26071. import { Animation } from "babylonjs/Animations/animation";
  26072. import { AnimationRange } from "babylonjs/Animations/animationRange";
  26073. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26074. /**
  26075. * Defines how a node can be built from a string name.
  26076. */
  26077. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  26078. /**
  26079. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  26080. */
  26081. export class Node implements IBehaviorAware<Node> {
  26082. /** @hidden */
  26083. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  26084. private static _NodeConstructors;
  26085. /**
  26086. * Add a new node constructor
  26087. * @param type defines the type name of the node to construct
  26088. * @param constructorFunc defines the constructor function
  26089. */
  26090. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  26091. /**
  26092. * Returns a node constructor based on type name
  26093. * @param type defines the type name
  26094. * @param name defines the new node name
  26095. * @param scene defines the hosting scene
  26096. * @param options defines optional options to transmit to constructors
  26097. * @returns the new constructor or null
  26098. */
  26099. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  26100. /**
  26101. * Gets or sets the name of the node
  26102. */
  26103. name: string;
  26104. /**
  26105. * Gets or sets the id of the node
  26106. */
  26107. id: string;
  26108. /**
  26109. * Gets or sets the unique id of the node
  26110. */
  26111. uniqueId: number;
  26112. /**
  26113. * Gets or sets a string used to store user defined state for the node
  26114. */
  26115. state: string;
  26116. /**
  26117. * Gets or sets an object used to store user defined information for the node
  26118. */
  26119. metadata: any;
  26120. /**
  26121. * For internal use only. Please do not use.
  26122. */
  26123. reservedDataStore: any;
  26124. /**
  26125. * List of inspectable custom properties (used by the Inspector)
  26126. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  26127. */
  26128. inspectableCustomProperties: IInspectable[];
  26129. /**
  26130. * Gets or sets a boolean used to define if the node must be serialized
  26131. */
  26132. doNotSerialize: boolean;
  26133. /** @hidden */
  26134. _isDisposed: boolean;
  26135. /**
  26136. * Gets a list of Animations associated with the node
  26137. */
  26138. animations: import("babylonjs/Animations/animation").Animation[];
  26139. protected _ranges: {
  26140. [name: string]: Nullable<AnimationRange>;
  26141. };
  26142. /**
  26143. * Callback raised when the node is ready to be used
  26144. */
  26145. onReady: Nullable<(node: Node) => void>;
  26146. private _isEnabled;
  26147. private _isParentEnabled;
  26148. private _isReady;
  26149. /** @hidden */
  26150. _currentRenderId: number;
  26151. private _parentUpdateId;
  26152. /** @hidden */
  26153. _childUpdateId: number;
  26154. /** @hidden */
  26155. _waitingParentId: Nullable<string>;
  26156. /** @hidden */
  26157. _scene: Scene;
  26158. /** @hidden */
  26159. _cache: any;
  26160. private _parentNode;
  26161. private _children;
  26162. /** @hidden */
  26163. _worldMatrix: Matrix;
  26164. /** @hidden */
  26165. _worldMatrixDeterminant: number;
  26166. /** @hidden */
  26167. _worldMatrixDeterminantIsDirty: boolean;
  26168. /** @hidden */
  26169. private _sceneRootNodesIndex;
  26170. /**
  26171. * Gets a boolean indicating if the node has been disposed
  26172. * @returns true if the node was disposed
  26173. */
  26174. isDisposed(): boolean;
  26175. /**
  26176. * Gets or sets the parent of the node (without keeping the current position in the scene)
  26177. * @see https://doc.babylonjs.com/how_to/parenting
  26178. */
  26179. parent: Nullable<Node>;
  26180. private addToSceneRootNodes;
  26181. private removeFromSceneRootNodes;
  26182. private _animationPropertiesOverride;
  26183. /**
  26184. * Gets or sets the animation properties override
  26185. */
  26186. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  26187. /**
  26188. * Gets a string idenfifying the name of the class
  26189. * @returns "Node" string
  26190. */
  26191. getClassName(): string;
  26192. /** @hidden */
  26193. readonly _isNode: boolean;
  26194. /**
  26195. * An event triggered when the mesh is disposed
  26196. */
  26197. onDisposeObservable: Observable<Node>;
  26198. private _onDisposeObserver;
  26199. /**
  26200. * Sets a callback that will be raised when the node will be disposed
  26201. */
  26202. onDispose: () => void;
  26203. /**
  26204. * Creates a new Node
  26205. * @param name the name and id to be given to this node
  26206. * @param scene the scene this node will be added to
  26207. * @param addToRootNodes the node will be added to scene.rootNodes
  26208. */
  26209. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  26210. /**
  26211. * Gets the scene of the node
  26212. * @returns a scene
  26213. */
  26214. getScene(): Scene;
  26215. /**
  26216. * Gets the engine of the node
  26217. * @returns a Engine
  26218. */
  26219. getEngine(): Engine;
  26220. private _behaviors;
  26221. /**
  26222. * Attach a behavior to the node
  26223. * @see http://doc.babylonjs.com/features/behaviour
  26224. * @param behavior defines the behavior to attach
  26225. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  26226. * @returns the current Node
  26227. */
  26228. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  26229. /**
  26230. * Remove an attached behavior
  26231. * @see http://doc.babylonjs.com/features/behaviour
  26232. * @param behavior defines the behavior to attach
  26233. * @returns the current Node
  26234. */
  26235. removeBehavior(behavior: Behavior<Node>): Node;
  26236. /**
  26237. * Gets the list of attached behaviors
  26238. * @see http://doc.babylonjs.com/features/behaviour
  26239. */
  26240. readonly behaviors: Behavior<Node>[];
  26241. /**
  26242. * Gets an attached behavior by name
  26243. * @param name defines the name of the behavior to look for
  26244. * @see http://doc.babylonjs.com/features/behaviour
  26245. * @returns null if behavior was not found else the requested behavior
  26246. */
  26247. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  26248. /**
  26249. * Returns the latest update of the World matrix
  26250. * @returns a Matrix
  26251. */
  26252. getWorldMatrix(): Matrix;
  26253. /** @hidden */
  26254. _getWorldMatrixDeterminant(): number;
  26255. /**
  26256. * Returns directly the latest state of the mesh World matrix.
  26257. * A Matrix is returned.
  26258. */
  26259. readonly worldMatrixFromCache: Matrix;
  26260. /** @hidden */
  26261. _initCache(): void;
  26262. /** @hidden */
  26263. updateCache(force?: boolean): void;
  26264. /** @hidden */
  26265. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26266. /** @hidden */
  26267. _updateCache(ignoreParentClass?: boolean): void;
  26268. /** @hidden */
  26269. _isSynchronized(): boolean;
  26270. /** @hidden */
  26271. _markSyncedWithParent(): void;
  26272. /** @hidden */
  26273. isSynchronizedWithParent(): boolean;
  26274. /** @hidden */
  26275. isSynchronized(): boolean;
  26276. /**
  26277. * Is this node ready to be used/rendered
  26278. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26279. * @return true if the node is ready
  26280. */
  26281. isReady(completeCheck?: boolean): boolean;
  26282. /**
  26283. * Is this node enabled?
  26284. * 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
  26285. * @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
  26286. * @return whether this node (and its parent) is enabled
  26287. */
  26288. isEnabled(checkAncestors?: boolean): boolean;
  26289. /** @hidden */
  26290. protected _syncParentEnabledState(): void;
  26291. /**
  26292. * Set the enabled state of this node
  26293. * @param value defines the new enabled state
  26294. */
  26295. setEnabled(value: boolean): void;
  26296. /**
  26297. * Is this node a descendant of the given node?
  26298. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  26299. * @param ancestor defines the parent node to inspect
  26300. * @returns a boolean indicating if this node is a descendant of the given node
  26301. */
  26302. isDescendantOf(ancestor: Node): boolean;
  26303. /** @hidden */
  26304. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  26305. /**
  26306. * Will return all nodes that have this node as ascendant
  26307. * @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
  26308. * @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
  26309. * @return all children nodes of all types
  26310. */
  26311. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  26312. /**
  26313. * Get all child-meshes of this node
  26314. * @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)
  26315. * @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
  26316. * @returns an array of AbstractMesh
  26317. */
  26318. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  26319. /**
  26320. * Get all direct children of this node
  26321. * @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
  26322. * @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)
  26323. * @returns an array of Node
  26324. */
  26325. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  26326. /** @hidden */
  26327. _setReady(state: boolean): void;
  26328. /**
  26329. * Get an animation by name
  26330. * @param name defines the name of the animation to look for
  26331. * @returns null if not found else the requested animation
  26332. */
  26333. getAnimationByName(name: string): Nullable<Animation>;
  26334. /**
  26335. * Creates an animation range for this node
  26336. * @param name defines the name of the range
  26337. * @param from defines the starting key
  26338. * @param to defines the end key
  26339. */
  26340. createAnimationRange(name: string, from: number, to: number): void;
  26341. /**
  26342. * Delete a specific animation range
  26343. * @param name defines the name of the range to delete
  26344. * @param deleteFrames defines if animation frames from the range must be deleted as well
  26345. */
  26346. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  26347. /**
  26348. * Get an animation range by name
  26349. * @param name defines the name of the animation range to look for
  26350. * @returns null if not found else the requested animation range
  26351. */
  26352. getAnimationRange(name: string): Nullable<AnimationRange>;
  26353. /**
  26354. * Gets the list of all animation ranges defined on this node
  26355. * @returns an array
  26356. */
  26357. getAnimationRanges(): Nullable<AnimationRange>[];
  26358. /**
  26359. * Will start the animation sequence
  26360. * @param name defines the range frames for animation sequence
  26361. * @param loop defines if the animation should loop (false by default)
  26362. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  26363. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  26364. * @returns the object created for this animation. If range does not exist, it will return null
  26365. */
  26366. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  26367. /**
  26368. * Serialize animation ranges into a JSON compatible object
  26369. * @returns serialization object
  26370. */
  26371. serializeAnimationRanges(): any;
  26372. /**
  26373. * Computes the world matrix of the node
  26374. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26375. * @returns the world matrix
  26376. */
  26377. computeWorldMatrix(force?: boolean): Matrix;
  26378. /**
  26379. * Releases resources associated with this node.
  26380. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26381. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26382. */
  26383. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26384. /**
  26385. * Parse animation range data from a serialization object and store them into a given node
  26386. * @param node defines where to store the animation ranges
  26387. * @param parsedNode defines the serialization object to read data from
  26388. * @param scene defines the hosting scene
  26389. */
  26390. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  26391. /**
  26392. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  26393. * @param includeDescendants Include bounding info from descendants as well (true by default)
  26394. * @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
  26395. * @returns the new bounding vectors
  26396. */
  26397. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  26398. min: Vector3;
  26399. max: Vector3;
  26400. };
  26401. }
  26402. }
  26403. declare module "babylonjs/Animations/animation" {
  26404. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  26405. import { Vector3, Quaternion, Vector2, Color3, Size, Matrix } from "babylonjs/Maths/math";
  26406. import { Nullable } from "babylonjs/types";
  26407. import { Scene } from "babylonjs/scene";
  26408. import { IAnimatable } from "babylonjs/Misc/tools";
  26409. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  26410. import { AnimationRange } from "babylonjs/Animations/animationRange";
  26411. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  26412. import { Node } from "babylonjs/node";
  26413. import { Animatable } from "babylonjs/Animations/animatable";
  26414. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  26415. /**
  26416. * @hidden
  26417. */
  26418. export class _IAnimationState {
  26419. key: number;
  26420. repeatCount: number;
  26421. workValue?: any;
  26422. loopMode?: number;
  26423. offsetValue?: any;
  26424. highLimitValue?: any;
  26425. }
  26426. /**
  26427. * Class used to store any kind of animation
  26428. */
  26429. export class Animation {
  26430. /**Name of the animation */
  26431. name: string;
  26432. /**Property to animate */
  26433. targetProperty: string;
  26434. /**The frames per second of the animation */
  26435. framePerSecond: number;
  26436. /**The data type of the animation */
  26437. dataType: number;
  26438. /**The loop mode of the animation */
  26439. loopMode?: number | undefined;
  26440. /**Specifies if blending should be enabled */
  26441. enableBlending?: boolean | undefined;
  26442. /**
  26443. * Use matrix interpolation instead of using direct key value when animating matrices
  26444. */
  26445. static AllowMatricesInterpolation: boolean;
  26446. /**
  26447. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  26448. */
  26449. static AllowMatrixDecomposeForInterpolation: boolean;
  26450. /**
  26451. * Stores the key frames of the animation
  26452. */
  26453. private _keys;
  26454. /**
  26455. * Stores the easing function of the animation
  26456. */
  26457. private _easingFunction;
  26458. /**
  26459. * @hidden Internal use only
  26460. */
  26461. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  26462. /**
  26463. * The set of event that will be linked to this animation
  26464. */
  26465. private _events;
  26466. /**
  26467. * Stores an array of target property paths
  26468. */
  26469. targetPropertyPath: string[];
  26470. /**
  26471. * Stores the blending speed of the animation
  26472. */
  26473. blendingSpeed: number;
  26474. /**
  26475. * Stores the animation ranges for the animation
  26476. */
  26477. private _ranges;
  26478. /**
  26479. * @hidden Internal use
  26480. */
  26481. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  26482. /**
  26483. * Sets up an animation
  26484. * @param property The property to animate
  26485. * @param animationType The animation type to apply
  26486. * @param framePerSecond The frames per second of the animation
  26487. * @param easingFunction The easing function used in the animation
  26488. * @returns The created animation
  26489. */
  26490. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  26491. /**
  26492. * Create and start an animation on a node
  26493. * @param name defines the name of the global animation that will be run on all nodes
  26494. * @param node defines the root node where the animation will take place
  26495. * @param targetProperty defines property to animate
  26496. * @param framePerSecond defines the number of frame per second yo use
  26497. * @param totalFrame defines the number of frames in total
  26498. * @param from defines the initial value
  26499. * @param to defines the final value
  26500. * @param loopMode defines which loop mode you want to use (off by default)
  26501. * @param easingFunction defines the easing function to use (linear by default)
  26502. * @param onAnimationEnd defines the callback to call when animation end
  26503. * @returns the animatable created for this animation
  26504. */
  26505. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26506. /**
  26507. * Create and start an animation on a node and its descendants
  26508. * @param name defines the name of the global animation that will be run on all nodes
  26509. * @param node defines the root node where the animation will take place
  26510. * @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
  26511. * @param targetProperty defines property to animate
  26512. * @param framePerSecond defines the number of frame per second to use
  26513. * @param totalFrame defines the number of frames in total
  26514. * @param from defines the initial value
  26515. * @param to defines the final value
  26516. * @param loopMode defines which loop mode you want to use (off by default)
  26517. * @param easingFunction defines the easing function to use (linear by default)
  26518. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26519. * @returns the list of animatables created for all nodes
  26520. * @example https://www.babylonjs-playground.com/#MH0VLI
  26521. */
  26522. 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[]>;
  26523. /**
  26524. * Creates a new animation, merges it with the existing animations and starts it
  26525. * @param name Name of the animation
  26526. * @param node Node which contains the scene that begins the animations
  26527. * @param targetProperty Specifies which property to animate
  26528. * @param framePerSecond The frames per second of the animation
  26529. * @param totalFrame The total number of frames
  26530. * @param from The frame at the beginning of the animation
  26531. * @param to The frame at the end of the animation
  26532. * @param loopMode Specifies the loop mode of the animation
  26533. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  26534. * @param onAnimationEnd Callback to run once the animation is complete
  26535. * @returns Nullable animation
  26536. */
  26537. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26538. /**
  26539. * Transition property of an host to the target Value
  26540. * @param property The property to transition
  26541. * @param targetValue The target Value of the property
  26542. * @param host The object where the property to animate belongs
  26543. * @param scene Scene used to run the animation
  26544. * @param frameRate Framerate (in frame/s) to use
  26545. * @param transition The transition type we want to use
  26546. * @param duration The duration of the animation, in milliseconds
  26547. * @param onAnimationEnd Callback trigger at the end of the animation
  26548. * @returns Nullable animation
  26549. */
  26550. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  26551. /**
  26552. * Return the array of runtime animations currently using this animation
  26553. */
  26554. readonly runtimeAnimations: RuntimeAnimation[];
  26555. /**
  26556. * Specifies if any of the runtime animations are currently running
  26557. */
  26558. readonly hasRunningRuntimeAnimations: boolean;
  26559. /**
  26560. * Initializes the animation
  26561. * @param name Name of the animation
  26562. * @param targetProperty Property to animate
  26563. * @param framePerSecond The frames per second of the animation
  26564. * @param dataType The data type of the animation
  26565. * @param loopMode The loop mode of the animation
  26566. * @param enableBlending Specifies if blending should be enabled
  26567. */
  26568. constructor(
  26569. /**Name of the animation */
  26570. name: string,
  26571. /**Property to animate */
  26572. targetProperty: string,
  26573. /**The frames per second of the animation */
  26574. framePerSecond: number,
  26575. /**The data type of the animation */
  26576. dataType: number,
  26577. /**The loop mode of the animation */
  26578. loopMode?: number | undefined,
  26579. /**Specifies if blending should be enabled */
  26580. enableBlending?: boolean | undefined);
  26581. /**
  26582. * Converts the animation to a string
  26583. * @param fullDetails support for multiple levels of logging within scene loading
  26584. * @returns String form of the animation
  26585. */
  26586. toString(fullDetails?: boolean): string;
  26587. /**
  26588. * Add an event to this animation
  26589. * @param event Event to add
  26590. */
  26591. addEvent(event: AnimationEvent): void;
  26592. /**
  26593. * Remove all events found at the given frame
  26594. * @param frame The frame to remove events from
  26595. */
  26596. removeEvents(frame: number): void;
  26597. /**
  26598. * Retrieves all the events from the animation
  26599. * @returns Events from the animation
  26600. */
  26601. getEvents(): AnimationEvent[];
  26602. /**
  26603. * Creates an animation range
  26604. * @param name Name of the animation range
  26605. * @param from Starting frame of the animation range
  26606. * @param to Ending frame of the animation
  26607. */
  26608. createRange(name: string, from: number, to: number): void;
  26609. /**
  26610. * Deletes an animation range by name
  26611. * @param name Name of the animation range to delete
  26612. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  26613. */
  26614. deleteRange(name: string, deleteFrames?: boolean): void;
  26615. /**
  26616. * Gets the animation range by name, or null if not defined
  26617. * @param name Name of the animation range
  26618. * @returns Nullable animation range
  26619. */
  26620. getRange(name: string): Nullable<AnimationRange>;
  26621. /**
  26622. * Gets the key frames from the animation
  26623. * @returns The key frames of the animation
  26624. */
  26625. getKeys(): Array<IAnimationKey>;
  26626. /**
  26627. * Gets the highest frame rate of the animation
  26628. * @returns Highest frame rate of the animation
  26629. */
  26630. getHighestFrame(): number;
  26631. /**
  26632. * Gets the easing function of the animation
  26633. * @returns Easing function of the animation
  26634. */
  26635. getEasingFunction(): IEasingFunction;
  26636. /**
  26637. * Sets the easing function of the animation
  26638. * @param easingFunction A custom mathematical formula for animation
  26639. */
  26640. setEasingFunction(easingFunction: EasingFunction): void;
  26641. /**
  26642. * Interpolates a scalar linearly
  26643. * @param startValue Start value of the animation curve
  26644. * @param endValue End value of the animation curve
  26645. * @param gradient Scalar amount to interpolate
  26646. * @returns Interpolated scalar value
  26647. */
  26648. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  26649. /**
  26650. * Interpolates a scalar cubically
  26651. * @param startValue Start value of the animation curve
  26652. * @param outTangent End tangent of the animation
  26653. * @param endValue End value of the animation curve
  26654. * @param inTangent Start tangent of the animation curve
  26655. * @param gradient Scalar amount to interpolate
  26656. * @returns Interpolated scalar value
  26657. */
  26658. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  26659. /**
  26660. * Interpolates a quaternion using a spherical linear interpolation
  26661. * @param startValue Start value of the animation curve
  26662. * @param endValue End value of the animation curve
  26663. * @param gradient Scalar amount to interpolate
  26664. * @returns Interpolated quaternion value
  26665. */
  26666. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  26667. /**
  26668. * Interpolates a quaternion cubically
  26669. * @param startValue Start value of the animation curve
  26670. * @param outTangent End tangent of the animation curve
  26671. * @param endValue End value of the animation curve
  26672. * @param inTangent Start tangent of the animation curve
  26673. * @param gradient Scalar amount to interpolate
  26674. * @returns Interpolated quaternion value
  26675. */
  26676. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  26677. /**
  26678. * Interpolates a Vector3 linearl
  26679. * @param startValue Start value of the animation curve
  26680. * @param endValue End value of the animation curve
  26681. * @param gradient Scalar amount to interpolate
  26682. * @returns Interpolated scalar value
  26683. */
  26684. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  26685. /**
  26686. * Interpolates a Vector3 cubically
  26687. * @param startValue Start value of the animation curve
  26688. * @param outTangent End tangent of the animation
  26689. * @param endValue End value of the animation curve
  26690. * @param inTangent Start tangent of the animation curve
  26691. * @param gradient Scalar amount to interpolate
  26692. * @returns InterpolatedVector3 value
  26693. */
  26694. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  26695. /**
  26696. * Interpolates a Vector2 linearly
  26697. * @param startValue Start value of the animation curve
  26698. * @param endValue End value of the animation curve
  26699. * @param gradient Scalar amount to interpolate
  26700. * @returns Interpolated Vector2 value
  26701. */
  26702. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  26703. /**
  26704. * Interpolates a Vector2 cubically
  26705. * @param startValue Start value of the animation curve
  26706. * @param outTangent End tangent of the animation
  26707. * @param endValue End value of the animation curve
  26708. * @param inTangent Start tangent of the animation curve
  26709. * @param gradient Scalar amount to interpolate
  26710. * @returns Interpolated Vector2 value
  26711. */
  26712. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  26713. /**
  26714. * Interpolates a size linearly
  26715. * @param startValue Start value of the animation curve
  26716. * @param endValue End value of the animation curve
  26717. * @param gradient Scalar amount to interpolate
  26718. * @returns Interpolated Size value
  26719. */
  26720. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  26721. /**
  26722. * Interpolates a Color3 linearly
  26723. * @param startValue Start value of the animation curve
  26724. * @param endValue End value of the animation curve
  26725. * @param gradient Scalar amount to interpolate
  26726. * @returns Interpolated Color3 value
  26727. */
  26728. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  26729. /**
  26730. * @hidden Internal use only
  26731. */
  26732. _getKeyValue(value: any): any;
  26733. /**
  26734. * @hidden Internal use only
  26735. */
  26736. _interpolate(currentFrame: number, state: _IAnimationState): any;
  26737. /**
  26738. * Defines the function to use to interpolate matrices
  26739. * @param startValue defines the start matrix
  26740. * @param endValue defines the end matrix
  26741. * @param gradient defines the gradient between both matrices
  26742. * @param result defines an optional target matrix where to store the interpolation
  26743. * @returns the interpolated matrix
  26744. */
  26745. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  26746. /**
  26747. * Makes a copy of the animation
  26748. * @returns Cloned animation
  26749. */
  26750. clone(): Animation;
  26751. /**
  26752. * Sets the key frames of the animation
  26753. * @param values The animation key frames to set
  26754. */
  26755. setKeys(values: Array<IAnimationKey>): void;
  26756. /**
  26757. * Serializes the animation to an object
  26758. * @returns Serialized object
  26759. */
  26760. serialize(): any;
  26761. /**
  26762. * Float animation type
  26763. */
  26764. private static _ANIMATIONTYPE_FLOAT;
  26765. /**
  26766. * Vector3 animation type
  26767. */
  26768. private static _ANIMATIONTYPE_VECTOR3;
  26769. /**
  26770. * Quaternion animation type
  26771. */
  26772. private static _ANIMATIONTYPE_QUATERNION;
  26773. /**
  26774. * Matrix animation type
  26775. */
  26776. private static _ANIMATIONTYPE_MATRIX;
  26777. /**
  26778. * Color3 animation type
  26779. */
  26780. private static _ANIMATIONTYPE_COLOR3;
  26781. /**
  26782. * Vector2 animation type
  26783. */
  26784. private static _ANIMATIONTYPE_VECTOR2;
  26785. /**
  26786. * Size animation type
  26787. */
  26788. private static _ANIMATIONTYPE_SIZE;
  26789. /**
  26790. * Relative Loop Mode
  26791. */
  26792. private static _ANIMATIONLOOPMODE_RELATIVE;
  26793. /**
  26794. * Cycle Loop Mode
  26795. */
  26796. private static _ANIMATIONLOOPMODE_CYCLE;
  26797. /**
  26798. * Constant Loop Mode
  26799. */
  26800. private static _ANIMATIONLOOPMODE_CONSTANT;
  26801. /**
  26802. * Get the float animation type
  26803. */
  26804. static readonly ANIMATIONTYPE_FLOAT: number;
  26805. /**
  26806. * Get the Vector3 animation type
  26807. */
  26808. static readonly ANIMATIONTYPE_VECTOR3: number;
  26809. /**
  26810. * Get the Vector2 animation type
  26811. */
  26812. static readonly ANIMATIONTYPE_VECTOR2: number;
  26813. /**
  26814. * Get the Size animation type
  26815. */
  26816. static readonly ANIMATIONTYPE_SIZE: number;
  26817. /**
  26818. * Get the Quaternion animation type
  26819. */
  26820. static readonly ANIMATIONTYPE_QUATERNION: number;
  26821. /**
  26822. * Get the Matrix animation type
  26823. */
  26824. static readonly ANIMATIONTYPE_MATRIX: number;
  26825. /**
  26826. * Get the Color3 animation type
  26827. */
  26828. static readonly ANIMATIONTYPE_COLOR3: number;
  26829. /**
  26830. * Get the Relative Loop Mode
  26831. */
  26832. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  26833. /**
  26834. * Get the Cycle Loop Mode
  26835. */
  26836. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  26837. /**
  26838. * Get the Constant Loop Mode
  26839. */
  26840. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  26841. /** @hidden */
  26842. static _UniversalLerp(left: any, right: any, amount: number): any;
  26843. /**
  26844. * Parses an animation object and creates an animation
  26845. * @param parsedAnimation Parsed animation object
  26846. * @returns Animation object
  26847. */
  26848. static Parse(parsedAnimation: any): Animation;
  26849. /**
  26850. * Appends the serialized animations from the source animations
  26851. * @param source Source containing the animations
  26852. * @param destination Target to store the animations
  26853. */
  26854. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  26855. }
  26856. }
  26857. declare module "babylonjs/Materials/Textures/baseTexture" {
  26858. import { Observable } from "babylonjs/Misc/observable";
  26859. import { IAnimatable } from "babylonjs/Misc/tools";
  26860. import { Nullable } from "babylonjs/types";
  26861. import { Scene } from "babylonjs/scene";
  26862. import { Matrix, ISize } from "babylonjs/Maths/math";
  26863. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  26864. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26865. /**
  26866. * Base class of all the textures in babylon.
  26867. * It groups all the common properties the materials, post process, lights... might need
  26868. * in order to make a correct use of the texture.
  26869. */
  26870. export class BaseTexture implements IAnimatable {
  26871. /**
  26872. * Default anisotropic filtering level for the application.
  26873. * It is set to 4 as a good tradeoff between perf and quality.
  26874. */
  26875. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  26876. /**
  26877. * Gets or sets the unique id of the texture
  26878. */
  26879. uniqueId: number;
  26880. /**
  26881. * Define the name of the texture.
  26882. */
  26883. name: string;
  26884. /**
  26885. * Gets or sets an object used to store user defined information.
  26886. */
  26887. metadata: any;
  26888. /**
  26889. * For internal use only. Please do not use.
  26890. */
  26891. reservedDataStore: any;
  26892. private _hasAlpha;
  26893. /**
  26894. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  26895. */
  26896. hasAlpha: boolean;
  26897. /**
  26898. * Defines if the alpha value should be determined via the rgb values.
  26899. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  26900. */
  26901. getAlphaFromRGB: boolean;
  26902. /**
  26903. * Intensity or strength of the texture.
  26904. * It is commonly used by materials to fine tune the intensity of the texture
  26905. */
  26906. level: number;
  26907. /**
  26908. * Define the UV chanel to use starting from 0 and defaulting to 0.
  26909. * This is part of the texture as textures usually maps to one uv set.
  26910. */
  26911. coordinatesIndex: number;
  26912. private _coordinatesMode;
  26913. /**
  26914. * How a texture is mapped.
  26915. *
  26916. * | Value | Type | Description |
  26917. * | ----- | ----------------------------------- | ----------- |
  26918. * | 0 | EXPLICIT_MODE | |
  26919. * | 1 | SPHERICAL_MODE | |
  26920. * | 2 | PLANAR_MODE | |
  26921. * | 3 | CUBIC_MODE | |
  26922. * | 4 | PROJECTION_MODE | |
  26923. * | 5 | SKYBOX_MODE | |
  26924. * | 6 | INVCUBIC_MODE | |
  26925. * | 7 | EQUIRECTANGULAR_MODE | |
  26926. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  26927. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  26928. */
  26929. coordinatesMode: number;
  26930. /**
  26931. * | Value | Type | Description |
  26932. * | ----- | ------------------ | ----------- |
  26933. * | 0 | CLAMP_ADDRESSMODE | |
  26934. * | 1 | WRAP_ADDRESSMODE | |
  26935. * | 2 | MIRROR_ADDRESSMODE | |
  26936. */
  26937. wrapU: number;
  26938. /**
  26939. * | Value | Type | Description |
  26940. * | ----- | ------------------ | ----------- |
  26941. * | 0 | CLAMP_ADDRESSMODE | |
  26942. * | 1 | WRAP_ADDRESSMODE | |
  26943. * | 2 | MIRROR_ADDRESSMODE | |
  26944. */
  26945. wrapV: number;
  26946. /**
  26947. * | Value | Type | Description |
  26948. * | ----- | ------------------ | ----------- |
  26949. * | 0 | CLAMP_ADDRESSMODE | |
  26950. * | 1 | WRAP_ADDRESSMODE | |
  26951. * | 2 | MIRROR_ADDRESSMODE | |
  26952. */
  26953. wrapR: number;
  26954. /**
  26955. * With compliant hardware and browser (supporting anisotropic filtering)
  26956. * this defines the level of anisotropic filtering in the texture.
  26957. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  26958. */
  26959. anisotropicFilteringLevel: number;
  26960. /**
  26961. * Define if the texture is a cube texture or if false a 2d texture.
  26962. */
  26963. isCube: boolean;
  26964. /**
  26965. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  26966. */
  26967. is3D: boolean;
  26968. /**
  26969. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  26970. * HDR texture are usually stored in linear space.
  26971. * This only impacts the PBR and Background materials
  26972. */
  26973. gammaSpace: boolean;
  26974. /**
  26975. * Gets whether or not the texture contains RGBD data.
  26976. */
  26977. readonly isRGBD: boolean;
  26978. /**
  26979. * Is Z inverted in the texture (useful in a cube texture).
  26980. */
  26981. invertZ: boolean;
  26982. /**
  26983. * Are mip maps generated for this texture or not.
  26984. */
  26985. readonly noMipmap: boolean;
  26986. /**
  26987. * @hidden
  26988. */
  26989. lodLevelInAlpha: boolean;
  26990. /**
  26991. * With prefiltered texture, defined the offset used during the prefiltering steps.
  26992. */
  26993. lodGenerationOffset: number;
  26994. /**
  26995. * With prefiltered texture, defined the scale used during the prefiltering steps.
  26996. */
  26997. lodGenerationScale: number;
  26998. /**
  26999. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  27000. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  27001. * average roughness values.
  27002. */
  27003. linearSpecularLOD: boolean;
  27004. /**
  27005. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  27006. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  27007. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  27008. */
  27009. irradianceTexture: Nullable<BaseTexture>;
  27010. /**
  27011. * Define if the texture is a render target.
  27012. */
  27013. isRenderTarget: boolean;
  27014. /**
  27015. * Define the unique id of the texture in the scene.
  27016. */
  27017. readonly uid: string;
  27018. /**
  27019. * Return a string representation of the texture.
  27020. * @returns the texture as a string
  27021. */
  27022. toString(): string;
  27023. /**
  27024. * Get the class name of the texture.
  27025. * @returns "BaseTexture"
  27026. */
  27027. getClassName(): string;
  27028. /**
  27029. * Define the list of animation attached to the texture.
  27030. */
  27031. animations: import("babylonjs/Animations/animation").Animation[];
  27032. /**
  27033. * An event triggered when the texture is disposed.
  27034. */
  27035. onDisposeObservable: Observable<BaseTexture>;
  27036. private _onDisposeObserver;
  27037. /**
  27038. * Callback triggered when the texture has been disposed.
  27039. * Kept for back compatibility, you can use the onDisposeObservable instead.
  27040. */
  27041. onDispose: () => void;
  27042. /**
  27043. * Define the current state of the loading sequence when in delayed load mode.
  27044. */
  27045. delayLoadState: number;
  27046. private _scene;
  27047. /** @hidden */
  27048. _texture: Nullable<InternalTexture>;
  27049. private _uid;
  27050. /**
  27051. * Define if the texture is preventinga material to render or not.
  27052. * If not and the texture is not ready, the engine will use a default black texture instead.
  27053. */
  27054. readonly isBlocking: boolean;
  27055. /**
  27056. * Instantiates a new BaseTexture.
  27057. * Base class of all the textures in babylon.
  27058. * It groups all the common properties the materials, post process, lights... might need
  27059. * in order to make a correct use of the texture.
  27060. * @param scene Define the scene the texture blongs to
  27061. */
  27062. constructor(scene: Nullable<Scene>);
  27063. /**
  27064. * Get the scene the texture belongs to.
  27065. * @returns the scene or null if undefined
  27066. */
  27067. getScene(): Nullable<Scene>;
  27068. /**
  27069. * Get the texture transform matrix used to offset tile the texture for istance.
  27070. * @returns the transformation matrix
  27071. */
  27072. getTextureMatrix(): Matrix;
  27073. /**
  27074. * Get the texture reflection matrix used to rotate/transform the reflection.
  27075. * @returns the reflection matrix
  27076. */
  27077. getReflectionTextureMatrix(): Matrix;
  27078. /**
  27079. * Get the underlying lower level texture from Babylon.
  27080. * @returns the insternal texture
  27081. */
  27082. getInternalTexture(): Nullable<InternalTexture>;
  27083. /**
  27084. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  27085. * @returns true if ready or not blocking
  27086. */
  27087. isReadyOrNotBlocking(): boolean;
  27088. /**
  27089. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  27090. * @returns true if fully ready
  27091. */
  27092. isReady(): boolean;
  27093. private _cachedSize;
  27094. /**
  27095. * Get the size of the texture.
  27096. * @returns the texture size.
  27097. */
  27098. getSize(): ISize;
  27099. /**
  27100. * Get the base size of the texture.
  27101. * It can be different from the size if the texture has been resized for POT for instance
  27102. * @returns the base size
  27103. */
  27104. getBaseSize(): ISize;
  27105. /**
  27106. * Update the sampling mode of the texture.
  27107. * Default is Trilinear mode.
  27108. *
  27109. * | Value | Type | Description |
  27110. * | ----- | ------------------ | ----------- |
  27111. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  27112. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  27113. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  27114. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  27115. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  27116. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  27117. * | 7 | NEAREST_LINEAR | |
  27118. * | 8 | NEAREST_NEAREST | |
  27119. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  27120. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  27121. * | 11 | LINEAR_LINEAR | |
  27122. * | 12 | LINEAR_NEAREST | |
  27123. *
  27124. * > _mag_: magnification filter (close to the viewer)
  27125. * > _min_: minification filter (far from the viewer)
  27126. * > _mip_: filter used between mip map levels
  27127. *@param samplingMode Define the new sampling mode of the texture
  27128. */
  27129. updateSamplingMode(samplingMode: number): void;
  27130. /**
  27131. * Scales the texture if is `canRescale()`
  27132. * @param ratio the resize factor we want to use to rescale
  27133. */
  27134. scale(ratio: number): void;
  27135. /**
  27136. * Get if the texture can rescale.
  27137. */
  27138. readonly canRescale: boolean;
  27139. /** @hidden */
  27140. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  27141. /** @hidden */
  27142. _rebuild(): void;
  27143. /**
  27144. * Triggers the load sequence in delayed load mode.
  27145. */
  27146. delayLoad(): void;
  27147. /**
  27148. * Clones the texture.
  27149. * @returns the cloned texture
  27150. */
  27151. clone(): Nullable<BaseTexture>;
  27152. /**
  27153. * Get the texture underlying type (INT, FLOAT...)
  27154. */
  27155. readonly textureType: number;
  27156. /**
  27157. * Get the texture underlying format (RGB, RGBA...)
  27158. */
  27159. readonly textureFormat: number;
  27160. /**
  27161. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  27162. * This will returns an RGBA array buffer containing either in values (0-255) or
  27163. * float values (0-1) depending of the underlying buffer type.
  27164. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  27165. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  27166. * @param buffer defines a user defined buffer to fill with data (can be null)
  27167. * @returns The Array buffer containing the pixels data.
  27168. */
  27169. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  27170. /**
  27171. * Release and destroy the underlying lower level texture aka internalTexture.
  27172. */
  27173. releaseInternalTexture(): void;
  27174. /**
  27175. * Get the polynomial representation of the texture data.
  27176. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  27177. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  27178. */
  27179. sphericalPolynomial: Nullable<SphericalPolynomial>;
  27180. /** @hidden */
  27181. readonly _lodTextureHigh: Nullable<BaseTexture>;
  27182. /** @hidden */
  27183. readonly _lodTextureMid: Nullable<BaseTexture>;
  27184. /** @hidden */
  27185. readonly _lodTextureLow: Nullable<BaseTexture>;
  27186. /**
  27187. * Dispose the texture and release its associated resources.
  27188. */
  27189. dispose(): void;
  27190. /**
  27191. * Serialize the texture into a JSON representation that can be parsed later on.
  27192. * @returns the JSON representation of the texture
  27193. */
  27194. serialize(): any;
  27195. /**
  27196. * Helper function to be called back once a list of texture contains only ready textures.
  27197. * @param textures Define the list of textures to wait for
  27198. * @param callback Define the callback triggered once the entire list will be ready
  27199. */
  27200. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  27201. }
  27202. }
  27203. declare module "babylonjs/Materials/uniformBuffer" {
  27204. import { Nullable, FloatArray } from "babylonjs/types";
  27205. import { Matrix, Vector3, Color3, Vector4 } from "babylonjs/Maths/math";
  27206. import { Engine } from "babylonjs/Engines/engine";
  27207. import { Effect } from "babylonjs/Materials/effect";
  27208. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27209. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  27210. /**
  27211. * Uniform buffer objects.
  27212. *
  27213. * Handles blocks of uniform on the GPU.
  27214. *
  27215. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  27216. *
  27217. * For more information, please refer to :
  27218. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  27219. */
  27220. export class UniformBuffer {
  27221. private _engine;
  27222. private _buffer;
  27223. private _data;
  27224. private _bufferData;
  27225. private _dynamic?;
  27226. private _uniformLocations;
  27227. private _uniformSizes;
  27228. private _uniformLocationPointer;
  27229. private _needSync;
  27230. private _noUBO;
  27231. private _currentEffect;
  27232. private static _MAX_UNIFORM_SIZE;
  27233. private static _tempBuffer;
  27234. /**
  27235. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  27236. * This is dynamic to allow compat with webgl 1 and 2.
  27237. * You will need to pass the name of the uniform as well as the value.
  27238. */
  27239. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  27240. /**
  27241. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  27242. * This is dynamic to allow compat with webgl 1 and 2.
  27243. * You will need to pass the name of the uniform as well as the value.
  27244. */
  27245. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  27246. /**
  27247. * Lambda to Update a single float in a uniform buffer.
  27248. * This is dynamic to allow compat with webgl 1 and 2.
  27249. * You will need to pass the name of the uniform as well as the value.
  27250. */
  27251. updateFloat: (name: string, x: number) => void;
  27252. /**
  27253. * Lambda to Update a vec2 of float in a uniform buffer.
  27254. * This is dynamic to allow compat with webgl 1 and 2.
  27255. * You will need to pass the name of the uniform as well as the value.
  27256. */
  27257. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  27258. /**
  27259. * Lambda to Update a vec3 of float in a uniform buffer.
  27260. * This is dynamic to allow compat with webgl 1 and 2.
  27261. * You will need to pass the name of the uniform as well as the value.
  27262. */
  27263. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  27264. /**
  27265. * Lambda to Update a vec4 of float in a uniform buffer.
  27266. * This is dynamic to allow compat with webgl 1 and 2.
  27267. * You will need to pass the name of the uniform as well as the value.
  27268. */
  27269. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  27270. /**
  27271. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  27272. * This is dynamic to allow compat with webgl 1 and 2.
  27273. * You will need to pass the name of the uniform as well as the value.
  27274. */
  27275. updateMatrix: (name: string, mat: Matrix) => void;
  27276. /**
  27277. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  27278. * This is dynamic to allow compat with webgl 1 and 2.
  27279. * You will need to pass the name of the uniform as well as the value.
  27280. */
  27281. updateVector3: (name: string, vector: Vector3) => void;
  27282. /**
  27283. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  27284. * This is dynamic to allow compat with webgl 1 and 2.
  27285. * You will need to pass the name of the uniform as well as the value.
  27286. */
  27287. updateVector4: (name: string, vector: Vector4) => void;
  27288. /**
  27289. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  27290. * This is dynamic to allow compat with webgl 1 and 2.
  27291. * You will need to pass the name of the uniform as well as the value.
  27292. */
  27293. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  27294. /**
  27295. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  27296. * This is dynamic to allow compat with webgl 1 and 2.
  27297. * You will need to pass the name of the uniform as well as the value.
  27298. */
  27299. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  27300. /**
  27301. * Instantiates a new Uniform buffer objects.
  27302. *
  27303. * Handles blocks of uniform on the GPU.
  27304. *
  27305. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  27306. *
  27307. * For more information, please refer to :
  27308. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  27309. * @param engine Define the engine the buffer is associated with
  27310. * @param data Define the data contained in the buffer
  27311. * @param dynamic Define if the buffer is updatable
  27312. */
  27313. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  27314. /**
  27315. * Indicates if the buffer is using the WebGL2 UBO implementation,
  27316. * or just falling back on setUniformXXX calls.
  27317. */
  27318. readonly useUbo: boolean;
  27319. /**
  27320. * Indicates if the WebGL underlying uniform buffer is in sync
  27321. * with the javascript cache data.
  27322. */
  27323. readonly isSync: boolean;
  27324. /**
  27325. * Indicates if the WebGL underlying uniform buffer is dynamic.
  27326. * Also, a dynamic UniformBuffer will disable cache verification and always
  27327. * update the underlying WebGL uniform buffer to the GPU.
  27328. * @returns if Dynamic, otherwise false
  27329. */
  27330. isDynamic(): boolean;
  27331. /**
  27332. * The data cache on JS side.
  27333. * @returns the underlying data as a float array
  27334. */
  27335. getData(): Float32Array;
  27336. /**
  27337. * The underlying WebGL Uniform buffer.
  27338. * @returns the webgl buffer
  27339. */
  27340. getBuffer(): Nullable<DataBuffer>;
  27341. /**
  27342. * std140 layout specifies how to align data within an UBO structure.
  27343. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  27344. * for specs.
  27345. */
  27346. private _fillAlignment;
  27347. /**
  27348. * Adds an uniform in the buffer.
  27349. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  27350. * for the layout to be correct !
  27351. * @param name Name of the uniform, as used in the uniform block in the shader.
  27352. * @param size Data size, or data directly.
  27353. */
  27354. addUniform(name: string, size: number | number[]): void;
  27355. /**
  27356. * Adds a Matrix 4x4 to the uniform buffer.
  27357. * @param name Name of the uniform, as used in the uniform block in the shader.
  27358. * @param mat A 4x4 matrix.
  27359. */
  27360. addMatrix(name: string, mat: Matrix): void;
  27361. /**
  27362. * Adds a vec2 to the uniform buffer.
  27363. * @param name Name of the uniform, as used in the uniform block in the shader.
  27364. * @param x Define the x component value of the vec2
  27365. * @param y Define the y component value of the vec2
  27366. */
  27367. addFloat2(name: string, x: number, y: number): void;
  27368. /**
  27369. * Adds a vec3 to the uniform buffer.
  27370. * @param name Name of the uniform, as used in the uniform block in the shader.
  27371. * @param x Define the x component value of the vec3
  27372. * @param y Define the y component value of the vec3
  27373. * @param z Define the z component value of the vec3
  27374. */
  27375. addFloat3(name: string, x: number, y: number, z: number): void;
  27376. /**
  27377. * Adds a vec3 to the uniform buffer.
  27378. * @param name Name of the uniform, as used in the uniform block in the shader.
  27379. * @param color Define the vec3 from a Color
  27380. */
  27381. addColor3(name: string, color: Color3): void;
  27382. /**
  27383. * Adds a vec4 to the uniform buffer.
  27384. * @param name Name of the uniform, as used in the uniform block in the shader.
  27385. * @param color Define the rgb components from a Color
  27386. * @param alpha Define the a component of the vec4
  27387. */
  27388. addColor4(name: string, color: Color3, alpha: number): void;
  27389. /**
  27390. * Adds a vec3 to the uniform buffer.
  27391. * @param name Name of the uniform, as used in the uniform block in the shader.
  27392. * @param vector Define the vec3 components from a Vector
  27393. */
  27394. addVector3(name: string, vector: Vector3): void;
  27395. /**
  27396. * Adds a Matrix 3x3 to the uniform buffer.
  27397. * @param name Name of the uniform, as used in the uniform block in the shader.
  27398. */
  27399. addMatrix3x3(name: string): void;
  27400. /**
  27401. * Adds a Matrix 2x2 to the uniform buffer.
  27402. * @param name Name of the uniform, as used in the uniform block in the shader.
  27403. */
  27404. addMatrix2x2(name: string): void;
  27405. /**
  27406. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  27407. */
  27408. create(): void;
  27409. /** @hidden */
  27410. _rebuild(): void;
  27411. /**
  27412. * Updates the WebGL Uniform Buffer on the GPU.
  27413. * If the `dynamic` flag is set to true, no cache comparison is done.
  27414. * Otherwise, the buffer will be updated only if the cache differs.
  27415. */
  27416. update(): void;
  27417. /**
  27418. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  27419. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  27420. * @param data Define the flattened data
  27421. * @param size Define the size of the data.
  27422. */
  27423. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  27424. private _updateMatrix3x3ForUniform;
  27425. private _updateMatrix3x3ForEffect;
  27426. private _updateMatrix2x2ForEffect;
  27427. private _updateMatrix2x2ForUniform;
  27428. private _updateFloatForEffect;
  27429. private _updateFloatForUniform;
  27430. private _updateFloat2ForEffect;
  27431. private _updateFloat2ForUniform;
  27432. private _updateFloat3ForEffect;
  27433. private _updateFloat3ForUniform;
  27434. private _updateFloat4ForEffect;
  27435. private _updateFloat4ForUniform;
  27436. private _updateMatrixForEffect;
  27437. private _updateMatrixForUniform;
  27438. private _updateVector3ForEffect;
  27439. private _updateVector3ForUniform;
  27440. private _updateVector4ForEffect;
  27441. private _updateVector4ForUniform;
  27442. private _updateColor3ForEffect;
  27443. private _updateColor3ForUniform;
  27444. private _updateColor4ForEffect;
  27445. private _updateColor4ForUniform;
  27446. /**
  27447. * Sets a sampler uniform on the effect.
  27448. * @param name Define the name of the sampler.
  27449. * @param texture Define the texture to set in the sampler
  27450. */
  27451. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  27452. /**
  27453. * Directly updates the value of the uniform in the cache AND on the GPU.
  27454. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  27455. * @param data Define the flattened data
  27456. */
  27457. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  27458. /**
  27459. * Binds this uniform buffer to an effect.
  27460. * @param effect Define the effect to bind the buffer to
  27461. * @param name Name of the uniform block in the shader.
  27462. */
  27463. bindToEffect(effect: Effect, name: string): void;
  27464. /**
  27465. * Disposes the uniform buffer.
  27466. */
  27467. dispose(): void;
  27468. }
  27469. }
  27470. declare module "babylonjs/Audio/analyser" {
  27471. import { Scene } from "babylonjs/scene";
  27472. /**
  27473. * Class used to work with sound analyzer using fast fourier transform (FFT)
  27474. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27475. */
  27476. export class Analyser {
  27477. /**
  27478. * Gets or sets the smoothing
  27479. * @ignorenaming
  27480. */
  27481. SMOOTHING: number;
  27482. /**
  27483. * Gets or sets the FFT table size
  27484. * @ignorenaming
  27485. */
  27486. FFT_SIZE: number;
  27487. /**
  27488. * Gets or sets the bar graph amplitude
  27489. * @ignorenaming
  27490. */
  27491. BARGRAPHAMPLITUDE: number;
  27492. /**
  27493. * Gets or sets the position of the debug canvas
  27494. * @ignorenaming
  27495. */
  27496. DEBUGCANVASPOS: {
  27497. x: number;
  27498. y: number;
  27499. };
  27500. /**
  27501. * Gets or sets the debug canvas size
  27502. * @ignorenaming
  27503. */
  27504. DEBUGCANVASSIZE: {
  27505. width: number;
  27506. height: number;
  27507. };
  27508. private _byteFreqs;
  27509. private _byteTime;
  27510. private _floatFreqs;
  27511. private _webAudioAnalyser;
  27512. private _debugCanvas;
  27513. private _debugCanvasContext;
  27514. private _scene;
  27515. private _registerFunc;
  27516. private _audioEngine;
  27517. /**
  27518. * Creates a new analyser
  27519. * @param scene defines hosting scene
  27520. */
  27521. constructor(scene: Scene);
  27522. /**
  27523. * Get the number of data values you will have to play with for the visualization
  27524. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  27525. * @returns a number
  27526. */
  27527. getFrequencyBinCount(): number;
  27528. /**
  27529. * Gets the current frequency data as a byte array
  27530. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  27531. * @returns a Uint8Array
  27532. */
  27533. getByteFrequencyData(): Uint8Array;
  27534. /**
  27535. * Gets the current waveform as a byte array
  27536. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  27537. * @returns a Uint8Array
  27538. */
  27539. getByteTimeDomainData(): Uint8Array;
  27540. /**
  27541. * Gets the current frequency data as a float array
  27542. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  27543. * @returns a Float32Array
  27544. */
  27545. getFloatFrequencyData(): Float32Array;
  27546. /**
  27547. * Renders the debug canvas
  27548. */
  27549. drawDebugCanvas(): void;
  27550. /**
  27551. * Stops rendering the debug canvas and removes it
  27552. */
  27553. stopDebugCanvas(): void;
  27554. /**
  27555. * Connects two audio nodes
  27556. * @param inputAudioNode defines first node to connect
  27557. * @param outputAudioNode defines second node to connect
  27558. */
  27559. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  27560. /**
  27561. * Releases all associated resources
  27562. */
  27563. dispose(): void;
  27564. }
  27565. }
  27566. declare module "babylonjs/Audio/audioEngine" {
  27567. import { IDisposable } from "babylonjs/scene";
  27568. import { Analyser } from "babylonjs/Audio/analyser";
  27569. import { Nullable } from "babylonjs/types";
  27570. import { Observable } from "babylonjs/Misc/observable";
  27571. /**
  27572. * This represents an audio engine and it is responsible
  27573. * to play, synchronize and analyse sounds throughout the application.
  27574. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27575. */
  27576. export interface IAudioEngine extends IDisposable {
  27577. /**
  27578. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27579. */
  27580. readonly canUseWebAudio: boolean;
  27581. /**
  27582. * Gets the current AudioContext if available.
  27583. */
  27584. readonly audioContext: Nullable<AudioContext>;
  27585. /**
  27586. * The master gain node defines the global audio volume of your audio engine.
  27587. */
  27588. readonly masterGain: GainNode;
  27589. /**
  27590. * Gets whether or not mp3 are supported by your browser.
  27591. */
  27592. readonly isMP3supported: boolean;
  27593. /**
  27594. * Gets whether or not ogg are supported by your browser.
  27595. */
  27596. readonly isOGGsupported: boolean;
  27597. /**
  27598. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27599. * @ignoreNaming
  27600. */
  27601. WarnedWebAudioUnsupported: boolean;
  27602. /**
  27603. * Defines if the audio engine relies on a custom unlocked button.
  27604. * In this case, the embedded button will not be displayed.
  27605. */
  27606. useCustomUnlockedButton: boolean;
  27607. /**
  27608. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  27609. */
  27610. readonly unlocked: boolean;
  27611. /**
  27612. * Event raised when audio has been unlocked on the browser.
  27613. */
  27614. onAudioUnlockedObservable: Observable<AudioEngine>;
  27615. /**
  27616. * Event raised when audio has been locked on the browser.
  27617. */
  27618. onAudioLockedObservable: Observable<AudioEngine>;
  27619. /**
  27620. * Flags the audio engine in Locked state.
  27621. * This happens due to new browser policies preventing audio to autoplay.
  27622. */
  27623. lock(): void;
  27624. /**
  27625. * Unlocks the audio engine once a user action has been done on the dom.
  27626. * This is helpful to resume play once browser policies have been satisfied.
  27627. */
  27628. unlock(): void;
  27629. }
  27630. /**
  27631. * This represents the default audio engine used in babylon.
  27632. * It is responsible to play, synchronize and analyse sounds throughout the application.
  27633. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27634. */
  27635. export class AudioEngine implements IAudioEngine {
  27636. private _audioContext;
  27637. private _audioContextInitialized;
  27638. private _muteButton;
  27639. private _hostElement;
  27640. /**
  27641. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27642. */
  27643. canUseWebAudio: boolean;
  27644. /**
  27645. * The master gain node defines the global audio volume of your audio engine.
  27646. */
  27647. masterGain: GainNode;
  27648. /**
  27649. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27650. * @ignoreNaming
  27651. */
  27652. WarnedWebAudioUnsupported: boolean;
  27653. /**
  27654. * Gets whether or not mp3 are supported by your browser.
  27655. */
  27656. isMP3supported: boolean;
  27657. /**
  27658. * Gets whether or not ogg are supported by your browser.
  27659. */
  27660. isOGGsupported: boolean;
  27661. /**
  27662. * Gets whether audio has been unlocked on the device.
  27663. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  27664. * a user interaction has happened.
  27665. */
  27666. unlocked: boolean;
  27667. /**
  27668. * Defines if the audio engine relies on a custom unlocked button.
  27669. * In this case, the embedded button will not be displayed.
  27670. */
  27671. useCustomUnlockedButton: boolean;
  27672. /**
  27673. * Event raised when audio has been unlocked on the browser.
  27674. */
  27675. onAudioUnlockedObservable: Observable<AudioEngine>;
  27676. /**
  27677. * Event raised when audio has been locked on the browser.
  27678. */
  27679. onAudioLockedObservable: Observable<AudioEngine>;
  27680. /**
  27681. * Gets the current AudioContext if available.
  27682. */
  27683. readonly audioContext: Nullable<AudioContext>;
  27684. private _connectedAnalyser;
  27685. /**
  27686. * Instantiates a new audio engine.
  27687. *
  27688. * There should be only one per page as some browsers restrict the number
  27689. * of audio contexts you can create.
  27690. * @param hostElement defines the host element where to display the mute icon if necessary
  27691. */
  27692. constructor(hostElement?: Nullable<HTMLElement>);
  27693. /**
  27694. * Flags the audio engine in Locked state.
  27695. * This happens due to new browser policies preventing audio to autoplay.
  27696. */
  27697. lock(): void;
  27698. /**
  27699. * Unlocks the audio engine once a user action has been done on the dom.
  27700. * This is helpful to resume play once browser policies have been satisfied.
  27701. */
  27702. unlock(): void;
  27703. private _resumeAudioContext;
  27704. private _initializeAudioContext;
  27705. private _tryToRun;
  27706. private _triggerRunningState;
  27707. private _triggerSuspendedState;
  27708. private _displayMuteButton;
  27709. private _moveButtonToTopLeft;
  27710. private _onResize;
  27711. private _hideMuteButton;
  27712. /**
  27713. * Destroy and release the resources associated with the audio ccontext.
  27714. */
  27715. dispose(): void;
  27716. /**
  27717. * Gets the global volume sets on the master gain.
  27718. * @returns the global volume if set or -1 otherwise
  27719. */
  27720. getGlobalVolume(): number;
  27721. /**
  27722. * Sets the global volume of your experience (sets on the master gain).
  27723. * @param newVolume Defines the new global volume of the application
  27724. */
  27725. setGlobalVolume(newVolume: number): void;
  27726. /**
  27727. * Connect the audio engine to an audio analyser allowing some amazing
  27728. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  27729. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  27730. * @param analyser The analyser to connect to the engine
  27731. */
  27732. connectToAnalyser(analyser: Analyser): void;
  27733. }
  27734. }
  27735. declare module "babylonjs/Loading/loadingScreen" {
  27736. /**
  27737. * Interface used to present a loading screen while loading a scene
  27738. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27739. */
  27740. export interface ILoadingScreen {
  27741. /**
  27742. * Function called to display the loading screen
  27743. */
  27744. displayLoadingUI: () => void;
  27745. /**
  27746. * Function called to hide the loading screen
  27747. */
  27748. hideLoadingUI: () => void;
  27749. /**
  27750. * Gets or sets the color to use for the background
  27751. */
  27752. loadingUIBackgroundColor: string;
  27753. /**
  27754. * Gets or sets the text to display while loading
  27755. */
  27756. loadingUIText: string;
  27757. }
  27758. /**
  27759. * Class used for the default loading screen
  27760. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27761. */
  27762. export class DefaultLoadingScreen implements ILoadingScreen {
  27763. private _renderingCanvas;
  27764. private _loadingText;
  27765. private _loadingDivBackgroundColor;
  27766. private _loadingDiv;
  27767. private _loadingTextDiv;
  27768. /** Gets or sets the logo url to use for the default loading screen */
  27769. static DefaultLogoUrl: string;
  27770. /** Gets or sets the spinner url to use for the default loading screen */
  27771. static DefaultSpinnerUrl: string;
  27772. /**
  27773. * Creates a new default loading screen
  27774. * @param _renderingCanvas defines the canvas used to render the scene
  27775. * @param _loadingText defines the default text to display
  27776. * @param _loadingDivBackgroundColor defines the default background color
  27777. */
  27778. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  27779. /**
  27780. * Function called to display the loading screen
  27781. */
  27782. displayLoadingUI(): void;
  27783. /**
  27784. * Function called to hide the loading screen
  27785. */
  27786. hideLoadingUI(): void;
  27787. /**
  27788. * Gets or sets the text to display while loading
  27789. */
  27790. loadingUIText: string;
  27791. /**
  27792. * Gets or sets the color to use for the background
  27793. */
  27794. loadingUIBackgroundColor: string;
  27795. private _resizeLoadingUI;
  27796. }
  27797. }
  27798. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  27799. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  27800. import { Engine } from "babylonjs/Engines/engine";
  27801. import { Nullable } from "babylonjs/types";
  27802. /** @hidden */
  27803. export class WebGLPipelineContext implements IPipelineContext {
  27804. engine: Engine;
  27805. program: Nullable<WebGLProgram>;
  27806. context?: WebGLRenderingContext;
  27807. vertexShader?: WebGLShader;
  27808. fragmentShader?: WebGLShader;
  27809. isParallelCompiled: boolean;
  27810. onCompiled?: () => void;
  27811. transformFeedback?: WebGLTransformFeedback | null;
  27812. readonly isAsync: boolean;
  27813. readonly isReady: boolean;
  27814. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  27815. }
  27816. }
  27817. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  27818. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  27819. /** @hidden */
  27820. export class WebGLDataBuffer extends DataBuffer {
  27821. private _buffer;
  27822. constructor(resource: WebGLBuffer);
  27823. readonly underlyingResource: any;
  27824. }
  27825. }
  27826. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  27827. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  27828. /** @hidden */
  27829. export class WebGL2ShaderProcessor implements IShaderProcessor {
  27830. attributeProcessor(attribute: string): string;
  27831. varyingProcessor(varying: string, isFragment: boolean): string;
  27832. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  27833. }
  27834. }
  27835. declare module "babylonjs/Materials/Textures/videoTexture" {
  27836. import { Observable } from "babylonjs/Misc/observable";
  27837. import { Nullable } from "babylonjs/types";
  27838. import { Scene } from "babylonjs/scene";
  27839. import { Texture } from "babylonjs/Materials/Textures/texture";
  27840. /**
  27841. * Settings for finer control over video usage
  27842. */
  27843. export interface VideoTextureSettings {
  27844. /**
  27845. * Applies `autoplay` to video, if specified
  27846. */
  27847. autoPlay?: boolean;
  27848. /**
  27849. * Applies `loop` to video, if specified
  27850. */
  27851. loop?: boolean;
  27852. /**
  27853. * Automatically updates internal texture from video at every frame in the render loop
  27854. */
  27855. autoUpdateTexture: boolean;
  27856. /**
  27857. * Image src displayed during the video loading or until the user interacts with the video.
  27858. */
  27859. poster?: string;
  27860. }
  27861. /**
  27862. * If you want to display a video in your scene, this is the special texture for that.
  27863. * This special texture works similar to other textures, with the exception of a few parameters.
  27864. * @see https://doc.babylonjs.com/how_to/video_texture
  27865. */
  27866. export class VideoTexture extends Texture {
  27867. /**
  27868. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  27869. */
  27870. readonly autoUpdateTexture: boolean;
  27871. /**
  27872. * The video instance used by the texture internally
  27873. */
  27874. readonly video: HTMLVideoElement;
  27875. private _onUserActionRequestedObservable;
  27876. /**
  27877. * Event triggerd when a dom action is required by the user to play the video.
  27878. * This happens due to recent changes in browser policies preventing video to auto start.
  27879. */
  27880. readonly onUserActionRequestedObservable: Observable<Texture>;
  27881. private _generateMipMaps;
  27882. private _engine;
  27883. private _stillImageCaptured;
  27884. private _displayingPosterTexture;
  27885. private _settings;
  27886. private _createInternalTextureOnEvent;
  27887. /**
  27888. * Creates a video texture.
  27889. * If you want to display a video in your scene, this is the special texture for that.
  27890. * This special texture works similar to other textures, with the exception of a few parameters.
  27891. * @see https://doc.babylonjs.com/how_to/video_texture
  27892. * @param name optional name, will detect from video source, if not defined
  27893. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  27894. * @param scene is obviously the current scene.
  27895. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  27896. * @param invertY is false by default but can be used to invert video on Y axis
  27897. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  27898. * @param settings allows finer control over video usage
  27899. */
  27900. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  27901. private _getName;
  27902. private _getVideo;
  27903. private _createInternalTexture;
  27904. private reset;
  27905. /**
  27906. * @hidden Internal method to initiate `update`.
  27907. */
  27908. _rebuild(): void;
  27909. /**
  27910. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  27911. */
  27912. update(): void;
  27913. /**
  27914. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  27915. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  27916. */
  27917. updateTexture(isVisible: boolean): void;
  27918. protected _updateInternalTexture: () => void;
  27919. /**
  27920. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  27921. * @param url New url.
  27922. */
  27923. updateURL(url: string): void;
  27924. /**
  27925. * Dispose the texture and release its associated resources.
  27926. */
  27927. dispose(): void;
  27928. /**
  27929. * Creates a video texture straight from a stream.
  27930. * @param scene Define the scene the texture should be created in
  27931. * @param stream Define the stream the texture should be created from
  27932. * @returns The created video texture as a promise
  27933. */
  27934. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  27935. /**
  27936. * Creates a video texture straight from your WebCam video feed.
  27937. * @param scene Define the scene the texture should be created in
  27938. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27939. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27940. * @returns The created video texture as a promise
  27941. */
  27942. static CreateFromWebCamAsync(scene: Scene, constraints: {
  27943. minWidth: number;
  27944. maxWidth: number;
  27945. minHeight: number;
  27946. maxHeight: number;
  27947. deviceId: string;
  27948. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  27949. /**
  27950. * Creates a video texture straight from your WebCam video feed.
  27951. * @param scene Define the scene the texture should be created in
  27952. * @param onReady Define a callback to triggered once the texture will be ready
  27953. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27954. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27955. */
  27956. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  27957. minWidth: number;
  27958. maxWidth: number;
  27959. minHeight: number;
  27960. maxHeight: number;
  27961. deviceId: string;
  27962. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  27963. }
  27964. }
  27965. declare module "babylonjs/Engines/engine" {
  27966. import { Observable } from "babylonjs/Misc/observable";
  27967. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  27968. import { ICustomAnimationFrameRequester, PerfCounter, IFileRequest } from "babylonjs/Misc/tools";
  27969. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  27970. import { Camera } from "babylonjs/Cameras/camera";
  27971. import { Scene } from "babylonjs/scene";
  27972. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  27973. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  27974. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  27975. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  27976. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  27977. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  27978. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27979. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  27980. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  27981. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  27982. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  27983. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  27984. import { WebRequest } from "babylonjs/Misc/webRequest";
  27985. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  27986. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  27987. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  27988. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  27989. import { Material } from "babylonjs/Materials/material";
  27990. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  27991. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27992. /**
  27993. * Interface for attribute information associated with buffer instanciation
  27994. */
  27995. export class InstancingAttributeInfo {
  27996. /**
  27997. * Index/offset of the attribute in the vertex shader
  27998. */
  27999. index: number;
  28000. /**
  28001. * size of the attribute, 1, 2, 3 or 4
  28002. */
  28003. attributeSize: number;
  28004. /**
  28005. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  28006. * default is FLOAT
  28007. */
  28008. attribyteType: number;
  28009. /**
  28010. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  28011. */
  28012. normalized: boolean;
  28013. /**
  28014. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  28015. */
  28016. offset: number;
  28017. /**
  28018. * Name of the GLSL attribute, for debugging purpose only
  28019. */
  28020. attributeName: string;
  28021. }
  28022. /**
  28023. * Define options used to create a depth texture
  28024. */
  28025. export class DepthTextureCreationOptions {
  28026. /** Specifies whether or not a stencil should be allocated in the texture */
  28027. generateStencil?: boolean;
  28028. /** Specifies whether or not bilinear filtering is enable on the texture */
  28029. bilinearFiltering?: boolean;
  28030. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  28031. comparisonFunction?: number;
  28032. /** Specifies if the created texture is a cube texture */
  28033. isCube?: boolean;
  28034. }
  28035. /**
  28036. * Class used to describe the capabilities of the engine relatively to the current browser
  28037. */
  28038. export class EngineCapabilities {
  28039. /** Maximum textures units per fragment shader */
  28040. maxTexturesImageUnits: number;
  28041. /** Maximum texture units per vertex shader */
  28042. maxVertexTextureImageUnits: number;
  28043. /** Maximum textures units in the entire pipeline */
  28044. maxCombinedTexturesImageUnits: number;
  28045. /** Maximum texture size */
  28046. maxTextureSize: number;
  28047. /** Maximum cube texture size */
  28048. maxCubemapTextureSize: number;
  28049. /** Maximum render texture size */
  28050. maxRenderTextureSize: number;
  28051. /** Maximum number of vertex attributes */
  28052. maxVertexAttribs: number;
  28053. /** Maximum number of varyings */
  28054. maxVaryingVectors: number;
  28055. /** Maximum number of uniforms per vertex shader */
  28056. maxVertexUniformVectors: number;
  28057. /** Maximum number of uniforms per fragment shader */
  28058. maxFragmentUniformVectors: number;
  28059. /** Defines if standard derivates (dx/dy) are supported */
  28060. standardDerivatives: boolean;
  28061. /** Defines if s3tc texture compression is supported */
  28062. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  28063. /** Defines if pvrtc texture compression is supported */
  28064. pvrtc: any;
  28065. /** Defines if etc1 texture compression is supported */
  28066. etc1: any;
  28067. /** Defines if etc2 texture compression is supported */
  28068. etc2: any;
  28069. /** Defines if astc texture compression is supported */
  28070. astc: any;
  28071. /** Defines if float textures are supported */
  28072. textureFloat: boolean;
  28073. /** Defines if vertex array objects are supported */
  28074. vertexArrayObject: boolean;
  28075. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  28076. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  28077. /** Gets the maximum level of anisotropy supported */
  28078. maxAnisotropy: number;
  28079. /** Defines if instancing is supported */
  28080. instancedArrays: boolean;
  28081. /** Defines if 32 bits indices are supported */
  28082. uintIndices: boolean;
  28083. /** Defines if high precision shaders are supported */
  28084. highPrecisionShaderSupported: boolean;
  28085. /** Defines if depth reading in the fragment shader is supported */
  28086. fragmentDepthSupported: boolean;
  28087. /** Defines if float texture linear filtering is supported*/
  28088. textureFloatLinearFiltering: boolean;
  28089. /** Defines if rendering to float textures is supported */
  28090. textureFloatRender: boolean;
  28091. /** Defines if half float textures are supported*/
  28092. textureHalfFloat: boolean;
  28093. /** Defines if half float texture linear filtering is supported*/
  28094. textureHalfFloatLinearFiltering: boolean;
  28095. /** Defines if rendering to half float textures is supported */
  28096. textureHalfFloatRender: boolean;
  28097. /** Defines if textureLOD shader command is supported */
  28098. textureLOD: boolean;
  28099. /** Defines if draw buffers extension is supported */
  28100. drawBuffersExtension: boolean;
  28101. /** Defines if depth textures are supported */
  28102. depthTextureExtension: boolean;
  28103. /** Defines if float color buffer are supported */
  28104. colorBufferFloat: boolean;
  28105. /** Gets disjoint timer query extension (null if not supported) */
  28106. timerQuery: EXT_disjoint_timer_query;
  28107. /** Defines if timestamp can be used with timer query */
  28108. canUseTimestampForTimerQuery: boolean;
  28109. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  28110. multiview: any;
  28111. /** Function used to let the system compiles shaders in background */
  28112. parallelShaderCompile: {
  28113. COMPLETION_STATUS_KHR: number;
  28114. };
  28115. }
  28116. /** Interface defining initialization parameters for Engine class */
  28117. export interface EngineOptions extends WebGLContextAttributes {
  28118. /**
  28119. * Defines if the engine should no exceed a specified device ratio
  28120. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  28121. */
  28122. limitDeviceRatio?: number;
  28123. /**
  28124. * Defines if webvr should be enabled automatically
  28125. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28126. */
  28127. autoEnableWebVR?: boolean;
  28128. /**
  28129. * Defines if webgl2 should be turned off even if supported
  28130. * @see http://doc.babylonjs.com/features/webgl2
  28131. */
  28132. disableWebGL2Support?: boolean;
  28133. /**
  28134. * Defines if webaudio should be initialized as well
  28135. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28136. */
  28137. audioEngine?: boolean;
  28138. /**
  28139. * Defines if animations should run using a deterministic lock step
  28140. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28141. */
  28142. deterministicLockstep?: boolean;
  28143. /** Defines the maximum steps to use with deterministic lock step mode */
  28144. lockstepMaxSteps?: number;
  28145. /**
  28146. * Defines that engine should ignore context lost events
  28147. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  28148. */
  28149. doNotHandleContextLost?: boolean;
  28150. /**
  28151. * Defines that engine should ignore modifying touch action attribute and style
  28152. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  28153. */
  28154. doNotHandleTouchAction?: boolean;
  28155. /**
  28156. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  28157. */
  28158. useHighPrecisionFloats?: boolean;
  28159. }
  28160. /**
  28161. * Defines the interface used by display changed events
  28162. */
  28163. export interface IDisplayChangedEventArgs {
  28164. /** Gets the vrDisplay object (if any) */
  28165. vrDisplay: Nullable<any>;
  28166. /** Gets a boolean indicating if webVR is supported */
  28167. vrSupported: boolean;
  28168. }
  28169. /**
  28170. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  28171. */
  28172. export class Engine {
  28173. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  28174. static ExceptionList: ({
  28175. key: string;
  28176. capture: string;
  28177. captureConstraint: number;
  28178. targets: string[];
  28179. } | {
  28180. key: string;
  28181. capture: null;
  28182. captureConstraint: null;
  28183. targets: string[];
  28184. })[];
  28185. /** Gets the list of created engines */
  28186. static readonly Instances: Engine[];
  28187. /**
  28188. * Gets the latest created engine
  28189. */
  28190. static readonly LastCreatedEngine: Nullable<Engine>;
  28191. /**
  28192. * Gets the latest created scene
  28193. */
  28194. static readonly LastCreatedScene: Nullable<Scene>;
  28195. /**
  28196. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  28197. * @param flag defines which part of the materials must be marked as dirty
  28198. * @param predicate defines a predicate used to filter which materials should be affected
  28199. */
  28200. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  28201. /** @hidden */
  28202. static _TextureLoaders: IInternalTextureLoader[];
  28203. /** Defines that alpha blending is disabled */
  28204. static readonly ALPHA_DISABLE: number;
  28205. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  28206. static readonly ALPHA_ADD: number;
  28207. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  28208. static readonly ALPHA_COMBINE: number;
  28209. /** Defines that alpha blending to DEST - SRC * DEST */
  28210. static readonly ALPHA_SUBTRACT: number;
  28211. /** Defines that alpha blending to SRC * DEST */
  28212. static readonly ALPHA_MULTIPLY: number;
  28213. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  28214. static readonly ALPHA_MAXIMIZED: number;
  28215. /** Defines that alpha blending to SRC + DEST */
  28216. static readonly ALPHA_ONEONE: number;
  28217. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  28218. static readonly ALPHA_PREMULTIPLIED: number;
  28219. /**
  28220. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  28221. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  28222. */
  28223. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  28224. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  28225. static readonly ALPHA_INTERPOLATE: number;
  28226. /**
  28227. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  28228. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  28229. */
  28230. static readonly ALPHA_SCREENMODE: number;
  28231. /** Defines that the ressource is not delayed*/
  28232. static readonly DELAYLOADSTATE_NONE: number;
  28233. /** Defines that the ressource was successfully delay loaded */
  28234. static readonly DELAYLOADSTATE_LOADED: number;
  28235. /** Defines that the ressource is currently delay loading */
  28236. static readonly DELAYLOADSTATE_LOADING: number;
  28237. /** Defines that the ressource is delayed and has not started loading */
  28238. static readonly DELAYLOADSTATE_NOTLOADED: number;
  28239. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  28240. static readonly NEVER: number;
  28241. /** 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 */
  28242. static readonly ALWAYS: number;
  28243. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  28244. static readonly LESS: number;
  28245. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  28246. static readonly EQUAL: number;
  28247. /** 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 */
  28248. static readonly LEQUAL: number;
  28249. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  28250. static readonly GREATER: number;
  28251. /** 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 */
  28252. static readonly GEQUAL: number;
  28253. /** 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 */
  28254. static readonly NOTEQUAL: number;
  28255. /** Passed to stencilOperation to specify that stencil value must be kept */
  28256. static readonly KEEP: number;
  28257. /** Passed to stencilOperation to specify that stencil value must be replaced */
  28258. static readonly REPLACE: number;
  28259. /** Passed to stencilOperation to specify that stencil value must be incremented */
  28260. static readonly INCR: number;
  28261. /** Passed to stencilOperation to specify that stencil value must be decremented */
  28262. static readonly DECR: number;
  28263. /** Passed to stencilOperation to specify that stencil value must be inverted */
  28264. static readonly INVERT: number;
  28265. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  28266. static readonly INCR_WRAP: number;
  28267. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  28268. static readonly DECR_WRAP: number;
  28269. /** Texture is not repeating outside of 0..1 UVs */
  28270. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  28271. /** Texture is repeating outside of 0..1 UVs */
  28272. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  28273. /** Texture is repeating and mirrored */
  28274. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  28275. /** ALPHA */
  28276. static readonly TEXTUREFORMAT_ALPHA: number;
  28277. /** LUMINANCE */
  28278. static readonly TEXTUREFORMAT_LUMINANCE: number;
  28279. /** LUMINANCE_ALPHA */
  28280. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  28281. /** RGB */
  28282. static readonly TEXTUREFORMAT_RGB: number;
  28283. /** RGBA */
  28284. static readonly TEXTUREFORMAT_RGBA: number;
  28285. /** RED */
  28286. static readonly TEXTUREFORMAT_RED: number;
  28287. /** RED (2nd reference) */
  28288. static readonly TEXTUREFORMAT_R: number;
  28289. /** RG */
  28290. static readonly TEXTUREFORMAT_RG: number;
  28291. /** RED_INTEGER */
  28292. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  28293. /** RED_INTEGER (2nd reference) */
  28294. static readonly TEXTUREFORMAT_R_INTEGER: number;
  28295. /** RG_INTEGER */
  28296. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  28297. /** RGB_INTEGER */
  28298. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  28299. /** RGBA_INTEGER */
  28300. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  28301. /** UNSIGNED_BYTE */
  28302. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  28303. /** UNSIGNED_BYTE (2nd reference) */
  28304. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  28305. /** FLOAT */
  28306. static readonly TEXTURETYPE_FLOAT: number;
  28307. /** HALF_FLOAT */
  28308. static readonly TEXTURETYPE_HALF_FLOAT: number;
  28309. /** BYTE */
  28310. static readonly TEXTURETYPE_BYTE: number;
  28311. /** SHORT */
  28312. static readonly TEXTURETYPE_SHORT: number;
  28313. /** UNSIGNED_SHORT */
  28314. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  28315. /** INT */
  28316. static readonly TEXTURETYPE_INT: number;
  28317. /** UNSIGNED_INT */
  28318. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  28319. /** UNSIGNED_SHORT_4_4_4_4 */
  28320. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  28321. /** UNSIGNED_SHORT_5_5_5_1 */
  28322. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  28323. /** UNSIGNED_SHORT_5_6_5 */
  28324. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  28325. /** UNSIGNED_INT_2_10_10_10_REV */
  28326. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  28327. /** UNSIGNED_INT_24_8 */
  28328. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  28329. /** UNSIGNED_INT_10F_11F_11F_REV */
  28330. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  28331. /** UNSIGNED_INT_5_9_9_9_REV */
  28332. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  28333. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  28334. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  28335. /** nearest is mag = nearest and min = nearest and mip = linear */
  28336. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  28337. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28338. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  28339. /** Trilinear is mag = linear and min = linear and mip = linear */
  28340. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  28341. /** nearest is mag = nearest and min = nearest and mip = linear */
  28342. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  28343. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28344. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  28345. /** Trilinear is mag = linear and min = linear and mip = linear */
  28346. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  28347. /** mag = nearest and min = nearest and mip = nearest */
  28348. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  28349. /** mag = nearest and min = linear and mip = nearest */
  28350. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  28351. /** mag = nearest and min = linear and mip = linear */
  28352. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  28353. /** mag = nearest and min = linear and mip = none */
  28354. static readonly TEXTURE_NEAREST_LINEAR: number;
  28355. /** mag = nearest and min = nearest and mip = none */
  28356. static readonly TEXTURE_NEAREST_NEAREST: number;
  28357. /** mag = linear and min = nearest and mip = nearest */
  28358. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  28359. /** mag = linear and min = nearest and mip = linear */
  28360. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  28361. /** mag = linear and min = linear and mip = none */
  28362. static readonly TEXTURE_LINEAR_LINEAR: number;
  28363. /** mag = linear and min = nearest and mip = none */
  28364. static readonly TEXTURE_LINEAR_NEAREST: number;
  28365. /** Explicit coordinates mode */
  28366. static readonly TEXTURE_EXPLICIT_MODE: number;
  28367. /** Spherical coordinates mode */
  28368. static readonly TEXTURE_SPHERICAL_MODE: number;
  28369. /** Planar coordinates mode */
  28370. static readonly TEXTURE_PLANAR_MODE: number;
  28371. /** Cubic coordinates mode */
  28372. static readonly TEXTURE_CUBIC_MODE: number;
  28373. /** Projection coordinates mode */
  28374. static readonly TEXTURE_PROJECTION_MODE: number;
  28375. /** Skybox coordinates mode */
  28376. static readonly TEXTURE_SKYBOX_MODE: number;
  28377. /** Inverse Cubic coordinates mode */
  28378. static readonly TEXTURE_INVCUBIC_MODE: number;
  28379. /** Equirectangular coordinates mode */
  28380. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  28381. /** Equirectangular Fixed coordinates mode */
  28382. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  28383. /** Equirectangular Fixed Mirrored coordinates mode */
  28384. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  28385. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  28386. static readonly SCALEMODE_FLOOR: number;
  28387. /** Defines that texture rescaling will look for the nearest power of 2 size */
  28388. static readonly SCALEMODE_NEAREST: number;
  28389. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  28390. static readonly SCALEMODE_CEILING: number;
  28391. /**
  28392. * Returns the current npm package of the sdk
  28393. */
  28394. static readonly NpmPackage: string;
  28395. /**
  28396. * Returns the current version of the framework
  28397. */
  28398. static readonly Version: string;
  28399. /**
  28400. * Returns a string describing the current engine
  28401. */
  28402. readonly description: string;
  28403. /**
  28404. * Gets or sets the epsilon value used by collision engine
  28405. */
  28406. static CollisionsEpsilon: number;
  28407. /**
  28408. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28409. */
  28410. static ShadersRepository: string;
  28411. /**
  28412. * Method called to create the default loading screen.
  28413. * This can be overriden in your own app.
  28414. * @param canvas The rendering canvas element
  28415. * @returns The loading screen
  28416. */
  28417. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  28418. /**
  28419. * Method called to create the default rescale post process on each engine.
  28420. */
  28421. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  28422. /** @hidden */
  28423. _shaderProcessor: IShaderProcessor;
  28424. /**
  28425. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  28426. */
  28427. forcePOTTextures: boolean;
  28428. /**
  28429. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  28430. */
  28431. isFullscreen: boolean;
  28432. /**
  28433. * Gets a boolean indicating if the pointer is currently locked
  28434. */
  28435. isPointerLock: boolean;
  28436. /**
  28437. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  28438. */
  28439. cullBackFaces: boolean;
  28440. /**
  28441. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  28442. */
  28443. renderEvenInBackground: boolean;
  28444. /**
  28445. * Gets or sets a boolean indicating that cache can be kept between frames
  28446. */
  28447. preventCacheWipeBetweenFrames: boolean;
  28448. /**
  28449. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  28450. **/
  28451. enableOfflineSupport: boolean;
  28452. /**
  28453. * 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)
  28454. **/
  28455. disableManifestCheck: boolean;
  28456. /**
  28457. * Gets the list of created scenes
  28458. */
  28459. scenes: Scene[];
  28460. /**
  28461. * Event raised when a new scene is created
  28462. */
  28463. onNewSceneAddedObservable: Observable<Scene>;
  28464. /**
  28465. * Gets the list of created postprocesses
  28466. */
  28467. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  28468. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  28469. validateShaderPrograms: boolean;
  28470. /**
  28471. * Observable event triggered each time the rendering canvas is resized
  28472. */
  28473. onResizeObservable: Observable<Engine>;
  28474. /**
  28475. * Observable event triggered each time the canvas loses focus
  28476. */
  28477. onCanvasBlurObservable: Observable<Engine>;
  28478. /**
  28479. * Observable event triggered each time the canvas gains focus
  28480. */
  28481. onCanvasFocusObservable: Observable<Engine>;
  28482. /**
  28483. * Observable event triggered each time the canvas receives pointerout event
  28484. */
  28485. onCanvasPointerOutObservable: Observable<PointerEvent>;
  28486. /**
  28487. * Observable event triggered before each texture is initialized
  28488. */
  28489. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  28490. /**
  28491. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  28492. */
  28493. disableUniformBuffers: boolean;
  28494. /** @hidden */
  28495. _uniformBuffers: UniformBuffer[];
  28496. /**
  28497. * Gets a boolean indicating that the engine supports uniform buffers
  28498. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28499. */
  28500. readonly supportsUniformBuffers: boolean;
  28501. /**
  28502. * Observable raised when the engine begins a new frame
  28503. */
  28504. onBeginFrameObservable: Observable<Engine>;
  28505. /**
  28506. * If set, will be used to request the next animation frame for the render loop
  28507. */
  28508. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  28509. /**
  28510. * Observable raised when the engine ends the current frame
  28511. */
  28512. onEndFrameObservable: Observable<Engine>;
  28513. /**
  28514. * Observable raised when the engine is about to compile a shader
  28515. */
  28516. onBeforeShaderCompilationObservable: Observable<Engine>;
  28517. /**
  28518. * Observable raised when the engine has jsut compiled a shader
  28519. */
  28520. onAfterShaderCompilationObservable: Observable<Engine>;
  28521. /** @hidden */
  28522. _gl: WebGLRenderingContext;
  28523. private _renderingCanvas;
  28524. private _windowIsBackground;
  28525. private _webGLVersion;
  28526. protected _highPrecisionShadersAllowed: boolean;
  28527. /** @hidden */
  28528. readonly _shouldUseHighPrecisionShader: boolean;
  28529. /**
  28530. * Gets a boolean indicating that only power of 2 textures are supported
  28531. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  28532. */
  28533. readonly needPOTTextures: boolean;
  28534. /** @hidden */
  28535. _badOS: boolean;
  28536. /** @hidden */
  28537. _badDesktopOS: boolean;
  28538. /**
  28539. * Gets the audio engine
  28540. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28541. * @ignorenaming
  28542. */
  28543. static audioEngine: IAudioEngine;
  28544. /**
  28545. * Default AudioEngine factory responsible of creating the Audio Engine.
  28546. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  28547. */
  28548. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  28549. /**
  28550. * Default offline support factory responsible of creating a tool used to store data locally.
  28551. * By default, this will create a Database object if the workload has been embedded.
  28552. */
  28553. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  28554. private _onFocus;
  28555. private _onBlur;
  28556. private _onCanvasPointerOut;
  28557. private _onCanvasBlur;
  28558. private _onCanvasFocus;
  28559. private _onFullscreenChange;
  28560. private _onPointerLockChange;
  28561. private _hardwareScalingLevel;
  28562. /** @hidden */
  28563. _caps: EngineCapabilities;
  28564. private _pointerLockRequested;
  28565. private _isStencilEnable;
  28566. private _colorWrite;
  28567. private _loadingScreen;
  28568. /** @hidden */
  28569. _drawCalls: PerfCounter;
  28570. private _glVersion;
  28571. private _glRenderer;
  28572. private _glVendor;
  28573. private _videoTextureSupported;
  28574. private _renderingQueueLaunched;
  28575. private _activeRenderLoops;
  28576. private _deterministicLockstep;
  28577. private _lockstepMaxSteps;
  28578. /**
  28579. * Observable signaled when a context lost event is raised
  28580. */
  28581. onContextLostObservable: Observable<Engine>;
  28582. /**
  28583. * Observable signaled when a context restored event is raised
  28584. */
  28585. onContextRestoredObservable: Observable<Engine>;
  28586. private _onContextLost;
  28587. private _onContextRestored;
  28588. private _contextWasLost;
  28589. /** @hidden */
  28590. _doNotHandleContextLost: boolean;
  28591. /**
  28592. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  28593. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  28594. */
  28595. doNotHandleContextLost: boolean;
  28596. private _performanceMonitor;
  28597. private _fps;
  28598. private _deltaTime;
  28599. /**
  28600. * Turn this value on if you want to pause FPS computation when in background
  28601. */
  28602. disablePerformanceMonitorInBackground: boolean;
  28603. /**
  28604. * Gets the performance monitor attached to this engine
  28605. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  28606. */
  28607. readonly performanceMonitor: PerformanceMonitor;
  28608. /**
  28609. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  28610. */
  28611. disableVertexArrayObjects: boolean;
  28612. /** @hidden */
  28613. protected _depthCullingState: _DepthCullingState;
  28614. /** @hidden */
  28615. protected _stencilState: _StencilState;
  28616. /** @hidden */
  28617. protected _alphaState: _AlphaState;
  28618. /** @hidden */
  28619. protected _alphaMode: number;
  28620. /** @hidden */
  28621. _internalTexturesCache: InternalTexture[];
  28622. /** @hidden */
  28623. protected _activeChannel: number;
  28624. private _currentTextureChannel;
  28625. /** @hidden */
  28626. protected _boundTexturesCache: {
  28627. [key: string]: Nullable<InternalTexture>;
  28628. };
  28629. /** @hidden */
  28630. protected _currentEffect: Nullable<Effect>;
  28631. /** @hidden */
  28632. protected _currentProgram: Nullable<WebGLProgram>;
  28633. private _compiledEffects;
  28634. private _vertexAttribArraysEnabled;
  28635. /** @hidden */
  28636. protected _cachedViewport: Nullable<Viewport>;
  28637. private _cachedVertexArrayObject;
  28638. /** @hidden */
  28639. protected _cachedVertexBuffers: any;
  28640. /** @hidden */
  28641. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  28642. /** @hidden */
  28643. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  28644. /** @hidden */
  28645. _currentRenderTarget: Nullable<InternalTexture>;
  28646. private _uintIndicesCurrentlySet;
  28647. private _currentBoundBuffer;
  28648. /** @hidden */
  28649. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  28650. private _currentBufferPointers;
  28651. private _currentInstanceLocations;
  28652. private _currentInstanceBuffers;
  28653. private _textureUnits;
  28654. /** @hidden */
  28655. _workingCanvas: Nullable<HTMLCanvasElement>;
  28656. /** @hidden */
  28657. _workingContext: Nullable<CanvasRenderingContext2D>;
  28658. private _rescalePostProcess;
  28659. private _dummyFramebuffer;
  28660. private _externalData;
  28661. /** @hidden */
  28662. _bindedRenderFunction: any;
  28663. private _vaoRecordInProgress;
  28664. private _mustWipeVertexAttributes;
  28665. private _emptyTexture;
  28666. private _emptyCubeTexture;
  28667. private _emptyTexture3D;
  28668. /** @hidden */
  28669. _frameHandler: number;
  28670. private _nextFreeTextureSlots;
  28671. private _maxSimultaneousTextures;
  28672. private _activeRequests;
  28673. private _texturesSupported;
  28674. /** @hidden */
  28675. _textureFormatInUse: Nullable<string>;
  28676. /**
  28677. * Gets the list of texture formats supported
  28678. */
  28679. readonly texturesSupported: Array<string>;
  28680. /**
  28681. * Gets the list of texture formats in use
  28682. */
  28683. readonly textureFormatInUse: Nullable<string>;
  28684. /**
  28685. * Gets the current viewport
  28686. */
  28687. readonly currentViewport: Nullable<Viewport>;
  28688. /**
  28689. * Gets the default empty texture
  28690. */
  28691. readonly emptyTexture: InternalTexture;
  28692. /**
  28693. * Gets the default empty 3D texture
  28694. */
  28695. readonly emptyTexture3D: InternalTexture;
  28696. /**
  28697. * Gets the default empty cube texture
  28698. */
  28699. readonly emptyCubeTexture: InternalTexture;
  28700. /**
  28701. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  28702. */
  28703. readonly premultipliedAlpha: boolean;
  28704. /**
  28705. * Creates a new engine
  28706. * @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
  28707. * @param antialias defines enable antialiasing (default: false)
  28708. * @param options defines further options to be sent to the getContext() function
  28709. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  28710. */
  28711. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  28712. /**
  28713. * Initializes a webVR display and starts listening to display change events
  28714. * The onVRDisplayChangedObservable will be notified upon these changes
  28715. * @returns The onVRDisplayChangedObservable
  28716. */
  28717. initWebVR(): Observable<IDisplayChangedEventArgs>;
  28718. /** @hidden */
  28719. _prepareVRComponent(): void;
  28720. /** @hidden */
  28721. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  28722. /** @hidden */
  28723. _submitVRFrame(): void;
  28724. /**
  28725. * Call this function to leave webVR mode
  28726. * Will do nothing if webVR is not supported or if there is no webVR device
  28727. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28728. */
  28729. disableVR(): void;
  28730. /**
  28731. * Gets a boolean indicating that the system is in VR mode and is presenting
  28732. * @returns true if VR mode is engaged
  28733. */
  28734. isVRPresenting(): boolean;
  28735. /** @hidden */
  28736. _requestVRFrame(): void;
  28737. private _disableTouchAction;
  28738. private _rebuildInternalTextures;
  28739. private _rebuildEffects;
  28740. /**
  28741. * Gets a boolean indicating if all created effects are ready
  28742. * @returns true if all effects are ready
  28743. */
  28744. areAllEffectsReady(): boolean;
  28745. private _rebuildBuffers;
  28746. private _initGLContext;
  28747. /**
  28748. * Gets version of the current webGL context
  28749. */
  28750. readonly webGLVersion: number;
  28751. /**
  28752. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  28753. */
  28754. readonly isStencilEnable: boolean;
  28755. /** @hidden */
  28756. _prepareWorkingCanvas(): void;
  28757. /**
  28758. * Reset the texture cache to empty state
  28759. */
  28760. resetTextureCache(): void;
  28761. /**
  28762. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  28763. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28764. * @returns true if engine is in deterministic lock step mode
  28765. */
  28766. isDeterministicLockStep(): boolean;
  28767. /**
  28768. * Gets the max steps when engine is running in deterministic lock step
  28769. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28770. * @returns the max steps
  28771. */
  28772. getLockstepMaxSteps(): number;
  28773. /**
  28774. * Gets an object containing information about the current webGL context
  28775. * @returns an object containing the vender, the renderer and the version of the current webGL context
  28776. */
  28777. getGlInfo(): {
  28778. vendor: string;
  28779. renderer: string;
  28780. version: string;
  28781. };
  28782. /**
  28783. * Gets current aspect ratio
  28784. * @param camera defines the camera to use to get the aspect ratio
  28785. * @param useScreen defines if screen size must be used (or the current render target if any)
  28786. * @returns a number defining the aspect ratio
  28787. */
  28788. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  28789. /**
  28790. * Gets current screen aspect ratio
  28791. * @returns a number defining the aspect ratio
  28792. */
  28793. getScreenAspectRatio(): number;
  28794. /**
  28795. * Gets the current render width
  28796. * @param useScreen defines if screen size must be used (or the current render target if any)
  28797. * @returns a number defining the current render width
  28798. */
  28799. getRenderWidth(useScreen?: boolean): number;
  28800. /**
  28801. * Gets the current render height
  28802. * @param useScreen defines if screen size must be used (or the current render target if any)
  28803. * @returns a number defining the current render height
  28804. */
  28805. getRenderHeight(useScreen?: boolean): number;
  28806. /**
  28807. * Gets the HTML canvas attached with the current webGL context
  28808. * @returns a HTML canvas
  28809. */
  28810. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  28811. /**
  28812. * Gets the client rect of the HTML canvas attached with the current webGL context
  28813. * @returns a client rectanglee
  28814. */
  28815. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  28816. /**
  28817. * Defines the hardware scaling level.
  28818. * By default the hardware scaling level is computed from the window device ratio.
  28819. * 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.
  28820. * @param level defines the level to use
  28821. */
  28822. setHardwareScalingLevel(level: number): void;
  28823. /**
  28824. * Gets the current hardware scaling level.
  28825. * By default the hardware scaling level is computed from the window device ratio.
  28826. * 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.
  28827. * @returns a number indicating the current hardware scaling level
  28828. */
  28829. getHardwareScalingLevel(): number;
  28830. /**
  28831. * Gets the list of loaded textures
  28832. * @returns an array containing all loaded textures
  28833. */
  28834. getLoadedTexturesCache(): InternalTexture[];
  28835. /**
  28836. * Gets the object containing all engine capabilities
  28837. * @returns the EngineCapabilities object
  28838. */
  28839. getCaps(): EngineCapabilities;
  28840. /**
  28841. * Gets the current depth function
  28842. * @returns a number defining the depth function
  28843. */
  28844. getDepthFunction(): Nullable<number>;
  28845. /**
  28846. * Sets the current depth function
  28847. * @param depthFunc defines the function to use
  28848. */
  28849. setDepthFunction(depthFunc: number): void;
  28850. /**
  28851. * Sets the current depth function to GREATER
  28852. */
  28853. setDepthFunctionToGreater(): void;
  28854. /**
  28855. * Sets the current depth function to GEQUAL
  28856. */
  28857. setDepthFunctionToGreaterOrEqual(): void;
  28858. /**
  28859. * Sets the current depth function to LESS
  28860. */
  28861. setDepthFunctionToLess(): void;
  28862. private _cachedStencilBuffer;
  28863. private _cachedStencilFunction;
  28864. private _cachedStencilMask;
  28865. private _cachedStencilOperationPass;
  28866. private _cachedStencilOperationFail;
  28867. private _cachedStencilOperationDepthFail;
  28868. private _cachedStencilReference;
  28869. /**
  28870. * Caches the the state of the stencil buffer
  28871. */
  28872. cacheStencilState(): void;
  28873. /**
  28874. * Restores the state of the stencil buffer
  28875. */
  28876. restoreStencilState(): void;
  28877. /**
  28878. * Sets the current depth function to LEQUAL
  28879. */
  28880. setDepthFunctionToLessOrEqual(): void;
  28881. /**
  28882. * Gets a boolean indicating if stencil buffer is enabled
  28883. * @returns the current stencil buffer state
  28884. */
  28885. getStencilBuffer(): boolean;
  28886. /**
  28887. * Enable or disable the stencil buffer
  28888. * @param enable defines if the stencil buffer must be enabled or disabled
  28889. */
  28890. setStencilBuffer(enable: boolean): void;
  28891. /**
  28892. * Gets the current stencil mask
  28893. * @returns a number defining the new stencil mask to use
  28894. */
  28895. getStencilMask(): number;
  28896. /**
  28897. * Sets the current stencil mask
  28898. * @param mask defines the new stencil mask to use
  28899. */
  28900. setStencilMask(mask: number): void;
  28901. /**
  28902. * Gets the current stencil function
  28903. * @returns a number defining the stencil function to use
  28904. */
  28905. getStencilFunction(): number;
  28906. /**
  28907. * Gets the current stencil reference value
  28908. * @returns a number defining the stencil reference value to use
  28909. */
  28910. getStencilFunctionReference(): number;
  28911. /**
  28912. * Gets the current stencil mask
  28913. * @returns a number defining the stencil mask to use
  28914. */
  28915. getStencilFunctionMask(): number;
  28916. /**
  28917. * Sets the current stencil function
  28918. * @param stencilFunc defines the new stencil function to use
  28919. */
  28920. setStencilFunction(stencilFunc: number): void;
  28921. /**
  28922. * Sets the current stencil reference
  28923. * @param reference defines the new stencil reference to use
  28924. */
  28925. setStencilFunctionReference(reference: number): void;
  28926. /**
  28927. * Sets the current stencil mask
  28928. * @param mask defines the new stencil mask to use
  28929. */
  28930. setStencilFunctionMask(mask: number): void;
  28931. /**
  28932. * Gets the current stencil operation when stencil fails
  28933. * @returns a number defining stencil operation to use when stencil fails
  28934. */
  28935. getStencilOperationFail(): number;
  28936. /**
  28937. * Gets the current stencil operation when depth fails
  28938. * @returns a number defining stencil operation to use when depth fails
  28939. */
  28940. getStencilOperationDepthFail(): number;
  28941. /**
  28942. * Gets the current stencil operation when stencil passes
  28943. * @returns a number defining stencil operation to use when stencil passes
  28944. */
  28945. getStencilOperationPass(): number;
  28946. /**
  28947. * Sets the stencil operation to use when stencil fails
  28948. * @param operation defines the stencil operation to use when stencil fails
  28949. */
  28950. setStencilOperationFail(operation: number): void;
  28951. /**
  28952. * Sets the stencil operation to use when depth fails
  28953. * @param operation defines the stencil operation to use when depth fails
  28954. */
  28955. setStencilOperationDepthFail(operation: number): void;
  28956. /**
  28957. * Sets the stencil operation to use when stencil passes
  28958. * @param operation defines the stencil operation to use when stencil passes
  28959. */
  28960. setStencilOperationPass(operation: number): void;
  28961. /**
  28962. * Sets a boolean indicating if the dithering state is enabled or disabled
  28963. * @param value defines the dithering state
  28964. */
  28965. setDitheringState(value: boolean): void;
  28966. /**
  28967. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  28968. * @param value defines the rasterizer state
  28969. */
  28970. setRasterizerState(value: boolean): void;
  28971. /**
  28972. * stop executing a render loop function and remove it from the execution array
  28973. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  28974. */
  28975. stopRenderLoop(renderFunction?: () => void): void;
  28976. /** @hidden */
  28977. _renderLoop(): void;
  28978. /**
  28979. * Register and execute a render loop. The engine can have more than one render function
  28980. * @param renderFunction defines the function to continuously execute
  28981. */
  28982. runRenderLoop(renderFunction: () => void): void;
  28983. /**
  28984. * Toggle full screen mode
  28985. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28986. */
  28987. switchFullscreen(requestPointerLock: boolean): void;
  28988. /**
  28989. * Enters full screen mode
  28990. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28991. */
  28992. enterFullscreen(requestPointerLock: boolean): void;
  28993. /**
  28994. * Exits full screen mode
  28995. */
  28996. exitFullscreen(): void;
  28997. /**
  28998. * Enters Pointerlock mode
  28999. */
  29000. enterPointerlock(): void;
  29001. /**
  29002. * Exits Pointerlock mode
  29003. */
  29004. exitPointerlock(): void;
  29005. /**
  29006. * Clear the current render buffer or the current render target (if any is set up)
  29007. * @param color defines the color to use
  29008. * @param backBuffer defines if the back buffer must be cleared
  29009. * @param depth defines if the depth buffer must be cleared
  29010. * @param stencil defines if the stencil buffer must be cleared
  29011. */
  29012. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  29013. /**
  29014. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  29015. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  29016. * @param y defines the y-coordinate of the corner of the clear rectangle
  29017. * @param width defines the width of the clear rectangle
  29018. * @param height defines the height of the clear rectangle
  29019. * @param clearColor defines the clear color
  29020. */
  29021. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  29022. /**
  29023. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  29024. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  29025. * @param y defines the y-coordinate of the corner of the clear rectangle
  29026. * @param width defines the width of the clear rectangle
  29027. * @param height defines the height of the clear rectangle
  29028. */
  29029. enableScissor(x: number, y: number, width: number, height: number): void;
  29030. /**
  29031. * Disable previously set scissor test rectangle
  29032. */
  29033. disableScissor(): void;
  29034. private _viewportCached;
  29035. /** @hidden */
  29036. _viewport(x: number, y: number, width: number, height: number): void;
  29037. /**
  29038. * Set the WebGL's viewport
  29039. * @param viewport defines the viewport element to be used
  29040. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  29041. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  29042. */
  29043. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  29044. /**
  29045. * Directly set the WebGL Viewport
  29046. * @param x defines the x coordinate of the viewport (in screen space)
  29047. * @param y defines the y coordinate of the viewport (in screen space)
  29048. * @param width defines the width of the viewport (in screen space)
  29049. * @param height defines the height of the viewport (in screen space)
  29050. * @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
  29051. */
  29052. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  29053. /**
  29054. * Begin a new frame
  29055. */
  29056. beginFrame(): void;
  29057. /**
  29058. * Enf the current frame
  29059. */
  29060. endFrame(): void;
  29061. /**
  29062. * Resize the view according to the canvas' size
  29063. */
  29064. resize(): void;
  29065. /**
  29066. * Force a specific size of the canvas
  29067. * @param width defines the new canvas' width
  29068. * @param height defines the new canvas' height
  29069. */
  29070. setSize(width: number, height: number): void;
  29071. /**
  29072. * Binds the frame buffer to the specified texture.
  29073. * @param texture The texture to render to or null for the default canvas
  29074. * @param faceIndex The face of the texture to render to in case of cube texture
  29075. * @param requiredWidth The width of the target to render to
  29076. * @param requiredHeight The height of the target to render to
  29077. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  29078. * @param depthStencilTexture The depth stencil texture to use to render
  29079. * @param lodLevel defines le lod level to bind to the frame buffer
  29080. */
  29081. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  29082. /** @hidden */
  29083. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  29084. /**
  29085. * Unbind the current render target texture from the webGL context
  29086. * @param texture defines the render target texture to unbind
  29087. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  29088. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  29089. */
  29090. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  29091. /**
  29092. * Force the mipmap generation for the given render target texture
  29093. * @param texture defines the render target texture to use
  29094. */
  29095. generateMipMapsForCubemap(texture: InternalTexture): void;
  29096. /**
  29097. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  29098. */
  29099. flushFramebuffer(): void;
  29100. /**
  29101. * Unbind the current render target and bind the default framebuffer
  29102. */
  29103. restoreDefaultFramebuffer(): void;
  29104. /**
  29105. * Create an uniform buffer
  29106. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29107. * @param elements defines the content of the uniform buffer
  29108. * @returns the webGL uniform buffer
  29109. */
  29110. createUniformBuffer(elements: FloatArray): DataBuffer;
  29111. /**
  29112. * Create a dynamic uniform buffer
  29113. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29114. * @param elements defines the content of the uniform buffer
  29115. * @returns the webGL uniform buffer
  29116. */
  29117. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  29118. /**
  29119. * Update an existing uniform buffer
  29120. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29121. * @param uniformBuffer defines the target uniform buffer
  29122. * @param elements defines the content to update
  29123. * @param offset defines the offset in the uniform buffer where update should start
  29124. * @param count defines the size of the data to update
  29125. */
  29126. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  29127. private _resetVertexBufferBinding;
  29128. /**
  29129. * Creates a vertex buffer
  29130. * @param data the data for the vertex buffer
  29131. * @returns the new WebGL static buffer
  29132. */
  29133. createVertexBuffer(data: DataArray): DataBuffer;
  29134. /**
  29135. * Creates a dynamic vertex buffer
  29136. * @param data the data for the dynamic vertex buffer
  29137. * @returns the new WebGL dynamic buffer
  29138. */
  29139. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  29140. /**
  29141. * Update a dynamic index buffer
  29142. * @param indexBuffer defines the target index buffer
  29143. * @param indices defines the data to update
  29144. * @param offset defines the offset in the target index buffer where update should start
  29145. */
  29146. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  29147. /**
  29148. * Updates a dynamic vertex buffer.
  29149. * @param vertexBuffer the vertex buffer to update
  29150. * @param data the data used to update the vertex buffer
  29151. * @param byteOffset the byte offset of the data
  29152. * @param byteLength the byte length of the data
  29153. */
  29154. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  29155. private _resetIndexBufferBinding;
  29156. /**
  29157. * Creates a new index buffer
  29158. * @param indices defines the content of the index buffer
  29159. * @param updatable defines if the index buffer must be updatable
  29160. * @returns a new webGL buffer
  29161. */
  29162. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  29163. /**
  29164. * Bind a webGL buffer to the webGL context
  29165. * @param buffer defines the buffer to bind
  29166. */
  29167. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  29168. /**
  29169. * Bind an uniform buffer to the current webGL context
  29170. * @param buffer defines the buffer to bind
  29171. */
  29172. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  29173. /**
  29174. * Bind a buffer to the current webGL context at a given location
  29175. * @param buffer defines the buffer to bind
  29176. * @param location defines the index where to bind the buffer
  29177. */
  29178. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  29179. /**
  29180. * Bind a specific block at a given index in a specific shader program
  29181. * @param pipelineContext defines the pipeline context to use
  29182. * @param blockName defines the block name
  29183. * @param index defines the index where to bind the block
  29184. */
  29185. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  29186. private bindIndexBuffer;
  29187. private bindBuffer;
  29188. /**
  29189. * update the bound buffer with the given data
  29190. * @param data defines the data to update
  29191. */
  29192. updateArrayBuffer(data: Float32Array): void;
  29193. private _vertexAttribPointer;
  29194. private _bindIndexBufferWithCache;
  29195. private _bindVertexBuffersAttributes;
  29196. /**
  29197. * Records a vertex array object
  29198. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29199. * @param vertexBuffers defines the list of vertex buffers to store
  29200. * @param indexBuffer defines the index buffer to store
  29201. * @param effect defines the effect to store
  29202. * @returns the new vertex array object
  29203. */
  29204. recordVertexArrayObject(vertexBuffers: {
  29205. [key: string]: VertexBuffer;
  29206. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  29207. /**
  29208. * Bind a specific vertex array object
  29209. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29210. * @param vertexArrayObject defines the vertex array object to bind
  29211. * @param indexBuffer defines the index buffer to bind
  29212. */
  29213. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  29214. /**
  29215. * Bind webGl buffers directly to the webGL context
  29216. * @param vertexBuffer defines the vertex buffer to bind
  29217. * @param indexBuffer defines the index buffer to bind
  29218. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  29219. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  29220. * @param effect defines the effect associated with the vertex buffer
  29221. */
  29222. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  29223. private _unbindVertexArrayObject;
  29224. /**
  29225. * Bind a list of vertex buffers to the webGL context
  29226. * @param vertexBuffers defines the list of vertex buffers to bind
  29227. * @param indexBuffer defines the index buffer to bind
  29228. * @param effect defines the effect associated with the vertex buffers
  29229. */
  29230. bindBuffers(vertexBuffers: {
  29231. [key: string]: Nullable<VertexBuffer>;
  29232. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  29233. /**
  29234. * Unbind all instance attributes
  29235. */
  29236. unbindInstanceAttributes(): void;
  29237. /**
  29238. * Release and free the memory of a vertex array object
  29239. * @param vao defines the vertex array object to delete
  29240. */
  29241. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  29242. /** @hidden */
  29243. _releaseBuffer(buffer: DataBuffer): boolean;
  29244. /**
  29245. * Creates a webGL buffer to use with instanciation
  29246. * @param capacity defines the size of the buffer
  29247. * @returns the webGL buffer
  29248. */
  29249. createInstancesBuffer(capacity: number): DataBuffer;
  29250. /**
  29251. * Delete a webGL buffer used with instanciation
  29252. * @param buffer defines the webGL buffer to delete
  29253. */
  29254. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  29255. /**
  29256. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  29257. * @param instancesBuffer defines the webGL buffer to update and bind
  29258. * @param data defines the data to store in the buffer
  29259. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  29260. */
  29261. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  29262. /**
  29263. * Apply all cached states (depth, culling, stencil and alpha)
  29264. */
  29265. applyStates(): void;
  29266. /**
  29267. * Send a draw order
  29268. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29269. * @param indexStart defines the starting index
  29270. * @param indexCount defines the number of index to draw
  29271. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29272. */
  29273. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  29274. /**
  29275. * Draw a list of points
  29276. * @param verticesStart defines the index of first vertex to draw
  29277. * @param verticesCount defines the count of vertices to draw
  29278. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29279. */
  29280. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29281. /**
  29282. * Draw a list of unindexed primitives
  29283. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29284. * @param verticesStart defines the index of first vertex to draw
  29285. * @param verticesCount defines the count of vertices to draw
  29286. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29287. */
  29288. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29289. /**
  29290. * Draw a list of indexed primitives
  29291. * @param fillMode defines the primitive to use
  29292. * @param indexStart defines the starting index
  29293. * @param indexCount defines the number of index to draw
  29294. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29295. */
  29296. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  29297. /**
  29298. * Draw a list of unindexed primitives
  29299. * @param fillMode defines the primitive to use
  29300. * @param verticesStart defines the index of first vertex to draw
  29301. * @param verticesCount defines the count of vertices to draw
  29302. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29303. */
  29304. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29305. private _drawMode;
  29306. /** @hidden */
  29307. _releaseEffect(effect: Effect): void;
  29308. /** @hidden */
  29309. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  29310. /**
  29311. * Create a new effect (used to store vertex/fragment shaders)
  29312. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  29313. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  29314. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  29315. * @param samplers defines an array of string used to represent textures
  29316. * @param defines defines the string containing the defines to use to compile the shaders
  29317. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  29318. * @param onCompiled defines a function to call when the effect creation is successful
  29319. * @param onError defines a function to call when the effect creation has failed
  29320. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  29321. * @returns the new Effect
  29322. */
  29323. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  29324. private _compileShader;
  29325. private _compileRawShader;
  29326. /**
  29327. * Directly creates a webGL program
  29328. * @param pipelineContext defines the pipeline context to attach to
  29329. * @param vertexCode defines the vertex shader code to use
  29330. * @param fragmentCode defines the fragment shader code to use
  29331. * @param context defines the webGL context to use (if not set, the current one will be used)
  29332. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29333. * @returns the new webGL program
  29334. */
  29335. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29336. /**
  29337. * Creates a webGL program
  29338. * @param pipelineContext defines the pipeline context to attach to
  29339. * @param vertexCode defines the vertex shader code to use
  29340. * @param fragmentCode defines the fragment shader code to use
  29341. * @param defines defines the string containing the defines to use to compile the shaders
  29342. * @param context defines the webGL context to use (if not set, the current one will be used)
  29343. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29344. * @returns the new webGL program
  29345. */
  29346. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29347. /**
  29348. * Creates a new pipeline context
  29349. * @returns the new pipeline
  29350. */
  29351. createPipelineContext(): WebGLPipelineContext;
  29352. private _createShaderProgram;
  29353. private _finalizePipelineContext;
  29354. /** @hidden */
  29355. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  29356. /** @hidden */
  29357. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  29358. /** @hidden */
  29359. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  29360. /**
  29361. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  29362. * @param pipelineContext defines the pipeline context to use
  29363. * @param uniformsNames defines the list of uniform names
  29364. * @returns an array of webGL uniform locations
  29365. */
  29366. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  29367. /**
  29368. * Gets the lsit of active attributes for a given webGL program
  29369. * @param pipelineContext defines the pipeline context to use
  29370. * @param attributesNames defines the list of attribute names to get
  29371. * @returns an array of indices indicating the offset of each attribute
  29372. */
  29373. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  29374. /**
  29375. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  29376. * @param effect defines the effect to activate
  29377. */
  29378. enableEffect(effect: Nullable<Effect>): void;
  29379. /**
  29380. * Set the value of an uniform to an array of int32
  29381. * @param uniform defines the webGL uniform location where to store the value
  29382. * @param array defines the array of int32 to store
  29383. */
  29384. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29385. /**
  29386. * Set the value of an uniform to an array of int32 (stored as vec2)
  29387. * @param uniform defines the webGL uniform location where to store the value
  29388. * @param array defines the array of int32 to store
  29389. */
  29390. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29391. /**
  29392. * Set the value of an uniform to an array of int32 (stored as vec3)
  29393. * @param uniform defines the webGL uniform location where to store the value
  29394. * @param array defines the array of int32 to store
  29395. */
  29396. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29397. /**
  29398. * Set the value of an uniform to an array of int32 (stored as vec4)
  29399. * @param uniform defines the webGL uniform location where to store the value
  29400. * @param array defines the array of int32 to store
  29401. */
  29402. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29403. /**
  29404. * Set the value of an uniform to an array of float32
  29405. * @param uniform defines the webGL uniform location where to store the value
  29406. * @param array defines the array of float32 to store
  29407. */
  29408. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29409. /**
  29410. * Set the value of an uniform to an array of float32 (stored as vec2)
  29411. * @param uniform defines the webGL uniform location where to store the value
  29412. * @param array defines the array of float32 to store
  29413. */
  29414. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29415. /**
  29416. * Set the value of an uniform to an array of float32 (stored as vec3)
  29417. * @param uniform defines the webGL uniform location where to store the value
  29418. * @param array defines the array of float32 to store
  29419. */
  29420. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29421. /**
  29422. * Set the value of an uniform to an array of float32 (stored as vec4)
  29423. * @param uniform defines the webGL uniform location where to store the value
  29424. * @param array defines the array of float32 to store
  29425. */
  29426. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29427. /**
  29428. * Set the value of an uniform to an array of number
  29429. * @param uniform defines the webGL uniform location where to store the value
  29430. * @param array defines the array of number to store
  29431. */
  29432. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29433. /**
  29434. * Set the value of an uniform to an array of number (stored as vec2)
  29435. * @param uniform defines the webGL uniform location where to store the value
  29436. * @param array defines the array of number to store
  29437. */
  29438. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29439. /**
  29440. * Set the value of an uniform to an array of number (stored as vec3)
  29441. * @param uniform defines the webGL uniform location where to store the value
  29442. * @param array defines the array of number to store
  29443. */
  29444. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29445. /**
  29446. * Set the value of an uniform to an array of number (stored as vec4)
  29447. * @param uniform defines the webGL uniform location where to store the value
  29448. * @param array defines the array of number to store
  29449. */
  29450. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29451. /**
  29452. * Set the value of an uniform to an array of float32 (stored as matrices)
  29453. * @param uniform defines the webGL uniform location where to store the value
  29454. * @param matrices defines the array of float32 to store
  29455. */
  29456. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  29457. /**
  29458. * Set the value of an uniform to a matrix
  29459. * @param uniform defines the webGL uniform location where to store the value
  29460. * @param matrix defines the matrix to store
  29461. */
  29462. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  29463. /**
  29464. * Set the value of an uniform to a matrix (3x3)
  29465. * @param uniform defines the webGL uniform location where to store the value
  29466. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  29467. */
  29468. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29469. /**
  29470. * Set the value of an uniform to a matrix (2x2)
  29471. * @param uniform defines the webGL uniform location where to store the value
  29472. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  29473. */
  29474. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29475. /**
  29476. * Set the value of an uniform to a number (int)
  29477. * @param uniform defines the webGL uniform location where to store the value
  29478. * @param value defines the int number to store
  29479. */
  29480. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29481. /**
  29482. * Set the value of an uniform to a number (float)
  29483. * @param uniform defines the webGL uniform location where to store the value
  29484. * @param value defines the float number to store
  29485. */
  29486. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29487. /**
  29488. * Set the value of an uniform to a vec2
  29489. * @param uniform defines the webGL uniform location where to store the value
  29490. * @param x defines the 1st component of the value
  29491. * @param y defines the 2nd component of the value
  29492. */
  29493. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  29494. /**
  29495. * Set the value of an uniform to a vec3
  29496. * @param uniform defines the webGL uniform location where to store the value
  29497. * @param x defines the 1st component of the value
  29498. * @param y defines the 2nd component of the value
  29499. * @param z defines the 3rd component of the value
  29500. */
  29501. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  29502. /**
  29503. * Set the value of an uniform to a boolean
  29504. * @param uniform defines the webGL uniform location where to store the value
  29505. * @param bool defines the boolean to store
  29506. */
  29507. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  29508. /**
  29509. * Set the value of an uniform to a vec4
  29510. * @param uniform defines the webGL uniform location where to store the value
  29511. * @param x defines the 1st component of the value
  29512. * @param y defines the 2nd component of the value
  29513. * @param z defines the 3rd component of the value
  29514. * @param w defines the 4th component of the value
  29515. */
  29516. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  29517. /**
  29518. * Set the value of an uniform to a Color3
  29519. * @param uniform defines the webGL uniform location where to store the value
  29520. * @param color3 defines the color to store
  29521. */
  29522. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  29523. /**
  29524. * Set the value of an uniform to a Color3 and an alpha value
  29525. * @param uniform defines the webGL uniform location where to store the value
  29526. * @param color3 defines the color to store
  29527. * @param alpha defines the alpha component to store
  29528. */
  29529. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  29530. /**
  29531. * Sets a Color4 on a uniform variable
  29532. * @param uniform defines the uniform location
  29533. * @param color4 defines the value to be set
  29534. */
  29535. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  29536. /**
  29537. * Set various states to the webGL context
  29538. * @param culling defines backface culling state
  29539. * @param zOffset defines the value to apply to zOffset (0 by default)
  29540. * @param force defines if states must be applied even if cache is up to date
  29541. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  29542. */
  29543. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  29544. /**
  29545. * Set the z offset to apply to current rendering
  29546. * @param value defines the offset to apply
  29547. */
  29548. setZOffset(value: number): void;
  29549. /**
  29550. * Gets the current value of the zOffset
  29551. * @returns the current zOffset state
  29552. */
  29553. getZOffset(): number;
  29554. /**
  29555. * Enable or disable depth buffering
  29556. * @param enable defines the state to set
  29557. */
  29558. setDepthBuffer(enable: boolean): void;
  29559. /**
  29560. * Gets a boolean indicating if depth writing is enabled
  29561. * @returns the current depth writing state
  29562. */
  29563. getDepthWrite(): boolean;
  29564. /**
  29565. * Enable or disable depth writing
  29566. * @param enable defines the state to set
  29567. */
  29568. setDepthWrite(enable: boolean): void;
  29569. /**
  29570. * Enable or disable color writing
  29571. * @param enable defines the state to set
  29572. */
  29573. setColorWrite(enable: boolean): void;
  29574. /**
  29575. * Gets a boolean indicating if color writing is enabled
  29576. * @returns the current color writing state
  29577. */
  29578. getColorWrite(): boolean;
  29579. /**
  29580. * Sets alpha constants used by some alpha blending modes
  29581. * @param r defines the red component
  29582. * @param g defines the green component
  29583. * @param b defines the blue component
  29584. * @param a defines the alpha component
  29585. */
  29586. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  29587. /**
  29588. * Sets the current alpha mode
  29589. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  29590. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  29591. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29592. */
  29593. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  29594. /**
  29595. * Gets the current alpha mode
  29596. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29597. * @returns the current alpha mode
  29598. */
  29599. getAlphaMode(): number;
  29600. /**
  29601. * Clears the list of texture accessible through engine.
  29602. * This can help preventing texture load conflict due to name collision.
  29603. */
  29604. clearInternalTexturesCache(): void;
  29605. /**
  29606. * Force the entire cache to be cleared
  29607. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  29608. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  29609. */
  29610. wipeCaches(bruteForce?: boolean): void;
  29611. /**
  29612. * Set the compressed texture format to use, based on the formats you have, and the formats
  29613. * supported by the hardware / browser.
  29614. *
  29615. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  29616. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  29617. * to API arguments needed to compressed textures. This puts the burden on the container
  29618. * generator to house the arcane code for determining these for current & future formats.
  29619. *
  29620. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  29621. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  29622. *
  29623. * Note: The result of this call is not taken into account when a texture is base64.
  29624. *
  29625. * @param formatsAvailable defines the list of those format families you have created
  29626. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  29627. *
  29628. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  29629. * @returns The extension selected.
  29630. */
  29631. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  29632. /** @hidden */
  29633. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  29634. min: number;
  29635. mag: number;
  29636. };
  29637. /** @hidden */
  29638. _createTexture(): WebGLTexture;
  29639. /**
  29640. * Usually called from Texture.ts.
  29641. * Passed information to create a WebGLTexture
  29642. * @param urlArg defines a value which contains one of the following:
  29643. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  29644. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  29645. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  29646. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  29647. * @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)
  29648. * @param scene needed for loading to the correct scene
  29649. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  29650. * @param onLoad optional callback to be called upon successful completion
  29651. * @param onError optional callback to be called upon failure
  29652. * @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
  29653. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  29654. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  29655. * @param forcedExtension defines the extension to use to pick the right loader
  29656. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  29657. * @returns a InternalTexture for assignment back into BABYLON.Texture
  29658. */
  29659. 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;
  29660. /**
  29661. * @hidden
  29662. * Rescales a texture
  29663. * @param source input texutre
  29664. * @param destination destination texture
  29665. * @param scene scene to use to render the resize
  29666. * @param internalFormat format to use when resizing
  29667. * @param onComplete callback to be called when resize has completed
  29668. */
  29669. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  29670. private _unpackFlipYCached;
  29671. /**
  29672. * In case you are sharing the context with other applications, it might
  29673. * be interested to not cache the unpack flip y state to ensure a consistent
  29674. * value would be set.
  29675. */
  29676. enableUnpackFlipYCached: boolean;
  29677. /** @hidden */
  29678. _unpackFlipY(value: boolean): void;
  29679. /** @hidden */
  29680. _getUnpackAlignement(): number;
  29681. /**
  29682. * Creates a dynamic texture
  29683. * @param width defines the width of the texture
  29684. * @param height defines the height of the texture
  29685. * @param generateMipMaps defines if the engine should generate the mip levels
  29686. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  29687. * @returns the dynamic texture inside an InternalTexture
  29688. */
  29689. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  29690. /**
  29691. * Update the sampling mode of a given texture
  29692. * @param samplingMode defines the required sampling mode
  29693. * @param texture defines the texture to update
  29694. */
  29695. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  29696. /**
  29697. * Update the content of a dynamic texture
  29698. * @param texture defines the texture to update
  29699. * @param canvas defines the canvas containing the source
  29700. * @param invertY defines if data must be stored with Y axis inverted
  29701. * @param premulAlpha defines if alpha is stored as premultiplied
  29702. * @param format defines the format of the data
  29703. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  29704. */
  29705. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  29706. /**
  29707. * Update a video texture
  29708. * @param texture defines the texture to update
  29709. * @param video defines the video element to use
  29710. * @param invertY defines if data must be stored with Y axis inverted
  29711. */
  29712. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29713. /**
  29714. * Updates a depth texture Comparison Mode and Function.
  29715. * If the comparison Function is equal to 0, the mode will be set to none.
  29716. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  29717. * @param texture The texture to set the comparison function for
  29718. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  29719. */
  29720. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  29721. /** @hidden */
  29722. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  29723. width: number;
  29724. height: number;
  29725. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  29726. /**
  29727. * Creates a depth stencil texture.
  29728. * This is only available in WebGL 2 or with the depth texture extension available.
  29729. * @param size The size of face edge in the texture.
  29730. * @param options The options defining the texture.
  29731. * @returns The texture
  29732. */
  29733. createDepthStencilTexture(size: number | {
  29734. width: number;
  29735. height: number;
  29736. }, options: DepthTextureCreationOptions): InternalTexture;
  29737. /**
  29738. * Creates a depth stencil texture.
  29739. * This is only available in WebGL 2 or with the depth texture extension available.
  29740. * @param size The size of face edge in the texture.
  29741. * @param options The options defining the texture.
  29742. * @returns The texture
  29743. */
  29744. private _createDepthStencilTexture;
  29745. /**
  29746. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  29747. * @param renderTarget The render target to set the frame buffer for
  29748. */
  29749. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  29750. /**
  29751. * Creates a new render target texture
  29752. * @param size defines the size of the texture
  29753. * @param options defines the options used to create the texture
  29754. * @returns a new render target texture stored in an InternalTexture
  29755. */
  29756. createRenderTargetTexture(size: number | {
  29757. width: number;
  29758. height: number;
  29759. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  29760. /** @hidden */
  29761. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  29762. /**
  29763. * Updates the sample count of a render target texture
  29764. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  29765. * @param texture defines the texture to update
  29766. * @param samples defines the sample count to set
  29767. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  29768. */
  29769. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  29770. /** @hidden */
  29771. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29772. /** @hidden */
  29773. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  29774. /** @hidden */
  29775. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29776. /** @hidden */
  29777. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  29778. /**
  29779. * @hidden
  29780. */
  29781. _setCubeMapTextureParams(loadMipmap: boolean): void;
  29782. private _prepareWebGLTextureContinuation;
  29783. private _prepareWebGLTexture;
  29784. /** @hidden */
  29785. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  29786. /** @hidden */
  29787. _releaseFramebufferObjects(texture: InternalTexture): void;
  29788. /** @hidden */
  29789. _releaseTexture(texture: InternalTexture): void;
  29790. private setProgram;
  29791. private _boundUniforms;
  29792. /**
  29793. * Binds an effect to the webGL context
  29794. * @param effect defines the effect to bind
  29795. */
  29796. bindSamplers(effect: Effect): void;
  29797. private _activateCurrentTexture;
  29798. /** @hidden */
  29799. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  29800. /** @hidden */
  29801. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  29802. /**
  29803. * Sets a texture to the webGL context from a postprocess
  29804. * @param channel defines the channel to use
  29805. * @param postProcess defines the source postprocess
  29806. */
  29807. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  29808. /**
  29809. * Binds the output of the passed in post process to the texture channel specified
  29810. * @param channel The channel the texture should be bound to
  29811. * @param postProcess The post process which's output should be bound
  29812. */
  29813. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  29814. /**
  29815. * Unbind all textures from the webGL context
  29816. */
  29817. unbindAllTextures(): void;
  29818. /**
  29819. * Sets a texture to the according uniform.
  29820. * @param channel The texture channel
  29821. * @param uniform The uniform to set
  29822. * @param texture The texture to apply
  29823. */
  29824. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  29825. /**
  29826. * Sets a depth stencil texture from a render target to the according uniform.
  29827. * @param channel The texture channel
  29828. * @param uniform The uniform to set
  29829. * @param texture The render target texture containing the depth stencil texture to apply
  29830. */
  29831. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  29832. private _bindSamplerUniformToChannel;
  29833. private _getTextureWrapMode;
  29834. private _setTexture;
  29835. /**
  29836. * Sets an array of texture to the webGL context
  29837. * @param channel defines the channel where the texture array must be set
  29838. * @param uniform defines the associated uniform location
  29839. * @param textures defines the array of textures to bind
  29840. */
  29841. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  29842. /** @hidden */
  29843. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  29844. private _setTextureParameterFloat;
  29845. private _setTextureParameterInteger;
  29846. /**
  29847. * Reads pixels from the current frame buffer. Please note that this function can be slow
  29848. * @param x defines the x coordinate of the rectangle where pixels must be read
  29849. * @param y defines the y coordinate of the rectangle where pixels must be read
  29850. * @param width defines the width of the rectangle where pixels must be read
  29851. * @param height defines the height of the rectangle where pixels must be read
  29852. * @returns a Uint8Array containing RGBA colors
  29853. */
  29854. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  29855. /**
  29856. * Add an externaly attached data from its key.
  29857. * This method call will fail and return false, if such key already exists.
  29858. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  29859. * @param key the unique key that identifies the data
  29860. * @param data the data object to associate to the key for this Engine instance
  29861. * @return true if no such key were already present and the data was added successfully, false otherwise
  29862. */
  29863. addExternalData<T>(key: string, data: T): boolean;
  29864. /**
  29865. * Get an externaly attached data from its key
  29866. * @param key the unique key that identifies the data
  29867. * @return the associated data, if present (can be null), or undefined if not present
  29868. */
  29869. getExternalData<T>(key: string): T;
  29870. /**
  29871. * Get an externaly attached data from its key, create it using a factory if it's not already present
  29872. * @param key the unique key that identifies the data
  29873. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  29874. * @return the associated data, can be null if the factory returned null.
  29875. */
  29876. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  29877. /**
  29878. * Remove an externaly attached data from the Engine instance
  29879. * @param key the unique key that identifies the data
  29880. * @return true if the data was successfully removed, false if it doesn't exist
  29881. */
  29882. removeExternalData(key: string): boolean;
  29883. /**
  29884. * Unbind all vertex attributes from the webGL context
  29885. */
  29886. unbindAllAttributes(): void;
  29887. /**
  29888. * 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
  29889. */
  29890. releaseEffects(): void;
  29891. /**
  29892. * Dispose and release all associated resources
  29893. */
  29894. dispose(): void;
  29895. /**
  29896. * Display the loading screen
  29897. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29898. */
  29899. displayLoadingUI(): void;
  29900. /**
  29901. * Hide the loading screen
  29902. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29903. */
  29904. hideLoadingUI(): void;
  29905. /**
  29906. * Gets the current loading screen object
  29907. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29908. */
  29909. /**
  29910. * Sets the current loading screen object
  29911. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29912. */
  29913. loadingScreen: ILoadingScreen;
  29914. /**
  29915. * Sets the current loading screen text
  29916. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29917. */
  29918. loadingUIText: string;
  29919. /**
  29920. * Sets the current loading screen background color
  29921. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29922. */
  29923. loadingUIBackgroundColor: string;
  29924. /**
  29925. * Attach a new callback raised when context lost event is fired
  29926. * @param callback defines the callback to call
  29927. */
  29928. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29929. /**
  29930. * Attach a new callback raised when context restored event is fired
  29931. * @param callback defines the callback to call
  29932. */
  29933. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29934. /**
  29935. * Gets the source code of the vertex shader associated with a specific webGL program
  29936. * @param program defines the program to use
  29937. * @returns a string containing the source code of the vertex shader associated with the program
  29938. */
  29939. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  29940. /**
  29941. * Gets the source code of the fragment shader associated with a specific webGL program
  29942. * @param program defines the program to use
  29943. * @returns a string containing the source code of the fragment shader associated with the program
  29944. */
  29945. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  29946. /**
  29947. * Get the current error code of the webGL context
  29948. * @returns the error code
  29949. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  29950. */
  29951. getError(): number;
  29952. /**
  29953. * Gets the current framerate
  29954. * @returns a number representing the framerate
  29955. */
  29956. getFps(): number;
  29957. /**
  29958. * Gets the time spent between current and previous frame
  29959. * @returns a number representing the delta time in ms
  29960. */
  29961. getDeltaTime(): number;
  29962. private _measureFps;
  29963. /** @hidden */
  29964. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  29965. private _canRenderToFloatFramebuffer;
  29966. private _canRenderToHalfFloatFramebuffer;
  29967. private _canRenderToFramebuffer;
  29968. /** @hidden */
  29969. _getWebGLTextureType(type: number): number;
  29970. /** @hidden */
  29971. _getInternalFormat(format: number): number;
  29972. /** @hidden */
  29973. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  29974. /** @hidden */
  29975. _getRGBAMultiSampleBufferFormat(type: number): number;
  29976. /** @hidden */
  29977. _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;
  29978. /** @hidden */
  29979. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  29980. /**
  29981. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  29982. * @returns true if the engine can be created
  29983. * @ignorenaming
  29984. */
  29985. static isSupported(): boolean;
  29986. }
  29987. }
  29988. declare module "babylonjs/Materials/effect" {
  29989. import { Observable } from "babylonjs/Misc/observable";
  29990. import { Nullable } from "babylonjs/types";
  29991. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  29992. import { IDisposable } from "babylonjs/scene";
  29993. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  29994. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29995. import { Engine } from "babylonjs/Engines/engine";
  29996. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29997. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29998. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29999. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30000. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30001. /**
  30002. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  30003. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  30004. */
  30005. export class EffectFallbacks {
  30006. private _defines;
  30007. private _currentRank;
  30008. private _maxRank;
  30009. private _mesh;
  30010. /**
  30011. * Removes the fallback from the bound mesh.
  30012. */
  30013. unBindMesh(): void;
  30014. /**
  30015. * Adds a fallback on the specified property.
  30016. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  30017. * @param define The name of the define in the shader
  30018. */
  30019. addFallback(rank: number, define: string): void;
  30020. /**
  30021. * Sets the mesh to use CPU skinning when needing to fallback.
  30022. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  30023. * @param mesh The mesh to use the fallbacks.
  30024. */
  30025. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  30026. /**
  30027. * Checks to see if more fallbacks are still availible.
  30028. */
  30029. readonly isMoreFallbacks: boolean;
  30030. /**
  30031. * Removes the defines that should be removed when falling back.
  30032. * @param currentDefines defines the current define statements for the shader.
  30033. * @param effect defines the current effect we try to compile
  30034. * @returns The resulting defines with defines of the current rank removed.
  30035. */
  30036. reduce(currentDefines: string, effect: Effect): string;
  30037. }
  30038. /**
  30039. * Options to be used when creating an effect.
  30040. */
  30041. export class EffectCreationOptions {
  30042. /**
  30043. * Atrributes that will be used in the shader.
  30044. */
  30045. attributes: string[];
  30046. /**
  30047. * Uniform varible names that will be set in the shader.
  30048. */
  30049. uniformsNames: string[];
  30050. /**
  30051. * Uniform buffer varible names that will be set in the shader.
  30052. */
  30053. uniformBuffersNames: string[];
  30054. /**
  30055. * Sampler texture variable names that will be set in the shader.
  30056. */
  30057. samplers: string[];
  30058. /**
  30059. * Define statements that will be set in the shader.
  30060. */
  30061. defines: any;
  30062. /**
  30063. * Possible fallbacks for this effect to improve performance when needed.
  30064. */
  30065. fallbacks: Nullable<EffectFallbacks>;
  30066. /**
  30067. * Callback that will be called when the shader is compiled.
  30068. */
  30069. onCompiled: Nullable<(effect: Effect) => void>;
  30070. /**
  30071. * Callback that will be called if an error occurs during shader compilation.
  30072. */
  30073. onError: Nullable<(effect: Effect, errors: string) => void>;
  30074. /**
  30075. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30076. */
  30077. indexParameters: any;
  30078. /**
  30079. * Max number of lights that can be used in the shader.
  30080. */
  30081. maxSimultaneousLights: number;
  30082. /**
  30083. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  30084. */
  30085. transformFeedbackVaryings: Nullable<string[]>;
  30086. }
  30087. /**
  30088. * Effect containing vertex and fragment shader that can be executed on an object.
  30089. */
  30090. export class Effect implements IDisposable {
  30091. /**
  30092. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30093. */
  30094. static ShadersRepository: string;
  30095. /**
  30096. * Name of the effect.
  30097. */
  30098. name: any;
  30099. /**
  30100. * String container all the define statements that should be set on the shader.
  30101. */
  30102. defines: string;
  30103. /**
  30104. * Callback that will be called when the shader is compiled.
  30105. */
  30106. onCompiled: Nullable<(effect: Effect) => void>;
  30107. /**
  30108. * Callback that will be called if an error occurs during shader compilation.
  30109. */
  30110. onError: Nullable<(effect: Effect, errors: string) => void>;
  30111. /**
  30112. * Callback that will be called when effect is bound.
  30113. */
  30114. onBind: Nullable<(effect: Effect) => void>;
  30115. /**
  30116. * Unique ID of the effect.
  30117. */
  30118. uniqueId: number;
  30119. /**
  30120. * Observable that will be called when the shader is compiled.
  30121. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30122. */
  30123. onCompileObservable: Observable<Effect>;
  30124. /**
  30125. * Observable that will be called if an error occurs during shader compilation.
  30126. */
  30127. onErrorObservable: Observable<Effect>;
  30128. /** @hidden */
  30129. _onBindObservable: Nullable<Observable<Effect>>;
  30130. /**
  30131. * Observable that will be called when effect is bound.
  30132. */
  30133. readonly onBindObservable: Observable<Effect>;
  30134. /** @hidden */
  30135. _bonesComputationForcedToCPU: boolean;
  30136. private static _uniqueIdSeed;
  30137. private _engine;
  30138. private _uniformBuffersNames;
  30139. private _uniformsNames;
  30140. private _samplerList;
  30141. private _samplers;
  30142. private _isReady;
  30143. private _compilationError;
  30144. private _attributesNames;
  30145. private _attributes;
  30146. private _uniforms;
  30147. /**
  30148. * Key for the effect.
  30149. * @hidden
  30150. */
  30151. _key: string;
  30152. private _indexParameters;
  30153. private _fallbacks;
  30154. private _vertexSourceCode;
  30155. private _fragmentSourceCode;
  30156. private _vertexSourceCodeOverride;
  30157. private _fragmentSourceCodeOverride;
  30158. private _transformFeedbackVaryings;
  30159. /**
  30160. * Compiled shader to webGL program.
  30161. * @hidden
  30162. */
  30163. _pipelineContext: Nullable<IPipelineContext>;
  30164. private _valueCache;
  30165. private static _baseCache;
  30166. /**
  30167. * Instantiates an effect.
  30168. * An effect can be used to create/manage/execute vertex and fragment shaders.
  30169. * @param baseName Name of the effect.
  30170. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  30171. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  30172. * @param samplers List of sampler variables that will be passed to the shader.
  30173. * @param engine Engine to be used to render the effect
  30174. * @param defines Define statements to be added to the shader.
  30175. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  30176. * @param onCompiled Callback that will be called when the shader is compiled.
  30177. * @param onError Callback that will be called if an error occurs during shader compilation.
  30178. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30179. */
  30180. 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);
  30181. private _useFinalCode;
  30182. /**
  30183. * Unique key for this effect
  30184. */
  30185. readonly key: string;
  30186. /**
  30187. * If the effect has been compiled and prepared.
  30188. * @returns if the effect is compiled and prepared.
  30189. */
  30190. isReady(): boolean;
  30191. /**
  30192. * The engine the effect was initialized with.
  30193. * @returns the engine.
  30194. */
  30195. getEngine(): Engine;
  30196. /**
  30197. * The pipeline context for this effect
  30198. * @returns the associated pipeline context
  30199. */
  30200. getPipelineContext(): Nullable<IPipelineContext>;
  30201. /**
  30202. * The set of names of attribute variables for the shader.
  30203. * @returns An array of attribute names.
  30204. */
  30205. getAttributesNames(): string[];
  30206. /**
  30207. * Returns the attribute at the given index.
  30208. * @param index The index of the attribute.
  30209. * @returns The location of the attribute.
  30210. */
  30211. getAttributeLocation(index: number): number;
  30212. /**
  30213. * Returns the attribute based on the name of the variable.
  30214. * @param name of the attribute to look up.
  30215. * @returns the attribute location.
  30216. */
  30217. getAttributeLocationByName(name: string): number;
  30218. /**
  30219. * The number of attributes.
  30220. * @returns the numnber of attributes.
  30221. */
  30222. getAttributesCount(): number;
  30223. /**
  30224. * Gets the index of a uniform variable.
  30225. * @param uniformName of the uniform to look up.
  30226. * @returns the index.
  30227. */
  30228. getUniformIndex(uniformName: string): number;
  30229. /**
  30230. * Returns the attribute based on the name of the variable.
  30231. * @param uniformName of the uniform to look up.
  30232. * @returns the location of the uniform.
  30233. */
  30234. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  30235. /**
  30236. * Returns an array of sampler variable names
  30237. * @returns The array of sampler variable neames.
  30238. */
  30239. getSamplers(): string[];
  30240. /**
  30241. * The error from the last compilation.
  30242. * @returns the error string.
  30243. */
  30244. getCompilationError(): string;
  30245. /**
  30246. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  30247. * @param func The callback to be used.
  30248. */
  30249. executeWhenCompiled(func: (effect: Effect) => void): void;
  30250. private _checkIsReady;
  30251. /** @hidden */
  30252. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  30253. /** @hidden */
  30254. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  30255. /** @hidden */
  30256. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  30257. /**
  30258. * Recompiles the webGL program
  30259. * @param vertexSourceCode The source code for the vertex shader.
  30260. * @param fragmentSourceCode The source code for the fragment shader.
  30261. * @param onCompiled Callback called when completed.
  30262. * @param onError Callback called on error.
  30263. * @hidden
  30264. */
  30265. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30266. /**
  30267. * Prepares the effect
  30268. * @hidden
  30269. */
  30270. _prepareEffect(): void;
  30271. /**
  30272. * Checks if the effect is supported. (Must be called after compilation)
  30273. */
  30274. readonly isSupported: boolean;
  30275. /**
  30276. * Binds a texture to the engine to be used as output of the shader.
  30277. * @param channel Name of the output variable.
  30278. * @param texture Texture to bind.
  30279. * @hidden
  30280. */
  30281. _bindTexture(channel: string, texture: InternalTexture): void;
  30282. /**
  30283. * Sets a texture on the engine to be used in the shader.
  30284. * @param channel Name of the sampler variable.
  30285. * @param texture Texture to set.
  30286. */
  30287. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30288. /**
  30289. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30290. * @param channel Name of the sampler variable.
  30291. * @param texture Texture to set.
  30292. */
  30293. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30294. /**
  30295. * Sets an array of textures on the engine to be used in the shader.
  30296. * @param channel Name of the variable.
  30297. * @param textures Textures to set.
  30298. */
  30299. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30300. /**
  30301. * 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)
  30302. * @param channel Name of the sampler variable.
  30303. * @param postProcess Post process to get the input texture from.
  30304. */
  30305. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30306. /**
  30307. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30308. * 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)
  30309. * @param channel Name of the sampler variable.
  30310. * @param postProcess Post process to get the output texture from.
  30311. */
  30312. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30313. /** @hidden */
  30314. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  30315. /** @hidden */
  30316. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30317. /** @hidden */
  30318. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30319. /** @hidden */
  30320. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30321. /**
  30322. * Binds a buffer to a uniform.
  30323. * @param buffer Buffer to bind.
  30324. * @param name Name of the uniform variable to bind to.
  30325. */
  30326. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30327. /**
  30328. * Binds block to a uniform.
  30329. * @param blockName Name of the block to bind.
  30330. * @param index Index to bind.
  30331. */
  30332. bindUniformBlock(blockName: string, index: number): void;
  30333. /**
  30334. * Sets an interger value on a uniform variable.
  30335. * @param uniformName Name of the variable.
  30336. * @param value Value to be set.
  30337. * @returns this effect.
  30338. */
  30339. setInt(uniformName: string, value: number): Effect;
  30340. /**
  30341. * Sets an int array on a uniform variable.
  30342. * @param uniformName Name of the variable.
  30343. * @param array array to be set.
  30344. * @returns this effect.
  30345. */
  30346. setIntArray(uniformName: string, array: Int32Array): Effect;
  30347. /**
  30348. * 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)
  30349. * @param uniformName Name of the variable.
  30350. * @param array array to be set.
  30351. * @returns this effect.
  30352. */
  30353. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30354. /**
  30355. * 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)
  30356. * @param uniformName Name of the variable.
  30357. * @param array array to be set.
  30358. * @returns this effect.
  30359. */
  30360. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30361. /**
  30362. * 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)
  30363. * @param uniformName Name of the variable.
  30364. * @param array array to be set.
  30365. * @returns this effect.
  30366. */
  30367. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30368. /**
  30369. * Sets an float array on a uniform variable.
  30370. * @param uniformName Name of the variable.
  30371. * @param array array to be set.
  30372. * @returns this effect.
  30373. */
  30374. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30375. /**
  30376. * 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)
  30377. * @param uniformName Name of the variable.
  30378. * @param array array to be set.
  30379. * @returns this effect.
  30380. */
  30381. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30382. /**
  30383. * 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)
  30384. * @param uniformName Name of the variable.
  30385. * @param array array to be set.
  30386. * @returns this effect.
  30387. */
  30388. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30389. /**
  30390. * 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)
  30391. * @param uniformName Name of the variable.
  30392. * @param array array to be set.
  30393. * @returns this effect.
  30394. */
  30395. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30396. /**
  30397. * Sets an array on a uniform variable.
  30398. * @param uniformName Name of the variable.
  30399. * @param array array to be set.
  30400. * @returns this effect.
  30401. */
  30402. setArray(uniformName: string, array: number[]): Effect;
  30403. /**
  30404. * 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)
  30405. * @param uniformName Name of the variable.
  30406. * @param array array to be set.
  30407. * @returns this effect.
  30408. */
  30409. setArray2(uniformName: string, array: number[]): Effect;
  30410. /**
  30411. * 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)
  30412. * @param uniformName Name of the variable.
  30413. * @param array array to be set.
  30414. * @returns this effect.
  30415. */
  30416. setArray3(uniformName: string, array: number[]): Effect;
  30417. /**
  30418. * 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)
  30419. * @param uniformName Name of the variable.
  30420. * @param array array to be set.
  30421. * @returns this effect.
  30422. */
  30423. setArray4(uniformName: string, array: number[]): Effect;
  30424. /**
  30425. * Sets matrices on a uniform variable.
  30426. * @param uniformName Name of the variable.
  30427. * @param matrices matrices to be set.
  30428. * @returns this effect.
  30429. */
  30430. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30431. /**
  30432. * Sets matrix on a uniform variable.
  30433. * @param uniformName Name of the variable.
  30434. * @param matrix matrix to be set.
  30435. * @returns this effect.
  30436. */
  30437. setMatrix(uniformName: string, matrix: Matrix): Effect;
  30438. /**
  30439. * 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)
  30440. * @param uniformName Name of the variable.
  30441. * @param matrix matrix to be set.
  30442. * @returns this effect.
  30443. */
  30444. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30445. /**
  30446. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30447. * @param uniformName Name of the variable.
  30448. * @param matrix matrix to be set.
  30449. * @returns this effect.
  30450. */
  30451. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30452. /**
  30453. * Sets a float on a uniform variable.
  30454. * @param uniformName Name of the variable.
  30455. * @param value value to be set.
  30456. * @returns this effect.
  30457. */
  30458. setFloat(uniformName: string, value: number): Effect;
  30459. /**
  30460. * Sets a boolean on a uniform variable.
  30461. * @param uniformName Name of the variable.
  30462. * @param bool value to be set.
  30463. * @returns this effect.
  30464. */
  30465. setBool(uniformName: string, bool: boolean): Effect;
  30466. /**
  30467. * Sets a Vector2 on a uniform variable.
  30468. * @param uniformName Name of the variable.
  30469. * @param vector2 vector2 to be set.
  30470. * @returns this effect.
  30471. */
  30472. setVector2(uniformName: string, vector2: Vector2): Effect;
  30473. /**
  30474. * Sets a float2 on a uniform variable.
  30475. * @param uniformName Name of the variable.
  30476. * @param x First float in float2.
  30477. * @param y Second float in float2.
  30478. * @returns this effect.
  30479. */
  30480. setFloat2(uniformName: string, x: number, y: number): Effect;
  30481. /**
  30482. * Sets a Vector3 on a uniform variable.
  30483. * @param uniformName Name of the variable.
  30484. * @param vector3 Value to be set.
  30485. * @returns this effect.
  30486. */
  30487. setVector3(uniformName: string, vector3: Vector3): Effect;
  30488. /**
  30489. * Sets a float3 on a uniform variable.
  30490. * @param uniformName Name of the variable.
  30491. * @param x First float in float3.
  30492. * @param y Second float in float3.
  30493. * @param z Third float in float3.
  30494. * @returns this effect.
  30495. */
  30496. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30497. /**
  30498. * Sets a Vector4 on a uniform variable.
  30499. * @param uniformName Name of the variable.
  30500. * @param vector4 Value to be set.
  30501. * @returns this effect.
  30502. */
  30503. setVector4(uniformName: string, vector4: Vector4): Effect;
  30504. /**
  30505. * Sets a float4 on a uniform variable.
  30506. * @param uniformName Name of the variable.
  30507. * @param x First float in float4.
  30508. * @param y Second float in float4.
  30509. * @param z Third float in float4.
  30510. * @param w Fourth float in float4.
  30511. * @returns this effect.
  30512. */
  30513. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30514. /**
  30515. * Sets a Color3 on a uniform variable.
  30516. * @param uniformName Name of the variable.
  30517. * @param color3 Value to be set.
  30518. * @returns this effect.
  30519. */
  30520. setColor3(uniformName: string, color3: Color3): Effect;
  30521. /**
  30522. * Sets a Color4 on a uniform variable.
  30523. * @param uniformName Name of the variable.
  30524. * @param color3 Value to be set.
  30525. * @param alpha Alpha value to be set.
  30526. * @returns this effect.
  30527. */
  30528. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  30529. /**
  30530. * Sets a Color4 on a uniform variable
  30531. * @param uniformName defines the name of the variable
  30532. * @param color4 defines the value to be set
  30533. * @returns this effect.
  30534. */
  30535. setDirectColor4(uniformName: string, color4: Color4): Effect;
  30536. /** Release all associated resources */
  30537. dispose(): void;
  30538. /**
  30539. * This function will add a new shader to the shader store
  30540. * @param name the name of the shader
  30541. * @param pixelShader optional pixel shader content
  30542. * @param vertexShader optional vertex shader content
  30543. */
  30544. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30545. /**
  30546. * Store of each shader (The can be looked up using effect.key)
  30547. */
  30548. static ShadersStore: {
  30549. [key: string]: string;
  30550. };
  30551. /**
  30552. * Store of each included file for a shader (The can be looked up using effect.key)
  30553. */
  30554. static IncludesShadersStore: {
  30555. [key: string]: string;
  30556. };
  30557. /**
  30558. * Resets the cache of effects.
  30559. */
  30560. static ResetCache(): void;
  30561. }
  30562. }
  30563. declare module "babylonjs/Materials/colorCurves" {
  30564. import { Effect } from "babylonjs/Materials/effect";
  30565. /**
  30566. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30567. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30568. * 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;
  30569. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30570. */
  30571. export class ColorCurves {
  30572. private _dirty;
  30573. private _tempColor;
  30574. private _globalCurve;
  30575. private _highlightsCurve;
  30576. private _midtonesCurve;
  30577. private _shadowsCurve;
  30578. private _positiveCurve;
  30579. private _negativeCurve;
  30580. private _globalHue;
  30581. private _globalDensity;
  30582. private _globalSaturation;
  30583. private _globalExposure;
  30584. /**
  30585. * Gets the global Hue value.
  30586. * 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).
  30587. */
  30588. /**
  30589. * Sets the global Hue value.
  30590. * 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).
  30591. */
  30592. globalHue: number;
  30593. /**
  30594. * Gets the global Density value.
  30595. * 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.
  30596. * Values less than zero provide a filter of opposite hue.
  30597. */
  30598. /**
  30599. * Sets the global Density value.
  30600. * 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.
  30601. * Values less than zero provide a filter of opposite hue.
  30602. */
  30603. globalDensity: number;
  30604. /**
  30605. * Gets the global Saturation value.
  30606. * 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.
  30607. */
  30608. /**
  30609. * Sets the global Saturation value.
  30610. * 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.
  30611. */
  30612. globalSaturation: number;
  30613. /**
  30614. * Gets the global Exposure value.
  30615. * 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.
  30616. */
  30617. /**
  30618. * Sets the global Exposure value.
  30619. * 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.
  30620. */
  30621. globalExposure: number;
  30622. private _highlightsHue;
  30623. private _highlightsDensity;
  30624. private _highlightsSaturation;
  30625. private _highlightsExposure;
  30626. /**
  30627. * Gets the highlights Hue value.
  30628. * 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).
  30629. */
  30630. /**
  30631. * Sets the highlights Hue value.
  30632. * 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).
  30633. */
  30634. highlightsHue: number;
  30635. /**
  30636. * Gets the highlights Density value.
  30637. * 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.
  30638. * Values less than zero provide a filter of opposite hue.
  30639. */
  30640. /**
  30641. * Sets the highlights Density value.
  30642. * 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.
  30643. * Values less than zero provide a filter of opposite hue.
  30644. */
  30645. highlightsDensity: number;
  30646. /**
  30647. * Gets the highlights Saturation value.
  30648. * 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.
  30649. */
  30650. /**
  30651. * Sets the highlights Saturation value.
  30652. * 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.
  30653. */
  30654. highlightsSaturation: number;
  30655. /**
  30656. * Gets the highlights Exposure value.
  30657. * 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.
  30658. */
  30659. /**
  30660. * Sets the highlights Exposure value.
  30661. * 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.
  30662. */
  30663. highlightsExposure: number;
  30664. private _midtonesHue;
  30665. private _midtonesDensity;
  30666. private _midtonesSaturation;
  30667. private _midtonesExposure;
  30668. /**
  30669. * Gets the midtones Hue value.
  30670. * 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).
  30671. */
  30672. /**
  30673. * Sets the midtones Hue value.
  30674. * 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).
  30675. */
  30676. midtonesHue: number;
  30677. /**
  30678. * Gets the midtones Density value.
  30679. * 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.
  30680. * Values less than zero provide a filter of opposite hue.
  30681. */
  30682. /**
  30683. * Sets the midtones Density value.
  30684. * 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.
  30685. * Values less than zero provide a filter of opposite hue.
  30686. */
  30687. midtonesDensity: number;
  30688. /**
  30689. * Gets the midtones Saturation value.
  30690. * 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.
  30691. */
  30692. /**
  30693. * Sets the midtones Saturation value.
  30694. * 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.
  30695. */
  30696. midtonesSaturation: number;
  30697. /**
  30698. * Gets the midtones Exposure value.
  30699. * 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.
  30700. */
  30701. /**
  30702. * Sets the midtones Exposure value.
  30703. * 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.
  30704. */
  30705. midtonesExposure: number;
  30706. private _shadowsHue;
  30707. private _shadowsDensity;
  30708. private _shadowsSaturation;
  30709. private _shadowsExposure;
  30710. /**
  30711. * Gets the shadows Hue value.
  30712. * 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).
  30713. */
  30714. /**
  30715. * Sets the shadows Hue value.
  30716. * 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).
  30717. */
  30718. shadowsHue: number;
  30719. /**
  30720. * Gets the shadows Density value.
  30721. * 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.
  30722. * Values less than zero provide a filter of opposite hue.
  30723. */
  30724. /**
  30725. * Sets the shadows Density value.
  30726. * 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.
  30727. * Values less than zero provide a filter of opposite hue.
  30728. */
  30729. shadowsDensity: number;
  30730. /**
  30731. * Gets the shadows Saturation value.
  30732. * 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.
  30733. */
  30734. /**
  30735. * Sets the shadows Saturation value.
  30736. * 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.
  30737. */
  30738. shadowsSaturation: number;
  30739. /**
  30740. * Gets the shadows Exposure value.
  30741. * 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.
  30742. */
  30743. /**
  30744. * Sets the shadows Exposure value.
  30745. * 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.
  30746. */
  30747. shadowsExposure: number;
  30748. /**
  30749. * Returns the class name
  30750. * @returns The class name
  30751. */
  30752. getClassName(): string;
  30753. /**
  30754. * Binds the color curves to the shader.
  30755. * @param colorCurves The color curve to bind
  30756. * @param effect The effect to bind to
  30757. * @param positiveUniform The positive uniform shader parameter
  30758. * @param neutralUniform The neutral uniform shader parameter
  30759. * @param negativeUniform The negative uniform shader parameter
  30760. */
  30761. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  30762. /**
  30763. * Prepare the list of uniforms associated with the ColorCurves effects.
  30764. * @param uniformsList The list of uniforms used in the effect
  30765. */
  30766. static PrepareUniforms(uniformsList: string[]): void;
  30767. /**
  30768. * Returns color grading data based on a hue, density, saturation and exposure value.
  30769. * @param filterHue The hue of the color filter.
  30770. * @param filterDensity The density of the color filter.
  30771. * @param saturation The saturation.
  30772. * @param exposure The exposure.
  30773. * @param result The result data container.
  30774. */
  30775. private getColorGradingDataToRef;
  30776. /**
  30777. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  30778. * @param value The input slider value in range [-100,100].
  30779. * @returns Adjusted value.
  30780. */
  30781. private static applyColorGradingSliderNonlinear;
  30782. /**
  30783. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  30784. * @param hue The hue (H) input.
  30785. * @param saturation The saturation (S) input.
  30786. * @param brightness The brightness (B) input.
  30787. * @result An RGBA color represented as Vector4.
  30788. */
  30789. private static fromHSBToRef;
  30790. /**
  30791. * Returns a value clamped between min and max
  30792. * @param value The value to clamp
  30793. * @param min The minimum of value
  30794. * @param max The maximum of value
  30795. * @returns The clamped value.
  30796. */
  30797. private static clamp;
  30798. /**
  30799. * Clones the current color curve instance.
  30800. * @return The cloned curves
  30801. */
  30802. clone(): ColorCurves;
  30803. /**
  30804. * Serializes the current color curve instance to a json representation.
  30805. * @return a JSON representation
  30806. */
  30807. serialize(): any;
  30808. /**
  30809. * Parses the color curve from a json representation.
  30810. * @param source the JSON source to parse
  30811. * @return The parsed curves
  30812. */
  30813. static Parse(source: any): ColorCurves;
  30814. }
  30815. }
  30816. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  30817. import { Observable } from "babylonjs/Misc/observable";
  30818. import { Nullable } from "babylonjs/types";
  30819. import { Color4 } from "babylonjs/Maths/math";
  30820. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30821. import { Effect } from "babylonjs/Materials/effect";
  30822. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30823. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  30824. /**
  30825. * Interface to follow in your material defines to integrate easily the
  30826. * Image proccessing functions.
  30827. * @hidden
  30828. */
  30829. export interface IImageProcessingConfigurationDefines {
  30830. IMAGEPROCESSING: boolean;
  30831. VIGNETTE: boolean;
  30832. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30833. VIGNETTEBLENDMODEOPAQUE: boolean;
  30834. TONEMAPPING: boolean;
  30835. TONEMAPPING_ACES: boolean;
  30836. CONTRAST: boolean;
  30837. EXPOSURE: boolean;
  30838. COLORCURVES: boolean;
  30839. COLORGRADING: boolean;
  30840. COLORGRADING3D: boolean;
  30841. SAMPLER3DGREENDEPTH: boolean;
  30842. SAMPLER3DBGRMAP: boolean;
  30843. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30844. }
  30845. /**
  30846. * @hidden
  30847. */
  30848. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  30849. IMAGEPROCESSING: boolean;
  30850. VIGNETTE: boolean;
  30851. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30852. VIGNETTEBLENDMODEOPAQUE: boolean;
  30853. TONEMAPPING: boolean;
  30854. TONEMAPPING_ACES: boolean;
  30855. CONTRAST: boolean;
  30856. COLORCURVES: boolean;
  30857. COLORGRADING: boolean;
  30858. COLORGRADING3D: boolean;
  30859. SAMPLER3DGREENDEPTH: boolean;
  30860. SAMPLER3DBGRMAP: boolean;
  30861. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30862. EXPOSURE: boolean;
  30863. constructor();
  30864. }
  30865. /**
  30866. * This groups together the common properties used for image processing either in direct forward pass
  30867. * or through post processing effect depending on the use of the image processing pipeline in your scene
  30868. * or not.
  30869. */
  30870. export class ImageProcessingConfiguration {
  30871. /**
  30872. * Default tone mapping applied in BabylonJS.
  30873. */
  30874. static readonly TONEMAPPING_STANDARD: number;
  30875. /**
  30876. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  30877. * to other engines rendering to increase portability.
  30878. */
  30879. static readonly TONEMAPPING_ACES: number;
  30880. /**
  30881. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  30882. */
  30883. colorCurves: Nullable<ColorCurves>;
  30884. private _colorCurvesEnabled;
  30885. /**
  30886. * Gets wether the color curves effect is enabled.
  30887. */
  30888. /**
  30889. * Sets wether the color curves effect is enabled.
  30890. */
  30891. colorCurvesEnabled: boolean;
  30892. private _colorGradingTexture;
  30893. /**
  30894. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30895. */
  30896. /**
  30897. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30898. */
  30899. colorGradingTexture: Nullable<BaseTexture>;
  30900. private _colorGradingEnabled;
  30901. /**
  30902. * Gets wether the color grading effect is enabled.
  30903. */
  30904. /**
  30905. * Sets wether the color grading effect is enabled.
  30906. */
  30907. colorGradingEnabled: boolean;
  30908. private _colorGradingWithGreenDepth;
  30909. /**
  30910. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  30911. */
  30912. /**
  30913. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  30914. */
  30915. colorGradingWithGreenDepth: boolean;
  30916. private _colorGradingBGR;
  30917. /**
  30918. * Gets wether the color grading texture contains BGR values.
  30919. */
  30920. /**
  30921. * Sets wether the color grading texture contains BGR values.
  30922. */
  30923. colorGradingBGR: boolean;
  30924. /** @hidden */
  30925. _exposure: number;
  30926. /**
  30927. * Gets the Exposure used in the effect.
  30928. */
  30929. /**
  30930. * Sets the Exposure used in the effect.
  30931. */
  30932. exposure: number;
  30933. private _toneMappingEnabled;
  30934. /**
  30935. * Gets wether the tone mapping effect is enabled.
  30936. */
  30937. /**
  30938. * Sets wether the tone mapping effect is enabled.
  30939. */
  30940. toneMappingEnabled: boolean;
  30941. private _toneMappingType;
  30942. /**
  30943. * Gets the type of tone mapping effect.
  30944. */
  30945. /**
  30946. * Sets the type of tone mapping effect used in BabylonJS.
  30947. */
  30948. toneMappingType: number;
  30949. protected _contrast: number;
  30950. /**
  30951. * Gets the contrast used in the effect.
  30952. */
  30953. /**
  30954. * Sets the contrast used in the effect.
  30955. */
  30956. contrast: number;
  30957. /**
  30958. * Vignette stretch size.
  30959. */
  30960. vignetteStretch: number;
  30961. /**
  30962. * Vignette centre X Offset.
  30963. */
  30964. vignetteCentreX: number;
  30965. /**
  30966. * Vignette centre Y Offset.
  30967. */
  30968. vignetteCentreY: number;
  30969. /**
  30970. * Vignette weight or intensity of the vignette effect.
  30971. */
  30972. vignetteWeight: number;
  30973. /**
  30974. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  30975. * if vignetteEnabled is set to true.
  30976. */
  30977. vignetteColor: Color4;
  30978. /**
  30979. * Camera field of view used by the Vignette effect.
  30980. */
  30981. vignetteCameraFov: number;
  30982. private _vignetteBlendMode;
  30983. /**
  30984. * Gets the vignette blend mode allowing different kind of effect.
  30985. */
  30986. /**
  30987. * Sets the vignette blend mode allowing different kind of effect.
  30988. */
  30989. vignetteBlendMode: number;
  30990. private _vignetteEnabled;
  30991. /**
  30992. * Gets wether the vignette effect is enabled.
  30993. */
  30994. /**
  30995. * Sets wether the vignette effect is enabled.
  30996. */
  30997. vignetteEnabled: boolean;
  30998. private _applyByPostProcess;
  30999. /**
  31000. * Gets wether the image processing is applied through a post process or not.
  31001. */
  31002. /**
  31003. * Sets wether the image processing is applied through a post process or not.
  31004. */
  31005. applyByPostProcess: boolean;
  31006. private _isEnabled;
  31007. /**
  31008. * Gets wether the image processing is enabled or not.
  31009. */
  31010. /**
  31011. * Sets wether the image processing is enabled or not.
  31012. */
  31013. isEnabled: boolean;
  31014. /**
  31015. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  31016. */
  31017. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  31018. /**
  31019. * Method called each time the image processing information changes requires to recompile the effect.
  31020. */
  31021. protected _updateParameters(): void;
  31022. /**
  31023. * Gets the current class name.
  31024. * @return "ImageProcessingConfiguration"
  31025. */
  31026. getClassName(): string;
  31027. /**
  31028. * Prepare the list of uniforms associated with the Image Processing effects.
  31029. * @param uniforms The list of uniforms used in the effect
  31030. * @param defines the list of defines currently in use
  31031. */
  31032. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  31033. /**
  31034. * Prepare the list of samplers associated with the Image Processing effects.
  31035. * @param samplersList The list of uniforms used in the effect
  31036. * @param defines the list of defines currently in use
  31037. */
  31038. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  31039. /**
  31040. * Prepare the list of defines associated to the shader.
  31041. * @param defines the list of defines to complete
  31042. * @param forPostProcess Define if we are currently in post process mode or not
  31043. */
  31044. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  31045. /**
  31046. * Returns true if all the image processing information are ready.
  31047. * @returns True if ready, otherwise, false
  31048. */
  31049. isReady(): boolean;
  31050. /**
  31051. * Binds the image processing to the shader.
  31052. * @param effect The effect to bind to
  31053. * @param aspectRatio Define the current aspect ratio of the effect
  31054. */
  31055. bind(effect: Effect, aspectRatio?: number): void;
  31056. /**
  31057. * Clones the current image processing instance.
  31058. * @return The cloned image processing
  31059. */
  31060. clone(): ImageProcessingConfiguration;
  31061. /**
  31062. * Serializes the current image processing instance to a json representation.
  31063. * @return a JSON representation
  31064. */
  31065. serialize(): any;
  31066. /**
  31067. * Parses the image processing from a json representation.
  31068. * @param source the JSON source to parse
  31069. * @return The parsed image processing
  31070. */
  31071. static Parse(source: any): ImageProcessingConfiguration;
  31072. private static _VIGNETTEMODE_MULTIPLY;
  31073. private static _VIGNETTEMODE_OPAQUE;
  31074. /**
  31075. * Used to apply the vignette as a mix with the pixel color.
  31076. */
  31077. static readonly VIGNETTEMODE_MULTIPLY: number;
  31078. /**
  31079. * Used to apply the vignette as a replacement of the pixel color.
  31080. */
  31081. static readonly VIGNETTEMODE_OPAQUE: number;
  31082. }
  31083. }
  31084. declare module "babylonjs/Materials/fresnelParameters" {
  31085. import { Color3 } from "babylonjs/Maths/math";
  31086. /**
  31087. * This represents all the required information to add a fresnel effect on a material:
  31088. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31089. */
  31090. export class FresnelParameters {
  31091. private _isEnabled;
  31092. /**
  31093. * Define if the fresnel effect is enable or not.
  31094. */
  31095. isEnabled: boolean;
  31096. /**
  31097. * Define the color used on edges (grazing angle)
  31098. */
  31099. leftColor: Color3;
  31100. /**
  31101. * Define the color used on center
  31102. */
  31103. rightColor: Color3;
  31104. /**
  31105. * Define bias applied to computed fresnel term
  31106. */
  31107. bias: number;
  31108. /**
  31109. * Defined the power exponent applied to fresnel term
  31110. */
  31111. power: number;
  31112. /**
  31113. * Clones the current fresnel and its valuues
  31114. * @returns a clone fresnel configuration
  31115. */
  31116. clone(): FresnelParameters;
  31117. /**
  31118. * Serializes the current fresnel parameters to a JSON representation.
  31119. * @return the JSON serialization
  31120. */
  31121. serialize(): any;
  31122. /**
  31123. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  31124. * @param parsedFresnelParameters Define the JSON representation
  31125. * @returns the parsed parameters
  31126. */
  31127. static Parse(parsedFresnelParameters: any): FresnelParameters;
  31128. }
  31129. }
  31130. declare module "babylonjs/Misc/decorators" {
  31131. import { Nullable } from "babylonjs/types";
  31132. import { Scene } from "babylonjs/scene";
  31133. import { IAnimatable } from "babylonjs/Misc/tools";
  31134. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  31135. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31136. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31137. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31138. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31139. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31140. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31141. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31142. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31143. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31144. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31145. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31146. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31147. /**
  31148. * Decorator used to define property that can be serialized as reference to a camera
  31149. * @param sourceName defines the name of the property to decorate
  31150. */
  31151. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31152. /**
  31153. * Class used to help serialization objects
  31154. */
  31155. export class SerializationHelper {
  31156. /** @hidden */
  31157. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  31158. /** @hidden */
  31159. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  31160. /** @hidden */
  31161. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  31162. /** @hidden */
  31163. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  31164. /**
  31165. * Appends the serialized animations from the source animations
  31166. * @param source Source containing the animations
  31167. * @param destination Target to store the animations
  31168. */
  31169. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  31170. /**
  31171. * Static function used to serialized a specific entity
  31172. * @param entity defines the entity to serialize
  31173. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  31174. * @returns a JSON compatible object representing the serialization of the entity
  31175. */
  31176. static Serialize<T>(entity: T, serializationObject?: any): any;
  31177. /**
  31178. * Creates a new entity from a serialization data object
  31179. * @param creationFunction defines a function used to instanciated the new entity
  31180. * @param source defines the source serialization data
  31181. * @param scene defines the hosting scene
  31182. * @param rootUrl defines the root url for resources
  31183. * @returns a new entity
  31184. */
  31185. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  31186. /**
  31187. * Clones an object
  31188. * @param creationFunction defines the function used to instanciate the new object
  31189. * @param source defines the source object
  31190. * @returns the cloned object
  31191. */
  31192. static Clone<T>(creationFunction: () => T, source: T): T;
  31193. /**
  31194. * Instanciates a new object based on a source one (some data will be shared between both object)
  31195. * @param creationFunction defines the function used to instanciate the new object
  31196. * @param source defines the source object
  31197. * @returns the new object
  31198. */
  31199. static Instanciate<T>(creationFunction: () => T, source: T): T;
  31200. }
  31201. }
  31202. declare module "babylonjs/Cameras/camera" {
  31203. import { SmartArray } from "babylonjs/Misc/smartArray";
  31204. import { Observable } from "babylonjs/Misc/observable";
  31205. import { Nullable } from "babylonjs/types";
  31206. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  31207. import { Scene } from "babylonjs/scene";
  31208. import { Matrix, Vector3, Viewport } from "babylonjs/Maths/math";
  31209. import { Node } from "babylonjs/node";
  31210. import { Mesh } from "babylonjs/Meshes/mesh";
  31211. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31212. import { ICullable } from "babylonjs/Culling/boundingInfo";
  31213. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31214. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31215. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  31216. import { Ray } from "babylonjs/Culling/ray";
  31217. /**
  31218. * This is the base class of all the camera used in the application.
  31219. * @see http://doc.babylonjs.com/features/cameras
  31220. */
  31221. export class Camera extends Node {
  31222. /** @hidden */
  31223. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  31224. /**
  31225. * This is the default projection mode used by the cameras.
  31226. * It helps recreating a feeling of perspective and better appreciate depth.
  31227. * This is the best way to simulate real life cameras.
  31228. */
  31229. static readonly PERSPECTIVE_CAMERA: number;
  31230. /**
  31231. * This helps creating camera with an orthographic mode.
  31232. * 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.
  31233. */
  31234. static readonly ORTHOGRAPHIC_CAMERA: number;
  31235. /**
  31236. * This is the default FOV mode for perspective cameras.
  31237. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  31238. */
  31239. static readonly FOVMODE_VERTICAL_FIXED: number;
  31240. /**
  31241. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  31242. */
  31243. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  31244. /**
  31245. * This specifies ther is no need for a camera rig.
  31246. * Basically only one eye is rendered corresponding to the camera.
  31247. */
  31248. static readonly RIG_MODE_NONE: number;
  31249. /**
  31250. * Simulates a camera Rig with one blue eye and one red eye.
  31251. * This can be use with 3d blue and red glasses.
  31252. */
  31253. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  31254. /**
  31255. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  31256. */
  31257. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  31258. /**
  31259. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  31260. */
  31261. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  31262. /**
  31263. * Defines that both eyes of the camera will be rendered over under each other.
  31264. */
  31265. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  31266. /**
  31267. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  31268. */
  31269. static readonly RIG_MODE_VR: number;
  31270. /**
  31271. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  31272. */
  31273. static readonly RIG_MODE_WEBVR: number;
  31274. /**
  31275. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  31276. */
  31277. static readonly RIG_MODE_CUSTOM: number;
  31278. /**
  31279. * Defines if by default attaching controls should prevent the default javascript event to continue.
  31280. */
  31281. static ForceAttachControlToAlwaysPreventDefault: boolean;
  31282. /**
  31283. * Define the input manager associated with the camera.
  31284. */
  31285. inputs: CameraInputsManager<Camera>;
  31286. /** @hidden */
  31287. _position: Vector3;
  31288. /**
  31289. * Define the current local position of the camera in the scene
  31290. */
  31291. position: Vector3;
  31292. /**
  31293. * The vector the camera should consider as up.
  31294. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  31295. */
  31296. upVector: Vector3;
  31297. /**
  31298. * Define the current limit on the left side for an orthographic camera
  31299. * In scene unit
  31300. */
  31301. orthoLeft: Nullable<number>;
  31302. /**
  31303. * Define the current limit on the right side for an orthographic camera
  31304. * In scene unit
  31305. */
  31306. orthoRight: Nullable<number>;
  31307. /**
  31308. * Define the current limit on the bottom side for an orthographic camera
  31309. * In scene unit
  31310. */
  31311. orthoBottom: Nullable<number>;
  31312. /**
  31313. * Define the current limit on the top side for an orthographic camera
  31314. * In scene unit
  31315. */
  31316. orthoTop: Nullable<number>;
  31317. /**
  31318. * Field Of View is set in Radians. (default is 0.8)
  31319. */
  31320. fov: number;
  31321. /**
  31322. * Define the minimum distance the camera can see from.
  31323. * This is important to note that the depth buffer are not infinite and the closer it starts
  31324. * the more your scene might encounter depth fighting issue.
  31325. */
  31326. minZ: number;
  31327. /**
  31328. * Define the maximum distance the camera can see to.
  31329. * This is important to note that the depth buffer are not infinite and the further it end
  31330. * the more your scene might encounter depth fighting issue.
  31331. */
  31332. maxZ: number;
  31333. /**
  31334. * Define the default inertia of the camera.
  31335. * This helps giving a smooth feeling to the camera movement.
  31336. */
  31337. inertia: number;
  31338. /**
  31339. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  31340. */
  31341. mode: number;
  31342. /**
  31343. * Define wether the camera is intermediate.
  31344. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  31345. */
  31346. isIntermediate: boolean;
  31347. /**
  31348. * Define the viewport of the camera.
  31349. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  31350. */
  31351. viewport: Viewport;
  31352. /**
  31353. * Restricts the camera to viewing objects with the same layerMask.
  31354. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  31355. */
  31356. layerMask: number;
  31357. /**
  31358. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  31359. */
  31360. fovMode: number;
  31361. /**
  31362. * Rig mode of the camera.
  31363. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  31364. * This is normally controlled byt the camera themselves as internal use.
  31365. */
  31366. cameraRigMode: number;
  31367. /**
  31368. * Defines the distance between both "eyes" in case of a RIG
  31369. */
  31370. interaxialDistance: number;
  31371. /**
  31372. * Defines if stereoscopic rendering is done side by side or over under.
  31373. */
  31374. isStereoscopicSideBySide: boolean;
  31375. /**
  31376. * 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
  31377. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  31378. * else in the scene.
  31379. */
  31380. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  31381. /**
  31382. * When set, the camera will render to this render target instead of the default canvas
  31383. */
  31384. outputRenderTarget: Nullable<RenderTargetTexture>;
  31385. /**
  31386. * Observable triggered when the camera view matrix has changed.
  31387. */
  31388. onViewMatrixChangedObservable: Observable<Camera>;
  31389. /**
  31390. * Observable triggered when the camera Projection matrix has changed.
  31391. */
  31392. onProjectionMatrixChangedObservable: Observable<Camera>;
  31393. /**
  31394. * Observable triggered when the inputs have been processed.
  31395. */
  31396. onAfterCheckInputsObservable: Observable<Camera>;
  31397. /**
  31398. * Observable triggered when reset has been called and applied to the camera.
  31399. */
  31400. onRestoreStateObservable: Observable<Camera>;
  31401. /** @hidden */
  31402. _cameraRigParams: any;
  31403. /** @hidden */
  31404. _rigCameras: Camera[];
  31405. /** @hidden */
  31406. _rigPostProcess: Nullable<PostProcess>;
  31407. protected _webvrViewMatrix: Matrix;
  31408. /** @hidden */
  31409. _skipRendering: boolean;
  31410. /** @hidden */
  31411. _projectionMatrix: Matrix;
  31412. /** @hidden */
  31413. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  31414. /** @hidden */
  31415. _activeMeshes: SmartArray<AbstractMesh>;
  31416. protected _globalPosition: Vector3;
  31417. /** @hidden */
  31418. _computedViewMatrix: Matrix;
  31419. private _doNotComputeProjectionMatrix;
  31420. private _transformMatrix;
  31421. private _frustumPlanes;
  31422. private _refreshFrustumPlanes;
  31423. private _storedFov;
  31424. private _stateStored;
  31425. /**
  31426. * Instantiates a new camera object.
  31427. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  31428. * @see http://doc.babylonjs.com/features/cameras
  31429. * @param name Defines the name of the camera in the scene
  31430. * @param position Defines the position of the camera
  31431. * @param scene Defines the scene the camera belongs too
  31432. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  31433. */
  31434. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  31435. /**
  31436. * Store current camera state (fov, position, etc..)
  31437. * @returns the camera
  31438. */
  31439. storeState(): Camera;
  31440. /**
  31441. * Restores the camera state values if it has been stored. You must call storeState() first
  31442. */
  31443. protected _restoreStateValues(): boolean;
  31444. /**
  31445. * Restored camera state. You must call storeState() first.
  31446. * @returns true if restored and false otherwise
  31447. */
  31448. restoreState(): boolean;
  31449. /**
  31450. * Gets the class name of the camera.
  31451. * @returns the class name
  31452. */
  31453. getClassName(): string;
  31454. /** @hidden */
  31455. readonly _isCamera: boolean;
  31456. /**
  31457. * Gets a string representation of the camera useful for debug purpose.
  31458. * @param fullDetails Defines that a more verboe level of logging is required
  31459. * @returns the string representation
  31460. */
  31461. toString(fullDetails?: boolean): string;
  31462. /**
  31463. * Gets the current world space position of the camera.
  31464. */
  31465. readonly globalPosition: Vector3;
  31466. /**
  31467. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  31468. * @returns the active meshe list
  31469. */
  31470. getActiveMeshes(): SmartArray<AbstractMesh>;
  31471. /**
  31472. * Check wether a mesh is part of the current active mesh list of the camera
  31473. * @param mesh Defines the mesh to check
  31474. * @returns true if active, false otherwise
  31475. */
  31476. isActiveMesh(mesh: Mesh): boolean;
  31477. /**
  31478. * Is this camera ready to be used/rendered
  31479. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  31480. * @return true if the camera is ready
  31481. */
  31482. isReady(completeCheck?: boolean): boolean;
  31483. /** @hidden */
  31484. _initCache(): void;
  31485. /** @hidden */
  31486. _updateCache(ignoreParentClass?: boolean): void;
  31487. /** @hidden */
  31488. _isSynchronized(): boolean;
  31489. /** @hidden */
  31490. _isSynchronizedViewMatrix(): boolean;
  31491. /** @hidden */
  31492. _isSynchronizedProjectionMatrix(): boolean;
  31493. /**
  31494. * Attach the input controls to a specific dom element to get the input from.
  31495. * @param element Defines the element the controls should be listened from
  31496. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  31497. */
  31498. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31499. /**
  31500. * Detach the current controls from the specified dom element.
  31501. * @param element Defines the element to stop listening the inputs from
  31502. */
  31503. detachControl(element: HTMLElement): void;
  31504. /**
  31505. * Update the camera state according to the different inputs gathered during the frame.
  31506. */
  31507. update(): void;
  31508. /** @hidden */
  31509. _checkInputs(): void;
  31510. /** @hidden */
  31511. readonly rigCameras: Camera[];
  31512. /**
  31513. * Gets the post process used by the rig cameras
  31514. */
  31515. readonly rigPostProcess: Nullable<PostProcess>;
  31516. /**
  31517. * Internal, gets the first post proces.
  31518. * @returns the first post process to be run on this camera.
  31519. */
  31520. _getFirstPostProcess(): Nullable<PostProcess>;
  31521. private _cascadePostProcessesToRigCams;
  31522. /**
  31523. * Attach a post process to the camera.
  31524. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31525. * @param postProcess The post process to attach to the camera
  31526. * @param insertAt The position of the post process in case several of them are in use in the scene
  31527. * @returns the position the post process has been inserted at
  31528. */
  31529. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  31530. /**
  31531. * Detach a post process to the camera.
  31532. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31533. * @param postProcess The post process to detach from the camera
  31534. */
  31535. detachPostProcess(postProcess: PostProcess): void;
  31536. /**
  31537. * Gets the current world matrix of the camera
  31538. */
  31539. getWorldMatrix(): Matrix;
  31540. /** @hidden */
  31541. _getViewMatrix(): Matrix;
  31542. /**
  31543. * Gets the current view matrix of the camera.
  31544. * @param force forces the camera to recompute the matrix without looking at the cached state
  31545. * @returns the view matrix
  31546. */
  31547. getViewMatrix(force?: boolean): Matrix;
  31548. /**
  31549. * Freeze the projection matrix.
  31550. * It will prevent the cache check of the camera projection compute and can speed up perf
  31551. * if no parameter of the camera are meant to change
  31552. * @param projection Defines manually a projection if necessary
  31553. */
  31554. freezeProjectionMatrix(projection?: Matrix): void;
  31555. /**
  31556. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  31557. */
  31558. unfreezeProjectionMatrix(): void;
  31559. /**
  31560. * Gets the current projection matrix of the camera.
  31561. * @param force forces the camera to recompute the matrix without looking at the cached state
  31562. * @returns the projection matrix
  31563. */
  31564. getProjectionMatrix(force?: boolean): Matrix;
  31565. /**
  31566. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  31567. * @returns a Matrix
  31568. */
  31569. getTransformationMatrix(): Matrix;
  31570. private _updateFrustumPlanes;
  31571. /**
  31572. * Checks if a cullable object (mesh...) is in the camera frustum
  31573. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  31574. * @param target The object to check
  31575. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  31576. * @returns true if the object is in frustum otherwise false
  31577. */
  31578. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  31579. /**
  31580. * Checks if a cullable object (mesh...) is in the camera frustum
  31581. * Unlike isInFrustum this cheks the full bounding box
  31582. * @param target The object to check
  31583. * @returns true if the object is in frustum otherwise false
  31584. */
  31585. isCompletelyInFrustum(target: ICullable): boolean;
  31586. /**
  31587. * Gets a ray in the forward direction from the camera.
  31588. * @param length Defines the length of the ray to create
  31589. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  31590. * @param origin Defines the start point of the ray which defaults to the camera position
  31591. * @returns the forward ray
  31592. */
  31593. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  31594. /**
  31595. * Releases resources associated with this node.
  31596. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  31597. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  31598. */
  31599. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  31600. /** @hidden */
  31601. _isLeftCamera: boolean;
  31602. /**
  31603. * Gets the left camera of a rig setup in case of Rigged Camera
  31604. */
  31605. readonly isLeftCamera: boolean;
  31606. /** @hidden */
  31607. _isRightCamera: boolean;
  31608. /**
  31609. * Gets the right camera of a rig setup in case of Rigged Camera
  31610. */
  31611. readonly isRightCamera: boolean;
  31612. /**
  31613. * Gets the left camera of a rig setup in case of Rigged Camera
  31614. */
  31615. readonly leftCamera: Nullable<FreeCamera>;
  31616. /**
  31617. * Gets the right camera of a rig setup in case of Rigged Camera
  31618. */
  31619. readonly rightCamera: Nullable<FreeCamera>;
  31620. /**
  31621. * Gets the left camera target of a rig setup in case of Rigged Camera
  31622. * @returns the target position
  31623. */
  31624. getLeftTarget(): Nullable<Vector3>;
  31625. /**
  31626. * Gets the right camera target of a rig setup in case of Rigged Camera
  31627. * @returns the target position
  31628. */
  31629. getRightTarget(): Nullable<Vector3>;
  31630. /**
  31631. * @hidden
  31632. */
  31633. setCameraRigMode(mode: number, rigParams: any): void;
  31634. /** @hidden */
  31635. static _setStereoscopicRigMode(camera: Camera): void;
  31636. /** @hidden */
  31637. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  31638. /** @hidden */
  31639. static _setVRRigMode(camera: Camera, rigParams: any): void;
  31640. /** @hidden */
  31641. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  31642. /** @hidden */
  31643. _getVRProjectionMatrix(): Matrix;
  31644. protected _updateCameraRotationMatrix(): void;
  31645. protected _updateWebVRCameraRotationMatrix(): void;
  31646. /**
  31647. * This function MUST be overwritten by the different WebVR cameras available.
  31648. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31649. * @hidden
  31650. */
  31651. _getWebVRProjectionMatrix(): Matrix;
  31652. /**
  31653. * This function MUST be overwritten by the different WebVR cameras available.
  31654. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31655. * @hidden
  31656. */
  31657. _getWebVRViewMatrix(): Matrix;
  31658. /** @hidden */
  31659. setCameraRigParameter(name: string, value: any): void;
  31660. /**
  31661. * needs to be overridden by children so sub has required properties to be copied
  31662. * @hidden
  31663. */
  31664. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  31665. /**
  31666. * May need to be overridden by children
  31667. * @hidden
  31668. */
  31669. _updateRigCameras(): void;
  31670. /** @hidden */
  31671. _setupInputs(): void;
  31672. /**
  31673. * Serialiaze the camera setup to a json represention
  31674. * @returns the JSON representation
  31675. */
  31676. serialize(): any;
  31677. /**
  31678. * Clones the current camera.
  31679. * @param name The cloned camera name
  31680. * @returns the cloned camera
  31681. */
  31682. clone(name: string): Camera;
  31683. /**
  31684. * Gets the direction of the camera relative to a given local axis.
  31685. * @param localAxis Defines the reference axis to provide a relative direction.
  31686. * @return the direction
  31687. */
  31688. getDirection(localAxis: Vector3): Vector3;
  31689. /**
  31690. * Gets the direction of the camera relative to a given local axis into a passed vector.
  31691. * @param localAxis Defines the reference axis to provide a relative direction.
  31692. * @param result Defines the vector to store the result in
  31693. */
  31694. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  31695. /**
  31696. * Gets a camera constructor for a given camera type
  31697. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  31698. * @param name The name of the camera the result will be able to instantiate
  31699. * @param scene The scene the result will construct the camera in
  31700. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  31701. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  31702. * @returns a factory method to construc the camera
  31703. */
  31704. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  31705. /**
  31706. * Compute the world matrix of the camera.
  31707. * @returns the camera workd matrix
  31708. */
  31709. computeWorldMatrix(): Matrix;
  31710. /**
  31711. * Parse a JSON and creates the camera from the parsed information
  31712. * @param parsedCamera The JSON to parse
  31713. * @param scene The scene to instantiate the camera in
  31714. * @returns the newly constructed camera
  31715. */
  31716. static Parse(parsedCamera: any, scene: Scene): Camera;
  31717. }
  31718. }
  31719. declare module "babylonjs/Misc/tools" {
  31720. import { FloatArray, IndicesArray, Nullable } from "babylonjs/types";
  31721. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  31722. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31723. import { Observable } from "babylonjs/Misc/observable";
  31724. import { DomManagement } from "babylonjs/Misc/domManagement";
  31725. import { WebRequest } from "babylonjs/Misc/webRequest";
  31726. import { Camera } from "babylonjs/Cameras/camera";
  31727. import { Engine } from "babylonjs/Engines/engine";
  31728. import { Animation } from "babylonjs/Animations/animation";
  31729. /**
  31730. * Interface for any object that can request an animation frame
  31731. */
  31732. export interface ICustomAnimationFrameRequester {
  31733. /**
  31734. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31735. */
  31736. renderFunction?: Function;
  31737. /**
  31738. * Called to request the next frame to render to
  31739. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31740. */
  31741. requestAnimationFrame: Function;
  31742. /**
  31743. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31744. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31745. */
  31746. requestID?: number;
  31747. }
  31748. /**
  31749. * Interface containing an array of animations
  31750. */
  31751. export interface IAnimatable {
  31752. /**
  31753. * Array of animations
  31754. */
  31755. animations: Nullable<Array<Animation>>;
  31756. }
  31757. /** Interface used by value gradients (color, factor, ...) */
  31758. export interface IValueGradient {
  31759. /**
  31760. * Gets or sets the gradient value (between 0 and 1)
  31761. */
  31762. gradient: number;
  31763. }
  31764. /** Class used to store color4 gradient */
  31765. export class ColorGradient implements IValueGradient {
  31766. /**
  31767. * Gets or sets the gradient value (between 0 and 1)
  31768. */
  31769. gradient: number;
  31770. /**
  31771. * Gets or sets first associated color
  31772. */
  31773. color1: Color4;
  31774. /**
  31775. * Gets or sets second associated color
  31776. */
  31777. color2?: Color4;
  31778. /**
  31779. * Will get a color picked randomly between color1 and color2.
  31780. * If color2 is undefined then color1 will be used
  31781. * @param result defines the target Color4 to store the result in
  31782. */
  31783. getColorToRef(result: Color4): void;
  31784. }
  31785. /** Class used to store color 3 gradient */
  31786. export class Color3Gradient implements IValueGradient {
  31787. /**
  31788. * Gets or sets the gradient value (between 0 and 1)
  31789. */
  31790. gradient: number;
  31791. /**
  31792. * Gets or sets the associated color
  31793. */
  31794. color: Color3;
  31795. }
  31796. /** Class used to store factor gradient */
  31797. export class FactorGradient implements IValueGradient {
  31798. /**
  31799. * Gets or sets the gradient value (between 0 and 1)
  31800. */
  31801. gradient: number;
  31802. /**
  31803. * Gets or sets first associated factor
  31804. */
  31805. factor1: number;
  31806. /**
  31807. * Gets or sets second associated factor
  31808. */
  31809. factor2?: number;
  31810. /**
  31811. * Will get a number picked randomly between factor1 and factor2.
  31812. * If factor2 is undefined then factor1 will be used
  31813. * @returns the picked number
  31814. */
  31815. getFactor(): number;
  31816. }
  31817. /**
  31818. * @ignore
  31819. * Application error to support additional information when loading a file
  31820. */
  31821. export class LoadFileError extends Error {
  31822. /** defines the optional web request */
  31823. request?: WebRequest | undefined;
  31824. private static _setPrototypeOf;
  31825. /**
  31826. * Creates a new LoadFileError
  31827. * @param message defines the message of the error
  31828. * @param request defines the optional web request
  31829. */
  31830. constructor(message: string,
  31831. /** defines the optional web request */
  31832. request?: WebRequest | undefined);
  31833. }
  31834. /**
  31835. * Class used to define a retry strategy when error happens while loading assets
  31836. */
  31837. export class RetryStrategy {
  31838. /**
  31839. * Function used to defines an exponential back off strategy
  31840. * @param maxRetries defines the maximum number of retries (3 by default)
  31841. * @param baseInterval defines the interval between retries
  31842. * @returns the strategy function to use
  31843. */
  31844. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  31845. }
  31846. /**
  31847. * File request interface
  31848. */
  31849. export interface IFileRequest {
  31850. /**
  31851. * Raised when the request is complete (success or error).
  31852. */
  31853. onCompleteObservable: Observable<IFileRequest>;
  31854. /**
  31855. * Aborts the request for a file.
  31856. */
  31857. abort: () => void;
  31858. }
  31859. /**
  31860. * Class containing a set of static utilities functions
  31861. */
  31862. export class Tools {
  31863. /**
  31864. * Gets or sets the base URL to use to load assets
  31865. */
  31866. static BaseUrl: string;
  31867. /**
  31868. * Enable/Disable Custom HTTP Request Headers globally.
  31869. * default = false
  31870. * @see CustomRequestHeaders
  31871. */
  31872. static UseCustomRequestHeaders: boolean;
  31873. /**
  31874. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31875. * i.e. when loading files, where the server/service expects an Authorization header
  31876. */
  31877. static CustomRequestHeaders: {
  31878. [key: string]: string;
  31879. };
  31880. /**
  31881. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31882. */
  31883. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31884. /**
  31885. * Default behaviour for cors in the application.
  31886. * It can be a string if the expected behavior is identical in the entire app.
  31887. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31888. */
  31889. static CorsBehavior: string | ((url: string | string[]) => string);
  31890. /**
  31891. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31892. * @ignorenaming
  31893. */
  31894. static UseFallbackTexture: boolean;
  31895. /**
  31896. * Use this object to register external classes like custom textures or material
  31897. * to allow the laoders to instantiate them
  31898. */
  31899. static RegisteredExternalClasses: {
  31900. [key: string]: Object;
  31901. };
  31902. /**
  31903. * Texture content used if a texture cannot loaded
  31904. * @ignorenaming
  31905. */
  31906. static fallbackTexture: string;
  31907. /**
  31908. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31909. * @param u defines the coordinate on X axis
  31910. * @param v defines the coordinate on Y axis
  31911. * @param width defines the width of the source data
  31912. * @param height defines the height of the source data
  31913. * @param pixels defines the source byte array
  31914. * @param color defines the output color
  31915. */
  31916. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  31917. /**
  31918. * Interpolates between a and b via alpha
  31919. * @param a The lower value (returned when alpha = 0)
  31920. * @param b The upper value (returned when alpha = 1)
  31921. * @param alpha The interpolation-factor
  31922. * @return The mixed value
  31923. */
  31924. static Mix(a: number, b: number, alpha: number): number;
  31925. /**
  31926. * Tries to instantiate a new object from a given class name
  31927. * @param className defines the class name to instantiate
  31928. * @returns the new object or null if the system was not able to do the instantiation
  31929. */
  31930. static Instantiate(className: string): any;
  31931. /**
  31932. * Provides a slice function that will work even on IE
  31933. * @param data defines the array to slice
  31934. * @param start defines the start of the data (optional)
  31935. * @param end defines the end of the data (optional)
  31936. * @returns the new sliced array
  31937. */
  31938. static Slice<T>(data: T, start?: number, end?: number): T;
  31939. /**
  31940. * Polyfill for setImmediate
  31941. * @param action defines the action to execute after the current execution block
  31942. */
  31943. static SetImmediate(action: () => void): void;
  31944. /**
  31945. * Function indicating if a number is an exponent of 2
  31946. * @param value defines the value to test
  31947. * @returns true if the value is an exponent of 2
  31948. */
  31949. static IsExponentOfTwo(value: number): boolean;
  31950. private static _tmpFloatArray;
  31951. /**
  31952. * Returns the nearest 32-bit single precision float representation of a Number
  31953. * @param value A Number. If the parameter is of a different type, it will get converted
  31954. * to a number or to NaN if it cannot be converted
  31955. * @returns number
  31956. */
  31957. static FloatRound(value: number): number;
  31958. /**
  31959. * Find the next highest power of two.
  31960. * @param x Number to start search from.
  31961. * @return Next highest power of two.
  31962. */
  31963. static CeilingPOT(x: number): number;
  31964. /**
  31965. * Find the next lowest power of two.
  31966. * @param x Number to start search from.
  31967. * @return Next lowest power of two.
  31968. */
  31969. static FloorPOT(x: number): number;
  31970. /**
  31971. * Find the nearest power of two.
  31972. * @param x Number to start search from.
  31973. * @return Next nearest power of two.
  31974. */
  31975. static NearestPOT(x: number): number;
  31976. /**
  31977. * Get the closest exponent of two
  31978. * @param value defines the value to approximate
  31979. * @param max defines the maximum value to return
  31980. * @param mode defines how to define the closest value
  31981. * @returns closest exponent of two of the given value
  31982. */
  31983. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31984. /**
  31985. * Extracts the filename from a path
  31986. * @param path defines the path to use
  31987. * @returns the filename
  31988. */
  31989. static GetFilename(path: string): string;
  31990. /**
  31991. * Extracts the "folder" part of a path (everything before the filename).
  31992. * @param uri The URI to extract the info from
  31993. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31994. * @returns The "folder" part of the path
  31995. */
  31996. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31997. /**
  31998. * Extracts text content from a DOM element hierarchy
  31999. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  32000. */
  32001. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  32002. /**
  32003. * Convert an angle in radians to degrees
  32004. * @param angle defines the angle to convert
  32005. * @returns the angle in degrees
  32006. */
  32007. static ToDegrees(angle: number): number;
  32008. /**
  32009. * Convert an angle in degrees to radians
  32010. * @param angle defines the angle to convert
  32011. * @returns the angle in radians
  32012. */
  32013. static ToRadians(angle: number): number;
  32014. /**
  32015. * Encode a buffer to a base64 string
  32016. * @param buffer defines the buffer to encode
  32017. * @returns the encoded string
  32018. */
  32019. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  32020. /**
  32021. * Extracts minimum and maximum values from a list of indexed positions
  32022. * @param positions defines the positions to use
  32023. * @param indices defines the indices to the positions
  32024. * @param indexStart defines the start index
  32025. * @param indexCount defines the end index
  32026. * @param bias defines bias value to add to the result
  32027. * @return minimum and maximum values
  32028. */
  32029. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  32030. minimum: Vector3;
  32031. maximum: Vector3;
  32032. };
  32033. /**
  32034. * Extracts minimum and maximum values from a list of positions
  32035. * @param positions defines the positions to use
  32036. * @param start defines the start index in the positions array
  32037. * @param count defines the number of positions to handle
  32038. * @param bias defines bias value to add to the result
  32039. * @param stride defines the stride size to use (distance between two positions in the positions array)
  32040. * @return minimum and maximum values
  32041. */
  32042. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  32043. minimum: Vector3;
  32044. maximum: Vector3;
  32045. };
  32046. /**
  32047. * Returns an array if obj is not an array
  32048. * @param obj defines the object to evaluate as an array
  32049. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  32050. * @returns either obj directly if obj is an array or a new array containing obj
  32051. */
  32052. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  32053. /**
  32054. * Gets the pointer prefix to use
  32055. * @returns "pointer" if touch is enabled. Else returns "mouse"
  32056. */
  32057. static GetPointerPrefix(): string;
  32058. /**
  32059. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32060. * @param func - the function to be called
  32061. * @param requester - the object that will request the next frame. Falls back to window.
  32062. * @returns frame number
  32063. */
  32064. static QueueNewFrame(func: () => void, requester?: any): number;
  32065. /**
  32066. * Ask the browser to promote the current element to fullscreen rendering mode
  32067. * @param element defines the DOM element to promote
  32068. */
  32069. static RequestFullscreen(element: HTMLElement): void;
  32070. /**
  32071. * Asks the browser to exit fullscreen mode
  32072. */
  32073. static ExitFullscreen(): void;
  32074. /**
  32075. * Ask the browser to promote the current element to pointerlock mode
  32076. * @param element defines the DOM element to promote
  32077. */
  32078. static RequestPointerlock(element: HTMLElement): void;
  32079. /**
  32080. * Asks the browser to exit pointerlock mode
  32081. */
  32082. static ExitPointerlock(): void;
  32083. /**
  32084. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  32085. * @param url define the url we are trying
  32086. * @param element define the dom element where to configure the cors policy
  32087. */
  32088. static SetCorsBehavior(url: string | string[], element: {
  32089. crossOrigin: string | null;
  32090. }): void;
  32091. /**
  32092. * Removes unwanted characters from an url
  32093. * @param url defines the url to clean
  32094. * @returns the cleaned url
  32095. */
  32096. static CleanUrl(url: string): string;
  32097. /**
  32098. * Gets or sets a function used to pre-process url before using them to load assets
  32099. */
  32100. static PreprocessUrl: (url: string) => string;
  32101. /**
  32102. * Loads an image as an HTMLImageElement.
  32103. * @param input url string, ArrayBuffer, or Blob to load
  32104. * @param onLoad callback called when the image successfully loads
  32105. * @param onError callback called when the image fails to load
  32106. * @param offlineProvider offline provider for caching
  32107. * @returns the HTMLImageElement of the loaded image
  32108. */
  32109. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  32110. /**
  32111. * Loads a file
  32112. * @param url url string, ArrayBuffer, or Blob to load
  32113. * @param onSuccess callback called when the file successfully loads
  32114. * @param onProgress callback called while file is loading (if the server supports this mode)
  32115. * @param offlineProvider defines the offline provider for caching
  32116. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32117. * @param onError callback called when the file fails to load
  32118. * @returns a file request object
  32119. */
  32120. 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;
  32121. /**
  32122. * Load a script (identified by an url). When the url returns, the
  32123. * content of this file is added into a new script element, attached to the DOM (body element)
  32124. * @param scriptUrl defines the url of the script to laod
  32125. * @param onSuccess defines the callback called when the script is loaded
  32126. * @param onError defines the callback to call if an error occurs
  32127. * @param scriptId defines the id of the script element
  32128. */
  32129. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  32130. /**
  32131. * Load an asynchronous script (identified by an url). When the url returns, the
  32132. * content of this file is added into a new script element, attached to the DOM (body element)
  32133. * @param scriptUrl defines the url of the script to laod
  32134. * @param scriptId defines the id of the script element
  32135. * @returns a promise request object
  32136. */
  32137. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  32138. /**
  32139. * Loads a file from a blob
  32140. * @param fileToLoad defines the blob to use
  32141. * @param callback defines the callback to call when data is loaded
  32142. * @param progressCallback defines the callback to call during loading process
  32143. * @returns a file request object
  32144. */
  32145. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  32146. /**
  32147. * Loads a file
  32148. * @param fileToLoad defines the file to load
  32149. * @param callback defines the callback to call when data is loaded
  32150. * @param progressCallBack defines the callback to call during loading process
  32151. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  32152. * @returns a file request object
  32153. */
  32154. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  32155. /**
  32156. * Creates a data url from a given string content
  32157. * @param content defines the content to convert
  32158. * @returns the new data url link
  32159. */
  32160. static FileAsURL(content: string): string;
  32161. /**
  32162. * Format the given number to a specific decimal format
  32163. * @param value defines the number to format
  32164. * @param decimals defines the number of decimals to use
  32165. * @returns the formatted string
  32166. */
  32167. static Format(value: number, decimals?: number): string;
  32168. /**
  32169. * Checks if a given vector is inside a specific range
  32170. * @param v defines the vector to test
  32171. * @param min defines the minimum range
  32172. * @param max defines the maximum range
  32173. */
  32174. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  32175. /**
  32176. * Tries to copy an object by duplicating every property
  32177. * @param source defines the source object
  32178. * @param destination defines the target object
  32179. * @param doNotCopyList defines a list of properties to avoid
  32180. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  32181. */
  32182. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  32183. /**
  32184. * Gets a boolean indicating if the given object has no own property
  32185. * @param obj defines the object to test
  32186. * @returns true if object has no own property
  32187. */
  32188. static IsEmpty(obj: any): boolean;
  32189. /**
  32190. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  32191. * @param str Source string
  32192. * @param suffix Suffix to search for in the source string
  32193. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  32194. */
  32195. static EndsWith(str: string, suffix: string): boolean;
  32196. /**
  32197. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  32198. * @param str Source string
  32199. * @param suffix Suffix to search for in the source string
  32200. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  32201. */
  32202. static StartsWith(str: string, suffix: string): boolean;
  32203. /**
  32204. * Function used to register events at window level
  32205. * @param events defines the events to register
  32206. */
  32207. static RegisterTopRootEvents(events: {
  32208. name: string;
  32209. handler: Nullable<(e: FocusEvent) => any>;
  32210. }[]): void;
  32211. /**
  32212. * Function used to unregister events from window level
  32213. * @param events defines the events to unregister
  32214. */
  32215. static UnregisterTopRootEvents(events: {
  32216. name: string;
  32217. handler: Nullable<(e: FocusEvent) => any>;
  32218. }[]): void;
  32219. /**
  32220. * @ignore
  32221. */
  32222. static _ScreenshotCanvas: HTMLCanvasElement;
  32223. /**
  32224. * Dumps the current bound framebuffer
  32225. * @param width defines the rendering width
  32226. * @param height defines the rendering height
  32227. * @param engine defines the hosting engine
  32228. * @param successCallback defines the callback triggered once the data are available
  32229. * @param mimeType defines the mime type of the result
  32230. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  32231. */
  32232. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32233. /**
  32234. * Converts the canvas data to blob.
  32235. * This acts as a polyfill for browsers not supporting the to blob function.
  32236. * @param canvas Defines the canvas to extract the data from
  32237. * @param successCallback Defines the callback triggered once the data are available
  32238. * @param mimeType Defines the mime type of the result
  32239. */
  32240. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  32241. /**
  32242. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  32243. * @param successCallback defines the callback triggered once the data are available
  32244. * @param mimeType defines the mime type of the result
  32245. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  32246. */
  32247. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32248. /**
  32249. * Downloads a blob in the browser
  32250. * @param blob defines the blob to download
  32251. * @param fileName defines the name of the downloaded file
  32252. */
  32253. static Download(blob: Blob, fileName: string): void;
  32254. /**
  32255. * Captures a screenshot of the current rendering
  32256. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32257. * @param engine defines the rendering engine
  32258. * @param camera defines the source camera
  32259. * @param size This parameter can be set to a single number or to an object with the
  32260. * following (optional) properties: precision, width, height. If a single number is passed,
  32261. * it will be used for both width and height. If an object is passed, the screenshot size
  32262. * will be derived from the parameters. The precision property is a multiplier allowing
  32263. * rendering at a higher or lower resolution
  32264. * @param successCallback defines the callback receives a single parameter which contains the
  32265. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32266. * src parameter of an <img> to display it
  32267. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32268. * Check your browser for supported MIME types
  32269. */
  32270. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  32271. /**
  32272. * Generates an image screenshot from the specified camera.
  32273. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32274. * @param engine The engine to use for rendering
  32275. * @param camera The camera to use for rendering
  32276. * @param size This parameter can be set to a single number or to an object with the
  32277. * following (optional) properties: precision, width, height. If a single number is passed,
  32278. * it will be used for both width and height. If an object is passed, the screenshot size
  32279. * will be derived from the parameters. The precision property is a multiplier allowing
  32280. * rendering at a higher or lower resolution
  32281. * @param successCallback The callback receives a single parameter which contains the
  32282. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32283. * src parameter of an <img> to display it
  32284. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32285. * Check your browser for supported MIME types
  32286. * @param samples Texture samples (default: 1)
  32287. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32288. * @param fileName A name for for the downloaded file.
  32289. */
  32290. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32291. /**
  32292. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32293. * Be aware Math.random() could cause collisions, but:
  32294. * "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"
  32295. * @returns a pseudo random id
  32296. */
  32297. static RandomId(): string;
  32298. /**
  32299. * Test if the given uri is a base64 string
  32300. * @param uri The uri to test
  32301. * @return True if the uri is a base64 string or false otherwise
  32302. */
  32303. static IsBase64(uri: string): boolean;
  32304. /**
  32305. * Decode the given base64 uri.
  32306. * @param uri The uri to decode
  32307. * @return The decoded base64 data.
  32308. */
  32309. static DecodeBase64(uri: string): ArrayBuffer;
  32310. /**
  32311. * Gets the absolute url.
  32312. * @param url the input url
  32313. * @return the absolute url
  32314. */
  32315. static GetAbsoluteUrl(url: string): string;
  32316. /**
  32317. * No log
  32318. */
  32319. static readonly NoneLogLevel: number;
  32320. /**
  32321. * Only message logs
  32322. */
  32323. static readonly MessageLogLevel: number;
  32324. /**
  32325. * Only warning logs
  32326. */
  32327. static readonly WarningLogLevel: number;
  32328. /**
  32329. * Only error logs
  32330. */
  32331. static readonly ErrorLogLevel: number;
  32332. /**
  32333. * All logs
  32334. */
  32335. static readonly AllLogLevel: number;
  32336. /**
  32337. * Gets a value indicating the number of loading errors
  32338. * @ignorenaming
  32339. */
  32340. static readonly errorsCount: number;
  32341. /**
  32342. * Callback called when a new log is added
  32343. */
  32344. static OnNewCacheEntry: (entry: string) => void;
  32345. /**
  32346. * Log a message to the console
  32347. * @param message defines the message to log
  32348. */
  32349. static Log(message: string): void;
  32350. /**
  32351. * Write a warning message to the console
  32352. * @param message defines the message to log
  32353. */
  32354. static Warn(message: string): void;
  32355. /**
  32356. * Write an error message to the console
  32357. * @param message defines the message to log
  32358. */
  32359. static Error(message: string): void;
  32360. /**
  32361. * Gets current log cache (list of logs)
  32362. */
  32363. static readonly LogCache: string;
  32364. /**
  32365. * Clears the log cache
  32366. */
  32367. static ClearLogCache(): void;
  32368. /**
  32369. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  32370. */
  32371. static LogLevels: number;
  32372. /**
  32373. * Checks if the loaded document was accessed via `file:`-Protocol.
  32374. * @returns boolean
  32375. */
  32376. static IsFileURL(): boolean;
  32377. /**
  32378. * Checks if the window object exists
  32379. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  32380. */
  32381. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  32382. /**
  32383. * No performance log
  32384. */
  32385. static readonly PerformanceNoneLogLevel: number;
  32386. /**
  32387. * Use user marks to log performance
  32388. */
  32389. static readonly PerformanceUserMarkLogLevel: number;
  32390. /**
  32391. * Log performance to the console
  32392. */
  32393. static readonly PerformanceConsoleLogLevel: number;
  32394. private static _performance;
  32395. /**
  32396. * Sets the current performance log level
  32397. */
  32398. static PerformanceLogLevel: number;
  32399. private static _StartPerformanceCounterDisabled;
  32400. private static _EndPerformanceCounterDisabled;
  32401. private static _StartUserMark;
  32402. private static _EndUserMark;
  32403. private static _StartPerformanceConsole;
  32404. private static _EndPerformanceConsole;
  32405. /**
  32406. * Starts a performance counter
  32407. */
  32408. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32409. /**
  32410. * Ends a specific performance coutner
  32411. */
  32412. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32413. /**
  32414. * Gets either window.performance.now() if supported or Date.now() else
  32415. */
  32416. static readonly Now: number;
  32417. /**
  32418. * This method will return the name of the class used to create the instance of the given object.
  32419. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32420. * @param object the object to get the class name from
  32421. * @param isType defines if the object is actually a type
  32422. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  32423. */
  32424. static GetClassName(object: any, isType?: boolean): string;
  32425. /**
  32426. * Gets the first element of an array satisfying a given predicate
  32427. * @param array defines the array to browse
  32428. * @param predicate defines the predicate to use
  32429. * @returns null if not found or the element
  32430. */
  32431. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  32432. /**
  32433. * This method will return the name of the full name of the class, including its owning module (if any).
  32434. * 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).
  32435. * @param object the object to get the class name from
  32436. * @param isType defines if the object is actually a type
  32437. * @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.
  32438. * @ignorenaming
  32439. */
  32440. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32441. /**
  32442. * Returns a promise that resolves after the given amount of time.
  32443. * @param delay Number of milliseconds to delay
  32444. * @returns Promise that resolves after the given amount of time
  32445. */
  32446. static DelayAsync(delay: number): Promise<void>;
  32447. /**
  32448. * Gets the current gradient from an array of IValueGradient
  32449. * @param ratio defines the current ratio to get
  32450. * @param gradients defines the array of IValueGradient
  32451. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  32452. */
  32453. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  32454. }
  32455. /**
  32456. * This class is used to track a performance counter which is number based.
  32457. * The user has access to many properties which give statistics of different nature.
  32458. *
  32459. * The implementer can track two kinds of Performance Counter: time and count.
  32460. * 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.
  32461. * 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.
  32462. */
  32463. export class PerfCounter {
  32464. /**
  32465. * Gets or sets a global boolean to turn on and off all the counters
  32466. */
  32467. static Enabled: boolean;
  32468. /**
  32469. * Returns the smallest value ever
  32470. */
  32471. readonly min: number;
  32472. /**
  32473. * Returns the biggest value ever
  32474. */
  32475. readonly max: number;
  32476. /**
  32477. * Returns the average value since the performance counter is running
  32478. */
  32479. readonly average: number;
  32480. /**
  32481. * Returns the average value of the last second the counter was monitored
  32482. */
  32483. readonly lastSecAverage: number;
  32484. /**
  32485. * Returns the current value
  32486. */
  32487. readonly current: number;
  32488. /**
  32489. * Gets the accumulated total
  32490. */
  32491. readonly total: number;
  32492. /**
  32493. * Gets the total value count
  32494. */
  32495. readonly count: number;
  32496. /**
  32497. * Creates a new counter
  32498. */
  32499. constructor();
  32500. /**
  32501. * Call this method to start monitoring a new frame.
  32502. * 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.
  32503. */
  32504. fetchNewFrame(): void;
  32505. /**
  32506. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32507. * @param newCount the count value to add to the monitored count
  32508. * @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.
  32509. */
  32510. addCount(newCount: number, fetchResult: boolean): void;
  32511. /**
  32512. * Start monitoring this performance counter
  32513. */
  32514. beginMonitoring(): void;
  32515. /**
  32516. * Compute the time lapsed since the previous beginMonitoring() call.
  32517. * @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
  32518. */
  32519. endMonitoring(newFrame?: boolean): void;
  32520. private _fetchResult;
  32521. private _startMonitoringTime;
  32522. private _min;
  32523. private _max;
  32524. private _average;
  32525. private _current;
  32526. private _totalValueCount;
  32527. private _totalAccumulated;
  32528. private _lastSecAverage;
  32529. private _lastSecAccumulated;
  32530. private _lastSecTime;
  32531. private _lastSecValueCount;
  32532. }
  32533. /**
  32534. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32535. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32536. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32537. * @param name The name of the class, case should be preserved
  32538. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32539. */
  32540. export function className(name: string, module?: string): (target: Object) => void;
  32541. /**
  32542. * An implementation of a loop for asynchronous functions.
  32543. */
  32544. export class AsyncLoop {
  32545. /**
  32546. * Defines the number of iterations for the loop
  32547. */
  32548. iterations: number;
  32549. /**
  32550. * Defines the current index of the loop.
  32551. */
  32552. index: number;
  32553. private _done;
  32554. private _fn;
  32555. private _successCallback;
  32556. /**
  32557. * Constructor.
  32558. * @param iterations the number of iterations.
  32559. * @param func the function to run each iteration
  32560. * @param successCallback the callback that will be called upon succesful execution
  32561. * @param offset starting offset.
  32562. */
  32563. constructor(
  32564. /**
  32565. * Defines the number of iterations for the loop
  32566. */
  32567. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  32568. /**
  32569. * Execute the next iteration. Must be called after the last iteration was finished.
  32570. */
  32571. executeNext(): void;
  32572. /**
  32573. * Break the loop and run the success callback.
  32574. */
  32575. breakLoop(): void;
  32576. /**
  32577. * Create and run an async loop.
  32578. * @param iterations the number of iterations.
  32579. * @param fn the function to run each iteration
  32580. * @param successCallback the callback that will be called upon succesful execution
  32581. * @param offset starting offset.
  32582. * @returns the created async loop object
  32583. */
  32584. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  32585. /**
  32586. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32587. * @param iterations total number of iterations
  32588. * @param syncedIterations number of synchronous iterations in each async iteration.
  32589. * @param fn the function to call each iteration.
  32590. * @param callback a success call back that will be called when iterating stops.
  32591. * @param breakFunction a break condition (optional)
  32592. * @param timeout timeout settings for the setTimeout function. default - 0.
  32593. * @returns the created async loop object
  32594. */
  32595. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  32596. }
  32597. }
  32598. declare module "babylonjs/Collisions/collisionCoordinator" {
  32599. import { Nullable } from "babylonjs/types";
  32600. import { Scene } from "babylonjs/scene";
  32601. import { Vector3 } from "babylonjs/Maths/math";
  32602. import { Collider } from "babylonjs/Collisions/collider";
  32603. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32604. /** @hidden */
  32605. export interface ICollisionCoordinator {
  32606. createCollider(): Collider;
  32607. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32608. init(scene: Scene): void;
  32609. }
  32610. /** @hidden */
  32611. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  32612. private _scene;
  32613. private _scaledPosition;
  32614. private _scaledVelocity;
  32615. private _finalPosition;
  32616. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32617. createCollider(): Collider;
  32618. init(scene: Scene): void;
  32619. private _collideWithWorld;
  32620. }
  32621. }
  32622. declare module "babylonjs/Inputs/scene.inputManager" {
  32623. import { Nullable } from "babylonjs/types";
  32624. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32625. import { Vector2 } from "babylonjs/Maths/math";
  32626. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32627. import { Scene } from "babylonjs/scene";
  32628. /**
  32629. * Class used to manage all inputs for the scene.
  32630. */
  32631. export class InputManager {
  32632. /** The distance in pixel that you have to move to prevent some events */
  32633. static DragMovementThreshold: number;
  32634. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32635. static LongPressDelay: number;
  32636. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32637. static DoubleClickDelay: number;
  32638. /** If you need to check double click without raising a single click at first click, enable this flag */
  32639. static ExclusiveDoubleClickMode: boolean;
  32640. private _wheelEventName;
  32641. private _onPointerMove;
  32642. private _onPointerDown;
  32643. private _onPointerUp;
  32644. private _initClickEvent;
  32645. private _initActionManager;
  32646. private _delayedSimpleClick;
  32647. private _delayedSimpleClickTimeout;
  32648. private _previousDelayedSimpleClickTimeout;
  32649. private _meshPickProceed;
  32650. private _previousButtonPressed;
  32651. private _currentPickResult;
  32652. private _previousPickResult;
  32653. private _totalPointersPressed;
  32654. private _doubleClickOccured;
  32655. private _pointerOverMesh;
  32656. private _pickedDownMesh;
  32657. private _pickedUpMesh;
  32658. private _pointerX;
  32659. private _pointerY;
  32660. private _unTranslatedPointerX;
  32661. private _unTranslatedPointerY;
  32662. private _startingPointerPosition;
  32663. private _previousStartingPointerPosition;
  32664. private _startingPointerTime;
  32665. private _previousStartingPointerTime;
  32666. private _pointerCaptures;
  32667. private _onKeyDown;
  32668. private _onKeyUp;
  32669. private _onCanvasFocusObserver;
  32670. private _onCanvasBlurObserver;
  32671. private _scene;
  32672. /**
  32673. * Creates a new InputManager
  32674. * @param scene defines the hosting scene
  32675. */
  32676. constructor(scene: Scene);
  32677. /**
  32678. * Gets the mesh that is currently under the pointer
  32679. */
  32680. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32681. /**
  32682. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  32683. */
  32684. readonly unTranslatedPointer: Vector2;
  32685. /**
  32686. * Gets or sets the current on-screen X position of the pointer
  32687. */
  32688. pointerX: number;
  32689. /**
  32690. * Gets or sets the current on-screen Y position of the pointer
  32691. */
  32692. pointerY: number;
  32693. private _updatePointerPosition;
  32694. private _processPointerMove;
  32695. private _setRayOnPointerInfo;
  32696. private _checkPrePointerObservable;
  32697. /**
  32698. * Use this method to simulate a pointer move on a mesh
  32699. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32700. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32701. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32702. */
  32703. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32704. /**
  32705. * Use this method to simulate a pointer down on a mesh
  32706. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32707. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32708. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32709. */
  32710. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32711. private _processPointerDown;
  32712. /** @hidden */
  32713. _isPointerSwiping(): boolean;
  32714. /**
  32715. * Use this method to simulate a pointer up on a mesh
  32716. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32717. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32718. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32719. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32720. */
  32721. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  32722. private _processPointerUp;
  32723. /**
  32724. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32725. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32726. * @returns true if the pointer was captured
  32727. */
  32728. isPointerCaptured(pointerId?: number): boolean;
  32729. /**
  32730. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32731. * @param attachUp defines if you want to attach events to pointerup
  32732. * @param attachDown defines if you want to attach events to pointerdown
  32733. * @param attachMove defines if you want to attach events to pointermove
  32734. */
  32735. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32736. /**
  32737. * Detaches all event handlers
  32738. */
  32739. detachControl(): void;
  32740. /**
  32741. * Force the value of meshUnderPointer
  32742. * @param mesh defines the mesh to use
  32743. */
  32744. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32745. /**
  32746. * Gets the mesh under the pointer
  32747. * @returns a Mesh or null if no mesh is under the pointer
  32748. */
  32749. getPointerOverMesh(): Nullable<AbstractMesh>;
  32750. }
  32751. }
  32752. declare module "babylonjs/Animations/animationGroup" {
  32753. import { Animatable } from "babylonjs/Animations/animatable";
  32754. import { Animation } from "babylonjs/Animations/animation";
  32755. import { Scene, IDisposable } from "babylonjs/scene";
  32756. import { Observable } from "babylonjs/Misc/observable";
  32757. import { Nullable } from "babylonjs/types";
  32758. import "babylonjs/Animations/animatable";
  32759. /**
  32760. * This class defines the direct association between an animation and a target
  32761. */
  32762. export class TargetedAnimation {
  32763. /**
  32764. * Animation to perform
  32765. */
  32766. animation: Animation;
  32767. /**
  32768. * Target to animate
  32769. */
  32770. target: any;
  32771. /**
  32772. * Serialize the object
  32773. * @returns the JSON object representing the current entity
  32774. */
  32775. serialize(): any;
  32776. }
  32777. /**
  32778. * Use this class to create coordinated animations on multiple targets
  32779. */
  32780. export class AnimationGroup implements IDisposable {
  32781. /** The name of the animation group */
  32782. name: string;
  32783. private _scene;
  32784. private _targetedAnimations;
  32785. private _animatables;
  32786. private _from;
  32787. private _to;
  32788. private _isStarted;
  32789. private _isPaused;
  32790. private _speedRatio;
  32791. private _loopAnimation;
  32792. /**
  32793. * Gets or sets the unique id of the node
  32794. */
  32795. uniqueId: number;
  32796. /**
  32797. * This observable will notify when one animation have ended
  32798. */
  32799. onAnimationEndObservable: Observable<TargetedAnimation>;
  32800. /**
  32801. * Observer raised when one animation loops
  32802. */
  32803. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32804. /**
  32805. * This observable will notify when all animations have ended.
  32806. */
  32807. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32808. /**
  32809. * This observable will notify when all animations have paused.
  32810. */
  32811. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32812. /**
  32813. * This observable will notify when all animations are playing.
  32814. */
  32815. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32816. /**
  32817. * Gets the first frame
  32818. */
  32819. readonly from: number;
  32820. /**
  32821. * Gets the last frame
  32822. */
  32823. readonly to: number;
  32824. /**
  32825. * Define if the animations are started
  32826. */
  32827. readonly isStarted: boolean;
  32828. /**
  32829. * Gets a value indicating that the current group is playing
  32830. */
  32831. readonly isPlaying: boolean;
  32832. /**
  32833. * Gets or sets the speed ratio to use for all animations
  32834. */
  32835. /**
  32836. * Gets or sets the speed ratio to use for all animations
  32837. */
  32838. speedRatio: number;
  32839. /**
  32840. * Gets or sets if all animations should loop or not
  32841. */
  32842. loopAnimation: boolean;
  32843. /**
  32844. * Gets the targeted animations for this animation group
  32845. */
  32846. readonly targetedAnimations: Array<TargetedAnimation>;
  32847. /**
  32848. * returning the list of animatables controlled by this animation group.
  32849. */
  32850. readonly animatables: Array<Animatable>;
  32851. /**
  32852. * Instantiates a new Animation Group.
  32853. * This helps managing several animations at once.
  32854. * @see http://doc.babylonjs.com/how_to/group
  32855. * @param name Defines the name of the group
  32856. * @param scene Defines the scene the group belongs to
  32857. */
  32858. constructor(
  32859. /** The name of the animation group */
  32860. name: string, scene?: Nullable<Scene>);
  32861. /**
  32862. * Add an animation (with its target) in the group
  32863. * @param animation defines the animation we want to add
  32864. * @param target defines the target of the animation
  32865. * @returns the TargetedAnimation object
  32866. */
  32867. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32868. /**
  32869. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32870. * It can add constant keys at begin or end
  32871. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32872. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32873. * @returns the animation group
  32874. */
  32875. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32876. /**
  32877. * Start all animations on given targets
  32878. * @param loop defines if animations must loop
  32879. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32880. * @param from defines the from key (optional)
  32881. * @param to defines the to key (optional)
  32882. * @returns the current animation group
  32883. */
  32884. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32885. /**
  32886. * Pause all animations
  32887. * @returns the animation group
  32888. */
  32889. pause(): AnimationGroup;
  32890. /**
  32891. * Play all animations to initial state
  32892. * This function will start() the animations if they were not started or will restart() them if they were paused
  32893. * @param loop defines if animations must loop
  32894. * @returns the animation group
  32895. */
  32896. play(loop?: boolean): AnimationGroup;
  32897. /**
  32898. * Reset all animations to initial state
  32899. * @returns the animation group
  32900. */
  32901. reset(): AnimationGroup;
  32902. /**
  32903. * Restart animations from key 0
  32904. * @returns the animation group
  32905. */
  32906. restart(): AnimationGroup;
  32907. /**
  32908. * Stop all animations
  32909. * @returns the animation group
  32910. */
  32911. stop(): AnimationGroup;
  32912. /**
  32913. * Set animation weight for all animatables
  32914. * @param weight defines the weight to use
  32915. * @return the animationGroup
  32916. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32917. */
  32918. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32919. /**
  32920. * Synchronize and normalize all animatables with a source animatable
  32921. * @param root defines the root animatable to synchronize with
  32922. * @return the animationGroup
  32923. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32924. */
  32925. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32926. /**
  32927. * Goes to a specific frame in this animation group
  32928. * @param frame the frame number to go to
  32929. * @return the animationGroup
  32930. */
  32931. goToFrame(frame: number): AnimationGroup;
  32932. /**
  32933. * Dispose all associated resources
  32934. */
  32935. dispose(): void;
  32936. private _checkAnimationGroupEnded;
  32937. /**
  32938. * Clone the current animation group and returns a copy
  32939. * @param newName defines the name of the new group
  32940. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  32941. * @returns the new aniamtion group
  32942. */
  32943. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  32944. /**
  32945. * Serializes the animationGroup to an object
  32946. * @returns Serialized object
  32947. */
  32948. serialize(): any;
  32949. /**
  32950. * Returns a new AnimationGroup object parsed from the source provided.
  32951. * @param parsedAnimationGroup defines the source
  32952. * @param scene defines the scene that will receive the animationGroup
  32953. * @returns a new AnimationGroup
  32954. */
  32955. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32956. /**
  32957. * Returns the string "AnimationGroup"
  32958. * @returns "AnimationGroup"
  32959. */
  32960. getClassName(): string;
  32961. /**
  32962. * Creates a detailled string about the object
  32963. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32964. * @returns a string representing the object
  32965. */
  32966. toString(fullDetails?: boolean): string;
  32967. }
  32968. }
  32969. declare module "babylonjs/scene" {
  32970. import { Nullable } from "babylonjs/types";
  32971. import { IAnimatable, IFileRequest, PerfCounter } from "babylonjs/Misc/tools";
  32972. import { Observable } from "babylonjs/Misc/observable";
  32973. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  32974. import { Color4, Color3, Plane, Vector2, Vector3, Matrix } from "babylonjs/Maths/math";
  32975. import { Geometry } from "babylonjs/Meshes/geometry";
  32976. import { TransformNode } from "babylonjs/Meshes/transformNode";
  32977. import { SubMesh } from "babylonjs/Meshes/subMesh";
  32978. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32979. import { Mesh } from "babylonjs/Meshes/mesh";
  32980. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  32981. import { Bone } from "babylonjs/Bones/bone";
  32982. import { Skeleton } from "babylonjs/Bones/skeleton";
  32983. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  32984. import { Camera } from "babylonjs/Cameras/camera";
  32985. import { AbstractScene } from "babylonjs/abstractScene";
  32986. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  32987. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  32988. import { Material } from "babylonjs/Materials/material";
  32989. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  32990. import { Effect } from "babylonjs/Materials/effect";
  32991. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  32992. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  32993. import { Light } from "babylonjs/Lights/light";
  32994. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32995. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  32996. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  32997. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  32998. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  32999. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  33000. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33001. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  33002. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  33003. import { Engine } from "babylonjs/Engines/engine";
  33004. import { Node } from "babylonjs/node";
  33005. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  33006. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33007. import { WebRequest } from "babylonjs/Misc/webRequest";
  33008. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  33009. import { Ray } from "babylonjs/Culling/ray";
  33010. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  33011. import { Animation } from "babylonjs/Animations/animation";
  33012. import { Animatable } from "babylonjs/Animations/animatable";
  33013. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33014. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  33015. import { Collider } from "babylonjs/Collisions/collider";
  33016. /**
  33017. * Define an interface for all classes that will hold resources
  33018. */
  33019. export interface IDisposable {
  33020. /**
  33021. * Releases all held resources
  33022. */
  33023. dispose(): void;
  33024. }
  33025. /** Interface defining initialization parameters for Scene class */
  33026. export interface SceneOptions {
  33027. /**
  33028. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  33029. * It will improve performance when the number of geometries becomes important.
  33030. */
  33031. useGeometryUniqueIdsMap?: boolean;
  33032. /**
  33033. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  33034. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33035. */
  33036. useMaterialMeshMap?: boolean;
  33037. /**
  33038. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  33039. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33040. */
  33041. useClonedMeshhMap?: boolean;
  33042. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  33043. virtual?: boolean;
  33044. }
  33045. /**
  33046. * Represents a scene to be rendered by the engine.
  33047. * @see http://doc.babylonjs.com/features/scene
  33048. */
  33049. export class Scene extends AbstractScene implements IAnimatable {
  33050. private static _uniqueIdCounter;
  33051. /** The fog is deactivated */
  33052. static readonly FOGMODE_NONE: number;
  33053. /** The fog density is following an exponential function */
  33054. static readonly FOGMODE_EXP: number;
  33055. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  33056. static readonly FOGMODE_EXP2: number;
  33057. /** The fog density is following a linear function. */
  33058. static readonly FOGMODE_LINEAR: number;
  33059. /**
  33060. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  33061. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33062. */
  33063. static MinDeltaTime: number;
  33064. /**
  33065. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  33066. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33067. */
  33068. static MaxDeltaTime: number;
  33069. /**
  33070. * Factory used to create the default material.
  33071. * @param name The name of the material to create
  33072. * @param scene The scene to create the material for
  33073. * @returns The default material
  33074. */
  33075. static DefaultMaterialFactory(scene: Scene): Material;
  33076. /**
  33077. * Factory used to create the a collision coordinator.
  33078. * @returns The collision coordinator
  33079. */
  33080. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  33081. /** @hidden */
  33082. _inputManager: InputManager;
  33083. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  33084. cameraToUseForPointers: Nullable<Camera>;
  33085. /** @hidden */
  33086. readonly _isScene: boolean;
  33087. /**
  33088. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  33089. */
  33090. autoClear: boolean;
  33091. /**
  33092. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  33093. */
  33094. autoClearDepthAndStencil: boolean;
  33095. /**
  33096. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  33097. */
  33098. clearColor: Color4;
  33099. /**
  33100. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  33101. */
  33102. ambientColor: Color3;
  33103. /**
  33104. * This is use to store the default BRDF lookup for PBR materials in your scene.
  33105. * It should only be one of the following (if not the default embedded one):
  33106. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  33107. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  33108. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  33109. * The material properties need to be setup according to the type of texture in use.
  33110. */
  33111. environmentBRDFTexture: BaseTexture;
  33112. /** @hidden */
  33113. protected _environmentTexture: Nullable<BaseTexture>;
  33114. /**
  33115. * Texture used in all pbr material as the reflection texture.
  33116. * As in the majority of the scene they are the same (exception for multi room and so on),
  33117. * this is easier to reference from here than from all the materials.
  33118. */
  33119. /**
  33120. * Texture used in all pbr material as the reflection texture.
  33121. * As in the majority of the scene they are the same (exception for multi room and so on),
  33122. * this is easier to set here than in all the materials.
  33123. */
  33124. environmentTexture: Nullable<BaseTexture>;
  33125. /** @hidden */
  33126. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  33127. /**
  33128. * Default image processing configuration used either in the rendering
  33129. * Forward main pass or through the imageProcessingPostProcess if present.
  33130. * As in the majority of the scene they are the same (exception for multi camera),
  33131. * this is easier to reference from here than from all the materials and post process.
  33132. *
  33133. * No setter as we it is a shared configuration, you can set the values instead.
  33134. */
  33135. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  33136. private _forceWireframe;
  33137. /**
  33138. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  33139. */
  33140. forceWireframe: boolean;
  33141. private _forcePointsCloud;
  33142. /**
  33143. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  33144. */
  33145. forcePointsCloud: boolean;
  33146. /**
  33147. * Gets or sets the active clipplane 1
  33148. */
  33149. clipPlane: Nullable<Plane>;
  33150. /**
  33151. * Gets or sets the active clipplane 2
  33152. */
  33153. clipPlane2: Nullable<Plane>;
  33154. /**
  33155. * Gets or sets the active clipplane 3
  33156. */
  33157. clipPlane3: Nullable<Plane>;
  33158. /**
  33159. * Gets or sets the active clipplane 4
  33160. */
  33161. clipPlane4: Nullable<Plane>;
  33162. /**
  33163. * Gets or sets a boolean indicating if animations are enabled
  33164. */
  33165. animationsEnabled: boolean;
  33166. private _animationPropertiesOverride;
  33167. /**
  33168. * Gets or sets the animation properties override
  33169. */
  33170. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  33171. /**
  33172. * Gets or sets a boolean indicating if a constant deltatime has to be used
  33173. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  33174. */
  33175. useConstantAnimationDeltaTime: boolean;
  33176. /**
  33177. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  33178. * Please note that it requires to run a ray cast through the scene on every frame
  33179. */
  33180. constantlyUpdateMeshUnderPointer: boolean;
  33181. /**
  33182. * Defines the HTML cursor to use when hovering over interactive elements
  33183. */
  33184. hoverCursor: string;
  33185. /**
  33186. * Defines the HTML default cursor to use (empty by default)
  33187. */
  33188. defaultCursor: string;
  33189. /**
  33190. * This is used to call preventDefault() on pointer down
  33191. * in order to block unwanted artifacts like system double clicks
  33192. */
  33193. preventDefaultOnPointerDown: boolean;
  33194. /**
  33195. * This is used to call preventDefault() on pointer up
  33196. * in order to block unwanted artifacts like system double clicks
  33197. */
  33198. preventDefaultOnPointerUp: boolean;
  33199. /**
  33200. * Gets or sets user defined metadata
  33201. */
  33202. metadata: any;
  33203. /**
  33204. * For internal use only. Please do not use.
  33205. */
  33206. reservedDataStore: any;
  33207. /**
  33208. * Gets the name of the plugin used to load this scene (null by default)
  33209. */
  33210. loadingPluginName: string;
  33211. /**
  33212. * Use this array to add regular expressions used to disable offline support for specific urls
  33213. */
  33214. disableOfflineSupportExceptionRules: RegExp[];
  33215. /**
  33216. * An event triggered when the scene is disposed.
  33217. */
  33218. onDisposeObservable: Observable<Scene>;
  33219. private _onDisposeObserver;
  33220. /** Sets a function to be executed when this scene is disposed. */
  33221. onDispose: () => void;
  33222. /**
  33223. * An event triggered before rendering the scene (right after animations and physics)
  33224. */
  33225. onBeforeRenderObservable: Observable<Scene>;
  33226. private _onBeforeRenderObserver;
  33227. /** Sets a function to be executed before rendering this scene */
  33228. beforeRender: Nullable<() => void>;
  33229. /**
  33230. * An event triggered after rendering the scene
  33231. */
  33232. onAfterRenderObservable: Observable<Scene>;
  33233. /**
  33234. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  33235. */
  33236. onAfterRenderCameraObservable: Observable<Camera>;
  33237. private _onAfterRenderObserver;
  33238. /** Sets a function to be executed after rendering this scene */
  33239. afterRender: Nullable<() => void>;
  33240. /**
  33241. * An event triggered before animating the scene
  33242. */
  33243. onBeforeAnimationsObservable: Observable<Scene>;
  33244. /**
  33245. * An event triggered after animations processing
  33246. */
  33247. onAfterAnimationsObservable: Observable<Scene>;
  33248. /**
  33249. * An event triggered before draw calls are ready to be sent
  33250. */
  33251. onBeforeDrawPhaseObservable: Observable<Scene>;
  33252. /**
  33253. * An event triggered after draw calls have been sent
  33254. */
  33255. onAfterDrawPhaseObservable: Observable<Scene>;
  33256. /**
  33257. * An event triggered when the scene is ready
  33258. */
  33259. onReadyObservable: Observable<Scene>;
  33260. /**
  33261. * An event triggered before rendering a camera
  33262. */
  33263. onBeforeCameraRenderObservable: Observable<Camera>;
  33264. private _onBeforeCameraRenderObserver;
  33265. /** Sets a function to be executed before rendering a camera*/
  33266. beforeCameraRender: () => void;
  33267. /**
  33268. * An event triggered after rendering a camera
  33269. */
  33270. onAfterCameraRenderObservable: Observable<Camera>;
  33271. private _onAfterCameraRenderObserver;
  33272. /** Sets a function to be executed after rendering a camera*/
  33273. afterCameraRender: () => void;
  33274. /**
  33275. * An event triggered when active meshes evaluation is about to start
  33276. */
  33277. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  33278. /**
  33279. * An event triggered when active meshes evaluation is done
  33280. */
  33281. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  33282. /**
  33283. * An event triggered when particles rendering is about to start
  33284. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33285. */
  33286. onBeforeParticlesRenderingObservable: Observable<Scene>;
  33287. /**
  33288. * An event triggered when particles rendering is done
  33289. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33290. */
  33291. onAfterParticlesRenderingObservable: Observable<Scene>;
  33292. /**
  33293. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  33294. */
  33295. onDataLoadedObservable: Observable<Scene>;
  33296. /**
  33297. * An event triggered when a camera is created
  33298. */
  33299. onNewCameraAddedObservable: Observable<Camera>;
  33300. /**
  33301. * An event triggered when a camera is removed
  33302. */
  33303. onCameraRemovedObservable: Observable<Camera>;
  33304. /**
  33305. * An event triggered when a light is created
  33306. */
  33307. onNewLightAddedObservable: Observable<Light>;
  33308. /**
  33309. * An event triggered when a light is removed
  33310. */
  33311. onLightRemovedObservable: Observable<Light>;
  33312. /**
  33313. * An event triggered when a geometry is created
  33314. */
  33315. onNewGeometryAddedObservable: Observable<Geometry>;
  33316. /**
  33317. * An event triggered when a geometry is removed
  33318. */
  33319. onGeometryRemovedObservable: Observable<Geometry>;
  33320. /**
  33321. * An event triggered when a transform node is created
  33322. */
  33323. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  33324. /**
  33325. * An event triggered when a transform node is removed
  33326. */
  33327. onTransformNodeRemovedObservable: Observable<TransformNode>;
  33328. /**
  33329. * An event triggered when a mesh is created
  33330. */
  33331. onNewMeshAddedObservable: Observable<AbstractMesh>;
  33332. /**
  33333. * An event triggered when a mesh is removed
  33334. */
  33335. onMeshRemovedObservable: Observable<AbstractMesh>;
  33336. /**
  33337. * An event triggered when a skeleton is created
  33338. */
  33339. onNewSkeletonAddedObservable: Observable<Skeleton>;
  33340. /**
  33341. * An event triggered when a skeleton is removed
  33342. */
  33343. onSkeletonRemovedObservable: Observable<Skeleton>;
  33344. /**
  33345. * An event triggered when a material is created
  33346. */
  33347. onNewMaterialAddedObservable: Observable<Material>;
  33348. /**
  33349. * An event triggered when a material is removed
  33350. */
  33351. onMaterialRemovedObservable: Observable<Material>;
  33352. /**
  33353. * An event triggered when a texture is created
  33354. */
  33355. onNewTextureAddedObservable: Observable<BaseTexture>;
  33356. /**
  33357. * An event triggered when a texture is removed
  33358. */
  33359. onTextureRemovedObservable: Observable<BaseTexture>;
  33360. /**
  33361. * An event triggered when render targets are about to be rendered
  33362. * Can happen multiple times per frame.
  33363. */
  33364. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  33365. /**
  33366. * An event triggered when render targets were rendered.
  33367. * Can happen multiple times per frame.
  33368. */
  33369. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  33370. /**
  33371. * An event triggered before calculating deterministic simulation step
  33372. */
  33373. onBeforeStepObservable: Observable<Scene>;
  33374. /**
  33375. * An event triggered after calculating deterministic simulation step
  33376. */
  33377. onAfterStepObservable: Observable<Scene>;
  33378. /**
  33379. * An event triggered when the activeCamera property is updated
  33380. */
  33381. onActiveCameraChanged: Observable<Scene>;
  33382. /**
  33383. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  33384. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33385. * 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)
  33386. */
  33387. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33388. /**
  33389. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  33390. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33391. * 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)
  33392. */
  33393. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33394. /**
  33395. * This Observable will when a mesh has been imported into the scene.
  33396. */
  33397. onMeshImportedObservable: Observable<AbstractMesh>;
  33398. /**
  33399. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  33400. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  33401. */
  33402. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  33403. /** @hidden */
  33404. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  33405. /**
  33406. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  33407. */
  33408. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  33409. /**
  33410. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  33411. */
  33412. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  33413. /**
  33414. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  33415. */
  33416. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  33417. /** Callback called when a pointer move is detected */
  33418. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33419. /** Callback called when a pointer down is detected */
  33420. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33421. /** Callback called when a pointer up is detected */
  33422. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  33423. /** Callback called when a pointer pick is detected */
  33424. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  33425. /**
  33426. * 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).
  33427. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  33428. */
  33429. onPrePointerObservable: Observable<PointerInfoPre>;
  33430. /**
  33431. * Observable event triggered each time an input event is received from the rendering canvas
  33432. */
  33433. onPointerObservable: Observable<PointerInfo>;
  33434. /**
  33435. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  33436. */
  33437. readonly unTranslatedPointer: Vector2;
  33438. /**
  33439. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  33440. */
  33441. static DragMovementThreshold: number;
  33442. /**
  33443. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  33444. */
  33445. static LongPressDelay: number;
  33446. /**
  33447. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  33448. */
  33449. static DoubleClickDelay: number;
  33450. /** If you need to check double click without raising a single click at first click, enable this flag */
  33451. static ExclusiveDoubleClickMode: boolean;
  33452. /** @hidden */
  33453. _mirroredCameraPosition: Nullable<Vector3>;
  33454. /**
  33455. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  33456. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  33457. */
  33458. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  33459. /**
  33460. * Observable event triggered each time an keyboard event is received from the hosting window
  33461. */
  33462. onKeyboardObservable: Observable<KeyboardInfo>;
  33463. private _useRightHandedSystem;
  33464. /**
  33465. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  33466. */
  33467. useRightHandedSystem: boolean;
  33468. private _timeAccumulator;
  33469. private _currentStepId;
  33470. private _currentInternalStep;
  33471. /**
  33472. * Sets the step Id used by deterministic lock step
  33473. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33474. * @param newStepId defines the step Id
  33475. */
  33476. setStepId(newStepId: number): void;
  33477. /**
  33478. * Gets the step Id used by deterministic lock step
  33479. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33480. * @returns the step Id
  33481. */
  33482. getStepId(): number;
  33483. /**
  33484. * Gets the internal step used by deterministic lock step
  33485. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33486. * @returns the internal step
  33487. */
  33488. getInternalStep(): number;
  33489. private _fogEnabled;
  33490. /**
  33491. * Gets or sets a boolean indicating if fog is enabled on this scene
  33492. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33493. * (Default is true)
  33494. */
  33495. fogEnabled: boolean;
  33496. private _fogMode;
  33497. /**
  33498. * Gets or sets the fog mode to use
  33499. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33500. * | mode | value |
  33501. * | --- | --- |
  33502. * | FOGMODE_NONE | 0 |
  33503. * | FOGMODE_EXP | 1 |
  33504. * | FOGMODE_EXP2 | 2 |
  33505. * | FOGMODE_LINEAR | 3 |
  33506. */
  33507. fogMode: number;
  33508. /**
  33509. * Gets or sets the fog color to use
  33510. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33511. * (Default is Color3(0.2, 0.2, 0.3))
  33512. */
  33513. fogColor: Color3;
  33514. /**
  33515. * Gets or sets the fog density to use
  33516. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33517. * (Default is 0.1)
  33518. */
  33519. fogDensity: number;
  33520. /**
  33521. * Gets or sets the fog start distance to use
  33522. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33523. * (Default is 0)
  33524. */
  33525. fogStart: number;
  33526. /**
  33527. * Gets or sets the fog end distance to use
  33528. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33529. * (Default is 1000)
  33530. */
  33531. fogEnd: number;
  33532. private _shadowsEnabled;
  33533. /**
  33534. * Gets or sets a boolean indicating if shadows are enabled on this scene
  33535. */
  33536. shadowsEnabled: boolean;
  33537. private _lightsEnabled;
  33538. /**
  33539. * Gets or sets a boolean indicating if lights are enabled on this scene
  33540. */
  33541. lightsEnabled: boolean;
  33542. /** All of the active cameras added to this scene. */
  33543. activeCameras: Camera[];
  33544. /** @hidden */
  33545. _activeCamera: Nullable<Camera>;
  33546. /** Gets or sets the current active camera */
  33547. activeCamera: Nullable<Camera>;
  33548. private _defaultMaterial;
  33549. /** The default material used on meshes when no material is affected */
  33550. /** The default material used on meshes when no material is affected */
  33551. defaultMaterial: Material;
  33552. private _texturesEnabled;
  33553. /**
  33554. * Gets or sets a boolean indicating if textures are enabled on this scene
  33555. */
  33556. texturesEnabled: boolean;
  33557. /**
  33558. * Gets or sets a boolean indicating if particles are enabled on this scene
  33559. */
  33560. particlesEnabled: boolean;
  33561. /**
  33562. * Gets or sets a boolean indicating if sprites are enabled on this scene
  33563. */
  33564. spritesEnabled: boolean;
  33565. private _skeletonsEnabled;
  33566. /**
  33567. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  33568. */
  33569. skeletonsEnabled: boolean;
  33570. /**
  33571. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  33572. */
  33573. lensFlaresEnabled: boolean;
  33574. /**
  33575. * Gets or sets a boolean indicating if collisions are enabled on this scene
  33576. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33577. */
  33578. collisionsEnabled: boolean;
  33579. private _collisionCoordinator;
  33580. /** @hidden */
  33581. readonly collisionCoordinator: ICollisionCoordinator;
  33582. /**
  33583. * Defines the gravity applied to this scene (used only for collisions)
  33584. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33585. */
  33586. gravity: Vector3;
  33587. /**
  33588. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  33589. */
  33590. postProcessesEnabled: boolean;
  33591. /**
  33592. * The list of postprocesses added to the scene
  33593. */
  33594. postProcesses: PostProcess[];
  33595. /**
  33596. * Gets the current postprocess manager
  33597. */
  33598. postProcessManager: PostProcessManager;
  33599. /**
  33600. * Gets or sets a boolean indicating if render targets are enabled on this scene
  33601. */
  33602. renderTargetsEnabled: boolean;
  33603. /**
  33604. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  33605. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  33606. */
  33607. dumpNextRenderTargets: boolean;
  33608. /**
  33609. * The list of user defined render targets added to the scene
  33610. */
  33611. customRenderTargets: RenderTargetTexture[];
  33612. /**
  33613. * Defines if texture loading must be delayed
  33614. * If true, textures will only be loaded when they need to be rendered
  33615. */
  33616. useDelayedTextureLoading: boolean;
  33617. /**
  33618. * Gets the list of meshes imported to the scene through SceneLoader
  33619. */
  33620. importedMeshesFiles: String[];
  33621. /**
  33622. * Gets or sets a boolean indicating if probes are enabled on this scene
  33623. */
  33624. probesEnabled: boolean;
  33625. /**
  33626. * Gets or sets the current offline provider to use to store scene data
  33627. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  33628. */
  33629. offlineProvider: IOfflineProvider;
  33630. /**
  33631. * Gets or sets the action manager associated with the scene
  33632. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33633. */
  33634. actionManager: AbstractActionManager;
  33635. private _meshesForIntersections;
  33636. /**
  33637. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  33638. */
  33639. proceduralTexturesEnabled: boolean;
  33640. private _engine;
  33641. private _totalVertices;
  33642. /** @hidden */
  33643. _activeIndices: PerfCounter;
  33644. /** @hidden */
  33645. _activeParticles: PerfCounter;
  33646. /** @hidden */
  33647. _activeBones: PerfCounter;
  33648. private _animationRatio;
  33649. /** @hidden */
  33650. _animationTimeLast: number;
  33651. /** @hidden */
  33652. _animationTime: number;
  33653. /**
  33654. * Gets or sets a general scale for animation speed
  33655. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  33656. */
  33657. animationTimeScale: number;
  33658. /** @hidden */
  33659. _cachedMaterial: Nullable<Material>;
  33660. /** @hidden */
  33661. _cachedEffect: Nullable<Effect>;
  33662. /** @hidden */
  33663. _cachedVisibility: Nullable<number>;
  33664. private _renderId;
  33665. private _frameId;
  33666. private _executeWhenReadyTimeoutId;
  33667. private _intermediateRendering;
  33668. private _viewUpdateFlag;
  33669. private _projectionUpdateFlag;
  33670. /** @hidden */
  33671. _toBeDisposed: Nullable<IDisposable>[];
  33672. private _activeRequests;
  33673. /** @hidden */
  33674. _pendingData: any[];
  33675. private _isDisposed;
  33676. /**
  33677. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  33678. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  33679. */
  33680. dispatchAllSubMeshesOfActiveMeshes: boolean;
  33681. private _activeMeshes;
  33682. private _processedMaterials;
  33683. private _renderTargets;
  33684. /** @hidden */
  33685. _activeParticleSystems: SmartArray<IParticleSystem>;
  33686. private _activeSkeletons;
  33687. private _softwareSkinnedMeshes;
  33688. private _renderingManager;
  33689. /** @hidden */
  33690. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  33691. private _transformMatrix;
  33692. private _sceneUbo;
  33693. /** @hidden */
  33694. _viewMatrix: Matrix;
  33695. private _projectionMatrix;
  33696. /** @hidden */
  33697. _forcedViewPosition: Nullable<Vector3>;
  33698. /** @hidden */
  33699. _frustumPlanes: Plane[];
  33700. /**
  33701. * Gets the list of frustum planes (built from the active camera)
  33702. */
  33703. readonly frustumPlanes: Plane[];
  33704. /**
  33705. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  33706. * This is useful if there are more lights that the maximum simulteanous authorized
  33707. */
  33708. requireLightSorting: boolean;
  33709. /** @hidden */
  33710. readonly useMaterialMeshMap: boolean;
  33711. /** @hidden */
  33712. readonly useClonedMeshhMap: boolean;
  33713. private _externalData;
  33714. private _uid;
  33715. /**
  33716. * @hidden
  33717. * Backing store of defined scene components.
  33718. */
  33719. _components: ISceneComponent[];
  33720. /**
  33721. * @hidden
  33722. * Backing store of defined scene components.
  33723. */
  33724. _serializableComponents: ISceneSerializableComponent[];
  33725. /**
  33726. * List of components to register on the next registration step.
  33727. */
  33728. private _transientComponents;
  33729. /**
  33730. * Registers the transient components if needed.
  33731. */
  33732. private _registerTransientComponents;
  33733. /**
  33734. * @hidden
  33735. * Add a component to the scene.
  33736. * Note that the ccomponent could be registered on th next frame if this is called after
  33737. * the register component stage.
  33738. * @param component Defines the component to add to the scene
  33739. */
  33740. _addComponent(component: ISceneComponent): void;
  33741. /**
  33742. * @hidden
  33743. * Gets a component from the scene.
  33744. * @param name defines the name of the component to retrieve
  33745. * @returns the component or null if not present
  33746. */
  33747. _getComponent(name: string): Nullable<ISceneComponent>;
  33748. /**
  33749. * @hidden
  33750. * Defines the actions happening before camera updates.
  33751. */
  33752. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  33753. /**
  33754. * @hidden
  33755. * Defines the actions happening before clear the canvas.
  33756. */
  33757. _beforeClearStage: Stage<SimpleStageAction>;
  33758. /**
  33759. * @hidden
  33760. * Defines the actions when collecting render targets for the frame.
  33761. */
  33762. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33763. /**
  33764. * @hidden
  33765. * Defines the actions happening for one camera in the frame.
  33766. */
  33767. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33768. /**
  33769. * @hidden
  33770. * Defines the actions happening during the per mesh ready checks.
  33771. */
  33772. _isReadyForMeshStage: Stage<MeshStageAction>;
  33773. /**
  33774. * @hidden
  33775. * Defines the actions happening before evaluate active mesh checks.
  33776. */
  33777. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33778. /**
  33779. * @hidden
  33780. * Defines the actions happening during the evaluate sub mesh checks.
  33781. */
  33782. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33783. /**
  33784. * @hidden
  33785. * Defines the actions happening during the active mesh stage.
  33786. */
  33787. _activeMeshStage: Stage<ActiveMeshStageAction>;
  33788. /**
  33789. * @hidden
  33790. * Defines the actions happening during the per camera render target step.
  33791. */
  33792. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  33793. /**
  33794. * @hidden
  33795. * Defines the actions happening just before the active camera is drawing.
  33796. */
  33797. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33798. /**
  33799. * @hidden
  33800. * Defines the actions happening just before a render target is drawing.
  33801. */
  33802. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33803. /**
  33804. * @hidden
  33805. * Defines the actions happening just before a rendering group is drawing.
  33806. */
  33807. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33808. /**
  33809. * @hidden
  33810. * Defines the actions happening just before a mesh is drawing.
  33811. */
  33812. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33813. /**
  33814. * @hidden
  33815. * Defines the actions happening just after a mesh has been drawn.
  33816. */
  33817. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33818. /**
  33819. * @hidden
  33820. * Defines the actions happening just after a rendering group has been drawn.
  33821. */
  33822. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33823. /**
  33824. * @hidden
  33825. * Defines the actions happening just after the active camera has been drawn.
  33826. */
  33827. _afterCameraDrawStage: Stage<CameraStageAction>;
  33828. /**
  33829. * @hidden
  33830. * Defines the actions happening just after a render target has been drawn.
  33831. */
  33832. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33833. /**
  33834. * @hidden
  33835. * Defines the actions happening just after rendering all cameras and computing intersections.
  33836. */
  33837. _afterRenderStage: Stage<SimpleStageAction>;
  33838. /**
  33839. * @hidden
  33840. * Defines the actions happening when a pointer move event happens.
  33841. */
  33842. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33843. /**
  33844. * @hidden
  33845. * Defines the actions happening when a pointer down event happens.
  33846. */
  33847. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33848. /**
  33849. * @hidden
  33850. * Defines the actions happening when a pointer up event happens.
  33851. */
  33852. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33853. /**
  33854. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33855. */
  33856. private geometriesByUniqueId;
  33857. /**
  33858. * Creates a new Scene
  33859. * @param engine defines the engine to use to render this scene
  33860. * @param options defines the scene options
  33861. */
  33862. constructor(engine: Engine, options?: SceneOptions);
  33863. /**
  33864. * Gets a string idenfifying the name of the class
  33865. * @returns "Scene" string
  33866. */
  33867. getClassName(): string;
  33868. private _defaultMeshCandidates;
  33869. /**
  33870. * @hidden
  33871. */
  33872. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33873. private _defaultSubMeshCandidates;
  33874. /**
  33875. * @hidden
  33876. */
  33877. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33878. /**
  33879. * Sets the default candidate providers for the scene.
  33880. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33881. * and getCollidingSubMeshCandidates to their default function
  33882. */
  33883. setDefaultCandidateProviders(): void;
  33884. /**
  33885. * Gets the mesh that is currently under the pointer
  33886. */
  33887. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33888. /**
  33889. * Gets or sets the current on-screen X position of the pointer
  33890. */
  33891. pointerX: number;
  33892. /**
  33893. * Gets or sets the current on-screen Y position of the pointer
  33894. */
  33895. pointerY: number;
  33896. /**
  33897. * Gets the cached material (ie. the latest rendered one)
  33898. * @returns the cached material
  33899. */
  33900. getCachedMaterial(): Nullable<Material>;
  33901. /**
  33902. * Gets the cached effect (ie. the latest rendered one)
  33903. * @returns the cached effect
  33904. */
  33905. getCachedEffect(): Nullable<Effect>;
  33906. /**
  33907. * Gets the cached visibility state (ie. the latest rendered one)
  33908. * @returns the cached visibility state
  33909. */
  33910. getCachedVisibility(): Nullable<number>;
  33911. /**
  33912. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33913. * @param material defines the current material
  33914. * @param effect defines the current effect
  33915. * @param visibility defines the current visibility state
  33916. * @returns true if one parameter is not cached
  33917. */
  33918. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33919. /**
  33920. * Gets the engine associated with the scene
  33921. * @returns an Engine
  33922. */
  33923. getEngine(): Engine;
  33924. /**
  33925. * Gets the total number of vertices rendered per frame
  33926. * @returns the total number of vertices rendered per frame
  33927. */
  33928. getTotalVertices(): number;
  33929. /**
  33930. * Gets the performance counter for total vertices
  33931. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33932. */
  33933. readonly totalVerticesPerfCounter: PerfCounter;
  33934. /**
  33935. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33936. * @returns the total number of active indices rendered per frame
  33937. */
  33938. getActiveIndices(): number;
  33939. /**
  33940. * Gets the performance counter for active indices
  33941. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33942. */
  33943. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33944. /**
  33945. * Gets the total number of active particles rendered per frame
  33946. * @returns the total number of active particles rendered per frame
  33947. */
  33948. getActiveParticles(): number;
  33949. /**
  33950. * Gets the performance counter for active particles
  33951. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33952. */
  33953. readonly activeParticlesPerfCounter: PerfCounter;
  33954. /**
  33955. * Gets the total number of active bones rendered per frame
  33956. * @returns the total number of active bones rendered per frame
  33957. */
  33958. getActiveBones(): number;
  33959. /**
  33960. * Gets the performance counter for active bones
  33961. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33962. */
  33963. readonly activeBonesPerfCounter: PerfCounter;
  33964. /**
  33965. * Gets the array of active meshes
  33966. * @returns an array of AbstractMesh
  33967. */
  33968. getActiveMeshes(): SmartArray<AbstractMesh>;
  33969. /**
  33970. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  33971. * @returns a number
  33972. */
  33973. getAnimationRatio(): number;
  33974. /**
  33975. * Gets an unique Id for the current render phase
  33976. * @returns a number
  33977. */
  33978. getRenderId(): number;
  33979. /**
  33980. * Gets an unique Id for the current frame
  33981. * @returns a number
  33982. */
  33983. getFrameId(): number;
  33984. /** Call this function if you want to manually increment the render Id*/
  33985. incrementRenderId(): void;
  33986. private _createUbo;
  33987. /**
  33988. * Use this method to simulate a pointer move on a mesh
  33989. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33990. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33991. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33992. * @returns the current scene
  33993. */
  33994. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33995. /**
  33996. * Use this method to simulate a pointer down on a mesh
  33997. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33998. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33999. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34000. * @returns the current scene
  34001. */
  34002. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34003. /**
  34004. * Use this method to simulate a pointer up on a mesh
  34005. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34006. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34007. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34008. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34009. * @returns the current scene
  34010. */
  34011. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  34012. /**
  34013. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34014. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34015. * @returns true if the pointer was captured
  34016. */
  34017. isPointerCaptured(pointerId?: number): boolean;
  34018. /**
  34019. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34020. * @param attachUp defines if you want to attach events to pointerup
  34021. * @param attachDown defines if you want to attach events to pointerdown
  34022. * @param attachMove defines if you want to attach events to pointermove
  34023. */
  34024. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34025. /** Detaches all event handlers*/
  34026. detachControl(): void;
  34027. /**
  34028. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  34029. * Delay loaded resources are not taking in account
  34030. * @return true if all required resources are ready
  34031. */
  34032. isReady(): boolean;
  34033. /** Resets all cached information relative to material (including effect and visibility) */
  34034. resetCachedMaterial(): void;
  34035. /**
  34036. * Registers a function to be called before every frame render
  34037. * @param func defines the function to register
  34038. */
  34039. registerBeforeRender(func: () => void): void;
  34040. /**
  34041. * Unregisters a function called before every frame render
  34042. * @param func defines the function to unregister
  34043. */
  34044. unregisterBeforeRender(func: () => void): void;
  34045. /**
  34046. * Registers a function to be called after every frame render
  34047. * @param func defines the function to register
  34048. */
  34049. registerAfterRender(func: () => void): void;
  34050. /**
  34051. * Unregisters a function called after every frame render
  34052. * @param func defines the function to unregister
  34053. */
  34054. unregisterAfterRender(func: () => void): void;
  34055. private _executeOnceBeforeRender;
  34056. /**
  34057. * The provided function will run before render once and will be disposed afterwards.
  34058. * A timeout delay can be provided so that the function will be executed in N ms.
  34059. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  34060. * @param func The function to be executed.
  34061. * @param timeout optional delay in ms
  34062. */
  34063. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  34064. /** @hidden */
  34065. _addPendingData(data: any): void;
  34066. /** @hidden */
  34067. _removePendingData(data: any): void;
  34068. /**
  34069. * Returns the number of items waiting to be loaded
  34070. * @returns the number of items waiting to be loaded
  34071. */
  34072. getWaitingItemsCount(): number;
  34073. /**
  34074. * Returns a boolean indicating if the scene is still loading data
  34075. */
  34076. readonly isLoading: boolean;
  34077. /**
  34078. * Registers a function to be executed when the scene is ready
  34079. * @param {Function} func - the function to be executed
  34080. */
  34081. executeWhenReady(func: () => void): void;
  34082. /**
  34083. * Returns a promise that resolves when the scene is ready
  34084. * @returns A promise that resolves when the scene is ready
  34085. */
  34086. whenReadyAsync(): Promise<void>;
  34087. /** @hidden */
  34088. _checkIsReady(): void;
  34089. /**
  34090. * Gets all animatable attached to the scene
  34091. */
  34092. readonly animatables: Animatable[];
  34093. /**
  34094. * Resets the last animation time frame.
  34095. * Useful to override when animations start running when loading a scene for the first time.
  34096. */
  34097. resetLastAnimationTimeFrame(): void;
  34098. /**
  34099. * Gets the current view matrix
  34100. * @returns a Matrix
  34101. */
  34102. getViewMatrix(): Matrix;
  34103. /**
  34104. * Gets the current projection matrix
  34105. * @returns a Matrix
  34106. */
  34107. getProjectionMatrix(): Matrix;
  34108. /**
  34109. * Gets the current transform matrix
  34110. * @returns a Matrix made of View * Projection
  34111. */
  34112. getTransformMatrix(): Matrix;
  34113. /**
  34114. * Sets the current transform matrix
  34115. * @param viewL defines the View matrix to use
  34116. * @param projectionL defines the Projection matrix to use
  34117. * @param viewR defines the right View matrix to use (if provided)
  34118. * @param projectionR defines the right Projection matrix to use (if provided)
  34119. */
  34120. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  34121. /**
  34122. * Gets the uniform buffer used to store scene data
  34123. * @returns a UniformBuffer
  34124. */
  34125. getSceneUniformBuffer(): UniformBuffer;
  34126. /**
  34127. * Gets an unique (relatively to the current scene) Id
  34128. * @returns an unique number for the scene
  34129. */
  34130. getUniqueId(): number;
  34131. /**
  34132. * Add a mesh to the list of scene's meshes
  34133. * @param newMesh defines the mesh to add
  34134. * @param recursive if all child meshes should also be added to the scene
  34135. */
  34136. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  34137. /**
  34138. * Remove a mesh for the list of scene's meshes
  34139. * @param toRemove defines the mesh to remove
  34140. * @param recursive if all child meshes should also be removed from the scene
  34141. * @returns the index where the mesh was in the mesh list
  34142. */
  34143. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  34144. /**
  34145. * Add a transform node to the list of scene's transform nodes
  34146. * @param newTransformNode defines the transform node to add
  34147. */
  34148. addTransformNode(newTransformNode: TransformNode): void;
  34149. /**
  34150. * Remove a transform node for the list of scene's transform nodes
  34151. * @param toRemove defines the transform node to remove
  34152. * @returns the index where the transform node was in the transform node list
  34153. */
  34154. removeTransformNode(toRemove: TransformNode): number;
  34155. /**
  34156. * Remove a skeleton for the list of scene's skeletons
  34157. * @param toRemove defines the skeleton to remove
  34158. * @returns the index where the skeleton was in the skeleton list
  34159. */
  34160. removeSkeleton(toRemove: Skeleton): number;
  34161. /**
  34162. * Remove a morph target for the list of scene's morph targets
  34163. * @param toRemove defines the morph target to remove
  34164. * @returns the index where the morph target was in the morph target list
  34165. */
  34166. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  34167. /**
  34168. * Remove a light for the list of scene's lights
  34169. * @param toRemove defines the light to remove
  34170. * @returns the index where the light was in the light list
  34171. */
  34172. removeLight(toRemove: Light): number;
  34173. /**
  34174. * Remove a camera for the list of scene's cameras
  34175. * @param toRemove defines the camera to remove
  34176. * @returns the index where the camera was in the camera list
  34177. */
  34178. removeCamera(toRemove: Camera): number;
  34179. /**
  34180. * Remove a particle system for the list of scene's particle systems
  34181. * @param toRemove defines the particle system to remove
  34182. * @returns the index where the particle system was in the particle system list
  34183. */
  34184. removeParticleSystem(toRemove: IParticleSystem): number;
  34185. /**
  34186. * Remove a animation for the list of scene's animations
  34187. * @param toRemove defines the animation to remove
  34188. * @returns the index where the animation was in the animation list
  34189. */
  34190. removeAnimation(toRemove: Animation): number;
  34191. /**
  34192. * Will stop the animation of the given target
  34193. * @param target - the target
  34194. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  34195. * @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)
  34196. */
  34197. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  34198. /**
  34199. * Removes the given animation group from this scene.
  34200. * @param toRemove The animation group to remove
  34201. * @returns The index of the removed animation group
  34202. */
  34203. removeAnimationGroup(toRemove: AnimationGroup): number;
  34204. /**
  34205. * Removes the given multi-material from this scene.
  34206. * @param toRemove The multi-material to remove
  34207. * @returns The index of the removed multi-material
  34208. */
  34209. removeMultiMaterial(toRemove: MultiMaterial): number;
  34210. /**
  34211. * Removes the given material from this scene.
  34212. * @param toRemove The material to remove
  34213. * @returns The index of the removed material
  34214. */
  34215. removeMaterial(toRemove: Material): number;
  34216. /**
  34217. * Removes the given action manager from this scene.
  34218. * @param toRemove The action manager to remove
  34219. * @returns The index of the removed action manager
  34220. */
  34221. removeActionManager(toRemove: AbstractActionManager): number;
  34222. /**
  34223. * Removes the given texture from this scene.
  34224. * @param toRemove The texture to remove
  34225. * @returns The index of the removed texture
  34226. */
  34227. removeTexture(toRemove: BaseTexture): number;
  34228. /**
  34229. * Adds the given light to this scene
  34230. * @param newLight The light to add
  34231. */
  34232. addLight(newLight: Light): void;
  34233. /**
  34234. * Sorts the list list based on light priorities
  34235. */
  34236. sortLightsByPriority(): void;
  34237. /**
  34238. * Adds the given camera to this scene
  34239. * @param newCamera The camera to add
  34240. */
  34241. addCamera(newCamera: Camera): void;
  34242. /**
  34243. * Adds the given skeleton to this scene
  34244. * @param newSkeleton The skeleton to add
  34245. */
  34246. addSkeleton(newSkeleton: Skeleton): void;
  34247. /**
  34248. * Adds the given particle system to this scene
  34249. * @param newParticleSystem The particle system to add
  34250. */
  34251. addParticleSystem(newParticleSystem: IParticleSystem): void;
  34252. /**
  34253. * Adds the given animation to this scene
  34254. * @param newAnimation The animation to add
  34255. */
  34256. addAnimation(newAnimation: Animation): void;
  34257. /**
  34258. * Adds the given animation group to this scene.
  34259. * @param newAnimationGroup The animation group to add
  34260. */
  34261. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  34262. /**
  34263. * Adds the given multi-material to this scene
  34264. * @param newMultiMaterial The multi-material to add
  34265. */
  34266. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  34267. /**
  34268. * Adds the given material to this scene
  34269. * @param newMaterial The material to add
  34270. */
  34271. addMaterial(newMaterial: Material): void;
  34272. /**
  34273. * Adds the given morph target to this scene
  34274. * @param newMorphTargetManager The morph target to add
  34275. */
  34276. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  34277. /**
  34278. * Adds the given geometry to this scene
  34279. * @param newGeometry The geometry to add
  34280. */
  34281. addGeometry(newGeometry: Geometry): void;
  34282. /**
  34283. * Adds the given action manager to this scene
  34284. * @param newActionManager The action manager to add
  34285. */
  34286. addActionManager(newActionManager: AbstractActionManager): void;
  34287. /**
  34288. * Adds the given texture to this scene.
  34289. * @param newTexture The texture to add
  34290. */
  34291. addTexture(newTexture: BaseTexture): void;
  34292. /**
  34293. * Switch active camera
  34294. * @param newCamera defines the new active camera
  34295. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  34296. */
  34297. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  34298. /**
  34299. * sets the active camera of the scene using its ID
  34300. * @param id defines the camera's ID
  34301. * @return the new active camera or null if none found.
  34302. */
  34303. setActiveCameraByID(id: string): Nullable<Camera>;
  34304. /**
  34305. * sets the active camera of the scene using its name
  34306. * @param name defines the camera's name
  34307. * @returns the new active camera or null if none found.
  34308. */
  34309. setActiveCameraByName(name: string): Nullable<Camera>;
  34310. /**
  34311. * get an animation group using its name
  34312. * @param name defines the material's name
  34313. * @return the animation group or null if none found.
  34314. */
  34315. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  34316. /**
  34317. * Get a material using its unique id
  34318. * @param uniqueId defines the material's unique id
  34319. * @return the material or null if none found.
  34320. */
  34321. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  34322. /**
  34323. * get a material using its id
  34324. * @param id defines the material's ID
  34325. * @return the material or null if none found.
  34326. */
  34327. getMaterialByID(id: string): Nullable<Material>;
  34328. /**
  34329. * Gets a material using its name
  34330. * @param name defines the material's name
  34331. * @return the material or null if none found.
  34332. */
  34333. getMaterialByName(name: string): Nullable<Material>;
  34334. /**
  34335. * Gets a camera using its id
  34336. * @param id defines the id to look for
  34337. * @returns the camera or null if not found
  34338. */
  34339. getCameraByID(id: string): Nullable<Camera>;
  34340. /**
  34341. * Gets a camera using its unique id
  34342. * @param uniqueId defines the unique id to look for
  34343. * @returns the camera or null if not found
  34344. */
  34345. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  34346. /**
  34347. * Gets a camera using its name
  34348. * @param name defines the camera's name
  34349. * @return the camera or null if none found.
  34350. */
  34351. getCameraByName(name: string): Nullable<Camera>;
  34352. /**
  34353. * Gets a bone using its id
  34354. * @param id defines the bone's id
  34355. * @return the bone or null if not found
  34356. */
  34357. getBoneByID(id: string): Nullable<Bone>;
  34358. /**
  34359. * Gets a bone using its id
  34360. * @param name defines the bone's name
  34361. * @return the bone or null if not found
  34362. */
  34363. getBoneByName(name: string): Nullable<Bone>;
  34364. /**
  34365. * Gets a light node using its name
  34366. * @param name defines the the light's name
  34367. * @return the light or null if none found.
  34368. */
  34369. getLightByName(name: string): Nullable<Light>;
  34370. /**
  34371. * Gets a light node using its id
  34372. * @param id defines the light's id
  34373. * @return the light or null if none found.
  34374. */
  34375. getLightByID(id: string): Nullable<Light>;
  34376. /**
  34377. * Gets a light node using its scene-generated unique ID
  34378. * @param uniqueId defines the light's unique id
  34379. * @return the light or null if none found.
  34380. */
  34381. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  34382. /**
  34383. * Gets a particle system by id
  34384. * @param id defines the particle system id
  34385. * @return the corresponding system or null if none found
  34386. */
  34387. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  34388. /**
  34389. * Gets a geometry using its ID
  34390. * @param id defines the geometry's id
  34391. * @return the geometry or null if none found.
  34392. */
  34393. getGeometryByID(id: string): Nullable<Geometry>;
  34394. private _getGeometryByUniqueID;
  34395. /**
  34396. * Add a new geometry to this scene
  34397. * @param geometry defines the geometry to be added to the scene.
  34398. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  34399. * @return a boolean defining if the geometry was added or not
  34400. */
  34401. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  34402. /**
  34403. * Removes an existing geometry
  34404. * @param geometry defines the geometry to be removed from the scene
  34405. * @return a boolean defining if the geometry was removed or not
  34406. */
  34407. removeGeometry(geometry: Geometry): boolean;
  34408. /**
  34409. * Gets the list of geometries attached to the scene
  34410. * @returns an array of Geometry
  34411. */
  34412. getGeometries(): Geometry[];
  34413. /**
  34414. * Gets the first added mesh found of a given ID
  34415. * @param id defines the id to search for
  34416. * @return the mesh found or null if not found at all
  34417. */
  34418. getMeshByID(id: string): Nullable<AbstractMesh>;
  34419. /**
  34420. * Gets a list of meshes using their id
  34421. * @param id defines the id to search for
  34422. * @returns a list of meshes
  34423. */
  34424. getMeshesByID(id: string): Array<AbstractMesh>;
  34425. /**
  34426. * Gets the first added transform node found of a given ID
  34427. * @param id defines the id to search for
  34428. * @return the found transform node or null if not found at all.
  34429. */
  34430. getTransformNodeByID(id: string): Nullable<TransformNode>;
  34431. /**
  34432. * Gets a transform node with its auto-generated unique id
  34433. * @param uniqueId efines the unique id to search for
  34434. * @return the found transform node or null if not found at all.
  34435. */
  34436. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  34437. /**
  34438. * Gets a list of transform nodes using their id
  34439. * @param id defines the id to search for
  34440. * @returns a list of transform nodes
  34441. */
  34442. getTransformNodesByID(id: string): Array<TransformNode>;
  34443. /**
  34444. * Gets a mesh with its auto-generated unique id
  34445. * @param uniqueId defines the unique id to search for
  34446. * @return the found mesh or null if not found at all.
  34447. */
  34448. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  34449. /**
  34450. * Gets a the last added mesh using a given id
  34451. * @param id defines the id to search for
  34452. * @return the found mesh or null if not found at all.
  34453. */
  34454. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  34455. /**
  34456. * Gets a the last added node (Mesh, Camera, Light) using a given id
  34457. * @param id defines the id to search for
  34458. * @return the found node or null if not found at all
  34459. */
  34460. getLastEntryByID(id: string): Nullable<Node>;
  34461. /**
  34462. * Gets a node (Mesh, Camera, Light) using a given id
  34463. * @param id defines the id to search for
  34464. * @return the found node or null if not found at all
  34465. */
  34466. getNodeByID(id: string): Nullable<Node>;
  34467. /**
  34468. * Gets a node (Mesh, Camera, Light) using a given name
  34469. * @param name defines the name to search for
  34470. * @return the found node or null if not found at all.
  34471. */
  34472. getNodeByName(name: string): Nullable<Node>;
  34473. /**
  34474. * Gets a mesh using a given name
  34475. * @param name defines the name to search for
  34476. * @return the found mesh or null if not found at all.
  34477. */
  34478. getMeshByName(name: string): Nullable<AbstractMesh>;
  34479. /**
  34480. * Gets a transform node using a given name
  34481. * @param name defines the name to search for
  34482. * @return the found transform node or null if not found at all.
  34483. */
  34484. getTransformNodeByName(name: string): Nullable<TransformNode>;
  34485. /**
  34486. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  34487. * @param id defines the id to search for
  34488. * @return the found skeleton or null if not found at all.
  34489. */
  34490. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  34491. /**
  34492. * Gets a skeleton using a given auto generated unique id
  34493. * @param uniqueId defines the unique id to search for
  34494. * @return the found skeleton or null if not found at all.
  34495. */
  34496. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  34497. /**
  34498. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  34499. * @param id defines the id to search for
  34500. * @return the found skeleton or null if not found at all.
  34501. */
  34502. getSkeletonById(id: string): Nullable<Skeleton>;
  34503. /**
  34504. * Gets a skeleton using a given name
  34505. * @param name defines the name to search for
  34506. * @return the found skeleton or null if not found at all.
  34507. */
  34508. getSkeletonByName(name: string): Nullable<Skeleton>;
  34509. /**
  34510. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  34511. * @param id defines the id to search for
  34512. * @return the found morph target manager or null if not found at all.
  34513. */
  34514. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  34515. /**
  34516. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  34517. * @param id defines the id to search for
  34518. * @return the found morph target or null if not found at all.
  34519. */
  34520. getMorphTargetById(id: string): Nullable<MorphTarget>;
  34521. /**
  34522. * Gets a boolean indicating if the given mesh is active
  34523. * @param mesh defines the mesh to look for
  34524. * @returns true if the mesh is in the active list
  34525. */
  34526. isActiveMesh(mesh: AbstractMesh): boolean;
  34527. /**
  34528. * Return a unique id as a string which can serve as an identifier for the scene
  34529. */
  34530. readonly uid: string;
  34531. /**
  34532. * Add an externaly attached data from its key.
  34533. * This method call will fail and return false, if such key already exists.
  34534. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  34535. * @param key the unique key that identifies the data
  34536. * @param data the data object to associate to the key for this Engine instance
  34537. * @return true if no such key were already present and the data was added successfully, false otherwise
  34538. */
  34539. addExternalData<T>(key: string, data: T): boolean;
  34540. /**
  34541. * Get an externaly attached data from its key
  34542. * @param key the unique key that identifies the data
  34543. * @return the associated data, if present (can be null), or undefined if not present
  34544. */
  34545. getExternalData<T>(key: string): Nullable<T>;
  34546. /**
  34547. * Get an externaly attached data from its key, create it using a factory if it's not already present
  34548. * @param key the unique key that identifies the data
  34549. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  34550. * @return the associated data, can be null if the factory returned null.
  34551. */
  34552. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  34553. /**
  34554. * Remove an externaly attached data from the Engine instance
  34555. * @param key the unique key that identifies the data
  34556. * @return true if the data was successfully removed, false if it doesn't exist
  34557. */
  34558. removeExternalData(key: string): boolean;
  34559. private _evaluateSubMesh;
  34560. /**
  34561. * Clear the processed materials smart array preventing retention point in material dispose.
  34562. */
  34563. freeProcessedMaterials(): void;
  34564. private _preventFreeActiveMeshesAndRenderingGroups;
  34565. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  34566. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  34567. * when disposing several meshes in a row or a hierarchy of meshes.
  34568. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  34569. */
  34570. blockfreeActiveMeshesAndRenderingGroups: boolean;
  34571. /**
  34572. * Clear the active meshes smart array preventing retention point in mesh dispose.
  34573. */
  34574. freeActiveMeshes(): void;
  34575. /**
  34576. * Clear the info related to rendering groups preventing retention points during dispose.
  34577. */
  34578. freeRenderingGroups(): void;
  34579. /** @hidden */
  34580. _isInIntermediateRendering(): boolean;
  34581. /**
  34582. * Lambda returning the list of potentially active meshes.
  34583. */
  34584. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  34585. /**
  34586. * Lambda returning the list of potentially active sub meshes.
  34587. */
  34588. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  34589. /**
  34590. * Lambda returning the list of potentially intersecting sub meshes.
  34591. */
  34592. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  34593. /**
  34594. * Lambda returning the list of potentially colliding sub meshes.
  34595. */
  34596. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  34597. private _activeMeshesFrozen;
  34598. /**
  34599. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  34600. * @returns the current scene
  34601. */
  34602. freezeActiveMeshes(): Scene;
  34603. /**
  34604. * Use this function to restart evaluating active meshes on every frame
  34605. * @returns the current scene
  34606. */
  34607. unfreezeActiveMeshes(): Scene;
  34608. private _evaluateActiveMeshes;
  34609. private _activeMesh;
  34610. /**
  34611. * Update the transform matrix to update from the current active camera
  34612. * @param force defines a boolean used to force the update even if cache is up to date
  34613. */
  34614. updateTransformMatrix(force?: boolean): void;
  34615. private _bindFrameBuffer;
  34616. /** @hidden */
  34617. _allowPostProcessClearColor: boolean;
  34618. /** @hidden */
  34619. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  34620. private _processSubCameras;
  34621. private _checkIntersections;
  34622. /** @hidden */
  34623. _advancePhysicsEngineStep(step: number): void;
  34624. /**
  34625. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  34626. */
  34627. getDeterministicFrameTime: () => number;
  34628. /** @hidden */
  34629. _animate(): void;
  34630. /** Execute all animations (for a frame) */
  34631. animate(): void;
  34632. /**
  34633. * Render the scene
  34634. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  34635. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  34636. */
  34637. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  34638. /**
  34639. * Freeze all materials
  34640. * A frozen material will not be updatable but should be faster to render
  34641. */
  34642. freezeMaterials(): void;
  34643. /**
  34644. * Unfreeze all materials
  34645. * A frozen material will not be updatable but should be faster to render
  34646. */
  34647. unfreezeMaterials(): void;
  34648. /**
  34649. * Releases all held ressources
  34650. */
  34651. dispose(): void;
  34652. /**
  34653. * Gets if the scene is already disposed
  34654. */
  34655. readonly isDisposed: boolean;
  34656. /**
  34657. * Call this function to reduce memory footprint of the scene.
  34658. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  34659. */
  34660. clearCachedVertexData(): void;
  34661. /**
  34662. * This function will remove the local cached buffer data from texture.
  34663. * It will save memory but will prevent the texture from being rebuilt
  34664. */
  34665. cleanCachedTextureBuffer(): void;
  34666. /**
  34667. * Get the world extend vectors with an optional filter
  34668. *
  34669. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  34670. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  34671. */
  34672. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  34673. min: Vector3;
  34674. max: Vector3;
  34675. };
  34676. /**
  34677. * Creates a ray that can be used to pick in the scene
  34678. * @param x defines the x coordinate of the origin (on-screen)
  34679. * @param y defines the y coordinate of the origin (on-screen)
  34680. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34681. * @param camera defines the camera to use for the picking
  34682. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34683. * @returns a Ray
  34684. */
  34685. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  34686. /**
  34687. * Creates a ray that can be used to pick in the scene
  34688. * @param x defines the x coordinate of the origin (on-screen)
  34689. * @param y defines the y coordinate of the origin (on-screen)
  34690. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34691. * @param result defines the ray where to store the picking ray
  34692. * @param camera defines the camera to use for the picking
  34693. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34694. * @returns the current scene
  34695. */
  34696. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  34697. /**
  34698. * Creates a ray that can be used to pick in the scene
  34699. * @param x defines the x coordinate of the origin (on-screen)
  34700. * @param y defines the y coordinate of the origin (on-screen)
  34701. * @param camera defines the camera to use for the picking
  34702. * @returns a Ray
  34703. */
  34704. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  34705. /**
  34706. * Creates a ray that can be used to pick in the scene
  34707. * @param x defines the x coordinate of the origin (on-screen)
  34708. * @param y defines the y coordinate of the origin (on-screen)
  34709. * @param result defines the ray where to store the picking ray
  34710. * @param camera defines the camera to use for the picking
  34711. * @returns the current scene
  34712. */
  34713. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  34714. /** Launch a ray to try to pick a mesh in the scene
  34715. * @param x position on screen
  34716. * @param y position on screen
  34717. * @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
  34718. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34719. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34720. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34721. * @returns a PickingInfo
  34722. */
  34723. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34724. /** Use the given ray to pick a mesh in the scene
  34725. * @param ray The ray to use to pick meshes
  34726. * @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
  34727. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  34728. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34729. * @returns a PickingInfo
  34730. */
  34731. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34732. /**
  34733. * Launch a ray to try to pick a mesh in the scene
  34734. * @param x X position on screen
  34735. * @param y Y position on screen
  34736. * @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
  34737. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34738. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34739. * @returns an array of PickingInfo
  34740. */
  34741. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34742. /**
  34743. * Launch a ray to try to pick a mesh in the scene
  34744. * @param ray Ray to use
  34745. * @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
  34746. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34747. * @returns an array of PickingInfo
  34748. */
  34749. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34750. /**
  34751. * Force the value of meshUnderPointer
  34752. * @param mesh defines the mesh to use
  34753. */
  34754. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34755. /**
  34756. * Gets the mesh under the pointer
  34757. * @returns a Mesh or null if no mesh is under the pointer
  34758. */
  34759. getPointerOverMesh(): Nullable<AbstractMesh>;
  34760. /** @hidden */
  34761. _rebuildGeometries(): void;
  34762. /** @hidden */
  34763. _rebuildTextures(): void;
  34764. private _getByTags;
  34765. /**
  34766. * Get a list of meshes by tags
  34767. * @param tagsQuery defines the tags query to use
  34768. * @param forEach defines a predicate used to filter results
  34769. * @returns an array of Mesh
  34770. */
  34771. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34772. /**
  34773. * Get a list of cameras by tags
  34774. * @param tagsQuery defines the tags query to use
  34775. * @param forEach defines a predicate used to filter results
  34776. * @returns an array of Camera
  34777. */
  34778. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34779. /**
  34780. * Get a list of lights by tags
  34781. * @param tagsQuery defines the tags query to use
  34782. * @param forEach defines a predicate used to filter results
  34783. * @returns an array of Light
  34784. */
  34785. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34786. /**
  34787. * Get a list of materials by tags
  34788. * @param tagsQuery defines the tags query to use
  34789. * @param forEach defines a predicate used to filter results
  34790. * @returns an array of Material
  34791. */
  34792. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34793. /**
  34794. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34795. * This allowed control for front to back rendering or reversly depending of the special needs.
  34796. *
  34797. * @param renderingGroupId The rendering group id corresponding to its index
  34798. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34799. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34800. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34801. */
  34802. 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;
  34803. /**
  34804. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34805. *
  34806. * @param renderingGroupId The rendering group id corresponding to its index
  34807. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34808. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34809. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34810. */
  34811. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34812. /**
  34813. * Gets the current auto clear configuration for one rendering group of the rendering
  34814. * manager.
  34815. * @param index the rendering group index to get the information for
  34816. * @returns The auto clear setup for the requested rendering group
  34817. */
  34818. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34819. private _blockMaterialDirtyMechanism;
  34820. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34821. blockMaterialDirtyMechanism: boolean;
  34822. /**
  34823. * Will flag all materials as dirty to trigger new shader compilation
  34824. * @param flag defines the flag used to specify which material part must be marked as dirty
  34825. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34826. */
  34827. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34828. /** @hidden */
  34829. _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;
  34830. /** @hidden */
  34831. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34832. }
  34833. }
  34834. declare module "babylonjs/assetContainer" {
  34835. import { AbstractScene } from "babylonjs/abstractScene";
  34836. import { Scene } from "babylonjs/scene";
  34837. import { Mesh } from "babylonjs/Meshes/mesh";
  34838. /**
  34839. * Set of assets to keep when moving a scene into an asset container.
  34840. */
  34841. export class KeepAssets extends AbstractScene {
  34842. }
  34843. /**
  34844. * Container with a set of assets that can be added or removed from a scene.
  34845. */
  34846. export class AssetContainer extends AbstractScene {
  34847. /**
  34848. * The scene the AssetContainer belongs to.
  34849. */
  34850. scene: Scene;
  34851. /**
  34852. * Instantiates an AssetContainer.
  34853. * @param scene The scene the AssetContainer belongs to.
  34854. */
  34855. constructor(scene: Scene);
  34856. /**
  34857. * Adds all the assets from the container to the scene.
  34858. */
  34859. addAllToScene(): void;
  34860. /**
  34861. * Removes all the assets in the container from the scene
  34862. */
  34863. removeAllFromScene(): void;
  34864. /**
  34865. * Disposes all the assets in the container
  34866. */
  34867. dispose(): void;
  34868. private _moveAssets;
  34869. /**
  34870. * Removes all the assets contained in the scene and adds them to the container.
  34871. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34872. */
  34873. moveAllFromScene(keepAssets?: KeepAssets): void;
  34874. /**
  34875. * 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.
  34876. * @returns the root mesh
  34877. */
  34878. createRootMesh(): Mesh;
  34879. }
  34880. }
  34881. declare module "babylonjs/abstractScene" {
  34882. import { Scene } from "babylonjs/scene";
  34883. import { Nullable } from "babylonjs/types";
  34884. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34885. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34886. import { Geometry } from "babylonjs/Meshes/geometry";
  34887. import { Skeleton } from "babylonjs/Bones/skeleton";
  34888. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  34889. import { AssetContainer } from "babylonjs/assetContainer";
  34890. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  34891. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  34892. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34893. import { Material } from "babylonjs/Materials/material";
  34894. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  34895. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  34896. import { Camera } from "babylonjs/Cameras/camera";
  34897. import { Light } from "babylonjs/Lights/light";
  34898. import { Node } from "babylonjs/node";
  34899. import { Animation } from "babylonjs/Animations/animation";
  34900. /**
  34901. * Defines how the parser contract is defined.
  34902. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34903. */
  34904. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34905. /**
  34906. * Defines how the individual parser contract is defined.
  34907. * These parser can parse an individual asset
  34908. */
  34909. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  34910. /**
  34911. * Base class of the scene acting as a container for the different elements composing a scene.
  34912. * This class is dynamically extended by the different components of the scene increasing
  34913. * flexibility and reducing coupling
  34914. */
  34915. export abstract class AbstractScene {
  34916. /**
  34917. * Stores the list of available parsers in the application.
  34918. */
  34919. private static _BabylonFileParsers;
  34920. /**
  34921. * Stores the list of available individual parsers in the application.
  34922. */
  34923. private static _IndividualBabylonFileParsers;
  34924. /**
  34925. * Adds a parser in the list of available ones
  34926. * @param name Defines the name of the parser
  34927. * @param parser Defines the parser to add
  34928. */
  34929. static AddParser(name: string, parser: BabylonFileParser): void;
  34930. /**
  34931. * Gets a general parser from the list of avaialble ones
  34932. * @param name Defines the name of the parser
  34933. * @returns the requested parser or null
  34934. */
  34935. static GetParser(name: string): Nullable<BabylonFileParser>;
  34936. /**
  34937. * Adds n individual parser in the list of available ones
  34938. * @param name Defines the name of the parser
  34939. * @param parser Defines the parser to add
  34940. */
  34941. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34942. /**
  34943. * Gets an individual parser from the list of avaialble ones
  34944. * @param name Defines the name of the parser
  34945. * @returns the requested parser or null
  34946. */
  34947. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34948. /**
  34949. * Parser json data and populate both a scene and its associated container object
  34950. * @param jsonData Defines the data to parse
  34951. * @param scene Defines the scene to parse the data for
  34952. * @param container Defines the container attached to the parsing sequence
  34953. * @param rootUrl Defines the root url of the data
  34954. */
  34955. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34956. /**
  34957. * Gets the list of root nodes (ie. nodes with no parent)
  34958. */
  34959. rootNodes: Node[];
  34960. /** All of the cameras added to this scene
  34961. * @see http://doc.babylonjs.com/babylon101/cameras
  34962. */
  34963. cameras: Camera[];
  34964. /**
  34965. * All of the lights added to this scene
  34966. * @see http://doc.babylonjs.com/babylon101/lights
  34967. */
  34968. lights: Light[];
  34969. /**
  34970. * All of the (abstract) meshes added to this scene
  34971. */
  34972. meshes: AbstractMesh[];
  34973. /**
  34974. * The list of skeletons added to the scene
  34975. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  34976. */
  34977. skeletons: Skeleton[];
  34978. /**
  34979. * All of the particle systems added to this scene
  34980. * @see http://doc.babylonjs.com/babylon101/particles
  34981. */
  34982. particleSystems: IParticleSystem[];
  34983. /**
  34984. * Gets a list of Animations associated with the scene
  34985. */
  34986. animations: Animation[];
  34987. /**
  34988. * All of the animation groups added to this scene
  34989. * @see http://doc.babylonjs.com/how_to/group
  34990. */
  34991. animationGroups: AnimationGroup[];
  34992. /**
  34993. * All of the multi-materials added to this scene
  34994. * @see http://doc.babylonjs.com/how_to/multi_materials
  34995. */
  34996. multiMaterials: MultiMaterial[];
  34997. /**
  34998. * All of the materials added to this scene
  34999. * In the context of a Scene, it is not supposed to be modified manually.
  35000. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  35001. * Note also that the order of the Material wihin the array is not significant and might change.
  35002. * @see http://doc.babylonjs.com/babylon101/materials
  35003. */
  35004. materials: Material[];
  35005. /**
  35006. * The list of morph target managers added to the scene
  35007. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  35008. */
  35009. morphTargetManagers: MorphTargetManager[];
  35010. /**
  35011. * The list of geometries used in the scene.
  35012. */
  35013. geometries: Geometry[];
  35014. /**
  35015. * All of the tranform nodes added to this scene
  35016. * In the context of a Scene, it is not supposed to be modified manually.
  35017. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  35018. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  35019. * @see http://doc.babylonjs.com/how_to/transformnode
  35020. */
  35021. transformNodes: TransformNode[];
  35022. /**
  35023. * ActionManagers available on the scene.
  35024. */
  35025. actionManagers: AbstractActionManager[];
  35026. /**
  35027. * Textures to keep.
  35028. */
  35029. textures: BaseTexture[];
  35030. /**
  35031. * Environment texture for the scene
  35032. */
  35033. environmentTexture: Nullable<BaseTexture>;
  35034. }
  35035. }
  35036. declare module "babylonjs/Audio/sound" {
  35037. import { Observable } from "babylonjs/Misc/observable";
  35038. import { Vector3 } from "babylonjs/Maths/math";
  35039. import { Nullable } from "babylonjs/types";
  35040. import { Scene } from "babylonjs/scene";
  35041. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35042. /**
  35043. * Defines a sound that can be played in the application.
  35044. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  35045. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35046. */
  35047. export class Sound {
  35048. /**
  35049. * The name of the sound in the scene.
  35050. */
  35051. name: string;
  35052. /**
  35053. * Does the sound autoplay once loaded.
  35054. */
  35055. autoplay: boolean;
  35056. /**
  35057. * Does the sound loop after it finishes playing once.
  35058. */
  35059. loop: boolean;
  35060. /**
  35061. * Does the sound use a custom attenuation curve to simulate the falloff
  35062. * happening when the source gets further away from the camera.
  35063. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35064. */
  35065. useCustomAttenuation: boolean;
  35066. /**
  35067. * The sound track id this sound belongs to.
  35068. */
  35069. soundTrackId: number;
  35070. /**
  35071. * Is this sound currently played.
  35072. */
  35073. isPlaying: boolean;
  35074. /**
  35075. * Is this sound currently paused.
  35076. */
  35077. isPaused: boolean;
  35078. /**
  35079. * Does this sound enables spatial sound.
  35080. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35081. */
  35082. spatialSound: boolean;
  35083. /**
  35084. * Define the reference distance the sound should be heard perfectly.
  35085. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35086. */
  35087. refDistance: number;
  35088. /**
  35089. * Define the roll off factor of spatial sounds.
  35090. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35091. */
  35092. rolloffFactor: number;
  35093. /**
  35094. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  35095. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35096. */
  35097. maxDistance: number;
  35098. /**
  35099. * Define the distance attenuation model the sound will follow.
  35100. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35101. */
  35102. distanceModel: string;
  35103. /**
  35104. * @hidden
  35105. * Back Compat
  35106. **/
  35107. onended: () => any;
  35108. /**
  35109. * Observable event when the current playing sound finishes.
  35110. */
  35111. onEndedObservable: Observable<Sound>;
  35112. private _panningModel;
  35113. private _playbackRate;
  35114. private _streaming;
  35115. private _startTime;
  35116. private _startOffset;
  35117. private _position;
  35118. /** @hidden */
  35119. _positionInEmitterSpace: boolean;
  35120. private _localDirection;
  35121. private _volume;
  35122. private _isReadyToPlay;
  35123. private _isDirectional;
  35124. private _readyToPlayCallback;
  35125. private _audioBuffer;
  35126. private _soundSource;
  35127. private _streamingSource;
  35128. private _soundPanner;
  35129. private _soundGain;
  35130. private _inputAudioNode;
  35131. private _outputAudioNode;
  35132. private _coneInnerAngle;
  35133. private _coneOuterAngle;
  35134. private _coneOuterGain;
  35135. private _scene;
  35136. private _connectedTransformNode;
  35137. private _customAttenuationFunction;
  35138. private _registerFunc;
  35139. private _isOutputConnected;
  35140. private _htmlAudioElement;
  35141. private _urlType;
  35142. /** @hidden */
  35143. static _SceneComponentInitialization: (scene: Scene) => void;
  35144. /**
  35145. * Create a sound and attach it to a scene
  35146. * @param name Name of your sound
  35147. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  35148. * @param scene defines the scene the sound belongs to
  35149. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  35150. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  35151. */
  35152. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  35153. /**
  35154. * Release the sound and its associated resources
  35155. */
  35156. dispose(): void;
  35157. /**
  35158. * Gets if the sounds is ready to be played or not.
  35159. * @returns true if ready, otherwise false
  35160. */
  35161. isReady(): boolean;
  35162. private _soundLoaded;
  35163. /**
  35164. * Sets the data of the sound from an audiobuffer
  35165. * @param audioBuffer The audioBuffer containing the data
  35166. */
  35167. setAudioBuffer(audioBuffer: AudioBuffer): void;
  35168. /**
  35169. * Updates the current sounds options such as maxdistance, loop...
  35170. * @param options A JSON object containing values named as the object properties
  35171. */
  35172. updateOptions(options: any): void;
  35173. private _createSpatialParameters;
  35174. private _updateSpatialParameters;
  35175. /**
  35176. * Switch the panning model to HRTF:
  35177. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35178. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35179. */
  35180. switchPanningModelToHRTF(): void;
  35181. /**
  35182. * Switch the panning model to Equal Power:
  35183. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35184. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35185. */
  35186. switchPanningModelToEqualPower(): void;
  35187. private _switchPanningModel;
  35188. /**
  35189. * Connect this sound to a sound track audio node like gain...
  35190. * @param soundTrackAudioNode the sound track audio node to connect to
  35191. */
  35192. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  35193. /**
  35194. * Transform this sound into a directional source
  35195. * @param coneInnerAngle Size of the inner cone in degree
  35196. * @param coneOuterAngle Size of the outer cone in degree
  35197. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  35198. */
  35199. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  35200. /**
  35201. * Gets or sets the inner angle for the directional cone.
  35202. */
  35203. /**
  35204. * Gets or sets the inner angle for the directional cone.
  35205. */
  35206. directionalConeInnerAngle: number;
  35207. /**
  35208. * Gets or sets the outer angle for the directional cone.
  35209. */
  35210. /**
  35211. * Gets or sets the outer angle for the directional cone.
  35212. */
  35213. directionalConeOuterAngle: number;
  35214. /**
  35215. * Sets the position of the emitter if spatial sound is enabled
  35216. * @param newPosition Defines the new posisiton
  35217. */
  35218. setPosition(newPosition: Vector3): void;
  35219. /**
  35220. * Sets the local direction of the emitter if spatial sound is enabled
  35221. * @param newLocalDirection Defines the new local direction
  35222. */
  35223. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  35224. private _updateDirection;
  35225. /** @hidden */
  35226. updateDistanceFromListener(): void;
  35227. /**
  35228. * Sets a new custom attenuation function for the sound.
  35229. * @param callback Defines the function used for the attenuation
  35230. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35231. */
  35232. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  35233. /**
  35234. * Play the sound
  35235. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  35236. * @param offset (optional) Start the sound setting it at a specific time
  35237. */
  35238. play(time?: number, offset?: number): void;
  35239. private _onended;
  35240. /**
  35241. * Stop the sound
  35242. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  35243. */
  35244. stop(time?: number): void;
  35245. /**
  35246. * Put the sound in pause
  35247. */
  35248. pause(): void;
  35249. /**
  35250. * Sets a dedicated volume for this sounds
  35251. * @param newVolume Define the new volume of the sound
  35252. * @param time Define in how long the sound should be at this value
  35253. */
  35254. setVolume(newVolume: number, time?: number): void;
  35255. /**
  35256. * Set the sound play back rate
  35257. * @param newPlaybackRate Define the playback rate the sound should be played at
  35258. */
  35259. setPlaybackRate(newPlaybackRate: number): void;
  35260. /**
  35261. * Gets the volume of the sound.
  35262. * @returns the volume of the sound
  35263. */
  35264. getVolume(): number;
  35265. /**
  35266. * Attach the sound to a dedicated mesh
  35267. * @param transformNode The transform node to connect the sound with
  35268. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35269. */
  35270. attachToMesh(transformNode: TransformNode): void;
  35271. /**
  35272. * Detach the sound from the previously attached mesh
  35273. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35274. */
  35275. detachFromMesh(): void;
  35276. private _onRegisterAfterWorldMatrixUpdate;
  35277. /**
  35278. * Clone the current sound in the scene.
  35279. * @returns the new sound clone
  35280. */
  35281. clone(): Nullable<Sound>;
  35282. /**
  35283. * Gets the current underlying audio buffer containing the data
  35284. * @returns the audio buffer
  35285. */
  35286. getAudioBuffer(): Nullable<AudioBuffer>;
  35287. /**
  35288. * Serializes the Sound in a JSON representation
  35289. * @returns the JSON representation of the sound
  35290. */
  35291. serialize(): any;
  35292. /**
  35293. * Parse a JSON representation of a sound to innstantiate in a given scene
  35294. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  35295. * @param scene Define the scene the new parsed sound should be created in
  35296. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  35297. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  35298. * @returns the newly parsed sound
  35299. */
  35300. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  35301. }
  35302. }
  35303. declare module "babylonjs/Actions/directAudioActions" {
  35304. import { Action } from "babylonjs/Actions/action";
  35305. import { Condition } from "babylonjs/Actions/condition";
  35306. import { Sound } from "babylonjs/Audio/sound";
  35307. /**
  35308. * This defines an action helpful to play a defined sound on a triggered action.
  35309. */
  35310. export class PlaySoundAction extends Action {
  35311. private _sound;
  35312. /**
  35313. * Instantiate the action
  35314. * @param triggerOptions defines the trigger options
  35315. * @param sound defines the sound to play
  35316. * @param condition defines the trigger related conditions
  35317. */
  35318. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35319. /** @hidden */
  35320. _prepare(): void;
  35321. /**
  35322. * Execute the action and play the sound.
  35323. */
  35324. execute(): void;
  35325. /**
  35326. * Serializes the actions and its related information.
  35327. * @param parent defines the object to serialize in
  35328. * @returns the serialized object
  35329. */
  35330. serialize(parent: any): any;
  35331. }
  35332. /**
  35333. * This defines an action helpful to stop a defined sound on a triggered action.
  35334. */
  35335. export class StopSoundAction extends Action {
  35336. private _sound;
  35337. /**
  35338. * Instantiate the action
  35339. * @param triggerOptions defines the trigger options
  35340. * @param sound defines the sound to stop
  35341. * @param condition defines the trigger related conditions
  35342. */
  35343. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35344. /** @hidden */
  35345. _prepare(): void;
  35346. /**
  35347. * Execute the action and stop the sound.
  35348. */
  35349. execute(): void;
  35350. /**
  35351. * Serializes the actions and its related information.
  35352. * @param parent defines the object to serialize in
  35353. * @returns the serialized object
  35354. */
  35355. serialize(parent: any): any;
  35356. }
  35357. }
  35358. declare module "babylonjs/Actions/interpolateValueAction" {
  35359. import { Action } from "babylonjs/Actions/action";
  35360. import { Condition } from "babylonjs/Actions/condition";
  35361. import { Observable } from "babylonjs/Misc/observable";
  35362. /**
  35363. * This defines an action responsible to change the value of a property
  35364. * by interpolating between its current value and the newly set one once triggered.
  35365. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35366. */
  35367. export class InterpolateValueAction extends Action {
  35368. /**
  35369. * Defines the path of the property where the value should be interpolated
  35370. */
  35371. propertyPath: string;
  35372. /**
  35373. * Defines the target value at the end of the interpolation.
  35374. */
  35375. value: any;
  35376. /**
  35377. * Defines the time it will take for the property to interpolate to the value.
  35378. */
  35379. duration: number;
  35380. /**
  35381. * Defines if the other scene animations should be stopped when the action has been triggered
  35382. */
  35383. stopOtherAnimations?: boolean;
  35384. /**
  35385. * Defines a callback raised once the interpolation animation has been done.
  35386. */
  35387. onInterpolationDone?: () => void;
  35388. /**
  35389. * Observable triggered once the interpolation animation has been done.
  35390. */
  35391. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  35392. private _target;
  35393. private _effectiveTarget;
  35394. private _property;
  35395. /**
  35396. * Instantiate the action
  35397. * @param triggerOptions defines the trigger options
  35398. * @param target defines the object containing the value to interpolate
  35399. * @param propertyPath defines the path to the property in the target object
  35400. * @param value defines the target value at the end of the interpolation
  35401. * @param duration deines the time it will take for the property to interpolate to the value.
  35402. * @param condition defines the trigger related conditions
  35403. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  35404. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  35405. */
  35406. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  35407. /** @hidden */
  35408. _prepare(): void;
  35409. /**
  35410. * Execute the action starts the value interpolation.
  35411. */
  35412. execute(): void;
  35413. /**
  35414. * Serializes the actions and its related information.
  35415. * @param parent defines the object to serialize in
  35416. * @returns the serialized object
  35417. */
  35418. serialize(parent: any): any;
  35419. }
  35420. }
  35421. declare module "babylonjs/Actions/index" {
  35422. export * from "babylonjs/Actions/action";
  35423. export * from "babylonjs/Actions/actionEvent";
  35424. export * from "babylonjs/Actions/actionManager";
  35425. export * from "babylonjs/Actions/condition";
  35426. export * from "babylonjs/Actions/directActions";
  35427. export * from "babylonjs/Actions/directAudioActions";
  35428. export * from "babylonjs/Actions/interpolateValueAction";
  35429. }
  35430. declare module "babylonjs/Animations/index" {
  35431. export * from "babylonjs/Animations/animatable";
  35432. export * from "babylonjs/Animations/animation";
  35433. export * from "babylonjs/Animations/animationGroup";
  35434. export * from "babylonjs/Animations/animationPropertiesOverride";
  35435. export * from "babylonjs/Animations/easing";
  35436. export * from "babylonjs/Animations/runtimeAnimation";
  35437. export * from "babylonjs/Animations/animationEvent";
  35438. export * from "babylonjs/Animations/animationGroup";
  35439. export * from "babylonjs/Animations/animationKey";
  35440. export * from "babylonjs/Animations/animationRange";
  35441. }
  35442. declare module "babylonjs/Audio/soundTrack" {
  35443. import { Sound } from "babylonjs/Audio/sound";
  35444. import { Analyser } from "babylonjs/Audio/analyser";
  35445. import { Scene } from "babylonjs/scene";
  35446. /**
  35447. * Options allowed during the creation of a sound track.
  35448. */
  35449. export interface ISoundTrackOptions {
  35450. /**
  35451. * The volume the sound track should take during creation
  35452. */
  35453. volume?: number;
  35454. /**
  35455. * Define if the sound track is the main sound track of the scene
  35456. */
  35457. mainTrack?: boolean;
  35458. }
  35459. /**
  35460. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  35461. * It will be also used in a future release to apply effects on a specific track.
  35462. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35463. */
  35464. export class SoundTrack {
  35465. /**
  35466. * The unique identifier of the sound track in the scene.
  35467. */
  35468. id: number;
  35469. /**
  35470. * The list of sounds included in the sound track.
  35471. */
  35472. soundCollection: Array<Sound>;
  35473. private _outputAudioNode;
  35474. private _scene;
  35475. private _isMainTrack;
  35476. private _connectedAnalyser;
  35477. private _options;
  35478. private _isInitialized;
  35479. /**
  35480. * Creates a new sound track.
  35481. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35482. * @param scene Define the scene the sound track belongs to
  35483. * @param options
  35484. */
  35485. constructor(scene: Scene, options?: ISoundTrackOptions);
  35486. private _initializeSoundTrackAudioGraph;
  35487. /**
  35488. * Release the sound track and its associated resources
  35489. */
  35490. dispose(): void;
  35491. /**
  35492. * Adds a sound to this sound track
  35493. * @param sound define the cound to add
  35494. * @ignoreNaming
  35495. */
  35496. AddSound(sound: Sound): void;
  35497. /**
  35498. * Removes a sound to this sound track
  35499. * @param sound define the cound to remove
  35500. * @ignoreNaming
  35501. */
  35502. RemoveSound(sound: Sound): void;
  35503. /**
  35504. * Set a global volume for the full sound track.
  35505. * @param newVolume Define the new volume of the sound track
  35506. */
  35507. setVolume(newVolume: number): void;
  35508. /**
  35509. * Switch the panning model to HRTF:
  35510. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35511. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35512. */
  35513. switchPanningModelToHRTF(): void;
  35514. /**
  35515. * Switch the panning model to Equal Power:
  35516. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35517. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35518. */
  35519. switchPanningModelToEqualPower(): void;
  35520. /**
  35521. * Connect the sound track to an audio analyser allowing some amazing
  35522. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35523. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35524. * @param analyser The analyser to connect to the engine
  35525. */
  35526. connectToAnalyser(analyser: Analyser): void;
  35527. }
  35528. }
  35529. declare module "babylonjs/Audio/audioSceneComponent" {
  35530. import { Sound } from "babylonjs/Audio/sound";
  35531. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  35532. import { Nullable } from "babylonjs/types";
  35533. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  35534. import { Scene } from "babylonjs/scene";
  35535. import { AbstractScene } from "babylonjs/abstractScene";
  35536. module "babylonjs/abstractScene" {
  35537. interface AbstractScene {
  35538. /**
  35539. * The list of sounds used in the scene.
  35540. */
  35541. sounds: Nullable<Array<Sound>>;
  35542. }
  35543. }
  35544. module "babylonjs/scene" {
  35545. interface Scene {
  35546. /**
  35547. * @hidden
  35548. * Backing field
  35549. */
  35550. _mainSoundTrack: SoundTrack;
  35551. /**
  35552. * The main sound track played by the scene.
  35553. * It cotains your primary collection of sounds.
  35554. */
  35555. mainSoundTrack: SoundTrack;
  35556. /**
  35557. * The list of sound tracks added to the scene
  35558. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35559. */
  35560. soundTracks: Nullable<Array<SoundTrack>>;
  35561. /**
  35562. * Gets a sound using a given name
  35563. * @param name defines the name to search for
  35564. * @return the found sound or null if not found at all.
  35565. */
  35566. getSoundByName(name: string): Nullable<Sound>;
  35567. /**
  35568. * Gets or sets if audio support is enabled
  35569. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35570. */
  35571. audioEnabled: boolean;
  35572. /**
  35573. * Gets or sets if audio will be output to headphones
  35574. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35575. */
  35576. headphone: boolean;
  35577. }
  35578. }
  35579. /**
  35580. * Defines the sound scene component responsible to manage any sounds
  35581. * in a given scene.
  35582. */
  35583. export class AudioSceneComponent implements ISceneSerializableComponent {
  35584. /**
  35585. * The component name helpfull to identify the component in the list of scene components.
  35586. */
  35587. readonly name: string;
  35588. /**
  35589. * The scene the component belongs to.
  35590. */
  35591. scene: Scene;
  35592. private _audioEnabled;
  35593. /**
  35594. * Gets whether audio is enabled or not.
  35595. * Please use related enable/disable method to switch state.
  35596. */
  35597. readonly audioEnabled: boolean;
  35598. private _headphone;
  35599. /**
  35600. * Gets whether audio is outputing to headphone or not.
  35601. * Please use the according Switch methods to change output.
  35602. */
  35603. readonly headphone: boolean;
  35604. /**
  35605. * Creates a new instance of the component for the given scene
  35606. * @param scene Defines the scene to register the component in
  35607. */
  35608. constructor(scene: Scene);
  35609. /**
  35610. * Registers the component in a given scene
  35611. */
  35612. register(): void;
  35613. /**
  35614. * Rebuilds the elements related to this component in case of
  35615. * context lost for instance.
  35616. */
  35617. rebuild(): void;
  35618. /**
  35619. * Serializes the component data to the specified json object
  35620. * @param serializationObject The object to serialize to
  35621. */
  35622. serialize(serializationObject: any): void;
  35623. /**
  35624. * Adds all the elements from the container to the scene
  35625. * @param container the container holding the elements
  35626. */
  35627. addFromContainer(container: AbstractScene): void;
  35628. /**
  35629. * Removes all the elements in the container from the scene
  35630. * @param container contains the elements to remove
  35631. * @param dispose if the removed element should be disposed (default: false)
  35632. */
  35633. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  35634. /**
  35635. * Disposes the component and the associated ressources.
  35636. */
  35637. dispose(): void;
  35638. /**
  35639. * Disables audio in the associated scene.
  35640. */
  35641. disableAudio(): void;
  35642. /**
  35643. * Enables audio in the associated scene.
  35644. */
  35645. enableAudio(): void;
  35646. /**
  35647. * Switch audio to headphone output.
  35648. */
  35649. switchAudioModeForHeadphones(): void;
  35650. /**
  35651. * Switch audio to normal speakers.
  35652. */
  35653. switchAudioModeForNormalSpeakers(): void;
  35654. private _afterRender;
  35655. }
  35656. }
  35657. declare module "babylonjs/Audio/weightedsound" {
  35658. import { Sound } from "babylonjs/Audio/sound";
  35659. /**
  35660. * Wraps one or more Sound objects and selects one with random weight for playback.
  35661. */
  35662. export class WeightedSound {
  35663. /** When true a Sound will be selected and played when the current playing Sound completes. */
  35664. loop: boolean;
  35665. private _coneInnerAngle;
  35666. private _coneOuterAngle;
  35667. private _volume;
  35668. /** A Sound is currently playing. */
  35669. isPlaying: boolean;
  35670. /** A Sound is currently paused. */
  35671. isPaused: boolean;
  35672. private _sounds;
  35673. private _weights;
  35674. private _currentIndex?;
  35675. /**
  35676. * Creates a new WeightedSound from the list of sounds given.
  35677. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  35678. * @param sounds Array of Sounds that will be selected from.
  35679. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  35680. */
  35681. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  35682. /**
  35683. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  35684. */
  35685. /**
  35686. * The size of cone in degress for a directional sound in which there will be no attenuation.
  35687. */
  35688. directionalConeInnerAngle: number;
  35689. /**
  35690. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35691. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35692. */
  35693. /**
  35694. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35695. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35696. */
  35697. directionalConeOuterAngle: number;
  35698. /**
  35699. * Playback volume.
  35700. */
  35701. /**
  35702. * Playback volume.
  35703. */
  35704. volume: number;
  35705. private _onended;
  35706. /**
  35707. * Suspend playback
  35708. */
  35709. pause(): void;
  35710. /**
  35711. * Stop playback
  35712. */
  35713. stop(): void;
  35714. /**
  35715. * Start playback.
  35716. * @param startOffset Position the clip head at a specific time in seconds.
  35717. */
  35718. play(startOffset?: number): void;
  35719. }
  35720. }
  35721. declare module "babylonjs/Audio/index" {
  35722. export * from "babylonjs/Audio/analyser";
  35723. export * from "babylonjs/Audio/audioEngine";
  35724. export * from "babylonjs/Audio/audioSceneComponent";
  35725. export * from "babylonjs/Audio/sound";
  35726. export * from "babylonjs/Audio/soundTrack";
  35727. export * from "babylonjs/Audio/weightedsound";
  35728. }
  35729. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  35730. import { Behavior } from "babylonjs/Behaviors/behavior";
  35731. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35732. import { BackEase } from "babylonjs/Animations/easing";
  35733. /**
  35734. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  35735. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35736. */
  35737. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  35738. /**
  35739. * Gets the name of the behavior.
  35740. */
  35741. readonly name: string;
  35742. /**
  35743. * The easing function used by animations
  35744. */
  35745. static EasingFunction: BackEase;
  35746. /**
  35747. * The easing mode used by animations
  35748. */
  35749. static EasingMode: number;
  35750. /**
  35751. * The duration of the animation, in milliseconds
  35752. */
  35753. transitionDuration: number;
  35754. /**
  35755. * Length of the distance animated by the transition when lower radius is reached
  35756. */
  35757. lowerRadiusTransitionRange: number;
  35758. /**
  35759. * Length of the distance animated by the transition when upper radius is reached
  35760. */
  35761. upperRadiusTransitionRange: number;
  35762. private _autoTransitionRange;
  35763. /**
  35764. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35765. */
  35766. /**
  35767. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35768. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35769. */
  35770. autoTransitionRange: boolean;
  35771. private _attachedCamera;
  35772. private _onAfterCheckInputsObserver;
  35773. private _onMeshTargetChangedObserver;
  35774. /**
  35775. * Initializes the behavior.
  35776. */
  35777. init(): void;
  35778. /**
  35779. * Attaches the behavior to its arc rotate camera.
  35780. * @param camera Defines the camera to attach the behavior to
  35781. */
  35782. attach(camera: ArcRotateCamera): void;
  35783. /**
  35784. * Detaches the behavior from its current arc rotate camera.
  35785. */
  35786. detach(): void;
  35787. private _radiusIsAnimating;
  35788. private _radiusBounceTransition;
  35789. private _animatables;
  35790. private _cachedWheelPrecision;
  35791. /**
  35792. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35793. * @param radiusLimit The limit to check against.
  35794. * @return Bool to indicate if at limit.
  35795. */
  35796. private _isRadiusAtLimit;
  35797. /**
  35798. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35799. * @param radiusDelta The delta by which to animate to. Can be negative.
  35800. */
  35801. private _applyBoundRadiusAnimation;
  35802. /**
  35803. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35804. */
  35805. protected _clearAnimationLocks(): void;
  35806. /**
  35807. * Stops and removes all animations that have been applied to the camera
  35808. */
  35809. stopAllAnimations(): void;
  35810. }
  35811. }
  35812. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  35813. import { Behavior } from "babylonjs/Behaviors/behavior";
  35814. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35815. import { ExponentialEase } from "babylonjs/Animations/easing";
  35816. import { Nullable } from "babylonjs/types";
  35817. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35818. import { Vector3 } from "babylonjs/Maths/math";
  35819. /**
  35820. * 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.
  35821. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35822. */
  35823. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  35824. /**
  35825. * Gets the name of the behavior.
  35826. */
  35827. readonly name: string;
  35828. private _mode;
  35829. private _radiusScale;
  35830. private _positionScale;
  35831. private _defaultElevation;
  35832. private _elevationReturnTime;
  35833. private _elevationReturnWaitTime;
  35834. private _zoomStopsAnimation;
  35835. private _framingTime;
  35836. /**
  35837. * The easing function used by animations
  35838. */
  35839. static EasingFunction: ExponentialEase;
  35840. /**
  35841. * The easing mode used by animations
  35842. */
  35843. static EasingMode: number;
  35844. /**
  35845. * Sets the current mode used by the behavior
  35846. */
  35847. /**
  35848. * Gets current mode used by the behavior.
  35849. */
  35850. mode: number;
  35851. /**
  35852. * Sets the scale applied to the radius (1 by default)
  35853. */
  35854. /**
  35855. * Gets the scale applied to the radius
  35856. */
  35857. radiusScale: number;
  35858. /**
  35859. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35860. */
  35861. /**
  35862. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35863. */
  35864. positionScale: number;
  35865. /**
  35866. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35867. * behaviour is triggered, in radians.
  35868. */
  35869. /**
  35870. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35871. * behaviour is triggered, in radians.
  35872. */
  35873. defaultElevation: number;
  35874. /**
  35875. * Sets the time (in milliseconds) taken to return to the default beta position.
  35876. * Negative value indicates camera should not return to default.
  35877. */
  35878. /**
  35879. * Gets the time (in milliseconds) taken to return to the default beta position.
  35880. * Negative value indicates camera should not return to default.
  35881. */
  35882. elevationReturnTime: number;
  35883. /**
  35884. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35885. */
  35886. /**
  35887. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35888. */
  35889. elevationReturnWaitTime: number;
  35890. /**
  35891. * Sets the flag that indicates if user zooming should stop animation.
  35892. */
  35893. /**
  35894. * Gets the flag that indicates if user zooming should stop animation.
  35895. */
  35896. zoomStopsAnimation: boolean;
  35897. /**
  35898. * Sets the transition time when framing the mesh, in milliseconds
  35899. */
  35900. /**
  35901. * Gets the transition time when framing the mesh, in milliseconds
  35902. */
  35903. framingTime: number;
  35904. /**
  35905. * Define if the behavior should automatically change the configured
  35906. * camera limits and sensibilities.
  35907. */
  35908. autoCorrectCameraLimitsAndSensibility: boolean;
  35909. private _onPrePointerObservableObserver;
  35910. private _onAfterCheckInputsObserver;
  35911. private _onMeshTargetChangedObserver;
  35912. private _attachedCamera;
  35913. private _isPointerDown;
  35914. private _lastInteractionTime;
  35915. /**
  35916. * Initializes the behavior.
  35917. */
  35918. init(): void;
  35919. /**
  35920. * Attaches the behavior to its arc rotate camera.
  35921. * @param camera Defines the camera to attach the behavior to
  35922. */
  35923. attach(camera: ArcRotateCamera): void;
  35924. /**
  35925. * Detaches the behavior from its current arc rotate camera.
  35926. */
  35927. detach(): void;
  35928. private _animatables;
  35929. private _betaIsAnimating;
  35930. private _betaTransition;
  35931. private _radiusTransition;
  35932. private _vectorTransition;
  35933. /**
  35934. * Targets the given mesh and updates zoom level accordingly.
  35935. * @param mesh The mesh to target.
  35936. * @param radius Optional. If a cached radius position already exists, overrides default.
  35937. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35938. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35939. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35940. */
  35941. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35942. /**
  35943. * Targets the given mesh with its children and updates zoom level accordingly.
  35944. * @param mesh The mesh to target.
  35945. * @param radius Optional. If a cached radius position already exists, overrides default.
  35946. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35947. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35948. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35949. */
  35950. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35951. /**
  35952. * Targets the given meshes with their children and updates zoom level accordingly.
  35953. * @param meshes The mesh to target.
  35954. * @param radius Optional. If a cached radius position already exists, overrides default.
  35955. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35956. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35957. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35958. */
  35959. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35960. /**
  35961. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  35962. * @param minimumWorld Determines the smaller position of the bounding box extend
  35963. * @param maximumWorld Determines the bigger position of the bounding box extend
  35964. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35965. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35966. */
  35967. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35968. /**
  35969. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  35970. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  35971. * frustum width.
  35972. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  35973. * to fully enclose the mesh in the viewing frustum.
  35974. */
  35975. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  35976. /**
  35977. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  35978. * is automatically returned to its default position (expected to be above ground plane).
  35979. */
  35980. private _maintainCameraAboveGround;
  35981. /**
  35982. * Returns the frustum slope based on the canvas ratio and camera FOV
  35983. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  35984. */
  35985. private _getFrustumSlope;
  35986. /**
  35987. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  35988. */
  35989. private _clearAnimationLocks;
  35990. /**
  35991. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35992. */
  35993. private _applyUserInteraction;
  35994. /**
  35995. * Stops and removes all animations that have been applied to the camera
  35996. */
  35997. stopAllAnimations(): void;
  35998. /**
  35999. * Gets a value indicating if the user is moving the camera
  36000. */
  36001. readonly isUserIsMoving: boolean;
  36002. /**
  36003. * The camera can move all the way towards the mesh.
  36004. */
  36005. static IgnoreBoundsSizeMode: number;
  36006. /**
  36007. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  36008. */
  36009. static FitFrustumSidesMode: number;
  36010. }
  36011. }
  36012. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  36013. import { Nullable } from "babylonjs/types";
  36014. import { Camera } from "babylonjs/Cameras/camera";
  36015. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36016. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36017. /**
  36018. * Base class for Camera Pointer Inputs.
  36019. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  36020. * for example usage.
  36021. */
  36022. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  36023. /**
  36024. * Defines the camera the input is attached to.
  36025. */
  36026. abstract camera: Camera;
  36027. /**
  36028. * Whether keyboard modifier keys are pressed at time of last mouse event.
  36029. */
  36030. protected _altKey: boolean;
  36031. protected _ctrlKey: boolean;
  36032. protected _metaKey: boolean;
  36033. protected _shiftKey: boolean;
  36034. /**
  36035. * Which mouse buttons were pressed at time of last mouse event.
  36036. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  36037. */
  36038. protected _buttonsPressed: number;
  36039. /**
  36040. * Defines the buttons associated with the input to handle camera move.
  36041. */
  36042. buttons: number[];
  36043. /**
  36044. * Attach the input controls to a specific dom element to get the input from.
  36045. * @param element Defines the element the controls should be listened from
  36046. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36047. */
  36048. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36049. /**
  36050. * Detach the current controls from the specified dom element.
  36051. * @param element Defines the element to stop listening the inputs from
  36052. */
  36053. detachControl(element: Nullable<HTMLElement>): void;
  36054. /**
  36055. * Gets the class name of the current input.
  36056. * @returns the class name
  36057. */
  36058. getClassName(): string;
  36059. /**
  36060. * Get the friendly name associated with the input class.
  36061. * @returns the input friendly name
  36062. */
  36063. getSimpleName(): string;
  36064. /**
  36065. * Called on pointer POINTERDOUBLETAP event.
  36066. * Override this method to provide functionality on POINTERDOUBLETAP event.
  36067. */
  36068. protected onDoubleTap(type: string): void;
  36069. /**
  36070. * Called on pointer POINTERMOVE event if only a single touch is active.
  36071. * Override this method to provide functionality.
  36072. */
  36073. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36074. /**
  36075. * Called on pointer POINTERMOVE event if multiple touches are active.
  36076. * Override this method to provide functionality.
  36077. */
  36078. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36079. /**
  36080. * Called on JS contextmenu event.
  36081. * Override this method to provide functionality.
  36082. */
  36083. protected onContextMenu(evt: PointerEvent): void;
  36084. /**
  36085. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36086. * press.
  36087. * Override this method to provide functionality.
  36088. */
  36089. protected onButtonDown(evt: PointerEvent): void;
  36090. /**
  36091. * Called each time a new POINTERUP event occurs. Ie, for each button
  36092. * release.
  36093. * Override this method to provide functionality.
  36094. */
  36095. protected onButtonUp(evt: PointerEvent): void;
  36096. /**
  36097. * Called when window becomes inactive.
  36098. * Override this method to provide functionality.
  36099. */
  36100. protected onLostFocus(): void;
  36101. private _pointerInput;
  36102. private _observer;
  36103. private _onLostFocus;
  36104. private pointA;
  36105. private pointB;
  36106. }
  36107. }
  36108. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  36109. import { Nullable } from "babylonjs/types";
  36110. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36111. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  36112. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36113. /**
  36114. * Manage the pointers inputs to control an arc rotate camera.
  36115. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36116. */
  36117. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  36118. /**
  36119. * Defines the camera the input is attached to.
  36120. */
  36121. camera: ArcRotateCamera;
  36122. /**
  36123. * Gets the class name of the current input.
  36124. * @returns the class name
  36125. */
  36126. getClassName(): string;
  36127. /**
  36128. * Defines the buttons associated with the input to handle camera move.
  36129. */
  36130. buttons: number[];
  36131. /**
  36132. * Defines the pointer angular sensibility along the X axis or how fast is
  36133. * the camera rotating.
  36134. */
  36135. angularSensibilityX: number;
  36136. /**
  36137. * Defines the pointer angular sensibility along the Y axis or how fast is
  36138. * the camera rotating.
  36139. */
  36140. angularSensibilityY: number;
  36141. /**
  36142. * Defines the pointer pinch precision or how fast is the camera zooming.
  36143. */
  36144. pinchPrecision: number;
  36145. /**
  36146. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36147. * from 0.
  36148. * It defines the percentage of current camera.radius to use as delta when
  36149. * pinch zoom is used.
  36150. */
  36151. pinchDeltaPercentage: number;
  36152. /**
  36153. * Defines the pointer panning sensibility or how fast is the camera moving.
  36154. */
  36155. panningSensibility: number;
  36156. /**
  36157. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  36158. */
  36159. multiTouchPanning: boolean;
  36160. /**
  36161. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  36162. * zoom (pinch) through multitouch.
  36163. */
  36164. multiTouchPanAndZoom: boolean;
  36165. /**
  36166. * Revers pinch action direction.
  36167. */
  36168. pinchInwards: boolean;
  36169. private _isPanClick;
  36170. private _twoFingerActivityCount;
  36171. private _isPinching;
  36172. /**
  36173. * Called on pointer POINTERMOVE event if only a single touch is active.
  36174. */
  36175. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36176. /**
  36177. * Called on pointer POINTERDOUBLETAP event.
  36178. */
  36179. protected onDoubleTap(type: string): void;
  36180. /**
  36181. * Called on pointer POINTERMOVE event if multiple touches are active.
  36182. */
  36183. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36184. /**
  36185. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36186. * press.
  36187. */
  36188. protected onButtonDown(evt: PointerEvent): void;
  36189. /**
  36190. * Called each time a new POINTERUP event occurs. Ie, for each button
  36191. * release.
  36192. */
  36193. protected onButtonUp(evt: PointerEvent): void;
  36194. /**
  36195. * Called when window becomes inactive.
  36196. */
  36197. protected onLostFocus(): void;
  36198. }
  36199. }
  36200. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  36201. import { Nullable } from "babylonjs/types";
  36202. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36203. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36204. /**
  36205. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  36206. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36207. */
  36208. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  36209. /**
  36210. * Defines the camera the input is attached to.
  36211. */
  36212. camera: ArcRotateCamera;
  36213. /**
  36214. * Defines the list of key codes associated with the up action (increase alpha)
  36215. */
  36216. keysUp: number[];
  36217. /**
  36218. * Defines the list of key codes associated with the down action (decrease alpha)
  36219. */
  36220. keysDown: number[];
  36221. /**
  36222. * Defines the list of key codes associated with the left action (increase beta)
  36223. */
  36224. keysLeft: number[];
  36225. /**
  36226. * Defines the list of key codes associated with the right action (decrease beta)
  36227. */
  36228. keysRight: number[];
  36229. /**
  36230. * Defines the list of key codes associated with the reset action.
  36231. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  36232. */
  36233. keysReset: number[];
  36234. /**
  36235. * Defines the panning sensibility of the inputs.
  36236. * (How fast is the camera paning)
  36237. */
  36238. panningSensibility: number;
  36239. /**
  36240. * Defines the zooming sensibility of the inputs.
  36241. * (How fast is the camera zooming)
  36242. */
  36243. zoomingSensibility: number;
  36244. /**
  36245. * Defines wether maintaining the alt key down switch the movement mode from
  36246. * orientation to zoom.
  36247. */
  36248. useAltToZoom: boolean;
  36249. /**
  36250. * Rotation speed of the camera
  36251. */
  36252. angularSpeed: number;
  36253. private _keys;
  36254. private _ctrlPressed;
  36255. private _altPressed;
  36256. private _onCanvasBlurObserver;
  36257. private _onKeyboardObserver;
  36258. private _engine;
  36259. private _scene;
  36260. /**
  36261. * Attach the input controls to a specific dom element to get the input from.
  36262. * @param element Defines the element the controls should be listened from
  36263. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36264. */
  36265. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36266. /**
  36267. * Detach the current controls from the specified dom element.
  36268. * @param element Defines the element to stop listening the inputs from
  36269. */
  36270. detachControl(element: Nullable<HTMLElement>): void;
  36271. /**
  36272. * Update the current camera state depending on the inputs that have been used this frame.
  36273. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36274. */
  36275. checkInputs(): void;
  36276. /**
  36277. * Gets the class name of the current intput.
  36278. * @returns the class name
  36279. */
  36280. getClassName(): string;
  36281. /**
  36282. * Get the friendly name associated with the input class.
  36283. * @returns the input friendly name
  36284. */
  36285. getSimpleName(): string;
  36286. }
  36287. }
  36288. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  36289. import { Nullable } from "babylonjs/types";
  36290. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36291. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36292. /**
  36293. * Manage the mouse wheel inputs to control an arc rotate camera.
  36294. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36295. */
  36296. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  36297. /**
  36298. * Defines the camera the input is attached to.
  36299. */
  36300. camera: ArcRotateCamera;
  36301. /**
  36302. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36303. */
  36304. wheelPrecision: number;
  36305. /**
  36306. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36307. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36308. */
  36309. wheelDeltaPercentage: number;
  36310. private _wheel;
  36311. private _observer;
  36312. private computeDeltaFromMouseWheelLegacyEvent;
  36313. /**
  36314. * Attach the input controls to a specific dom element to get the input from.
  36315. * @param element Defines the element the controls should be listened from
  36316. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36317. */
  36318. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36319. /**
  36320. * Detach the current controls from the specified dom element.
  36321. * @param element Defines the element to stop listening the inputs from
  36322. */
  36323. detachControl(element: Nullable<HTMLElement>): void;
  36324. /**
  36325. * Gets the class name of the current intput.
  36326. * @returns the class name
  36327. */
  36328. getClassName(): string;
  36329. /**
  36330. * Get the friendly name associated with the input class.
  36331. * @returns the input friendly name
  36332. */
  36333. getSimpleName(): string;
  36334. }
  36335. }
  36336. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  36337. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36338. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36339. /**
  36340. * Default Inputs manager for the ArcRotateCamera.
  36341. * It groups all the default supported inputs for ease of use.
  36342. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36343. */
  36344. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  36345. /**
  36346. * Instantiates a new ArcRotateCameraInputsManager.
  36347. * @param camera Defines the camera the inputs belong to
  36348. */
  36349. constructor(camera: ArcRotateCamera);
  36350. /**
  36351. * Add mouse wheel input support to the input manager.
  36352. * @returns the current input manager
  36353. */
  36354. addMouseWheel(): ArcRotateCameraInputsManager;
  36355. /**
  36356. * Add pointers input support to the input manager.
  36357. * @returns the current input manager
  36358. */
  36359. addPointers(): ArcRotateCameraInputsManager;
  36360. /**
  36361. * Add keyboard input support to the input manager.
  36362. * @returns the current input manager
  36363. */
  36364. addKeyboard(): ArcRotateCameraInputsManager;
  36365. }
  36366. }
  36367. declare module "babylonjs/Cameras/arcRotateCamera" {
  36368. import { Observable } from "babylonjs/Misc/observable";
  36369. import { Nullable } from "babylonjs/types";
  36370. import { Scene } from "babylonjs/scene";
  36371. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  36372. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36373. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36374. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36375. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  36376. import { Camera } from "babylonjs/Cameras/camera";
  36377. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36378. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  36379. import { Collider } from "babylonjs/Collisions/collider";
  36380. /**
  36381. * This represents an orbital type of camera.
  36382. *
  36383. * 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.
  36384. * 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.
  36385. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  36386. */
  36387. export class ArcRotateCamera extends TargetCamera {
  36388. /**
  36389. * Defines the rotation angle of the camera along the longitudinal axis.
  36390. */
  36391. alpha: number;
  36392. /**
  36393. * Defines the rotation angle of the camera along the latitudinal axis.
  36394. */
  36395. beta: number;
  36396. /**
  36397. * Defines the radius of the camera from it s target point.
  36398. */
  36399. radius: number;
  36400. protected _target: Vector3;
  36401. protected _targetHost: Nullable<AbstractMesh>;
  36402. /**
  36403. * Defines the target point of the camera.
  36404. * The camera looks towards it form the radius distance.
  36405. */
  36406. target: Vector3;
  36407. /**
  36408. * Define the current local position of the camera in the scene
  36409. */
  36410. position: Vector3;
  36411. protected _upVector: Vector3;
  36412. protected _upToYMatrix: Matrix;
  36413. protected _YToUpMatrix: Matrix;
  36414. /**
  36415. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  36416. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  36417. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  36418. */
  36419. upVector: Vector3;
  36420. /**
  36421. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  36422. */
  36423. setMatUp(): void;
  36424. /**
  36425. * Current inertia value on the longitudinal axis.
  36426. * The bigger this number the longer it will take for the camera to stop.
  36427. */
  36428. inertialAlphaOffset: number;
  36429. /**
  36430. * Current inertia value on the latitudinal axis.
  36431. * The bigger this number the longer it will take for the camera to stop.
  36432. */
  36433. inertialBetaOffset: number;
  36434. /**
  36435. * Current inertia value on the radius axis.
  36436. * The bigger this number the longer it will take for the camera to stop.
  36437. */
  36438. inertialRadiusOffset: number;
  36439. /**
  36440. * Minimum allowed angle on the longitudinal axis.
  36441. * This can help limiting how the Camera is able to move in the scene.
  36442. */
  36443. lowerAlphaLimit: Nullable<number>;
  36444. /**
  36445. * Maximum allowed angle on the longitudinal axis.
  36446. * This can help limiting how the Camera is able to move in the scene.
  36447. */
  36448. upperAlphaLimit: Nullable<number>;
  36449. /**
  36450. * Minimum allowed angle on the latitudinal axis.
  36451. * This can help limiting how the Camera is able to move in the scene.
  36452. */
  36453. lowerBetaLimit: number;
  36454. /**
  36455. * Maximum allowed angle on the latitudinal axis.
  36456. * This can help limiting how the Camera is able to move in the scene.
  36457. */
  36458. upperBetaLimit: number;
  36459. /**
  36460. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  36461. * This can help limiting how the Camera is able to move in the scene.
  36462. */
  36463. lowerRadiusLimit: Nullable<number>;
  36464. /**
  36465. * Maximum allowed distance of the camera to the target (The camera can not get further).
  36466. * This can help limiting how the Camera is able to move in the scene.
  36467. */
  36468. upperRadiusLimit: Nullable<number>;
  36469. /**
  36470. * Defines the current inertia value used during panning of the camera along the X axis.
  36471. */
  36472. inertialPanningX: number;
  36473. /**
  36474. * Defines the current inertia value used during panning of the camera along the Y axis.
  36475. */
  36476. inertialPanningY: number;
  36477. /**
  36478. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  36479. * Basically if your fingers moves away from more than this distance you will be considered
  36480. * in pinch mode.
  36481. */
  36482. pinchToPanMaxDistance: number;
  36483. /**
  36484. * Defines the maximum distance the camera can pan.
  36485. * This could help keeping the cammera always in your scene.
  36486. */
  36487. panningDistanceLimit: Nullable<number>;
  36488. /**
  36489. * Defines the target of the camera before paning.
  36490. */
  36491. panningOriginTarget: Vector3;
  36492. /**
  36493. * Defines the value of the inertia used during panning.
  36494. * 0 would mean stop inertia and one would mean no decelleration at all.
  36495. */
  36496. panningInertia: number;
  36497. /**
  36498. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  36499. */
  36500. angularSensibilityX: number;
  36501. /**
  36502. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  36503. */
  36504. angularSensibilityY: number;
  36505. /**
  36506. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  36507. */
  36508. pinchPrecision: number;
  36509. /**
  36510. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  36511. * It will be used instead of pinchDeltaPrecision if different from 0.
  36512. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36513. */
  36514. pinchDeltaPercentage: number;
  36515. /**
  36516. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  36517. */
  36518. panningSensibility: number;
  36519. /**
  36520. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  36521. */
  36522. keysUp: number[];
  36523. /**
  36524. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  36525. */
  36526. keysDown: number[];
  36527. /**
  36528. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  36529. */
  36530. keysLeft: number[];
  36531. /**
  36532. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  36533. */
  36534. keysRight: number[];
  36535. /**
  36536. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36537. */
  36538. wheelPrecision: number;
  36539. /**
  36540. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  36541. * It will be used instead of pinchDeltaPrecision if different from 0.
  36542. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36543. */
  36544. wheelDeltaPercentage: number;
  36545. /**
  36546. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  36547. */
  36548. zoomOnFactor: number;
  36549. /**
  36550. * Defines a screen offset for the camera position.
  36551. */
  36552. targetScreenOffset: Vector2;
  36553. /**
  36554. * Allows the camera to be completely reversed.
  36555. * If false the camera can not arrive upside down.
  36556. */
  36557. allowUpsideDown: boolean;
  36558. /**
  36559. * Define if double tap/click is used to restore the previously saved state of the camera.
  36560. */
  36561. useInputToRestoreState: boolean;
  36562. /** @hidden */
  36563. _viewMatrix: Matrix;
  36564. /** @hidden */
  36565. _useCtrlForPanning: boolean;
  36566. /** @hidden */
  36567. _panningMouseButton: number;
  36568. /**
  36569. * Defines the input associated to the camera.
  36570. */
  36571. inputs: ArcRotateCameraInputsManager;
  36572. /** @hidden */
  36573. _reset: () => void;
  36574. /**
  36575. * Defines the allowed panning axis.
  36576. */
  36577. panningAxis: Vector3;
  36578. protected _localDirection: Vector3;
  36579. protected _transformedDirection: Vector3;
  36580. private _bouncingBehavior;
  36581. /**
  36582. * Gets the bouncing behavior of the camera if it has been enabled.
  36583. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36584. */
  36585. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  36586. /**
  36587. * Defines if the bouncing behavior of the camera is enabled on the camera.
  36588. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36589. */
  36590. useBouncingBehavior: boolean;
  36591. private _framingBehavior;
  36592. /**
  36593. * Gets the framing behavior of the camera if it has been enabled.
  36594. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36595. */
  36596. readonly framingBehavior: Nullable<FramingBehavior>;
  36597. /**
  36598. * Defines if the framing behavior of the camera is enabled on the camera.
  36599. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36600. */
  36601. useFramingBehavior: boolean;
  36602. private _autoRotationBehavior;
  36603. /**
  36604. * Gets the auto rotation behavior of the camera if it has been enabled.
  36605. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36606. */
  36607. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  36608. /**
  36609. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  36610. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36611. */
  36612. useAutoRotationBehavior: boolean;
  36613. /**
  36614. * Observable triggered when the mesh target has been changed on the camera.
  36615. */
  36616. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  36617. /**
  36618. * Event raised when the camera is colliding with a mesh.
  36619. */
  36620. onCollide: (collidedMesh: AbstractMesh) => void;
  36621. /**
  36622. * Defines whether the camera should check collision with the objects oh the scene.
  36623. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  36624. */
  36625. checkCollisions: boolean;
  36626. /**
  36627. * Defines the collision radius of the camera.
  36628. * This simulates a sphere around the camera.
  36629. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36630. */
  36631. collisionRadius: Vector3;
  36632. protected _collider: Collider;
  36633. protected _previousPosition: Vector3;
  36634. protected _collisionVelocity: Vector3;
  36635. protected _newPosition: Vector3;
  36636. protected _previousAlpha: number;
  36637. protected _previousBeta: number;
  36638. protected _previousRadius: number;
  36639. protected _collisionTriggered: boolean;
  36640. protected _targetBoundingCenter: Nullable<Vector3>;
  36641. private _computationVector;
  36642. /**
  36643. * Instantiates a new ArcRotateCamera in a given scene
  36644. * @param name Defines the name of the camera
  36645. * @param alpha Defines the camera rotation along the logitudinal axis
  36646. * @param beta Defines the camera rotation along the latitudinal axis
  36647. * @param radius Defines the camera distance from its target
  36648. * @param target Defines the camera target
  36649. * @param scene Defines the scene the camera belongs to
  36650. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  36651. */
  36652. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36653. /** @hidden */
  36654. _initCache(): void;
  36655. /** @hidden */
  36656. _updateCache(ignoreParentClass?: boolean): void;
  36657. protected _getTargetPosition(): Vector3;
  36658. private _storedAlpha;
  36659. private _storedBeta;
  36660. private _storedRadius;
  36661. private _storedTarget;
  36662. /**
  36663. * Stores the current state of the camera (alpha, beta, radius and target)
  36664. * @returns the camera itself
  36665. */
  36666. storeState(): Camera;
  36667. /**
  36668. * @hidden
  36669. * Restored camera state. You must call storeState() first
  36670. */
  36671. _restoreStateValues(): boolean;
  36672. /** @hidden */
  36673. _isSynchronizedViewMatrix(): boolean;
  36674. /**
  36675. * Attached controls to the current camera.
  36676. * @param element Defines the element the controls should be listened from
  36677. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36678. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  36679. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  36680. */
  36681. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  36682. /**
  36683. * Detach the current controls from the camera.
  36684. * The camera will stop reacting to inputs.
  36685. * @param element Defines the element to stop listening the inputs from
  36686. */
  36687. detachControl(element: HTMLElement): void;
  36688. /** @hidden */
  36689. _checkInputs(): void;
  36690. protected _checkLimits(): void;
  36691. /**
  36692. * Rebuilds angles (alpha, beta) and radius from the give position and target
  36693. */
  36694. rebuildAnglesAndRadius(): void;
  36695. /**
  36696. * Use a position to define the current camera related information like aplha, beta and radius
  36697. * @param position Defines the position to set the camera at
  36698. */
  36699. setPosition(position: Vector3): void;
  36700. /**
  36701. * Defines the target the camera should look at.
  36702. * This will automatically adapt alpha beta and radius to fit within the new target.
  36703. * @param target Defines the new target as a Vector or a mesh
  36704. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  36705. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  36706. */
  36707. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  36708. /** @hidden */
  36709. _getViewMatrix(): Matrix;
  36710. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  36711. /**
  36712. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  36713. * @param meshes Defines the mesh to zoom on
  36714. * @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)
  36715. */
  36716. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  36717. /**
  36718. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  36719. * The target will be changed but the radius
  36720. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  36721. * @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)
  36722. */
  36723. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  36724. min: Vector3;
  36725. max: Vector3;
  36726. distance: number;
  36727. }, doNotUpdateMaxZ?: boolean): void;
  36728. /**
  36729. * @override
  36730. * Override Camera.createRigCamera
  36731. */
  36732. createRigCamera(name: string, cameraIndex: number): Camera;
  36733. /**
  36734. * @hidden
  36735. * @override
  36736. * Override Camera._updateRigCameras
  36737. */
  36738. _updateRigCameras(): void;
  36739. /**
  36740. * Destroy the camera and release the current resources hold by it.
  36741. */
  36742. dispose(): void;
  36743. /**
  36744. * Gets the current object class name.
  36745. * @return the class name
  36746. */
  36747. getClassName(): string;
  36748. }
  36749. }
  36750. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  36751. import { Behavior } from "babylonjs/Behaviors/behavior";
  36752. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36753. /**
  36754. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  36755. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36756. */
  36757. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  36758. /**
  36759. * Gets the name of the behavior.
  36760. */
  36761. readonly name: string;
  36762. private _zoomStopsAnimation;
  36763. private _idleRotationSpeed;
  36764. private _idleRotationWaitTime;
  36765. private _idleRotationSpinupTime;
  36766. /**
  36767. * Sets the flag that indicates if user zooming should stop animation.
  36768. */
  36769. /**
  36770. * Gets the flag that indicates if user zooming should stop animation.
  36771. */
  36772. zoomStopsAnimation: boolean;
  36773. /**
  36774. * Sets the default speed at which the camera rotates around the model.
  36775. */
  36776. /**
  36777. * Gets the default speed at which the camera rotates around the model.
  36778. */
  36779. idleRotationSpeed: number;
  36780. /**
  36781. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36782. */
  36783. /**
  36784. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  36785. */
  36786. idleRotationWaitTime: number;
  36787. /**
  36788. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36789. */
  36790. /**
  36791. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36792. */
  36793. idleRotationSpinupTime: number;
  36794. /**
  36795. * Gets a value indicating if the camera is currently rotating because of this behavior
  36796. */
  36797. readonly rotationInProgress: boolean;
  36798. private _onPrePointerObservableObserver;
  36799. private _onAfterCheckInputsObserver;
  36800. private _attachedCamera;
  36801. private _isPointerDown;
  36802. private _lastFrameTime;
  36803. private _lastInteractionTime;
  36804. private _cameraRotationSpeed;
  36805. /**
  36806. * Initializes the behavior.
  36807. */
  36808. init(): void;
  36809. /**
  36810. * Attaches the behavior to its arc rotate camera.
  36811. * @param camera Defines the camera to attach the behavior to
  36812. */
  36813. attach(camera: ArcRotateCamera): void;
  36814. /**
  36815. * Detaches the behavior from its current arc rotate camera.
  36816. */
  36817. detach(): void;
  36818. /**
  36819. * Returns true if user is scrolling.
  36820. * @return true if user is scrolling.
  36821. */
  36822. private _userIsZooming;
  36823. private _lastFrameRadius;
  36824. private _shouldAnimationStopForInteraction;
  36825. /**
  36826. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36827. */
  36828. private _applyUserInteraction;
  36829. private _userIsMoving;
  36830. }
  36831. }
  36832. declare module "babylonjs/Behaviors/Cameras/index" {
  36833. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36834. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36835. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  36836. }
  36837. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  36838. import { Mesh } from "babylonjs/Meshes/mesh";
  36839. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36840. import { Behavior } from "babylonjs/Behaviors/behavior";
  36841. /**
  36842. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36843. */
  36844. export class AttachToBoxBehavior implements Behavior<Mesh> {
  36845. private ui;
  36846. /**
  36847. * The name of the behavior
  36848. */
  36849. name: string;
  36850. /**
  36851. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36852. */
  36853. distanceAwayFromFace: number;
  36854. /**
  36855. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  36856. */
  36857. distanceAwayFromBottomOfFace: number;
  36858. private _faceVectors;
  36859. private _target;
  36860. private _scene;
  36861. private _onRenderObserver;
  36862. private _tmpMatrix;
  36863. private _tmpVector;
  36864. /**
  36865. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  36866. * @param ui The transform node that should be attched to the mesh
  36867. */
  36868. constructor(ui: TransformNode);
  36869. /**
  36870. * Initializes the behavior
  36871. */
  36872. init(): void;
  36873. private _closestFace;
  36874. private _zeroVector;
  36875. private _lookAtTmpMatrix;
  36876. private _lookAtToRef;
  36877. /**
  36878. * Attaches the AttachToBoxBehavior to the passed in mesh
  36879. * @param target The mesh that the specified node will be attached to
  36880. */
  36881. attach(target: Mesh): void;
  36882. /**
  36883. * Detaches the behavior from the mesh
  36884. */
  36885. detach(): void;
  36886. }
  36887. }
  36888. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  36889. import { Behavior } from "babylonjs/Behaviors/behavior";
  36890. import { Mesh } from "babylonjs/Meshes/mesh";
  36891. /**
  36892. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  36893. */
  36894. export class FadeInOutBehavior implements Behavior<Mesh> {
  36895. /**
  36896. * Time in milliseconds to delay before fading in (Default: 0)
  36897. */
  36898. delay: number;
  36899. /**
  36900. * Time in milliseconds for the mesh to fade in (Default: 300)
  36901. */
  36902. fadeInTime: number;
  36903. private _millisecondsPerFrame;
  36904. private _hovered;
  36905. private _hoverValue;
  36906. private _ownerNode;
  36907. /**
  36908. * Instatiates the FadeInOutBehavior
  36909. */
  36910. constructor();
  36911. /**
  36912. * The name of the behavior
  36913. */
  36914. readonly name: string;
  36915. /**
  36916. * Initializes the behavior
  36917. */
  36918. init(): void;
  36919. /**
  36920. * Attaches the fade behavior on the passed in mesh
  36921. * @param ownerNode The mesh that will be faded in/out once attached
  36922. */
  36923. attach(ownerNode: Mesh): void;
  36924. /**
  36925. * Detaches the behavior from the mesh
  36926. */
  36927. detach(): void;
  36928. /**
  36929. * Triggers the mesh to begin fading in or out
  36930. * @param value if the object should fade in or out (true to fade in)
  36931. */
  36932. fadeIn(value: boolean): void;
  36933. private _update;
  36934. private _setAllVisibility;
  36935. }
  36936. }
  36937. declare module "babylonjs/Misc/pivotTools" {
  36938. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36939. /**
  36940. * Class containing a set of static utilities functions for managing Pivots
  36941. * @hidden
  36942. */
  36943. export class PivotTools {
  36944. private static _PivotCached;
  36945. private static _OldPivotPoint;
  36946. private static _PivotTranslation;
  36947. private static _PivotTmpVector;
  36948. /** @hidden */
  36949. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  36950. /** @hidden */
  36951. static _RestorePivotPoint(mesh: AbstractMesh): void;
  36952. }
  36953. }
  36954. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  36955. import { Scene } from "babylonjs/scene";
  36956. import { Vector4, Plane } from "babylonjs/Maths/math";
  36957. import { Mesh } from "babylonjs/Meshes/mesh";
  36958. import { Nullable } from "babylonjs/types";
  36959. /**
  36960. * Class containing static functions to help procedurally build meshes
  36961. */
  36962. export class PlaneBuilder {
  36963. /**
  36964. * Creates a plane mesh
  36965. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  36966. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  36967. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  36968. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36969. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  36970. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36971. * @param name defines the name of the mesh
  36972. * @param options defines the options used to create the mesh
  36973. * @param scene defines the hosting scene
  36974. * @returns the plane mesh
  36975. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  36976. */
  36977. static CreatePlane(name: string, options: {
  36978. size?: number;
  36979. width?: number;
  36980. height?: number;
  36981. sideOrientation?: number;
  36982. frontUVs?: Vector4;
  36983. backUVs?: Vector4;
  36984. updatable?: boolean;
  36985. sourcePlane?: Plane;
  36986. }, scene?: Nullable<Scene>): Mesh;
  36987. }
  36988. }
  36989. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  36990. import { Behavior } from "babylonjs/Behaviors/behavior";
  36991. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36992. import { Observable } from "babylonjs/Misc/observable";
  36993. import { Vector3 } from "babylonjs/Maths/math";
  36994. import { Ray } from "babylonjs/Culling/ray";
  36995. import "babylonjs/Meshes/Builders/planeBuilder";
  36996. /**
  36997. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  36998. */
  36999. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  37000. private static _AnyMouseID;
  37001. /**
  37002. * Abstract mesh the behavior is set on
  37003. */
  37004. attachedNode: AbstractMesh;
  37005. private _dragPlane;
  37006. private _scene;
  37007. private _pointerObserver;
  37008. private _beforeRenderObserver;
  37009. private static _planeScene;
  37010. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  37011. /**
  37012. * 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)
  37013. */
  37014. maxDragAngle: number;
  37015. /**
  37016. * @hidden
  37017. */
  37018. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  37019. /**
  37020. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37021. */
  37022. currentDraggingPointerID: number;
  37023. /**
  37024. * The last position where the pointer hit the drag plane in world space
  37025. */
  37026. lastDragPosition: Vector3;
  37027. /**
  37028. * If the behavior is currently in a dragging state
  37029. */
  37030. dragging: boolean;
  37031. /**
  37032. * 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)
  37033. */
  37034. dragDeltaRatio: number;
  37035. /**
  37036. * If the drag plane orientation should be updated during the dragging (Default: true)
  37037. */
  37038. updateDragPlane: boolean;
  37039. private _debugMode;
  37040. private _moving;
  37041. /**
  37042. * Fires each time the attached mesh is dragged with the pointer
  37043. * * delta between last drag position and current drag position in world space
  37044. * * dragDistance along the drag axis
  37045. * * dragPlaneNormal normal of the current drag plane used during the drag
  37046. * * dragPlanePoint in world space where the drag intersects the drag plane
  37047. */
  37048. onDragObservable: Observable<{
  37049. delta: Vector3;
  37050. dragPlanePoint: Vector3;
  37051. dragPlaneNormal: Vector3;
  37052. dragDistance: number;
  37053. pointerId: number;
  37054. }>;
  37055. /**
  37056. * Fires each time a drag begins (eg. mouse down on mesh)
  37057. */
  37058. onDragStartObservable: Observable<{
  37059. dragPlanePoint: Vector3;
  37060. pointerId: number;
  37061. }>;
  37062. /**
  37063. * Fires each time a drag ends (eg. mouse release after drag)
  37064. */
  37065. onDragEndObservable: Observable<{
  37066. dragPlanePoint: Vector3;
  37067. pointerId: number;
  37068. }>;
  37069. /**
  37070. * If the attached mesh should be moved when dragged
  37071. */
  37072. moveAttached: boolean;
  37073. /**
  37074. * If the drag behavior will react to drag events (Default: true)
  37075. */
  37076. enabled: boolean;
  37077. /**
  37078. * If camera controls should be detached during the drag
  37079. */
  37080. detachCameraControls: boolean;
  37081. /**
  37082. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  37083. */
  37084. useObjectOrienationForDragging: boolean;
  37085. private _options;
  37086. /**
  37087. * Creates a pointer drag behavior that can be attached to a mesh
  37088. * @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)
  37089. */
  37090. constructor(options?: {
  37091. dragAxis?: Vector3;
  37092. dragPlaneNormal?: Vector3;
  37093. });
  37094. /**
  37095. * Predicate to determine if it is valid to move the object to a new position when it is moved
  37096. */
  37097. validateDrag: (targetPosition: Vector3) => boolean;
  37098. /**
  37099. * The name of the behavior
  37100. */
  37101. readonly name: string;
  37102. /**
  37103. * Initializes the behavior
  37104. */
  37105. init(): void;
  37106. private _tmpVector;
  37107. private _alternatePickedPoint;
  37108. private _worldDragAxis;
  37109. private _targetPosition;
  37110. private _attachedElement;
  37111. /**
  37112. * Attaches the drag behavior the passed in mesh
  37113. * @param ownerNode The mesh that will be dragged around once attached
  37114. */
  37115. attach(ownerNode: AbstractMesh): void;
  37116. /**
  37117. * Force relase the drag action by code.
  37118. */
  37119. releaseDrag(): void;
  37120. private _startDragRay;
  37121. private _lastPointerRay;
  37122. /**
  37123. * Simulates the start of a pointer drag event on the behavior
  37124. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  37125. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  37126. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  37127. */
  37128. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  37129. private _startDrag;
  37130. private _dragDelta;
  37131. private _moveDrag;
  37132. private _pickWithRayOnDragPlane;
  37133. private _pointA;
  37134. private _pointB;
  37135. private _pointC;
  37136. private _lineA;
  37137. private _lineB;
  37138. private _localAxis;
  37139. private _lookAt;
  37140. private _updateDragPlanePosition;
  37141. /**
  37142. * Detaches the behavior from the mesh
  37143. */
  37144. detach(): void;
  37145. }
  37146. }
  37147. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  37148. import { Mesh } from "babylonjs/Meshes/mesh";
  37149. import { Behavior } from "babylonjs/Behaviors/behavior";
  37150. /**
  37151. * A behavior that when attached to a mesh will allow the mesh to be scaled
  37152. */
  37153. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  37154. private _dragBehaviorA;
  37155. private _dragBehaviorB;
  37156. private _startDistance;
  37157. private _initialScale;
  37158. private _targetScale;
  37159. private _ownerNode;
  37160. private _sceneRenderObserver;
  37161. /**
  37162. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  37163. */
  37164. constructor();
  37165. /**
  37166. * The name of the behavior
  37167. */
  37168. readonly name: string;
  37169. /**
  37170. * Initializes the behavior
  37171. */
  37172. init(): void;
  37173. private _getCurrentDistance;
  37174. /**
  37175. * Attaches the scale behavior the passed in mesh
  37176. * @param ownerNode The mesh that will be scaled around once attached
  37177. */
  37178. attach(ownerNode: Mesh): void;
  37179. /**
  37180. * Detaches the behavior from the mesh
  37181. */
  37182. detach(): void;
  37183. }
  37184. }
  37185. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  37186. import { Behavior } from "babylonjs/Behaviors/behavior";
  37187. import { Mesh } from "babylonjs/Meshes/mesh";
  37188. import { Observable } from "babylonjs/Misc/observable";
  37189. /**
  37190. * 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
  37191. */
  37192. export class SixDofDragBehavior implements Behavior<Mesh> {
  37193. private static _virtualScene;
  37194. private _ownerNode;
  37195. private _sceneRenderObserver;
  37196. private _scene;
  37197. private _targetPosition;
  37198. private _virtualOriginMesh;
  37199. private _virtualDragMesh;
  37200. private _pointerObserver;
  37201. private _moving;
  37202. private _startingOrientation;
  37203. /**
  37204. * 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)
  37205. */
  37206. private zDragFactor;
  37207. /**
  37208. * If the object should rotate to face the drag origin
  37209. */
  37210. rotateDraggedObject: boolean;
  37211. /**
  37212. * If the behavior is currently in a dragging state
  37213. */
  37214. dragging: boolean;
  37215. /**
  37216. * 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)
  37217. */
  37218. dragDeltaRatio: number;
  37219. /**
  37220. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37221. */
  37222. currentDraggingPointerID: number;
  37223. /**
  37224. * If camera controls should be detached during the drag
  37225. */
  37226. detachCameraControls: boolean;
  37227. /**
  37228. * Fires each time a drag starts
  37229. */
  37230. onDragStartObservable: Observable<{}>;
  37231. /**
  37232. * Fires each time a drag ends (eg. mouse release after drag)
  37233. */
  37234. onDragEndObservable: Observable<{}>;
  37235. /**
  37236. * 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
  37237. */
  37238. constructor();
  37239. /**
  37240. * The name of the behavior
  37241. */
  37242. readonly name: string;
  37243. /**
  37244. * Initializes the behavior
  37245. */
  37246. init(): void;
  37247. /**
  37248. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  37249. */
  37250. private readonly _pointerCamera;
  37251. /**
  37252. * Attaches the scale behavior the passed in mesh
  37253. * @param ownerNode The mesh that will be scaled around once attached
  37254. */
  37255. attach(ownerNode: Mesh): void;
  37256. /**
  37257. * Detaches the behavior from the mesh
  37258. */
  37259. detach(): void;
  37260. }
  37261. }
  37262. declare module "babylonjs/Behaviors/Meshes/index" {
  37263. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  37264. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  37265. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  37266. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  37267. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  37268. }
  37269. declare module "babylonjs/Behaviors/index" {
  37270. export * from "babylonjs/Behaviors/behavior";
  37271. export * from "babylonjs/Behaviors/Cameras/index";
  37272. export * from "babylonjs/Behaviors/Meshes/index";
  37273. }
  37274. declare module "babylonjs/Bones/boneIKController" {
  37275. import { Bone } from "babylonjs/Bones/bone";
  37276. import { Vector3 } from "babylonjs/Maths/math";
  37277. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37278. import { Nullable } from "babylonjs/types";
  37279. /**
  37280. * Class used to apply inverse kinematics to bones
  37281. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  37282. */
  37283. export class BoneIKController {
  37284. private static _tmpVecs;
  37285. private static _tmpQuat;
  37286. private static _tmpMats;
  37287. /**
  37288. * Gets or sets the target mesh
  37289. */
  37290. targetMesh: AbstractMesh;
  37291. /** Gets or sets the mesh used as pole */
  37292. poleTargetMesh: AbstractMesh;
  37293. /**
  37294. * Gets or sets the bone used as pole
  37295. */
  37296. poleTargetBone: Nullable<Bone>;
  37297. /**
  37298. * Gets or sets the target position
  37299. */
  37300. targetPosition: Vector3;
  37301. /**
  37302. * Gets or sets the pole target position
  37303. */
  37304. poleTargetPosition: Vector3;
  37305. /**
  37306. * Gets or sets the pole target local offset
  37307. */
  37308. poleTargetLocalOffset: Vector3;
  37309. /**
  37310. * Gets or sets the pole angle
  37311. */
  37312. poleAngle: number;
  37313. /**
  37314. * Gets or sets the mesh associated with the controller
  37315. */
  37316. mesh: AbstractMesh;
  37317. /**
  37318. * 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)
  37319. */
  37320. slerpAmount: number;
  37321. private _bone1Quat;
  37322. private _bone1Mat;
  37323. private _bone2Ang;
  37324. private _bone1;
  37325. private _bone2;
  37326. private _bone1Length;
  37327. private _bone2Length;
  37328. private _maxAngle;
  37329. private _maxReach;
  37330. private _rightHandedSystem;
  37331. private _bendAxis;
  37332. private _slerping;
  37333. private _adjustRoll;
  37334. /**
  37335. * Gets or sets maximum allowed angle
  37336. */
  37337. maxAngle: number;
  37338. /**
  37339. * Creates a new BoneIKController
  37340. * @param mesh defines the mesh to control
  37341. * @param bone defines the bone to control
  37342. * @param options defines options to set up the controller
  37343. */
  37344. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  37345. targetMesh?: AbstractMesh;
  37346. poleTargetMesh?: AbstractMesh;
  37347. poleTargetBone?: Bone;
  37348. poleTargetLocalOffset?: Vector3;
  37349. poleAngle?: number;
  37350. bendAxis?: Vector3;
  37351. maxAngle?: number;
  37352. slerpAmount?: number;
  37353. });
  37354. private _setMaxAngle;
  37355. /**
  37356. * Force the controller to update the bones
  37357. */
  37358. update(): void;
  37359. }
  37360. }
  37361. declare module "babylonjs/Bones/boneLookController" {
  37362. import { Vector3, Space } from "babylonjs/Maths/math";
  37363. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37364. import { Bone } from "babylonjs/Bones/bone";
  37365. /**
  37366. * Class used to make a bone look toward a point in space
  37367. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  37368. */
  37369. export class BoneLookController {
  37370. private static _tmpVecs;
  37371. private static _tmpQuat;
  37372. private static _tmpMats;
  37373. /**
  37374. * The target Vector3 that the bone will look at
  37375. */
  37376. target: Vector3;
  37377. /**
  37378. * The mesh that the bone is attached to
  37379. */
  37380. mesh: AbstractMesh;
  37381. /**
  37382. * The bone that will be looking to the target
  37383. */
  37384. bone: Bone;
  37385. /**
  37386. * The up axis of the coordinate system that is used when the bone is rotated
  37387. */
  37388. upAxis: Vector3;
  37389. /**
  37390. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  37391. */
  37392. upAxisSpace: Space;
  37393. /**
  37394. * Used to make an adjustment to the yaw of the bone
  37395. */
  37396. adjustYaw: number;
  37397. /**
  37398. * Used to make an adjustment to the pitch of the bone
  37399. */
  37400. adjustPitch: number;
  37401. /**
  37402. * Used to make an adjustment to the roll of the bone
  37403. */
  37404. adjustRoll: number;
  37405. /**
  37406. * 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)
  37407. */
  37408. slerpAmount: number;
  37409. private _minYaw;
  37410. private _maxYaw;
  37411. private _minPitch;
  37412. private _maxPitch;
  37413. private _minYawSin;
  37414. private _minYawCos;
  37415. private _maxYawSin;
  37416. private _maxYawCos;
  37417. private _midYawConstraint;
  37418. private _minPitchTan;
  37419. private _maxPitchTan;
  37420. private _boneQuat;
  37421. private _slerping;
  37422. private _transformYawPitch;
  37423. private _transformYawPitchInv;
  37424. private _firstFrameSkipped;
  37425. private _yawRange;
  37426. private _fowardAxis;
  37427. /**
  37428. * Gets or sets the minimum yaw angle that the bone can look to
  37429. */
  37430. minYaw: number;
  37431. /**
  37432. * Gets or sets the maximum yaw angle that the bone can look to
  37433. */
  37434. maxYaw: number;
  37435. /**
  37436. * Gets or sets the minimum pitch angle that the bone can look to
  37437. */
  37438. minPitch: number;
  37439. /**
  37440. * Gets or sets the maximum pitch angle that the bone can look to
  37441. */
  37442. maxPitch: number;
  37443. /**
  37444. * Create a BoneLookController
  37445. * @param mesh the mesh that the bone belongs to
  37446. * @param bone the bone that will be looking to the target
  37447. * @param target the target Vector3 to look at
  37448. * @param options optional settings:
  37449. * * maxYaw: the maximum angle the bone will yaw to
  37450. * * minYaw: the minimum angle the bone will yaw to
  37451. * * maxPitch: the maximum angle the bone will pitch to
  37452. * * minPitch: the minimum angle the bone will yaw to
  37453. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  37454. * * upAxis: the up axis of the coordinate system
  37455. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  37456. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  37457. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  37458. * * adjustYaw: used to make an adjustment to the yaw of the bone
  37459. * * adjustPitch: used to make an adjustment to the pitch of the bone
  37460. * * adjustRoll: used to make an adjustment to the roll of the bone
  37461. **/
  37462. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  37463. maxYaw?: number;
  37464. minYaw?: number;
  37465. maxPitch?: number;
  37466. minPitch?: number;
  37467. slerpAmount?: number;
  37468. upAxis?: Vector3;
  37469. upAxisSpace?: Space;
  37470. yawAxis?: Vector3;
  37471. pitchAxis?: Vector3;
  37472. adjustYaw?: number;
  37473. adjustPitch?: number;
  37474. adjustRoll?: number;
  37475. });
  37476. /**
  37477. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  37478. */
  37479. update(): void;
  37480. private _getAngleDiff;
  37481. private _getAngleBetween;
  37482. private _isAngleBetween;
  37483. }
  37484. }
  37485. declare module "babylonjs/Bones/index" {
  37486. export * from "babylonjs/Bones/bone";
  37487. export * from "babylonjs/Bones/boneIKController";
  37488. export * from "babylonjs/Bones/boneLookController";
  37489. export * from "babylonjs/Bones/skeleton";
  37490. }
  37491. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  37492. import { Nullable } from "babylonjs/types";
  37493. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37494. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37495. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  37496. /**
  37497. * Manage the gamepad inputs to control an arc rotate camera.
  37498. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37499. */
  37500. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  37501. /**
  37502. * Defines the camera the input is attached to.
  37503. */
  37504. camera: ArcRotateCamera;
  37505. /**
  37506. * Defines the gamepad the input is gathering event from.
  37507. */
  37508. gamepad: Nullable<Gamepad>;
  37509. /**
  37510. * Defines the gamepad rotation sensiblity.
  37511. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37512. */
  37513. gamepadRotationSensibility: number;
  37514. /**
  37515. * Defines the gamepad move sensiblity.
  37516. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37517. */
  37518. gamepadMoveSensibility: number;
  37519. private _onGamepadConnectedObserver;
  37520. private _onGamepadDisconnectedObserver;
  37521. /**
  37522. * Attach the input controls to a specific dom element to get the input from.
  37523. * @param element Defines the element the controls should be listened from
  37524. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37525. */
  37526. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37527. /**
  37528. * Detach the current controls from the specified dom element.
  37529. * @param element Defines the element to stop listening the inputs from
  37530. */
  37531. detachControl(element: Nullable<HTMLElement>): void;
  37532. /**
  37533. * Update the current camera state depending on the inputs that have been used this frame.
  37534. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37535. */
  37536. checkInputs(): void;
  37537. /**
  37538. * Gets the class name of the current intput.
  37539. * @returns the class name
  37540. */
  37541. getClassName(): string;
  37542. /**
  37543. * Get the friendly name associated with the input class.
  37544. * @returns the input friendly name
  37545. */
  37546. getSimpleName(): string;
  37547. }
  37548. }
  37549. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  37550. import { Nullable } from "babylonjs/types";
  37551. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37552. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37553. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37554. interface ArcRotateCameraInputsManager {
  37555. /**
  37556. * Add orientation input support to the input manager.
  37557. * @returns the current input manager
  37558. */
  37559. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  37560. }
  37561. }
  37562. /**
  37563. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  37564. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37565. */
  37566. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  37567. /**
  37568. * Defines the camera the input is attached to.
  37569. */
  37570. camera: ArcRotateCamera;
  37571. /**
  37572. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  37573. */
  37574. alphaCorrection: number;
  37575. /**
  37576. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  37577. */
  37578. gammaCorrection: number;
  37579. private _alpha;
  37580. private _gamma;
  37581. private _dirty;
  37582. private _deviceOrientationHandler;
  37583. /**
  37584. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  37585. */
  37586. constructor();
  37587. /**
  37588. * Attach the input controls to a specific dom element to get the input from.
  37589. * @param element Defines the element the controls should be listened from
  37590. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37591. */
  37592. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37593. /** @hidden */
  37594. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  37595. /**
  37596. * Update the current camera state depending on the inputs that have been used this frame.
  37597. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37598. */
  37599. checkInputs(): void;
  37600. /**
  37601. * Detach the current controls from the specified dom element.
  37602. * @param element Defines the element to stop listening the inputs from
  37603. */
  37604. detachControl(element: Nullable<HTMLElement>): void;
  37605. /**
  37606. * Gets the class name of the current intput.
  37607. * @returns the class name
  37608. */
  37609. getClassName(): string;
  37610. /**
  37611. * Get the friendly name associated with the input class.
  37612. * @returns the input friendly name
  37613. */
  37614. getSimpleName(): string;
  37615. }
  37616. }
  37617. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  37618. import { Nullable } from "babylonjs/types";
  37619. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37620. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37621. /**
  37622. * Listen to mouse events to control the camera.
  37623. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37624. */
  37625. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  37626. /**
  37627. * Defines the camera the input is attached to.
  37628. */
  37629. camera: FlyCamera;
  37630. /**
  37631. * Defines if touch is enabled. (Default is true.)
  37632. */
  37633. touchEnabled: boolean;
  37634. /**
  37635. * Defines the buttons associated with the input to handle camera rotation.
  37636. */
  37637. buttons: number[];
  37638. /**
  37639. * Assign buttons for Yaw control.
  37640. */
  37641. buttonsYaw: number[];
  37642. /**
  37643. * Assign buttons for Pitch control.
  37644. */
  37645. buttonsPitch: number[];
  37646. /**
  37647. * Assign buttons for Roll control.
  37648. */
  37649. buttonsRoll: number[];
  37650. /**
  37651. * Detect if any button is being pressed while mouse is moved.
  37652. * -1 = Mouse locked.
  37653. * 0 = Left button.
  37654. * 1 = Middle Button.
  37655. * 2 = Right Button.
  37656. */
  37657. activeButton: number;
  37658. /**
  37659. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  37660. * Higher values reduce its sensitivity.
  37661. */
  37662. angularSensibility: number;
  37663. private _mousemoveCallback;
  37664. private _observer;
  37665. private _rollObserver;
  37666. private previousPosition;
  37667. private noPreventDefault;
  37668. private element;
  37669. /**
  37670. * Listen to mouse events to control the camera.
  37671. * @param touchEnabled Define if touch is enabled. (Default is true.)
  37672. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37673. */
  37674. constructor(touchEnabled?: boolean);
  37675. /**
  37676. * Attach the mouse control to the HTML DOM element.
  37677. * @param element Defines the element that listens to the input events.
  37678. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  37679. */
  37680. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37681. /**
  37682. * Detach the current controls from the specified dom element.
  37683. * @param element Defines the element to stop listening the inputs from
  37684. */
  37685. detachControl(element: Nullable<HTMLElement>): void;
  37686. /**
  37687. * Gets the class name of the current input.
  37688. * @returns the class name.
  37689. */
  37690. getClassName(): string;
  37691. /**
  37692. * Get the friendly name associated with the input class.
  37693. * @returns the input's friendly name.
  37694. */
  37695. getSimpleName(): string;
  37696. private _pointerInput;
  37697. private _onMouseMove;
  37698. /**
  37699. * Rotate camera by mouse offset.
  37700. */
  37701. private rotateCamera;
  37702. }
  37703. }
  37704. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  37705. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37706. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37707. /**
  37708. * Default Inputs manager for the FlyCamera.
  37709. * It groups all the default supported inputs for ease of use.
  37710. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37711. */
  37712. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  37713. /**
  37714. * Instantiates a new FlyCameraInputsManager.
  37715. * @param camera Defines the camera the inputs belong to.
  37716. */
  37717. constructor(camera: FlyCamera);
  37718. /**
  37719. * Add keyboard input support to the input manager.
  37720. * @returns the new FlyCameraKeyboardMoveInput().
  37721. */
  37722. addKeyboard(): FlyCameraInputsManager;
  37723. /**
  37724. * Add mouse input support to the input manager.
  37725. * @param touchEnabled Enable touch screen support.
  37726. * @returns the new FlyCameraMouseInput().
  37727. */
  37728. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  37729. }
  37730. }
  37731. declare module "babylonjs/Cameras/flyCamera" {
  37732. import { Scene } from "babylonjs/scene";
  37733. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  37734. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37735. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37736. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  37737. /**
  37738. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37739. * such as in a 3D Space Shooter or a Flight Simulator.
  37740. */
  37741. export class FlyCamera extends TargetCamera {
  37742. /**
  37743. * Define the collision ellipsoid of the camera.
  37744. * This is helpful for simulating a camera body, like a player's body.
  37745. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37746. */
  37747. ellipsoid: Vector3;
  37748. /**
  37749. * Define an offset for the position of the ellipsoid around the camera.
  37750. * This can be helpful if the camera is attached away from the player's body center,
  37751. * such as at its head.
  37752. */
  37753. ellipsoidOffset: Vector3;
  37754. /**
  37755. * Enable or disable collisions of the camera with the rest of the scene objects.
  37756. */
  37757. checkCollisions: boolean;
  37758. /**
  37759. * Enable or disable gravity on the camera.
  37760. */
  37761. applyGravity: boolean;
  37762. /**
  37763. * Define the current direction the camera is moving to.
  37764. */
  37765. cameraDirection: Vector3;
  37766. /**
  37767. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  37768. * This overrides and empties cameraRotation.
  37769. */
  37770. rotationQuaternion: Quaternion;
  37771. /**
  37772. * Track Roll to maintain the wanted Rolling when looking around.
  37773. */
  37774. _trackRoll: number;
  37775. /**
  37776. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  37777. */
  37778. rollCorrect: number;
  37779. /**
  37780. * Mimic a banked turn, Rolling the camera when Yawing.
  37781. * It's recommended to use rollCorrect = 10 for faster banking correction.
  37782. */
  37783. bankedTurn: boolean;
  37784. /**
  37785. * Limit in radians for how much Roll banking will add. (Default: 90°)
  37786. */
  37787. bankedTurnLimit: number;
  37788. /**
  37789. * Value of 0 disables the banked Roll.
  37790. * Value of 1 is equal to the Yaw angle in radians.
  37791. */
  37792. bankedTurnMultiplier: number;
  37793. /**
  37794. * The inputs manager loads all the input sources, such as keyboard and mouse.
  37795. */
  37796. inputs: FlyCameraInputsManager;
  37797. /**
  37798. * Gets the input sensibility for mouse input.
  37799. * Higher values reduce sensitivity.
  37800. */
  37801. /**
  37802. * Sets the input sensibility for a mouse input.
  37803. * Higher values reduce sensitivity.
  37804. */
  37805. angularSensibility: number;
  37806. /**
  37807. * Get the keys for camera movement forward.
  37808. */
  37809. /**
  37810. * Set the keys for camera movement forward.
  37811. */
  37812. keysForward: number[];
  37813. /**
  37814. * Get the keys for camera movement backward.
  37815. */
  37816. keysBackward: number[];
  37817. /**
  37818. * Get the keys for camera movement up.
  37819. */
  37820. /**
  37821. * Set the keys for camera movement up.
  37822. */
  37823. keysUp: number[];
  37824. /**
  37825. * Get the keys for camera movement down.
  37826. */
  37827. /**
  37828. * Set the keys for camera movement down.
  37829. */
  37830. keysDown: number[];
  37831. /**
  37832. * Get the keys for camera movement left.
  37833. */
  37834. /**
  37835. * Set the keys for camera movement left.
  37836. */
  37837. keysLeft: number[];
  37838. /**
  37839. * Set the keys for camera movement right.
  37840. */
  37841. /**
  37842. * Set the keys for camera movement right.
  37843. */
  37844. keysRight: number[];
  37845. /**
  37846. * Event raised when the camera collides with a mesh in the scene.
  37847. */
  37848. onCollide: (collidedMesh: AbstractMesh) => void;
  37849. private _collider;
  37850. private _needMoveForGravity;
  37851. private _oldPosition;
  37852. private _diffPosition;
  37853. private _newPosition;
  37854. /** @hidden */
  37855. _localDirection: Vector3;
  37856. /** @hidden */
  37857. _transformedDirection: Vector3;
  37858. /**
  37859. * Instantiates a FlyCamera.
  37860. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37861. * such as in a 3D Space Shooter or a Flight Simulator.
  37862. * @param name Define the name of the camera in the scene.
  37863. * @param position Define the starting position of the camera in the scene.
  37864. * @param scene Define the scene the camera belongs to.
  37865. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  37866. */
  37867. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37868. /**
  37869. * Attach a control to the HTML DOM element.
  37870. * @param element Defines the element that listens to the input events.
  37871. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  37872. */
  37873. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37874. /**
  37875. * Detach a control from the HTML DOM element.
  37876. * The camera will stop reacting to that input.
  37877. * @param element Defines the element that listens to the input events.
  37878. */
  37879. detachControl(element: HTMLElement): void;
  37880. private _collisionMask;
  37881. /**
  37882. * Get the mask that the camera ignores in collision events.
  37883. */
  37884. /**
  37885. * Set the mask that the camera ignores in collision events.
  37886. */
  37887. collisionMask: number;
  37888. /** @hidden */
  37889. _collideWithWorld(displacement: Vector3): void;
  37890. /** @hidden */
  37891. private _onCollisionPositionChange;
  37892. /** @hidden */
  37893. _checkInputs(): void;
  37894. /** @hidden */
  37895. _decideIfNeedsToMove(): boolean;
  37896. /** @hidden */
  37897. _updatePosition(): void;
  37898. /**
  37899. * Restore the Roll to its target value at the rate specified.
  37900. * @param rate - Higher means slower restoring.
  37901. * @hidden
  37902. */
  37903. restoreRoll(rate: number): void;
  37904. /**
  37905. * Destroy the camera and release the current resources held by it.
  37906. */
  37907. dispose(): void;
  37908. /**
  37909. * Get the current object class name.
  37910. * @returns the class name.
  37911. */
  37912. getClassName(): string;
  37913. }
  37914. }
  37915. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  37916. import { Nullable } from "babylonjs/types";
  37917. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37918. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37919. /**
  37920. * Listen to keyboard events to control the camera.
  37921. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37922. */
  37923. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37924. /**
  37925. * Defines the camera the input is attached to.
  37926. */
  37927. camera: FlyCamera;
  37928. /**
  37929. * The list of keyboard keys used to control the forward move of the camera.
  37930. */
  37931. keysForward: number[];
  37932. /**
  37933. * The list of keyboard keys used to control the backward move of the camera.
  37934. */
  37935. keysBackward: number[];
  37936. /**
  37937. * The list of keyboard keys used to control the forward move of the camera.
  37938. */
  37939. keysUp: number[];
  37940. /**
  37941. * The list of keyboard keys used to control the backward move of the camera.
  37942. */
  37943. keysDown: number[];
  37944. /**
  37945. * The list of keyboard keys used to control the right strafe move of the camera.
  37946. */
  37947. keysRight: number[];
  37948. /**
  37949. * The list of keyboard keys used to control the left strafe move of the camera.
  37950. */
  37951. keysLeft: number[];
  37952. private _keys;
  37953. private _onCanvasBlurObserver;
  37954. private _onKeyboardObserver;
  37955. private _engine;
  37956. private _scene;
  37957. /**
  37958. * Attach the input controls to a specific dom element to get the input from.
  37959. * @param element Defines the element the controls should be listened from
  37960. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37961. */
  37962. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37963. /**
  37964. * Detach the current controls from the specified dom element.
  37965. * @param element Defines the element to stop listening the inputs from
  37966. */
  37967. detachControl(element: Nullable<HTMLElement>): void;
  37968. /**
  37969. * Gets the class name of the current intput.
  37970. * @returns the class name
  37971. */
  37972. getClassName(): string;
  37973. /** @hidden */
  37974. _onLostFocus(e: FocusEvent): void;
  37975. /**
  37976. * Get the friendly name associated with the input class.
  37977. * @returns the input friendly name
  37978. */
  37979. getSimpleName(): string;
  37980. /**
  37981. * Update the current camera state depending on the inputs that have been used this frame.
  37982. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37983. */
  37984. checkInputs(): void;
  37985. }
  37986. }
  37987. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  37988. import { Nullable } from "babylonjs/types";
  37989. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37990. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37991. /**
  37992. * Manage the mouse wheel inputs to control a follow camera.
  37993. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37994. */
  37995. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  37996. /**
  37997. * Defines the camera the input is attached to.
  37998. */
  37999. camera: FollowCamera;
  38000. /**
  38001. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  38002. */
  38003. axisControlRadius: boolean;
  38004. /**
  38005. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  38006. */
  38007. axisControlHeight: boolean;
  38008. /**
  38009. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  38010. */
  38011. axisControlRotation: boolean;
  38012. /**
  38013. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  38014. * relation to mouseWheel events.
  38015. */
  38016. wheelPrecision: number;
  38017. /**
  38018. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38019. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38020. */
  38021. wheelDeltaPercentage: number;
  38022. private _wheel;
  38023. private _observer;
  38024. /**
  38025. * Attach the input controls to a specific dom element to get the input from.
  38026. * @param element Defines the element the controls should be listened from
  38027. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38028. */
  38029. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38030. /**
  38031. * Detach the current controls from the specified dom element.
  38032. * @param element Defines the element to stop listening the inputs from
  38033. */
  38034. detachControl(element: Nullable<HTMLElement>): void;
  38035. /**
  38036. * Gets the class name of the current intput.
  38037. * @returns the class name
  38038. */
  38039. getClassName(): string;
  38040. /**
  38041. * Get the friendly name associated with the input class.
  38042. * @returns the input friendly name
  38043. */
  38044. getSimpleName(): string;
  38045. }
  38046. }
  38047. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  38048. import { Nullable } from "babylonjs/types";
  38049. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38050. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  38051. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  38052. /**
  38053. * Manage the pointers inputs to control an follow camera.
  38054. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38055. */
  38056. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  38057. /**
  38058. * Defines the camera the input is attached to.
  38059. */
  38060. camera: FollowCamera;
  38061. /**
  38062. * Gets the class name of the current input.
  38063. * @returns the class name
  38064. */
  38065. getClassName(): string;
  38066. /**
  38067. * Defines the pointer angular sensibility along the X axis or how fast is
  38068. * the camera rotating.
  38069. * A negative number will reverse the axis direction.
  38070. */
  38071. angularSensibilityX: number;
  38072. /**
  38073. * Defines the pointer angular sensibility along the Y axis or how fast is
  38074. * the camera rotating.
  38075. * A negative number will reverse the axis direction.
  38076. */
  38077. angularSensibilityY: number;
  38078. /**
  38079. * Defines the pointer pinch precision or how fast is the camera zooming.
  38080. * A negative number will reverse the axis direction.
  38081. */
  38082. pinchPrecision: number;
  38083. /**
  38084. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38085. * from 0.
  38086. * It defines the percentage of current camera.radius to use as delta when
  38087. * pinch zoom is used.
  38088. */
  38089. pinchDeltaPercentage: number;
  38090. /**
  38091. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  38092. */
  38093. axisXControlRadius: boolean;
  38094. /**
  38095. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  38096. */
  38097. axisXControlHeight: boolean;
  38098. /**
  38099. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  38100. */
  38101. axisXControlRotation: boolean;
  38102. /**
  38103. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  38104. */
  38105. axisYControlRadius: boolean;
  38106. /**
  38107. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  38108. */
  38109. axisYControlHeight: boolean;
  38110. /**
  38111. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  38112. */
  38113. axisYControlRotation: boolean;
  38114. /**
  38115. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  38116. */
  38117. axisPinchControlRadius: boolean;
  38118. /**
  38119. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  38120. */
  38121. axisPinchControlHeight: boolean;
  38122. /**
  38123. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  38124. */
  38125. axisPinchControlRotation: boolean;
  38126. /**
  38127. * Log error messages if basic misconfiguration has occurred.
  38128. */
  38129. warningEnable: boolean;
  38130. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38131. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38132. private _warningCounter;
  38133. private _warning;
  38134. }
  38135. }
  38136. declare module "babylonjs/Cameras/followCameraInputsManager" {
  38137. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38138. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38139. /**
  38140. * Default Inputs manager for the FollowCamera.
  38141. * It groups all the default supported inputs for ease of use.
  38142. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38143. */
  38144. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  38145. /**
  38146. * Instantiates a new FollowCameraInputsManager.
  38147. * @param camera Defines the camera the inputs belong to
  38148. */
  38149. constructor(camera: FollowCamera);
  38150. /**
  38151. * Add keyboard input support to the input manager.
  38152. * @returns the current input manager
  38153. */
  38154. addKeyboard(): FollowCameraInputsManager;
  38155. /**
  38156. * Add mouse wheel input support to the input manager.
  38157. * @returns the current input manager
  38158. */
  38159. addMouseWheel(): FollowCameraInputsManager;
  38160. /**
  38161. * Add pointers input support to the input manager.
  38162. * @returns the current input manager
  38163. */
  38164. addPointers(): FollowCameraInputsManager;
  38165. /**
  38166. * Add orientation input support to the input manager.
  38167. * @returns the current input manager
  38168. */
  38169. addVRDeviceOrientation(): FollowCameraInputsManager;
  38170. }
  38171. }
  38172. declare module "babylonjs/Cameras/followCamera" {
  38173. import { Nullable } from "babylonjs/types";
  38174. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38175. import { Scene } from "babylonjs/scene";
  38176. import { Vector3 } from "babylonjs/Maths/math";
  38177. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38178. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  38179. /**
  38180. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  38181. * an arc rotate version arcFollowCamera are available.
  38182. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38183. */
  38184. export class FollowCamera extends TargetCamera {
  38185. /**
  38186. * Distance the follow camera should follow an object at
  38187. */
  38188. radius: number;
  38189. /**
  38190. * Minimum allowed distance of the camera to the axis of rotation
  38191. * (The camera can not get closer).
  38192. * This can help limiting how the Camera is able to move in the scene.
  38193. */
  38194. lowerRadiusLimit: Nullable<number>;
  38195. /**
  38196. * Maximum allowed distance of the camera to the axis of rotation
  38197. * (The camera can not get further).
  38198. * This can help limiting how the Camera is able to move in the scene.
  38199. */
  38200. upperRadiusLimit: Nullable<number>;
  38201. /**
  38202. * Define a rotation offset between the camera and the object it follows
  38203. */
  38204. rotationOffset: number;
  38205. /**
  38206. * Minimum allowed angle to camera position relative to target object.
  38207. * This can help limiting how the Camera is able to move in the scene.
  38208. */
  38209. lowerRotationOffsetLimit: Nullable<number>;
  38210. /**
  38211. * Maximum allowed angle to camera position relative to target object.
  38212. * This can help limiting how the Camera is able to move in the scene.
  38213. */
  38214. upperRotationOffsetLimit: Nullable<number>;
  38215. /**
  38216. * Define a height offset between the camera and the object it follows.
  38217. * It can help following an object from the top (like a car chaing a plane)
  38218. */
  38219. heightOffset: number;
  38220. /**
  38221. * Minimum allowed height of camera position relative to target object.
  38222. * This can help limiting how the Camera is able to move in the scene.
  38223. */
  38224. lowerHeightOffsetLimit: Nullable<number>;
  38225. /**
  38226. * Maximum allowed height of camera position relative to target object.
  38227. * This can help limiting how the Camera is able to move in the scene.
  38228. */
  38229. upperHeightOffsetLimit: Nullable<number>;
  38230. /**
  38231. * Define how fast the camera can accelerate to follow it s target.
  38232. */
  38233. cameraAcceleration: number;
  38234. /**
  38235. * Define the speed limit of the camera following an object.
  38236. */
  38237. maxCameraSpeed: number;
  38238. /**
  38239. * Define the target of the camera.
  38240. */
  38241. lockedTarget: Nullable<AbstractMesh>;
  38242. /**
  38243. * Defines the input associated with the camera.
  38244. */
  38245. inputs: FollowCameraInputsManager;
  38246. /**
  38247. * Instantiates the follow camera.
  38248. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38249. * @param name Define the name of the camera in the scene
  38250. * @param position Define the position of the camera
  38251. * @param scene Define the scene the camera belong to
  38252. * @param lockedTarget Define the target of the camera
  38253. */
  38254. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  38255. private _follow;
  38256. /**
  38257. * Attached controls to the current camera.
  38258. * @param element Defines the element the controls should be listened from
  38259. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38260. */
  38261. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38262. /**
  38263. * Detach the current controls from the camera.
  38264. * The camera will stop reacting to inputs.
  38265. * @param element Defines the element to stop listening the inputs from
  38266. */
  38267. detachControl(element: HTMLElement): void;
  38268. /** @hidden */
  38269. _checkInputs(): void;
  38270. private _checkLimits;
  38271. /**
  38272. * Gets the camera class name.
  38273. * @returns the class name
  38274. */
  38275. getClassName(): string;
  38276. }
  38277. /**
  38278. * Arc Rotate version of the follow camera.
  38279. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  38280. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38281. */
  38282. export class ArcFollowCamera extends TargetCamera {
  38283. /** The longitudinal angle of the camera */
  38284. alpha: number;
  38285. /** The latitudinal angle of the camera */
  38286. beta: number;
  38287. /** The radius of the camera from its target */
  38288. radius: number;
  38289. /** Define the camera target (the messh it should follow) */
  38290. target: Nullable<AbstractMesh>;
  38291. private _cartesianCoordinates;
  38292. /**
  38293. * Instantiates a new ArcFollowCamera
  38294. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38295. * @param name Define the name of the camera
  38296. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  38297. * @param beta Define the rotation angle of the camera around the elevation axis
  38298. * @param radius Define the radius of the camera from its target point
  38299. * @param target Define the target of the camera
  38300. * @param scene Define the scene the camera belongs to
  38301. */
  38302. constructor(name: string,
  38303. /** The longitudinal angle of the camera */
  38304. alpha: number,
  38305. /** The latitudinal angle of the camera */
  38306. beta: number,
  38307. /** The radius of the camera from its target */
  38308. radius: number,
  38309. /** Define the camera target (the messh it should follow) */
  38310. target: Nullable<AbstractMesh>, scene: Scene);
  38311. private _follow;
  38312. /** @hidden */
  38313. _checkInputs(): void;
  38314. /**
  38315. * Returns the class name of the object.
  38316. * It is mostly used internally for serialization purposes.
  38317. */
  38318. getClassName(): string;
  38319. }
  38320. }
  38321. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  38322. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38323. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38324. import { Nullable } from "babylonjs/types";
  38325. /**
  38326. * Manage the keyboard inputs to control the movement of a follow camera.
  38327. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38328. */
  38329. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  38330. /**
  38331. * Defines the camera the input is attached to.
  38332. */
  38333. camera: FollowCamera;
  38334. /**
  38335. * Defines the list of key codes associated with the up action (increase heightOffset)
  38336. */
  38337. keysHeightOffsetIncr: number[];
  38338. /**
  38339. * Defines the list of key codes associated with the down action (decrease heightOffset)
  38340. */
  38341. keysHeightOffsetDecr: number[];
  38342. /**
  38343. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  38344. */
  38345. keysHeightOffsetModifierAlt: boolean;
  38346. /**
  38347. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  38348. */
  38349. keysHeightOffsetModifierCtrl: boolean;
  38350. /**
  38351. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  38352. */
  38353. keysHeightOffsetModifierShift: boolean;
  38354. /**
  38355. * Defines the list of key codes associated with the left action (increase rotationOffset)
  38356. */
  38357. keysRotationOffsetIncr: number[];
  38358. /**
  38359. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  38360. */
  38361. keysRotationOffsetDecr: number[];
  38362. /**
  38363. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  38364. */
  38365. keysRotationOffsetModifierAlt: boolean;
  38366. /**
  38367. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  38368. */
  38369. keysRotationOffsetModifierCtrl: boolean;
  38370. /**
  38371. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  38372. */
  38373. keysRotationOffsetModifierShift: boolean;
  38374. /**
  38375. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  38376. */
  38377. keysRadiusIncr: number[];
  38378. /**
  38379. * Defines the list of key codes associated with the zoom-out action (increase radius)
  38380. */
  38381. keysRadiusDecr: number[];
  38382. /**
  38383. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  38384. */
  38385. keysRadiusModifierAlt: boolean;
  38386. /**
  38387. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  38388. */
  38389. keysRadiusModifierCtrl: boolean;
  38390. /**
  38391. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  38392. */
  38393. keysRadiusModifierShift: boolean;
  38394. /**
  38395. * Defines the rate of change of heightOffset.
  38396. */
  38397. heightSensibility: number;
  38398. /**
  38399. * Defines the rate of change of rotationOffset.
  38400. */
  38401. rotationSensibility: number;
  38402. /**
  38403. * Defines the rate of change of radius.
  38404. */
  38405. radiusSensibility: number;
  38406. private _keys;
  38407. private _ctrlPressed;
  38408. private _altPressed;
  38409. private _shiftPressed;
  38410. private _onCanvasBlurObserver;
  38411. private _onKeyboardObserver;
  38412. private _engine;
  38413. private _scene;
  38414. /**
  38415. * Attach the input controls to a specific dom element to get the input from.
  38416. * @param element Defines the element the controls should be listened from
  38417. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38418. */
  38419. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38420. /**
  38421. * Detach the current controls from the specified dom element.
  38422. * @param element Defines the element to stop listening the inputs from
  38423. */
  38424. detachControl(element: Nullable<HTMLElement>): void;
  38425. /**
  38426. * Update the current camera state depending on the inputs that have been used this frame.
  38427. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38428. */
  38429. checkInputs(): void;
  38430. /**
  38431. * Gets the class name of the current input.
  38432. * @returns the class name
  38433. */
  38434. getClassName(): string;
  38435. /**
  38436. * Get the friendly name associated with the input class.
  38437. * @returns the input friendly name
  38438. */
  38439. getSimpleName(): string;
  38440. /**
  38441. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38442. * allow modification of the heightOffset value.
  38443. */
  38444. private _modifierHeightOffset;
  38445. /**
  38446. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38447. * allow modification of the rotationOffset value.
  38448. */
  38449. private _modifierRotationOffset;
  38450. /**
  38451. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38452. * allow modification of the radius value.
  38453. */
  38454. private _modifierRadius;
  38455. }
  38456. }
  38457. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  38458. import { Nullable } from "babylonjs/types";
  38459. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38460. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38461. import { Observable } from "babylonjs/Misc/observable";
  38462. module "babylonjs/Cameras/freeCameraInputsManager" {
  38463. interface FreeCameraInputsManager {
  38464. /**
  38465. * @hidden
  38466. */
  38467. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  38468. /**
  38469. * Add orientation input support to the input manager.
  38470. * @returns the current input manager
  38471. */
  38472. addDeviceOrientation(): FreeCameraInputsManager;
  38473. }
  38474. }
  38475. /**
  38476. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  38477. * Screen rotation is taken into account.
  38478. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38479. */
  38480. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  38481. private _camera;
  38482. private _screenOrientationAngle;
  38483. private _constantTranform;
  38484. private _screenQuaternion;
  38485. private _alpha;
  38486. private _beta;
  38487. private _gamma;
  38488. /**
  38489. * Can be used to detect if a device orientation sensor is availible on a device
  38490. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  38491. * @returns a promise that will resolve on orientation change
  38492. */
  38493. static WaitForOrientationChangeAsync(timeout?: number): Promise<{}>;
  38494. /**
  38495. * @hidden
  38496. */
  38497. _onDeviceOrientationChangedObservable: Observable<void>;
  38498. /**
  38499. * Instantiates a new input
  38500. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38501. */
  38502. constructor();
  38503. /**
  38504. * Define the camera controlled by the input.
  38505. */
  38506. camera: FreeCamera;
  38507. /**
  38508. * Attach the input controls to a specific dom element to get the input from.
  38509. * @param element Defines the element the controls should be listened from
  38510. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38511. */
  38512. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38513. private _orientationChanged;
  38514. private _deviceOrientation;
  38515. /**
  38516. * Detach the current controls from the specified dom element.
  38517. * @param element Defines the element to stop listening the inputs from
  38518. */
  38519. detachControl(element: Nullable<HTMLElement>): void;
  38520. /**
  38521. * Update the current camera state depending on the inputs that have been used this frame.
  38522. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38523. */
  38524. checkInputs(): void;
  38525. /**
  38526. * Gets the class name of the current intput.
  38527. * @returns the class name
  38528. */
  38529. getClassName(): string;
  38530. /**
  38531. * Get the friendly name associated with the input class.
  38532. * @returns the input friendly name
  38533. */
  38534. getSimpleName(): string;
  38535. }
  38536. }
  38537. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  38538. import { Nullable } from "babylonjs/types";
  38539. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38540. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38541. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38542. /**
  38543. * Manage the gamepad inputs to control a free camera.
  38544. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38545. */
  38546. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  38547. /**
  38548. * Define the camera the input is attached to.
  38549. */
  38550. camera: FreeCamera;
  38551. /**
  38552. * Define the Gamepad controlling the input
  38553. */
  38554. gamepad: Nullable<Gamepad>;
  38555. /**
  38556. * Defines the gamepad rotation sensiblity.
  38557. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38558. */
  38559. gamepadAngularSensibility: number;
  38560. /**
  38561. * Defines the gamepad move sensiblity.
  38562. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38563. */
  38564. gamepadMoveSensibility: number;
  38565. private _onGamepadConnectedObserver;
  38566. private _onGamepadDisconnectedObserver;
  38567. private _cameraTransform;
  38568. private _deltaTransform;
  38569. private _vector3;
  38570. private _vector2;
  38571. /**
  38572. * Attach the input controls to a specific dom element to get the input from.
  38573. * @param element Defines the element the controls should be listened from
  38574. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38575. */
  38576. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38577. /**
  38578. * Detach the current controls from the specified dom element.
  38579. * @param element Defines the element to stop listening the inputs from
  38580. */
  38581. detachControl(element: Nullable<HTMLElement>): void;
  38582. /**
  38583. * Update the current camera state depending on the inputs that have been used this frame.
  38584. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38585. */
  38586. checkInputs(): void;
  38587. /**
  38588. * Gets the class name of the current intput.
  38589. * @returns the class name
  38590. */
  38591. getClassName(): string;
  38592. /**
  38593. * Get the friendly name associated with the input class.
  38594. * @returns the input friendly name
  38595. */
  38596. getSimpleName(): string;
  38597. }
  38598. }
  38599. declare module "babylonjs/Misc/virtualJoystick" {
  38600. import { Nullable } from "babylonjs/types";
  38601. import { Vector3 } from "babylonjs/Maths/math";
  38602. /**
  38603. * Defines the potential axis of a Joystick
  38604. */
  38605. export enum JoystickAxis {
  38606. /** X axis */
  38607. X = 0,
  38608. /** Y axis */
  38609. Y = 1,
  38610. /** Z axis */
  38611. Z = 2
  38612. }
  38613. /**
  38614. * Class used to define virtual joystick (used in touch mode)
  38615. */
  38616. export class VirtualJoystick {
  38617. /**
  38618. * Gets or sets a boolean indicating that left and right values must be inverted
  38619. */
  38620. reverseLeftRight: boolean;
  38621. /**
  38622. * Gets or sets a boolean indicating that up and down values must be inverted
  38623. */
  38624. reverseUpDown: boolean;
  38625. /**
  38626. * Gets the offset value for the position (ie. the change of the position value)
  38627. */
  38628. deltaPosition: Vector3;
  38629. /**
  38630. * Gets a boolean indicating if the virtual joystick was pressed
  38631. */
  38632. pressed: boolean;
  38633. /**
  38634. * Canvas the virtual joystick will render onto, default z-index of this is 5
  38635. */
  38636. static Canvas: Nullable<HTMLCanvasElement>;
  38637. private static _globalJoystickIndex;
  38638. private static vjCanvasContext;
  38639. private static vjCanvasWidth;
  38640. private static vjCanvasHeight;
  38641. private static halfWidth;
  38642. private _action;
  38643. private _axisTargetedByLeftAndRight;
  38644. private _axisTargetedByUpAndDown;
  38645. private _joystickSensibility;
  38646. private _inversedSensibility;
  38647. private _joystickPointerID;
  38648. private _joystickColor;
  38649. private _joystickPointerPos;
  38650. private _joystickPreviousPointerPos;
  38651. private _joystickPointerStartPos;
  38652. private _deltaJoystickVector;
  38653. private _leftJoystick;
  38654. private _touches;
  38655. private _onPointerDownHandlerRef;
  38656. private _onPointerMoveHandlerRef;
  38657. private _onPointerUpHandlerRef;
  38658. private _onResize;
  38659. /**
  38660. * Creates a new virtual joystick
  38661. * @param leftJoystick defines that the joystick is for left hand (false by default)
  38662. */
  38663. constructor(leftJoystick?: boolean);
  38664. /**
  38665. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  38666. * @param newJoystickSensibility defines the new sensibility
  38667. */
  38668. setJoystickSensibility(newJoystickSensibility: number): void;
  38669. private _onPointerDown;
  38670. private _onPointerMove;
  38671. private _onPointerUp;
  38672. /**
  38673. * Change the color of the virtual joystick
  38674. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  38675. */
  38676. setJoystickColor(newColor: string): void;
  38677. /**
  38678. * Defines a callback to call when the joystick is touched
  38679. * @param action defines the callback
  38680. */
  38681. setActionOnTouch(action: () => any): void;
  38682. /**
  38683. * Defines which axis you'd like to control for left & right
  38684. * @param axis defines the axis to use
  38685. */
  38686. setAxisForLeftRight(axis: JoystickAxis): void;
  38687. /**
  38688. * Defines which axis you'd like to control for up & down
  38689. * @param axis defines the axis to use
  38690. */
  38691. setAxisForUpDown(axis: JoystickAxis): void;
  38692. private _drawVirtualJoystick;
  38693. /**
  38694. * Release internal HTML canvas
  38695. */
  38696. releaseCanvas(): void;
  38697. }
  38698. }
  38699. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  38700. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  38701. import { Nullable } from "babylonjs/types";
  38702. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38703. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38704. module "babylonjs/Cameras/freeCameraInputsManager" {
  38705. interface FreeCameraInputsManager {
  38706. /**
  38707. * Add virtual joystick input support to the input manager.
  38708. * @returns the current input manager
  38709. */
  38710. addVirtualJoystick(): FreeCameraInputsManager;
  38711. }
  38712. }
  38713. /**
  38714. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  38715. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38716. */
  38717. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  38718. /**
  38719. * Defines the camera the input is attached to.
  38720. */
  38721. camera: FreeCamera;
  38722. private _leftjoystick;
  38723. private _rightjoystick;
  38724. /**
  38725. * Gets the left stick of the virtual joystick.
  38726. * @returns The virtual Joystick
  38727. */
  38728. getLeftJoystick(): VirtualJoystick;
  38729. /**
  38730. * Gets the right stick of the virtual joystick.
  38731. * @returns The virtual Joystick
  38732. */
  38733. getRightJoystick(): VirtualJoystick;
  38734. /**
  38735. * Update the current camera state depending on the inputs that have been used this frame.
  38736. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38737. */
  38738. checkInputs(): void;
  38739. /**
  38740. * Attach the input controls to a specific dom element to get the input from.
  38741. * @param element Defines the element the controls should be listened from
  38742. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38743. */
  38744. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38745. /**
  38746. * Detach the current controls from the specified dom element.
  38747. * @param element Defines the element to stop listening the inputs from
  38748. */
  38749. detachControl(element: Nullable<HTMLElement>): void;
  38750. /**
  38751. * Gets the class name of the current intput.
  38752. * @returns the class name
  38753. */
  38754. getClassName(): string;
  38755. /**
  38756. * Get the friendly name associated with the input class.
  38757. * @returns the input friendly name
  38758. */
  38759. getSimpleName(): string;
  38760. }
  38761. }
  38762. declare module "babylonjs/Cameras/Inputs/index" {
  38763. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  38764. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  38765. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  38766. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  38767. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  38768. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  38769. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  38770. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  38771. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  38772. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  38773. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  38774. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  38775. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  38776. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  38777. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  38778. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  38779. }
  38780. declare module "babylonjs/Cameras/touchCamera" {
  38781. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38782. import { Scene } from "babylonjs/scene";
  38783. import { Vector3 } from "babylonjs/Maths/math";
  38784. /**
  38785. * This represents a FPS type of camera controlled by touch.
  38786. * This is like a universal camera minus the Gamepad controls.
  38787. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38788. */
  38789. export class TouchCamera extends FreeCamera {
  38790. /**
  38791. * Defines the touch sensibility for rotation.
  38792. * The higher the faster.
  38793. */
  38794. touchAngularSensibility: number;
  38795. /**
  38796. * Defines the touch sensibility for move.
  38797. * The higher the faster.
  38798. */
  38799. touchMoveSensibility: number;
  38800. /**
  38801. * Instantiates a new touch camera.
  38802. * This represents a FPS type of camera controlled by touch.
  38803. * This is like a universal camera minus the Gamepad controls.
  38804. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38805. * @param name Define the name of the camera in the scene
  38806. * @param position Define the start position of the camera in the scene
  38807. * @param scene Define the scene the camera belongs to
  38808. */
  38809. constructor(name: string, position: Vector3, scene: Scene);
  38810. /**
  38811. * Gets the current object class name.
  38812. * @return the class name
  38813. */
  38814. getClassName(): string;
  38815. /** @hidden */
  38816. _setupInputs(): void;
  38817. }
  38818. }
  38819. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  38820. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38821. import { Scene } from "babylonjs/scene";
  38822. import { Vector3, Axis } from "babylonjs/Maths/math";
  38823. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  38824. /**
  38825. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  38826. * being tilted forward or back and left or right.
  38827. */
  38828. export class DeviceOrientationCamera extends FreeCamera {
  38829. private _initialQuaternion;
  38830. private _quaternionCache;
  38831. private _tmpDragQuaternion;
  38832. /**
  38833. * Creates a new device orientation camera
  38834. * @param name The name of the camera
  38835. * @param position The start position camera
  38836. * @param scene The scene the camera belongs to
  38837. */
  38838. constructor(name: string, position: Vector3, scene: Scene);
  38839. /**
  38840. * @hidden
  38841. * Disabled pointer input on first orientation sensor update (Default: true)
  38842. */
  38843. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  38844. private _dragFactor;
  38845. /**
  38846. * Enabled turning on the y axis when the orientation sensor is active
  38847. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  38848. */
  38849. enableHorizontalDragging(dragFactor?: number): void;
  38850. /**
  38851. * Gets the current instance class name ("DeviceOrientationCamera").
  38852. * This helps avoiding instanceof at run time.
  38853. * @returns the class name
  38854. */
  38855. getClassName(): string;
  38856. /**
  38857. * @hidden
  38858. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  38859. */
  38860. _checkInputs(): void;
  38861. /**
  38862. * Reset the camera to its default orientation on the specified axis only.
  38863. * @param axis The axis to reset
  38864. */
  38865. resetToCurrentRotation(axis?: Axis): void;
  38866. }
  38867. }
  38868. declare module "babylonjs/Gamepads/xboxGamepad" {
  38869. import { Observable } from "babylonjs/Misc/observable";
  38870. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38871. /**
  38872. * Defines supported buttons for XBox360 compatible gamepads
  38873. */
  38874. export enum Xbox360Button {
  38875. /** A */
  38876. A = 0,
  38877. /** B */
  38878. B = 1,
  38879. /** X */
  38880. X = 2,
  38881. /** Y */
  38882. Y = 3,
  38883. /** Start */
  38884. Start = 4,
  38885. /** Back */
  38886. Back = 5,
  38887. /** Left button */
  38888. LB = 6,
  38889. /** Right button */
  38890. RB = 7,
  38891. /** Left stick */
  38892. LeftStick = 8,
  38893. /** Right stick */
  38894. RightStick = 9
  38895. }
  38896. /** Defines values for XBox360 DPad */
  38897. export enum Xbox360Dpad {
  38898. /** Up */
  38899. Up = 0,
  38900. /** Down */
  38901. Down = 1,
  38902. /** Left */
  38903. Left = 2,
  38904. /** Right */
  38905. Right = 3
  38906. }
  38907. /**
  38908. * Defines a XBox360 gamepad
  38909. */
  38910. export class Xbox360Pad extends Gamepad {
  38911. private _leftTrigger;
  38912. private _rightTrigger;
  38913. private _onlefttriggerchanged;
  38914. private _onrighttriggerchanged;
  38915. private _onbuttondown;
  38916. private _onbuttonup;
  38917. private _ondpaddown;
  38918. private _ondpadup;
  38919. /** Observable raised when a button is pressed */
  38920. onButtonDownObservable: Observable<Xbox360Button>;
  38921. /** Observable raised when a button is released */
  38922. onButtonUpObservable: Observable<Xbox360Button>;
  38923. /** Observable raised when a pad is pressed */
  38924. onPadDownObservable: Observable<Xbox360Dpad>;
  38925. /** Observable raised when a pad is released */
  38926. onPadUpObservable: Observable<Xbox360Dpad>;
  38927. private _buttonA;
  38928. private _buttonB;
  38929. private _buttonX;
  38930. private _buttonY;
  38931. private _buttonBack;
  38932. private _buttonStart;
  38933. private _buttonLB;
  38934. private _buttonRB;
  38935. private _buttonLeftStick;
  38936. private _buttonRightStick;
  38937. private _dPadUp;
  38938. private _dPadDown;
  38939. private _dPadLeft;
  38940. private _dPadRight;
  38941. private _isXboxOnePad;
  38942. /**
  38943. * Creates a new XBox360 gamepad object
  38944. * @param id defines the id of this gamepad
  38945. * @param index defines its index
  38946. * @param gamepad defines the internal HTML gamepad object
  38947. * @param xboxOne defines if it is a XBox One gamepad
  38948. */
  38949. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  38950. /**
  38951. * Defines the callback to call when left trigger is pressed
  38952. * @param callback defines the callback to use
  38953. */
  38954. onlefttriggerchanged(callback: (value: number) => void): void;
  38955. /**
  38956. * Defines the callback to call when right trigger is pressed
  38957. * @param callback defines the callback to use
  38958. */
  38959. onrighttriggerchanged(callback: (value: number) => void): void;
  38960. /**
  38961. * Gets the left trigger value
  38962. */
  38963. /**
  38964. * Sets the left trigger value
  38965. */
  38966. leftTrigger: number;
  38967. /**
  38968. * Gets the right trigger value
  38969. */
  38970. /**
  38971. * Sets the right trigger value
  38972. */
  38973. rightTrigger: number;
  38974. /**
  38975. * Defines the callback to call when a button is pressed
  38976. * @param callback defines the callback to use
  38977. */
  38978. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  38979. /**
  38980. * Defines the callback to call when a button is released
  38981. * @param callback defines the callback to use
  38982. */
  38983. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  38984. /**
  38985. * Defines the callback to call when a pad is pressed
  38986. * @param callback defines the callback to use
  38987. */
  38988. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  38989. /**
  38990. * Defines the callback to call when a pad is released
  38991. * @param callback defines the callback to use
  38992. */
  38993. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  38994. private _setButtonValue;
  38995. private _setDPadValue;
  38996. /**
  38997. * Gets the value of the `A` button
  38998. */
  38999. /**
  39000. * Sets the value of the `A` button
  39001. */
  39002. buttonA: number;
  39003. /**
  39004. * Gets the value of the `B` button
  39005. */
  39006. /**
  39007. * Sets the value of the `B` button
  39008. */
  39009. buttonB: number;
  39010. /**
  39011. * Gets the value of the `X` button
  39012. */
  39013. /**
  39014. * Sets the value of the `X` button
  39015. */
  39016. buttonX: number;
  39017. /**
  39018. * Gets the value of the `Y` button
  39019. */
  39020. /**
  39021. * Sets the value of the `Y` button
  39022. */
  39023. buttonY: number;
  39024. /**
  39025. * Gets the value of the `Start` button
  39026. */
  39027. /**
  39028. * Sets the value of the `Start` button
  39029. */
  39030. buttonStart: number;
  39031. /**
  39032. * Gets the value of the `Back` button
  39033. */
  39034. /**
  39035. * Sets the value of the `Back` button
  39036. */
  39037. buttonBack: number;
  39038. /**
  39039. * Gets the value of the `Left` button
  39040. */
  39041. /**
  39042. * Sets the value of the `Left` button
  39043. */
  39044. buttonLB: number;
  39045. /**
  39046. * Gets the value of the `Right` button
  39047. */
  39048. /**
  39049. * Sets the value of the `Right` button
  39050. */
  39051. buttonRB: number;
  39052. /**
  39053. * Gets the value of the Left joystick
  39054. */
  39055. /**
  39056. * Sets the value of the Left joystick
  39057. */
  39058. buttonLeftStick: number;
  39059. /**
  39060. * Gets the value of the Right joystick
  39061. */
  39062. /**
  39063. * Sets the value of the Right joystick
  39064. */
  39065. buttonRightStick: number;
  39066. /**
  39067. * Gets the value of D-pad up
  39068. */
  39069. /**
  39070. * Sets the value of D-pad up
  39071. */
  39072. dPadUp: number;
  39073. /**
  39074. * Gets the value of D-pad down
  39075. */
  39076. /**
  39077. * Sets the value of D-pad down
  39078. */
  39079. dPadDown: number;
  39080. /**
  39081. * Gets the value of D-pad left
  39082. */
  39083. /**
  39084. * Sets the value of D-pad left
  39085. */
  39086. dPadLeft: number;
  39087. /**
  39088. * Gets the value of D-pad right
  39089. */
  39090. /**
  39091. * Sets the value of D-pad right
  39092. */
  39093. dPadRight: number;
  39094. /**
  39095. * Force the gamepad to synchronize with device values
  39096. */
  39097. update(): void;
  39098. /**
  39099. * Disposes the gamepad
  39100. */
  39101. dispose(): void;
  39102. }
  39103. }
  39104. declare module "babylonjs/Gamepads/gamepadManager" {
  39105. import { Observable } from "babylonjs/Misc/observable";
  39106. import { Nullable } from "babylonjs/types";
  39107. import { Scene } from "babylonjs/scene";
  39108. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39109. /**
  39110. * Manager for handling gamepads
  39111. */
  39112. export class GamepadManager {
  39113. private _scene?;
  39114. private _babylonGamepads;
  39115. private _oneGamepadConnected;
  39116. /** @hidden */
  39117. _isMonitoring: boolean;
  39118. private _gamepadEventSupported;
  39119. private _gamepadSupport;
  39120. /**
  39121. * observable to be triggered when the gamepad controller has been connected
  39122. */
  39123. onGamepadConnectedObservable: Observable<Gamepad>;
  39124. /**
  39125. * observable to be triggered when the gamepad controller has been disconnected
  39126. */
  39127. onGamepadDisconnectedObservable: Observable<Gamepad>;
  39128. private _onGamepadConnectedEvent;
  39129. private _onGamepadDisconnectedEvent;
  39130. /**
  39131. * Initializes the gamepad manager
  39132. * @param _scene BabylonJS scene
  39133. */
  39134. constructor(_scene?: Scene | undefined);
  39135. /**
  39136. * The gamepads in the game pad manager
  39137. */
  39138. readonly gamepads: Gamepad[];
  39139. /**
  39140. * Get the gamepad controllers based on type
  39141. * @param type The type of gamepad controller
  39142. * @returns Nullable gamepad
  39143. */
  39144. getGamepadByType(type?: number): Nullable<Gamepad>;
  39145. /**
  39146. * Disposes the gamepad manager
  39147. */
  39148. dispose(): void;
  39149. private _addNewGamepad;
  39150. private _startMonitoringGamepads;
  39151. private _stopMonitoringGamepads;
  39152. /** @hidden */
  39153. _checkGamepadsStatus(): void;
  39154. private _updateGamepadObjects;
  39155. }
  39156. }
  39157. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  39158. import { Nullable } from "babylonjs/types";
  39159. import { Scene } from "babylonjs/scene";
  39160. import { ISceneComponent } from "babylonjs/sceneComponent";
  39161. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  39162. module "babylonjs/scene" {
  39163. interface Scene {
  39164. /** @hidden */
  39165. _gamepadManager: Nullable<GamepadManager>;
  39166. /**
  39167. * Gets the gamepad manager associated with the scene
  39168. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  39169. */
  39170. gamepadManager: GamepadManager;
  39171. }
  39172. }
  39173. module "babylonjs/Cameras/freeCameraInputsManager" {
  39174. /**
  39175. * Interface representing a free camera inputs manager
  39176. */
  39177. interface FreeCameraInputsManager {
  39178. /**
  39179. * Adds gamepad input support to the FreeCameraInputsManager.
  39180. * @returns the FreeCameraInputsManager
  39181. */
  39182. addGamepad(): FreeCameraInputsManager;
  39183. }
  39184. }
  39185. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39186. /**
  39187. * Interface representing an arc rotate camera inputs manager
  39188. */
  39189. interface ArcRotateCameraInputsManager {
  39190. /**
  39191. * Adds gamepad input support to the ArcRotateCamera InputManager.
  39192. * @returns the camera inputs manager
  39193. */
  39194. addGamepad(): ArcRotateCameraInputsManager;
  39195. }
  39196. }
  39197. /**
  39198. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  39199. */
  39200. export class GamepadSystemSceneComponent implements ISceneComponent {
  39201. /**
  39202. * The component name helpfull to identify the component in the list of scene components.
  39203. */
  39204. readonly name: string;
  39205. /**
  39206. * The scene the component belongs to.
  39207. */
  39208. scene: Scene;
  39209. /**
  39210. * Creates a new instance of the component for the given scene
  39211. * @param scene Defines the scene to register the component in
  39212. */
  39213. constructor(scene: Scene);
  39214. /**
  39215. * Registers the component in a given scene
  39216. */
  39217. register(): void;
  39218. /**
  39219. * Rebuilds the elements related to this component in case of
  39220. * context lost for instance.
  39221. */
  39222. rebuild(): void;
  39223. /**
  39224. * Disposes the component and the associated ressources
  39225. */
  39226. dispose(): void;
  39227. private _beforeCameraUpdate;
  39228. }
  39229. }
  39230. declare module "babylonjs/Cameras/universalCamera" {
  39231. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  39232. import { Scene } from "babylonjs/scene";
  39233. import { Vector3 } from "babylonjs/Maths/math";
  39234. import "babylonjs/Gamepads/gamepadSceneComponent";
  39235. /**
  39236. * 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,
  39237. * which still works and will still be found in many Playgrounds.
  39238. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39239. */
  39240. export class UniversalCamera extends TouchCamera {
  39241. /**
  39242. * Defines the gamepad rotation sensiblity.
  39243. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39244. */
  39245. gamepadAngularSensibility: number;
  39246. /**
  39247. * Defines the gamepad move sensiblity.
  39248. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39249. */
  39250. gamepadMoveSensibility: number;
  39251. /**
  39252. * 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,
  39253. * which still works and will still be found in many Playgrounds.
  39254. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39255. * @param name Define the name of the camera in the scene
  39256. * @param position Define the start position of the camera in the scene
  39257. * @param scene Define the scene the camera belongs to
  39258. */
  39259. constructor(name: string, position: Vector3, scene: Scene);
  39260. /**
  39261. * Gets the current object class name.
  39262. * @return the class name
  39263. */
  39264. getClassName(): string;
  39265. }
  39266. }
  39267. declare module "babylonjs/Cameras/gamepadCamera" {
  39268. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  39269. import { Scene } from "babylonjs/scene";
  39270. import { Vector3 } from "babylonjs/Maths/math";
  39271. /**
  39272. * This represents a FPS type of camera. This is only here for back compat purpose.
  39273. * Please use the UniversalCamera instead as both are identical.
  39274. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39275. */
  39276. export class GamepadCamera extends UniversalCamera {
  39277. /**
  39278. * Instantiates a new Gamepad Camera
  39279. * This represents a FPS type of camera. This is only here for back compat purpose.
  39280. * Please use the UniversalCamera instead as both are identical.
  39281. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39282. * @param name Define the name of the camera in the scene
  39283. * @param position Define the start position of the camera in the scene
  39284. * @param scene Define the scene the camera belongs to
  39285. */
  39286. constructor(name: string, position: Vector3, scene: Scene);
  39287. /**
  39288. * Gets the current object class name.
  39289. * @return the class name
  39290. */
  39291. getClassName(): string;
  39292. }
  39293. }
  39294. declare module "babylonjs/Shaders/pass.fragment" {
  39295. /** @hidden */
  39296. export var passPixelShader: {
  39297. name: string;
  39298. shader: string;
  39299. };
  39300. }
  39301. declare module "babylonjs/Shaders/passCube.fragment" {
  39302. /** @hidden */
  39303. export var passCubePixelShader: {
  39304. name: string;
  39305. shader: string;
  39306. };
  39307. }
  39308. declare module "babylonjs/PostProcesses/passPostProcess" {
  39309. import { Nullable } from "babylonjs/types";
  39310. import { Camera } from "babylonjs/Cameras/camera";
  39311. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39312. import { Engine } from "babylonjs/Engines/engine";
  39313. import "babylonjs/Shaders/pass.fragment";
  39314. import "babylonjs/Shaders/passCube.fragment";
  39315. /**
  39316. * PassPostProcess which produces an output the same as it's input
  39317. */
  39318. export class PassPostProcess extends PostProcess {
  39319. /**
  39320. * Creates the PassPostProcess
  39321. * @param name The name of the effect.
  39322. * @param options The required width/height ratio to downsize to before computing the render pass.
  39323. * @param camera The camera to apply the render pass to.
  39324. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39325. * @param engine The engine which the post process will be applied. (default: current engine)
  39326. * @param reusable If the post process can be reused on the same frame. (default: false)
  39327. * @param textureType The type of texture to be used when performing the post processing.
  39328. * @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)
  39329. */
  39330. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39331. }
  39332. /**
  39333. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  39334. */
  39335. export class PassCubePostProcess extends PostProcess {
  39336. private _face;
  39337. /**
  39338. * Gets or sets the cube face to display.
  39339. * * 0 is +X
  39340. * * 1 is -X
  39341. * * 2 is +Y
  39342. * * 3 is -Y
  39343. * * 4 is +Z
  39344. * * 5 is -Z
  39345. */
  39346. face: number;
  39347. /**
  39348. * Creates the PassCubePostProcess
  39349. * @param name The name of the effect.
  39350. * @param options The required width/height ratio to downsize to before computing the render pass.
  39351. * @param camera The camera to apply the render pass to.
  39352. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39353. * @param engine The engine which the post process will be applied. (default: current engine)
  39354. * @param reusable If the post process can be reused on the same frame. (default: false)
  39355. * @param textureType The type of texture to be used when performing the post processing.
  39356. * @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)
  39357. */
  39358. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39359. }
  39360. }
  39361. declare module "babylonjs/Shaders/anaglyph.fragment" {
  39362. /** @hidden */
  39363. export var anaglyphPixelShader: {
  39364. name: string;
  39365. shader: string;
  39366. };
  39367. }
  39368. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  39369. import { Engine } from "babylonjs/Engines/engine";
  39370. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39371. import { Camera } from "babylonjs/Cameras/camera";
  39372. import "babylonjs/Shaders/anaglyph.fragment";
  39373. /**
  39374. * Postprocess used to generate anaglyphic rendering
  39375. */
  39376. export class AnaglyphPostProcess extends PostProcess {
  39377. private _passedProcess;
  39378. /**
  39379. * Creates a new AnaglyphPostProcess
  39380. * @param name defines postprocess name
  39381. * @param options defines creation options or target ratio scale
  39382. * @param rigCameras defines cameras using this postprocess
  39383. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  39384. * @param engine defines hosting engine
  39385. * @param reusable defines if the postprocess will be reused multiple times per frame
  39386. */
  39387. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  39388. }
  39389. }
  39390. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  39391. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  39392. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39393. import { Scene } from "babylonjs/scene";
  39394. import { Vector3 } from "babylonjs/Maths/math";
  39395. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39396. /**
  39397. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  39398. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39399. */
  39400. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  39401. /**
  39402. * Creates a new AnaglyphArcRotateCamera
  39403. * @param name defines camera name
  39404. * @param alpha defines alpha angle (in radians)
  39405. * @param beta defines beta angle (in radians)
  39406. * @param radius defines radius
  39407. * @param target defines camera target
  39408. * @param interaxialDistance defines distance between each color axis
  39409. * @param scene defines the hosting scene
  39410. */
  39411. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  39412. /**
  39413. * Gets camera class name
  39414. * @returns AnaglyphArcRotateCamera
  39415. */
  39416. getClassName(): string;
  39417. }
  39418. }
  39419. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  39420. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39421. import { Scene } from "babylonjs/scene";
  39422. import { Vector3 } from "babylonjs/Maths/math";
  39423. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39424. /**
  39425. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  39426. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39427. */
  39428. export class AnaglyphFreeCamera extends FreeCamera {
  39429. /**
  39430. * Creates a new AnaglyphFreeCamera
  39431. * @param name defines camera name
  39432. * @param position defines initial position
  39433. * @param interaxialDistance defines distance between each color axis
  39434. * @param scene defines the hosting scene
  39435. */
  39436. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39437. /**
  39438. * Gets camera class name
  39439. * @returns AnaglyphFreeCamera
  39440. */
  39441. getClassName(): string;
  39442. }
  39443. }
  39444. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  39445. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  39446. import { Scene } from "babylonjs/scene";
  39447. import { Vector3 } from "babylonjs/Maths/math";
  39448. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39449. /**
  39450. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  39451. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39452. */
  39453. export class AnaglyphGamepadCamera extends GamepadCamera {
  39454. /**
  39455. * Creates a new AnaglyphGamepadCamera
  39456. * @param name defines camera name
  39457. * @param position defines initial position
  39458. * @param interaxialDistance defines distance between each color axis
  39459. * @param scene defines the hosting scene
  39460. */
  39461. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39462. /**
  39463. * Gets camera class name
  39464. * @returns AnaglyphGamepadCamera
  39465. */
  39466. getClassName(): string;
  39467. }
  39468. }
  39469. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  39470. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  39471. import { Scene } from "babylonjs/scene";
  39472. import { Vector3 } from "babylonjs/Maths/math";
  39473. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39474. /**
  39475. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  39476. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39477. */
  39478. export class AnaglyphUniversalCamera extends UniversalCamera {
  39479. /**
  39480. * Creates a new AnaglyphUniversalCamera
  39481. * @param name defines camera name
  39482. * @param position defines initial position
  39483. * @param interaxialDistance defines distance between each color axis
  39484. * @param scene defines the hosting scene
  39485. */
  39486. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39487. /**
  39488. * Gets camera class name
  39489. * @returns AnaglyphUniversalCamera
  39490. */
  39491. getClassName(): string;
  39492. }
  39493. }
  39494. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  39495. /** @hidden */
  39496. export var stereoscopicInterlacePixelShader: {
  39497. name: string;
  39498. shader: string;
  39499. };
  39500. }
  39501. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  39502. import { Camera } from "babylonjs/Cameras/camera";
  39503. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39504. import { Engine } from "babylonjs/Engines/engine";
  39505. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  39506. /**
  39507. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  39508. */
  39509. export class StereoscopicInterlacePostProcess extends PostProcess {
  39510. private _stepSize;
  39511. private _passedProcess;
  39512. /**
  39513. * Initializes a StereoscopicInterlacePostProcess
  39514. * @param name The name of the effect.
  39515. * @param rigCameras The rig cameras to be appled to the post process
  39516. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  39517. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39518. * @param engine The engine which the post process will be applied. (default: current engine)
  39519. * @param reusable If the post process can be reused on the same frame. (default: false)
  39520. */
  39521. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  39522. }
  39523. }
  39524. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  39525. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  39526. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39527. import { Scene } from "babylonjs/scene";
  39528. import { Vector3 } from "babylonjs/Maths/math";
  39529. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39530. /**
  39531. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  39532. * @see http://doc.babylonjs.com/features/cameras
  39533. */
  39534. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  39535. /**
  39536. * Creates a new StereoscopicArcRotateCamera
  39537. * @param name defines camera name
  39538. * @param alpha defines alpha angle (in radians)
  39539. * @param beta defines beta angle (in radians)
  39540. * @param radius defines radius
  39541. * @param target defines camera target
  39542. * @param interaxialDistance defines distance between each color axis
  39543. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39544. * @param scene defines the hosting scene
  39545. */
  39546. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39547. /**
  39548. * Gets camera class name
  39549. * @returns StereoscopicArcRotateCamera
  39550. */
  39551. getClassName(): string;
  39552. }
  39553. }
  39554. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  39555. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39556. import { Scene } from "babylonjs/scene";
  39557. import { Vector3 } from "babylonjs/Maths/math";
  39558. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39559. /**
  39560. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  39561. * @see http://doc.babylonjs.com/features/cameras
  39562. */
  39563. export class StereoscopicFreeCamera extends FreeCamera {
  39564. /**
  39565. * Creates a new StereoscopicFreeCamera
  39566. * @param name defines camera name
  39567. * @param position defines initial position
  39568. * @param interaxialDistance defines distance between each color axis
  39569. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39570. * @param scene defines the hosting scene
  39571. */
  39572. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39573. /**
  39574. * Gets camera class name
  39575. * @returns StereoscopicFreeCamera
  39576. */
  39577. getClassName(): string;
  39578. }
  39579. }
  39580. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  39581. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  39582. import { Scene } from "babylonjs/scene";
  39583. import { Vector3 } from "babylonjs/Maths/math";
  39584. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39585. /**
  39586. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  39587. * @see http://doc.babylonjs.com/features/cameras
  39588. */
  39589. export class StereoscopicGamepadCamera extends GamepadCamera {
  39590. /**
  39591. * Creates a new StereoscopicGamepadCamera
  39592. * @param name defines camera name
  39593. * @param position defines initial position
  39594. * @param interaxialDistance defines distance between each color axis
  39595. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39596. * @param scene defines the hosting scene
  39597. */
  39598. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39599. /**
  39600. * Gets camera class name
  39601. * @returns StereoscopicGamepadCamera
  39602. */
  39603. getClassName(): string;
  39604. }
  39605. }
  39606. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  39607. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  39608. import { Scene } from "babylonjs/scene";
  39609. import { Vector3 } from "babylonjs/Maths/math";
  39610. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39611. /**
  39612. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  39613. * @see http://doc.babylonjs.com/features/cameras
  39614. */
  39615. export class StereoscopicUniversalCamera extends UniversalCamera {
  39616. /**
  39617. * Creates a new StereoscopicUniversalCamera
  39618. * @param name defines camera name
  39619. * @param position defines initial position
  39620. * @param interaxialDistance defines distance between each color axis
  39621. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39622. * @param scene defines the hosting scene
  39623. */
  39624. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39625. /**
  39626. * Gets camera class name
  39627. * @returns StereoscopicUniversalCamera
  39628. */
  39629. getClassName(): string;
  39630. }
  39631. }
  39632. declare module "babylonjs/Cameras/Stereoscopic/index" {
  39633. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  39634. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  39635. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  39636. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  39637. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  39638. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  39639. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  39640. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  39641. }
  39642. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  39643. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39644. import { Scene } from "babylonjs/scene";
  39645. import { Vector3 } from "babylonjs/Maths/math";
  39646. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  39647. /**
  39648. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  39649. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39650. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39651. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39652. */
  39653. export class VirtualJoysticksCamera extends FreeCamera {
  39654. /**
  39655. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  39656. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39657. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39658. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39659. * @param name Define the name of the camera in the scene
  39660. * @param position Define the start position of the camera in the scene
  39661. * @param scene Define the scene the camera belongs to
  39662. */
  39663. constructor(name: string, position: Vector3, scene: Scene);
  39664. /**
  39665. * Gets the current object class name.
  39666. * @return the class name
  39667. */
  39668. getClassName(): string;
  39669. }
  39670. }
  39671. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  39672. import { Matrix } from "babylonjs/Maths/math";
  39673. /**
  39674. * This represents all the required metrics to create a VR camera.
  39675. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  39676. */
  39677. export class VRCameraMetrics {
  39678. /**
  39679. * Define the horizontal resolution off the screen.
  39680. */
  39681. hResolution: number;
  39682. /**
  39683. * Define the vertical resolution off the screen.
  39684. */
  39685. vResolution: number;
  39686. /**
  39687. * Define the horizontal screen size.
  39688. */
  39689. hScreenSize: number;
  39690. /**
  39691. * Define the vertical screen size.
  39692. */
  39693. vScreenSize: number;
  39694. /**
  39695. * Define the vertical screen center position.
  39696. */
  39697. vScreenCenter: number;
  39698. /**
  39699. * Define the distance of the eyes to the screen.
  39700. */
  39701. eyeToScreenDistance: number;
  39702. /**
  39703. * Define the distance between both lenses
  39704. */
  39705. lensSeparationDistance: number;
  39706. /**
  39707. * Define the distance between both viewer's eyes.
  39708. */
  39709. interpupillaryDistance: number;
  39710. /**
  39711. * Define the distortion factor of the VR postprocess.
  39712. * Please, touch with care.
  39713. */
  39714. distortionK: number[];
  39715. /**
  39716. * Define the chromatic aberration correction factors for the VR post process.
  39717. */
  39718. chromaAbCorrection: number[];
  39719. /**
  39720. * Define the scale factor of the post process.
  39721. * The smaller the better but the slower.
  39722. */
  39723. postProcessScaleFactor: number;
  39724. /**
  39725. * Define an offset for the lens center.
  39726. */
  39727. lensCenterOffset: number;
  39728. /**
  39729. * Define if the current vr camera should compensate the distortion of the lense or not.
  39730. */
  39731. compensateDistortion: boolean;
  39732. /**
  39733. * Defines if multiview should be enabled when rendering (Default: false)
  39734. */
  39735. multiviewEnabled: boolean;
  39736. /**
  39737. * Gets the rendering aspect ratio based on the provided resolutions.
  39738. */
  39739. readonly aspectRatio: number;
  39740. /**
  39741. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  39742. */
  39743. readonly aspectRatioFov: number;
  39744. /**
  39745. * @hidden
  39746. */
  39747. readonly leftHMatrix: Matrix;
  39748. /**
  39749. * @hidden
  39750. */
  39751. readonly rightHMatrix: Matrix;
  39752. /**
  39753. * @hidden
  39754. */
  39755. readonly leftPreViewMatrix: Matrix;
  39756. /**
  39757. * @hidden
  39758. */
  39759. readonly rightPreViewMatrix: Matrix;
  39760. /**
  39761. * Get the default VRMetrics based on the most generic setup.
  39762. * @returns the default vr metrics
  39763. */
  39764. static GetDefault(): VRCameraMetrics;
  39765. }
  39766. }
  39767. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  39768. /** @hidden */
  39769. export var vrDistortionCorrectionPixelShader: {
  39770. name: string;
  39771. shader: string;
  39772. };
  39773. }
  39774. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  39775. import { Camera } from "babylonjs/Cameras/camera";
  39776. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39777. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39778. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  39779. /**
  39780. * VRDistortionCorrectionPostProcess used for mobile VR
  39781. */
  39782. export class VRDistortionCorrectionPostProcess extends PostProcess {
  39783. private _isRightEye;
  39784. private _distortionFactors;
  39785. private _postProcessScaleFactor;
  39786. private _lensCenterOffset;
  39787. private _scaleIn;
  39788. private _scaleFactor;
  39789. private _lensCenter;
  39790. /**
  39791. * Initializes the VRDistortionCorrectionPostProcess
  39792. * @param name The name of the effect.
  39793. * @param camera The camera to apply the render pass to.
  39794. * @param isRightEye If this is for the right eye distortion
  39795. * @param vrMetrics All the required metrics for the VR camera
  39796. */
  39797. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  39798. }
  39799. }
  39800. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  39801. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  39802. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39803. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39804. import { Scene } from "babylonjs/scene";
  39805. import { Vector3 } from "babylonjs/Maths/math";
  39806. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  39807. import "babylonjs/Cameras/RigModes/vrRigMode";
  39808. /**
  39809. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  39810. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39811. */
  39812. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  39813. /**
  39814. * Creates a new VRDeviceOrientationArcRotateCamera
  39815. * @param name defines camera name
  39816. * @param alpha defines the camera rotation along the logitudinal axis
  39817. * @param beta defines the camera rotation along the latitudinal axis
  39818. * @param radius defines the camera distance from its target
  39819. * @param target defines the camera target
  39820. * @param scene defines the scene the camera belongs to
  39821. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39822. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39823. */
  39824. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39825. /**
  39826. * Gets camera class name
  39827. * @returns VRDeviceOrientationArcRotateCamera
  39828. */
  39829. getClassName(): string;
  39830. }
  39831. }
  39832. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  39833. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  39834. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39835. import { Scene } from "babylonjs/scene";
  39836. import { Vector3 } from "babylonjs/Maths/math";
  39837. import "babylonjs/Cameras/RigModes/vrRigMode";
  39838. /**
  39839. * Camera used to simulate VR rendering (based on FreeCamera)
  39840. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39841. */
  39842. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  39843. /**
  39844. * Creates a new VRDeviceOrientationFreeCamera
  39845. * @param name defines camera name
  39846. * @param position defines the start position of the camera
  39847. * @param scene defines the scene the camera belongs to
  39848. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39849. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39850. */
  39851. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39852. /**
  39853. * Gets camera class name
  39854. * @returns VRDeviceOrientationFreeCamera
  39855. */
  39856. getClassName(): string;
  39857. }
  39858. }
  39859. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  39860. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  39861. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39862. import { Scene } from "babylonjs/scene";
  39863. import { Vector3 } from "babylonjs/Maths/math";
  39864. import "babylonjs/Gamepads/gamepadSceneComponent";
  39865. /**
  39866. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  39867. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39868. */
  39869. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  39870. /**
  39871. * Creates a new VRDeviceOrientationGamepadCamera
  39872. * @param name defines camera name
  39873. * @param position defines the start position of the camera
  39874. * @param scene defines the scene the camera belongs to
  39875. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39876. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39877. */
  39878. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39879. /**
  39880. * Gets camera class name
  39881. * @returns VRDeviceOrientationGamepadCamera
  39882. */
  39883. getClassName(): string;
  39884. }
  39885. }
  39886. declare module "babylonjs/Materials/pushMaterial" {
  39887. import { Nullable } from "babylonjs/types";
  39888. import { Scene } from "babylonjs/scene";
  39889. import { Matrix } from "babylonjs/Maths/math";
  39890. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39891. import { Mesh } from "babylonjs/Meshes/mesh";
  39892. import { Material } from "babylonjs/Materials/material";
  39893. import { Effect } from "babylonjs/Materials/effect";
  39894. /**
  39895. * Base class of materials working in push mode in babylon JS
  39896. * @hidden
  39897. */
  39898. export class PushMaterial extends Material {
  39899. protected _activeEffect: Effect;
  39900. protected _normalMatrix: Matrix;
  39901. /**
  39902. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  39903. * This means that the material can keep using a previous shader while a new one is being compiled.
  39904. * This is mostly used when shader parallel compilation is supported (true by default)
  39905. */
  39906. allowShaderHotSwapping: boolean;
  39907. constructor(name: string, scene: Scene);
  39908. getEffect(): Effect;
  39909. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  39910. /**
  39911. * Binds the given world matrix to the active effect
  39912. *
  39913. * @param world the matrix to bind
  39914. */
  39915. bindOnlyWorldMatrix(world: Matrix): void;
  39916. /**
  39917. * Binds the given normal matrix to the active effect
  39918. *
  39919. * @param normalMatrix the matrix to bind
  39920. */
  39921. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  39922. bind(world: Matrix, mesh?: Mesh): void;
  39923. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  39924. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  39925. }
  39926. }
  39927. declare module "babylonjs/Materials/materialFlags" {
  39928. /**
  39929. * This groups all the flags used to control the materials channel.
  39930. */
  39931. export class MaterialFlags {
  39932. private static _DiffuseTextureEnabled;
  39933. /**
  39934. * Are diffuse textures enabled in the application.
  39935. */
  39936. static DiffuseTextureEnabled: boolean;
  39937. private static _AmbientTextureEnabled;
  39938. /**
  39939. * Are ambient textures enabled in the application.
  39940. */
  39941. static AmbientTextureEnabled: boolean;
  39942. private static _OpacityTextureEnabled;
  39943. /**
  39944. * Are opacity textures enabled in the application.
  39945. */
  39946. static OpacityTextureEnabled: boolean;
  39947. private static _ReflectionTextureEnabled;
  39948. /**
  39949. * Are reflection textures enabled in the application.
  39950. */
  39951. static ReflectionTextureEnabled: boolean;
  39952. private static _EmissiveTextureEnabled;
  39953. /**
  39954. * Are emissive textures enabled in the application.
  39955. */
  39956. static EmissiveTextureEnabled: boolean;
  39957. private static _SpecularTextureEnabled;
  39958. /**
  39959. * Are specular textures enabled in the application.
  39960. */
  39961. static SpecularTextureEnabled: boolean;
  39962. private static _BumpTextureEnabled;
  39963. /**
  39964. * Are bump textures enabled in the application.
  39965. */
  39966. static BumpTextureEnabled: boolean;
  39967. private static _LightmapTextureEnabled;
  39968. /**
  39969. * Are lightmap textures enabled in the application.
  39970. */
  39971. static LightmapTextureEnabled: boolean;
  39972. private static _RefractionTextureEnabled;
  39973. /**
  39974. * Are refraction textures enabled in the application.
  39975. */
  39976. static RefractionTextureEnabled: boolean;
  39977. private static _ColorGradingTextureEnabled;
  39978. /**
  39979. * Are color grading textures enabled in the application.
  39980. */
  39981. static ColorGradingTextureEnabled: boolean;
  39982. private static _FresnelEnabled;
  39983. /**
  39984. * Are fresnels enabled in the application.
  39985. */
  39986. static FresnelEnabled: boolean;
  39987. private static _ClearCoatTextureEnabled;
  39988. /**
  39989. * Are clear coat textures enabled in the application.
  39990. */
  39991. static ClearCoatTextureEnabled: boolean;
  39992. private static _ClearCoatBumpTextureEnabled;
  39993. /**
  39994. * Are clear coat bump textures enabled in the application.
  39995. */
  39996. static ClearCoatBumpTextureEnabled: boolean;
  39997. private static _ClearCoatTintTextureEnabled;
  39998. /**
  39999. * Are clear coat tint textures enabled in the application.
  40000. */
  40001. static ClearCoatTintTextureEnabled: boolean;
  40002. private static _SheenTextureEnabled;
  40003. /**
  40004. * Are sheen textures enabled in the application.
  40005. */
  40006. static SheenTextureEnabled: boolean;
  40007. private static _AnisotropicTextureEnabled;
  40008. /**
  40009. * Are anisotropic textures enabled in the application.
  40010. */
  40011. static AnisotropicTextureEnabled: boolean;
  40012. private static _ThicknessTextureEnabled;
  40013. /**
  40014. * Are thickness textures enabled in the application.
  40015. */
  40016. static ThicknessTextureEnabled: boolean;
  40017. }
  40018. }
  40019. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  40020. /** @hidden */
  40021. export var defaultFragmentDeclaration: {
  40022. name: string;
  40023. shader: string;
  40024. };
  40025. }
  40026. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  40027. /** @hidden */
  40028. export var defaultUboDeclaration: {
  40029. name: string;
  40030. shader: string;
  40031. };
  40032. }
  40033. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  40034. /** @hidden */
  40035. export var lightFragmentDeclaration: {
  40036. name: string;
  40037. shader: string;
  40038. };
  40039. }
  40040. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  40041. /** @hidden */
  40042. export var lightUboDeclaration: {
  40043. name: string;
  40044. shader: string;
  40045. };
  40046. }
  40047. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  40048. /** @hidden */
  40049. export var lightsFragmentFunctions: {
  40050. name: string;
  40051. shader: string;
  40052. };
  40053. }
  40054. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  40055. /** @hidden */
  40056. export var shadowsFragmentFunctions: {
  40057. name: string;
  40058. shader: string;
  40059. };
  40060. }
  40061. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  40062. /** @hidden */
  40063. export var fresnelFunction: {
  40064. name: string;
  40065. shader: string;
  40066. };
  40067. }
  40068. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  40069. /** @hidden */
  40070. export var reflectionFunction: {
  40071. name: string;
  40072. shader: string;
  40073. };
  40074. }
  40075. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  40076. /** @hidden */
  40077. export var bumpFragmentFunctions: {
  40078. name: string;
  40079. shader: string;
  40080. };
  40081. }
  40082. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  40083. /** @hidden */
  40084. export var logDepthDeclaration: {
  40085. name: string;
  40086. shader: string;
  40087. };
  40088. }
  40089. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  40090. /** @hidden */
  40091. export var bumpFragment: {
  40092. name: string;
  40093. shader: string;
  40094. };
  40095. }
  40096. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  40097. /** @hidden */
  40098. export var depthPrePass: {
  40099. name: string;
  40100. shader: string;
  40101. };
  40102. }
  40103. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  40104. /** @hidden */
  40105. export var lightFragment: {
  40106. name: string;
  40107. shader: string;
  40108. };
  40109. }
  40110. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  40111. /** @hidden */
  40112. export var logDepthFragment: {
  40113. name: string;
  40114. shader: string;
  40115. };
  40116. }
  40117. declare module "babylonjs/Shaders/default.fragment" {
  40118. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  40119. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  40120. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40121. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  40122. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  40123. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  40124. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  40125. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  40126. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  40127. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  40128. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  40129. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  40130. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  40131. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  40132. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  40133. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  40134. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  40135. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  40136. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  40137. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  40138. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  40139. /** @hidden */
  40140. export var defaultPixelShader: {
  40141. name: string;
  40142. shader: string;
  40143. };
  40144. }
  40145. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  40146. /** @hidden */
  40147. export var defaultVertexDeclaration: {
  40148. name: string;
  40149. shader: string;
  40150. };
  40151. }
  40152. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  40153. /** @hidden */
  40154. export var bumpVertexDeclaration: {
  40155. name: string;
  40156. shader: string;
  40157. };
  40158. }
  40159. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  40160. /** @hidden */
  40161. export var bumpVertex: {
  40162. name: string;
  40163. shader: string;
  40164. };
  40165. }
  40166. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  40167. /** @hidden */
  40168. export var fogVertex: {
  40169. name: string;
  40170. shader: string;
  40171. };
  40172. }
  40173. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  40174. /** @hidden */
  40175. export var shadowsVertex: {
  40176. name: string;
  40177. shader: string;
  40178. };
  40179. }
  40180. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  40181. /** @hidden */
  40182. export var pointCloudVertex: {
  40183. name: string;
  40184. shader: string;
  40185. };
  40186. }
  40187. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  40188. /** @hidden */
  40189. export var logDepthVertex: {
  40190. name: string;
  40191. shader: string;
  40192. };
  40193. }
  40194. declare module "babylonjs/Shaders/default.vertex" {
  40195. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  40196. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  40197. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40198. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  40199. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  40200. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  40201. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  40202. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  40203. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  40204. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  40205. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  40206. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  40207. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  40208. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  40209. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  40210. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  40211. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  40212. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  40213. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  40214. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  40215. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  40216. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  40217. /** @hidden */
  40218. export var defaultVertexShader: {
  40219. name: string;
  40220. shader: string;
  40221. };
  40222. }
  40223. declare module "babylonjs/Materials/standardMaterial" {
  40224. import { SmartArray } from "babylonjs/Misc/smartArray";
  40225. import { IAnimatable } from "babylonjs/Misc/tools";
  40226. import { Nullable } from "babylonjs/types";
  40227. import { Scene } from "babylonjs/scene";
  40228. import { Matrix, Color3 } from "babylonjs/Maths/math";
  40229. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40230. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40231. import { Mesh } from "babylonjs/Meshes/mesh";
  40232. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  40233. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  40234. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  40235. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  40236. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  40237. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40238. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  40239. import "babylonjs/Shaders/default.fragment";
  40240. import "babylonjs/Shaders/default.vertex";
  40241. /** @hidden */
  40242. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  40243. MAINUV1: boolean;
  40244. MAINUV2: boolean;
  40245. DIFFUSE: boolean;
  40246. DIFFUSEDIRECTUV: number;
  40247. AMBIENT: boolean;
  40248. AMBIENTDIRECTUV: number;
  40249. OPACITY: boolean;
  40250. OPACITYDIRECTUV: number;
  40251. OPACITYRGB: boolean;
  40252. REFLECTION: boolean;
  40253. EMISSIVE: boolean;
  40254. EMISSIVEDIRECTUV: number;
  40255. SPECULAR: boolean;
  40256. SPECULARDIRECTUV: number;
  40257. BUMP: boolean;
  40258. BUMPDIRECTUV: number;
  40259. PARALLAX: boolean;
  40260. PARALLAXOCCLUSION: boolean;
  40261. SPECULAROVERALPHA: boolean;
  40262. CLIPPLANE: boolean;
  40263. CLIPPLANE2: boolean;
  40264. CLIPPLANE3: boolean;
  40265. CLIPPLANE4: boolean;
  40266. ALPHATEST: boolean;
  40267. DEPTHPREPASS: boolean;
  40268. ALPHAFROMDIFFUSE: boolean;
  40269. POINTSIZE: boolean;
  40270. FOG: boolean;
  40271. SPECULARTERM: boolean;
  40272. DIFFUSEFRESNEL: boolean;
  40273. OPACITYFRESNEL: boolean;
  40274. REFLECTIONFRESNEL: boolean;
  40275. REFRACTIONFRESNEL: boolean;
  40276. EMISSIVEFRESNEL: boolean;
  40277. FRESNEL: boolean;
  40278. NORMAL: boolean;
  40279. UV1: boolean;
  40280. UV2: boolean;
  40281. VERTEXCOLOR: boolean;
  40282. VERTEXALPHA: boolean;
  40283. NUM_BONE_INFLUENCERS: number;
  40284. BonesPerMesh: number;
  40285. BONETEXTURE: boolean;
  40286. INSTANCES: boolean;
  40287. GLOSSINESS: boolean;
  40288. ROUGHNESS: boolean;
  40289. EMISSIVEASILLUMINATION: boolean;
  40290. LINKEMISSIVEWITHDIFFUSE: boolean;
  40291. REFLECTIONFRESNELFROMSPECULAR: boolean;
  40292. LIGHTMAP: boolean;
  40293. LIGHTMAPDIRECTUV: number;
  40294. OBJECTSPACE_NORMALMAP: boolean;
  40295. USELIGHTMAPASSHADOWMAP: boolean;
  40296. REFLECTIONMAP_3D: boolean;
  40297. REFLECTIONMAP_SPHERICAL: boolean;
  40298. REFLECTIONMAP_PLANAR: boolean;
  40299. REFLECTIONMAP_CUBIC: boolean;
  40300. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  40301. REFLECTIONMAP_PROJECTION: boolean;
  40302. REFLECTIONMAP_SKYBOX: boolean;
  40303. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  40304. REFLECTIONMAP_EXPLICIT: boolean;
  40305. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  40306. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  40307. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  40308. INVERTCUBICMAP: boolean;
  40309. LOGARITHMICDEPTH: boolean;
  40310. REFRACTION: boolean;
  40311. REFRACTIONMAP_3D: boolean;
  40312. REFLECTIONOVERALPHA: boolean;
  40313. TWOSIDEDLIGHTING: boolean;
  40314. SHADOWFLOAT: boolean;
  40315. MORPHTARGETS: boolean;
  40316. MORPHTARGETS_NORMAL: boolean;
  40317. MORPHTARGETS_TANGENT: boolean;
  40318. NUM_MORPH_INFLUENCERS: number;
  40319. NONUNIFORMSCALING: boolean;
  40320. PREMULTIPLYALPHA: boolean;
  40321. IMAGEPROCESSING: boolean;
  40322. VIGNETTE: boolean;
  40323. VIGNETTEBLENDMODEMULTIPLY: boolean;
  40324. VIGNETTEBLENDMODEOPAQUE: boolean;
  40325. TONEMAPPING: boolean;
  40326. TONEMAPPING_ACES: boolean;
  40327. CONTRAST: boolean;
  40328. COLORCURVES: boolean;
  40329. COLORGRADING: boolean;
  40330. COLORGRADING3D: boolean;
  40331. SAMPLER3DGREENDEPTH: boolean;
  40332. SAMPLER3DBGRMAP: boolean;
  40333. IMAGEPROCESSINGPOSTPROCESS: boolean;
  40334. MULTIVIEW: boolean;
  40335. /**
  40336. * If the reflection texture on this material is in linear color space
  40337. * @hidden
  40338. */
  40339. IS_REFLECTION_LINEAR: boolean;
  40340. /**
  40341. * If the refraction texture on this material is in linear color space
  40342. * @hidden
  40343. */
  40344. IS_REFRACTION_LINEAR: boolean;
  40345. EXPOSURE: boolean;
  40346. constructor();
  40347. setReflectionMode(modeToEnable: string): void;
  40348. }
  40349. /**
  40350. * This is the default material used in Babylon. It is the best trade off between quality
  40351. * and performances.
  40352. * @see http://doc.babylonjs.com/babylon101/materials
  40353. */
  40354. export class StandardMaterial extends PushMaterial {
  40355. private _diffuseTexture;
  40356. /**
  40357. * The basic texture of the material as viewed under a light.
  40358. */
  40359. diffuseTexture: Nullable<BaseTexture>;
  40360. private _ambientTexture;
  40361. /**
  40362. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  40363. */
  40364. ambientTexture: Nullable<BaseTexture>;
  40365. private _opacityTexture;
  40366. /**
  40367. * Define the transparency of the material from a texture.
  40368. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  40369. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  40370. */
  40371. opacityTexture: Nullable<BaseTexture>;
  40372. private _reflectionTexture;
  40373. /**
  40374. * Define the texture used to display the reflection.
  40375. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40376. */
  40377. reflectionTexture: Nullable<BaseTexture>;
  40378. private _emissiveTexture;
  40379. /**
  40380. * Define texture of the material as if self lit.
  40381. * This will be mixed in the final result even in the absence of light.
  40382. */
  40383. emissiveTexture: Nullable<BaseTexture>;
  40384. private _specularTexture;
  40385. /**
  40386. * Define how the color and intensity of the highlight given by the light in the material.
  40387. */
  40388. specularTexture: Nullable<BaseTexture>;
  40389. private _bumpTexture;
  40390. /**
  40391. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  40392. * 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.
  40393. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  40394. */
  40395. bumpTexture: Nullable<BaseTexture>;
  40396. private _lightmapTexture;
  40397. /**
  40398. * Complex lighting can be computationally expensive to compute at runtime.
  40399. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  40400. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  40401. */
  40402. lightmapTexture: Nullable<BaseTexture>;
  40403. private _refractionTexture;
  40404. /**
  40405. * Define the texture used to display the refraction.
  40406. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40407. */
  40408. refractionTexture: Nullable<BaseTexture>;
  40409. /**
  40410. * The color of the material lit by the environmental background lighting.
  40411. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  40412. */
  40413. ambientColor: Color3;
  40414. /**
  40415. * The basic color of the material as viewed under a light.
  40416. */
  40417. diffuseColor: Color3;
  40418. /**
  40419. * Define how the color and intensity of the highlight given by the light in the material.
  40420. */
  40421. specularColor: Color3;
  40422. /**
  40423. * Define the color of the material as if self lit.
  40424. * This will be mixed in the final result even in the absence of light.
  40425. */
  40426. emissiveColor: Color3;
  40427. /**
  40428. * Defines how sharp are the highlights in the material.
  40429. * The bigger the value the sharper giving a more glossy feeling to the result.
  40430. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  40431. */
  40432. specularPower: number;
  40433. private _useAlphaFromDiffuseTexture;
  40434. /**
  40435. * Does the transparency come from the diffuse texture alpha channel.
  40436. */
  40437. useAlphaFromDiffuseTexture: boolean;
  40438. private _useEmissiveAsIllumination;
  40439. /**
  40440. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  40441. */
  40442. useEmissiveAsIllumination: boolean;
  40443. private _linkEmissiveWithDiffuse;
  40444. /**
  40445. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  40446. * the emissive level when the final color is close to one.
  40447. */
  40448. linkEmissiveWithDiffuse: boolean;
  40449. private _useSpecularOverAlpha;
  40450. /**
  40451. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  40452. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  40453. */
  40454. useSpecularOverAlpha: boolean;
  40455. private _useReflectionOverAlpha;
  40456. /**
  40457. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  40458. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  40459. */
  40460. useReflectionOverAlpha: boolean;
  40461. private _disableLighting;
  40462. /**
  40463. * Does lights from the scene impacts this material.
  40464. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  40465. */
  40466. disableLighting: boolean;
  40467. private _useObjectSpaceNormalMap;
  40468. /**
  40469. * Allows using an object space normal map (instead of tangent space).
  40470. */
  40471. useObjectSpaceNormalMap: boolean;
  40472. private _useParallax;
  40473. /**
  40474. * Is parallax enabled or not.
  40475. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40476. */
  40477. useParallax: boolean;
  40478. private _useParallaxOcclusion;
  40479. /**
  40480. * Is parallax occlusion enabled or not.
  40481. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  40482. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40483. */
  40484. useParallaxOcclusion: boolean;
  40485. /**
  40486. * 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.
  40487. */
  40488. parallaxScaleBias: number;
  40489. private _roughness;
  40490. /**
  40491. * Helps to define how blurry the reflections should appears in the material.
  40492. */
  40493. roughness: number;
  40494. /**
  40495. * In case of refraction, define the value of the index of refraction.
  40496. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40497. */
  40498. indexOfRefraction: number;
  40499. /**
  40500. * Invert the refraction texture alongside the y axis.
  40501. * It can be useful with procedural textures or probe for instance.
  40502. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40503. */
  40504. invertRefractionY: boolean;
  40505. /**
  40506. * Defines the alpha limits in alpha test mode.
  40507. */
  40508. alphaCutOff: number;
  40509. private _useLightmapAsShadowmap;
  40510. /**
  40511. * In case of light mapping, define whether the map contains light or shadow informations.
  40512. */
  40513. useLightmapAsShadowmap: boolean;
  40514. private _diffuseFresnelParameters;
  40515. /**
  40516. * Define the diffuse fresnel parameters of the material.
  40517. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40518. */
  40519. diffuseFresnelParameters: FresnelParameters;
  40520. private _opacityFresnelParameters;
  40521. /**
  40522. * Define the opacity fresnel parameters of the material.
  40523. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40524. */
  40525. opacityFresnelParameters: FresnelParameters;
  40526. private _reflectionFresnelParameters;
  40527. /**
  40528. * Define the reflection fresnel parameters of the material.
  40529. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40530. */
  40531. reflectionFresnelParameters: FresnelParameters;
  40532. private _refractionFresnelParameters;
  40533. /**
  40534. * Define the refraction fresnel parameters of the material.
  40535. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40536. */
  40537. refractionFresnelParameters: FresnelParameters;
  40538. private _emissiveFresnelParameters;
  40539. /**
  40540. * Define the emissive fresnel parameters of the material.
  40541. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40542. */
  40543. emissiveFresnelParameters: FresnelParameters;
  40544. private _useReflectionFresnelFromSpecular;
  40545. /**
  40546. * If true automatically deducts the fresnels values from the material specularity.
  40547. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40548. */
  40549. useReflectionFresnelFromSpecular: boolean;
  40550. private _useGlossinessFromSpecularMapAlpha;
  40551. /**
  40552. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  40553. */
  40554. useGlossinessFromSpecularMapAlpha: boolean;
  40555. private _maxSimultaneousLights;
  40556. /**
  40557. * Defines the maximum number of lights that can be used in the material
  40558. */
  40559. maxSimultaneousLights: number;
  40560. private _invertNormalMapX;
  40561. /**
  40562. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  40563. */
  40564. invertNormalMapX: boolean;
  40565. private _invertNormalMapY;
  40566. /**
  40567. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  40568. */
  40569. invertNormalMapY: boolean;
  40570. private _twoSidedLighting;
  40571. /**
  40572. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  40573. */
  40574. twoSidedLighting: boolean;
  40575. /**
  40576. * Default configuration related to image processing available in the standard Material.
  40577. */
  40578. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40579. /**
  40580. * Gets the image processing configuration used either in this material.
  40581. */
  40582. /**
  40583. * Sets the Default image processing configuration used either in the this material.
  40584. *
  40585. * If sets to null, the scene one is in use.
  40586. */
  40587. imageProcessingConfiguration: ImageProcessingConfiguration;
  40588. /**
  40589. * Keep track of the image processing observer to allow dispose and replace.
  40590. */
  40591. private _imageProcessingObserver;
  40592. /**
  40593. * Attaches a new image processing configuration to the Standard Material.
  40594. * @param configuration
  40595. */
  40596. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  40597. /**
  40598. * Gets wether the color curves effect is enabled.
  40599. */
  40600. /**
  40601. * Sets wether the color curves effect is enabled.
  40602. */
  40603. cameraColorCurvesEnabled: boolean;
  40604. /**
  40605. * Gets wether the color grading effect is enabled.
  40606. */
  40607. /**
  40608. * Gets wether the color grading effect is enabled.
  40609. */
  40610. cameraColorGradingEnabled: boolean;
  40611. /**
  40612. * Gets wether tonemapping is enabled or not.
  40613. */
  40614. /**
  40615. * Sets wether tonemapping is enabled or not
  40616. */
  40617. cameraToneMappingEnabled: boolean;
  40618. /**
  40619. * The camera exposure used on this material.
  40620. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40621. * This corresponds to a photographic exposure.
  40622. */
  40623. /**
  40624. * The camera exposure used on this material.
  40625. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40626. * This corresponds to a photographic exposure.
  40627. */
  40628. cameraExposure: number;
  40629. /**
  40630. * Gets The camera contrast used on this material.
  40631. */
  40632. /**
  40633. * Sets The camera contrast used on this material.
  40634. */
  40635. cameraContrast: number;
  40636. /**
  40637. * Gets the Color Grading 2D Lookup Texture.
  40638. */
  40639. /**
  40640. * Sets the Color Grading 2D Lookup Texture.
  40641. */
  40642. cameraColorGradingTexture: Nullable<BaseTexture>;
  40643. /**
  40644. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40645. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40646. * 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;
  40647. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40648. */
  40649. /**
  40650. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40651. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40652. * 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;
  40653. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40654. */
  40655. cameraColorCurves: Nullable<ColorCurves>;
  40656. /**
  40657. * Custom callback helping to override the default shader used in the material.
  40658. */
  40659. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  40660. protected _renderTargets: SmartArray<RenderTargetTexture>;
  40661. protected _worldViewProjectionMatrix: Matrix;
  40662. protected _globalAmbientColor: Color3;
  40663. protected _useLogarithmicDepth: boolean;
  40664. /**
  40665. * Instantiates a new standard material.
  40666. * This is the default material used in Babylon. It is the best trade off between quality
  40667. * and performances.
  40668. * @see http://doc.babylonjs.com/babylon101/materials
  40669. * @param name Define the name of the material in the scene
  40670. * @param scene Define the scene the material belong to
  40671. */
  40672. constructor(name: string, scene: Scene);
  40673. /**
  40674. * Gets a boolean indicating that current material needs to register RTT
  40675. */
  40676. readonly hasRenderTargetTextures: boolean;
  40677. /**
  40678. * Gets the current class name of the material e.g. "StandardMaterial"
  40679. * Mainly use in serialization.
  40680. * @returns the class name
  40681. */
  40682. getClassName(): string;
  40683. /**
  40684. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  40685. * You can try switching to logarithmic depth.
  40686. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  40687. */
  40688. useLogarithmicDepth: boolean;
  40689. /**
  40690. * Specifies if the material will require alpha blending
  40691. * @returns a boolean specifying if alpha blending is needed
  40692. */
  40693. needAlphaBlending(): boolean;
  40694. /**
  40695. * Specifies if this material should be rendered in alpha test mode
  40696. * @returns a boolean specifying if an alpha test is needed.
  40697. */
  40698. needAlphaTesting(): boolean;
  40699. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  40700. /**
  40701. * Get the texture used for alpha test purpose.
  40702. * @returns the diffuse texture in case of the standard material.
  40703. */
  40704. getAlphaTestTexture(): Nullable<BaseTexture>;
  40705. /**
  40706. * Get if the submesh is ready to be used and all its information available.
  40707. * Child classes can use it to update shaders
  40708. * @param mesh defines the mesh to check
  40709. * @param subMesh defines which submesh to check
  40710. * @param useInstances specifies that instances should be used
  40711. * @returns a boolean indicating that the submesh is ready or not
  40712. */
  40713. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  40714. /**
  40715. * Builds the material UBO layouts.
  40716. * Used internally during the effect preparation.
  40717. */
  40718. buildUniformLayout(): void;
  40719. /**
  40720. * Unbinds the material from the mesh
  40721. */
  40722. unbind(): void;
  40723. /**
  40724. * Binds the submesh to this material by preparing the effect and shader to draw
  40725. * @param world defines the world transformation matrix
  40726. * @param mesh defines the mesh containing the submesh
  40727. * @param subMesh defines the submesh to bind the material to
  40728. */
  40729. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  40730. /**
  40731. * Get the list of animatables in the material.
  40732. * @returns the list of animatables object used in the material
  40733. */
  40734. getAnimatables(): IAnimatable[];
  40735. /**
  40736. * Gets the active textures from the material
  40737. * @returns an array of textures
  40738. */
  40739. getActiveTextures(): BaseTexture[];
  40740. /**
  40741. * Specifies if the material uses a texture
  40742. * @param texture defines the texture to check against the material
  40743. * @returns a boolean specifying if the material uses the texture
  40744. */
  40745. hasTexture(texture: BaseTexture): boolean;
  40746. /**
  40747. * Disposes the material
  40748. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  40749. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  40750. */
  40751. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  40752. /**
  40753. * Makes a duplicate of the material, and gives it a new name
  40754. * @param name defines the new name for the duplicated material
  40755. * @returns the cloned material
  40756. */
  40757. clone(name: string): StandardMaterial;
  40758. /**
  40759. * Serializes this material in a JSON representation
  40760. * @returns the serialized material object
  40761. */
  40762. serialize(): any;
  40763. /**
  40764. * Creates a standard material from parsed material data
  40765. * @param source defines the JSON representation of the material
  40766. * @param scene defines the hosting scene
  40767. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  40768. * @returns a new standard material
  40769. */
  40770. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  40771. /**
  40772. * Are diffuse textures enabled in the application.
  40773. */
  40774. static DiffuseTextureEnabled: boolean;
  40775. /**
  40776. * Are ambient textures enabled in the application.
  40777. */
  40778. static AmbientTextureEnabled: boolean;
  40779. /**
  40780. * Are opacity textures enabled in the application.
  40781. */
  40782. static OpacityTextureEnabled: boolean;
  40783. /**
  40784. * Are reflection textures enabled in the application.
  40785. */
  40786. static ReflectionTextureEnabled: boolean;
  40787. /**
  40788. * Are emissive textures enabled in the application.
  40789. */
  40790. static EmissiveTextureEnabled: boolean;
  40791. /**
  40792. * Are specular textures enabled in the application.
  40793. */
  40794. static SpecularTextureEnabled: boolean;
  40795. /**
  40796. * Are bump textures enabled in the application.
  40797. */
  40798. static BumpTextureEnabled: boolean;
  40799. /**
  40800. * Are lightmap textures enabled in the application.
  40801. */
  40802. static LightmapTextureEnabled: boolean;
  40803. /**
  40804. * Are refraction textures enabled in the application.
  40805. */
  40806. static RefractionTextureEnabled: boolean;
  40807. /**
  40808. * Are color grading textures enabled in the application.
  40809. */
  40810. static ColorGradingTextureEnabled: boolean;
  40811. /**
  40812. * Are fresnels enabled in the application.
  40813. */
  40814. static FresnelEnabled: boolean;
  40815. }
  40816. }
  40817. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  40818. import { Scene } from "babylonjs/scene";
  40819. import { Texture } from "babylonjs/Materials/Textures/texture";
  40820. /**
  40821. * A class extending Texture allowing drawing on a texture
  40822. * @see http://doc.babylonjs.com/how_to/dynamictexture
  40823. */
  40824. export class DynamicTexture extends Texture {
  40825. private _generateMipMaps;
  40826. private _canvas;
  40827. private _context;
  40828. private _engine;
  40829. /**
  40830. * Creates a DynamicTexture
  40831. * @param name defines the name of the texture
  40832. * @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
  40833. * @param scene defines the scene where you want the texture
  40834. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  40835. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  40836. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  40837. */
  40838. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  40839. /**
  40840. * Get the current class name of the texture useful for serialization or dynamic coding.
  40841. * @returns "DynamicTexture"
  40842. */
  40843. getClassName(): string;
  40844. /**
  40845. * Gets the current state of canRescale
  40846. */
  40847. readonly canRescale: boolean;
  40848. private _recreate;
  40849. /**
  40850. * Scales the texture
  40851. * @param ratio the scale factor to apply to both width and height
  40852. */
  40853. scale(ratio: number): void;
  40854. /**
  40855. * Resizes the texture
  40856. * @param width the new width
  40857. * @param height the new height
  40858. */
  40859. scaleTo(width: number, height: number): void;
  40860. /**
  40861. * Gets the context of the canvas used by the texture
  40862. * @returns the canvas context of the dynamic texture
  40863. */
  40864. getContext(): CanvasRenderingContext2D;
  40865. /**
  40866. * Clears the texture
  40867. */
  40868. clear(): void;
  40869. /**
  40870. * Updates the texture
  40871. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40872. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  40873. */
  40874. update(invertY?: boolean, premulAlpha?: boolean): void;
  40875. /**
  40876. * Draws text onto the texture
  40877. * @param text defines the text to be drawn
  40878. * @param x defines the placement of the text from the left
  40879. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  40880. * @param font defines the font to be used with font-style, font-size, font-name
  40881. * @param color defines the color used for the text
  40882. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  40883. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40884. * @param update defines whether texture is immediately update (default is true)
  40885. */
  40886. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  40887. /**
  40888. * Clones the texture
  40889. * @returns the clone of the texture.
  40890. */
  40891. clone(): DynamicTexture;
  40892. /**
  40893. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  40894. * @returns a serialized dynamic texture object
  40895. */
  40896. serialize(): any;
  40897. /** @hidden */
  40898. _rebuild(): void;
  40899. }
  40900. }
  40901. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  40902. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  40903. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40904. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  40905. /** @hidden */
  40906. export var imageProcessingPixelShader: {
  40907. name: string;
  40908. shader: string;
  40909. };
  40910. }
  40911. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  40912. import { Nullable } from "babylonjs/types";
  40913. import { Color4 } from "babylonjs/Maths/math";
  40914. import { Camera } from "babylonjs/Cameras/camera";
  40915. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40916. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  40917. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  40918. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40919. import { Engine } from "babylonjs/Engines/engine";
  40920. import "babylonjs/Shaders/imageProcessing.fragment";
  40921. import "babylonjs/Shaders/postprocess.vertex";
  40922. /**
  40923. * ImageProcessingPostProcess
  40924. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  40925. */
  40926. export class ImageProcessingPostProcess extends PostProcess {
  40927. /**
  40928. * Default configuration related to image processing available in the PBR Material.
  40929. */
  40930. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40931. /**
  40932. * Gets the image processing configuration used either in this material.
  40933. */
  40934. /**
  40935. * Sets the Default image processing configuration used either in the this material.
  40936. *
  40937. * If sets to null, the scene one is in use.
  40938. */
  40939. imageProcessingConfiguration: ImageProcessingConfiguration;
  40940. /**
  40941. * Keep track of the image processing observer to allow dispose and replace.
  40942. */
  40943. private _imageProcessingObserver;
  40944. /**
  40945. * Attaches a new image processing configuration to the PBR Material.
  40946. * @param configuration
  40947. */
  40948. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  40949. /**
  40950. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40951. */
  40952. /**
  40953. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40954. */
  40955. colorCurves: Nullable<ColorCurves>;
  40956. /**
  40957. * Gets wether the color curves effect is enabled.
  40958. */
  40959. /**
  40960. * Sets wether the color curves effect is enabled.
  40961. */
  40962. colorCurvesEnabled: boolean;
  40963. /**
  40964. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40965. */
  40966. /**
  40967. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40968. */
  40969. colorGradingTexture: Nullable<BaseTexture>;
  40970. /**
  40971. * Gets wether the color grading effect is enabled.
  40972. */
  40973. /**
  40974. * Gets wether the color grading effect is enabled.
  40975. */
  40976. colorGradingEnabled: boolean;
  40977. /**
  40978. * Gets exposure used in the effect.
  40979. */
  40980. /**
  40981. * Sets exposure used in the effect.
  40982. */
  40983. exposure: number;
  40984. /**
  40985. * Gets wether tonemapping is enabled or not.
  40986. */
  40987. /**
  40988. * Sets wether tonemapping is enabled or not
  40989. */
  40990. toneMappingEnabled: boolean;
  40991. /**
  40992. * Gets the type of tone mapping effect.
  40993. */
  40994. /**
  40995. * Sets the type of tone mapping effect.
  40996. */
  40997. toneMappingType: number;
  40998. /**
  40999. * Gets contrast used in the effect.
  41000. */
  41001. /**
  41002. * Sets contrast used in the effect.
  41003. */
  41004. contrast: number;
  41005. /**
  41006. * Gets Vignette stretch size.
  41007. */
  41008. /**
  41009. * Sets Vignette stretch size.
  41010. */
  41011. vignetteStretch: number;
  41012. /**
  41013. * Gets Vignette centre X Offset.
  41014. */
  41015. /**
  41016. * Sets Vignette centre X Offset.
  41017. */
  41018. vignetteCentreX: number;
  41019. /**
  41020. * Gets Vignette centre Y Offset.
  41021. */
  41022. /**
  41023. * Sets Vignette centre Y Offset.
  41024. */
  41025. vignetteCentreY: number;
  41026. /**
  41027. * Gets Vignette weight or intensity of the vignette effect.
  41028. */
  41029. /**
  41030. * Sets Vignette weight or intensity of the vignette effect.
  41031. */
  41032. vignetteWeight: number;
  41033. /**
  41034. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41035. * if vignetteEnabled is set to true.
  41036. */
  41037. /**
  41038. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41039. * if vignetteEnabled is set to true.
  41040. */
  41041. vignetteColor: Color4;
  41042. /**
  41043. * Gets Camera field of view used by the Vignette effect.
  41044. */
  41045. /**
  41046. * Sets Camera field of view used by the Vignette effect.
  41047. */
  41048. vignetteCameraFov: number;
  41049. /**
  41050. * Gets the vignette blend mode allowing different kind of effect.
  41051. */
  41052. /**
  41053. * Sets the vignette blend mode allowing different kind of effect.
  41054. */
  41055. vignetteBlendMode: number;
  41056. /**
  41057. * Gets wether the vignette effect is enabled.
  41058. */
  41059. /**
  41060. * Sets wether the vignette effect is enabled.
  41061. */
  41062. vignetteEnabled: boolean;
  41063. private _fromLinearSpace;
  41064. /**
  41065. * Gets wether the input of the processing is in Gamma or Linear Space.
  41066. */
  41067. /**
  41068. * Sets wether the input of the processing is in Gamma or Linear Space.
  41069. */
  41070. fromLinearSpace: boolean;
  41071. /**
  41072. * Defines cache preventing GC.
  41073. */
  41074. private _defines;
  41075. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  41076. /**
  41077. * "ImageProcessingPostProcess"
  41078. * @returns "ImageProcessingPostProcess"
  41079. */
  41080. getClassName(): string;
  41081. protected _updateParameters(): void;
  41082. dispose(camera?: Camera): void;
  41083. }
  41084. }
  41085. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  41086. import { Scene } from "babylonjs/scene";
  41087. import { Color3 } from "babylonjs/Maths/math";
  41088. import { Mesh } from "babylonjs/Meshes/mesh";
  41089. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  41090. import { Nullable } from "babylonjs/types";
  41091. /**
  41092. * Class containing static functions to help procedurally build meshes
  41093. */
  41094. export class GroundBuilder {
  41095. /**
  41096. * Creates a ground mesh
  41097. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  41098. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  41099. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41100. * @param name defines the name of the mesh
  41101. * @param options defines the options used to create the mesh
  41102. * @param scene defines the hosting scene
  41103. * @returns the ground mesh
  41104. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  41105. */
  41106. static CreateGround(name: string, options: {
  41107. width?: number;
  41108. height?: number;
  41109. subdivisions?: number;
  41110. subdivisionsX?: number;
  41111. subdivisionsY?: number;
  41112. updatable?: boolean;
  41113. }, scene: any): Mesh;
  41114. /**
  41115. * Creates a tiled ground mesh
  41116. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  41117. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  41118. * * 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
  41119. * * 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
  41120. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41121. * @param name defines the name of the mesh
  41122. * @param options defines the options used to create the mesh
  41123. * @param scene defines the hosting scene
  41124. * @returns the tiled ground mesh
  41125. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  41126. */
  41127. static CreateTiledGround(name: string, options: {
  41128. xmin: number;
  41129. zmin: number;
  41130. xmax: number;
  41131. zmax: number;
  41132. subdivisions?: {
  41133. w: number;
  41134. h: number;
  41135. };
  41136. precision?: {
  41137. w: number;
  41138. h: number;
  41139. };
  41140. updatable?: boolean;
  41141. }, scene?: Nullable<Scene>): Mesh;
  41142. /**
  41143. * Creates a ground mesh from a height map
  41144. * * The parameter `url` sets the URL of the height map image resource.
  41145. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  41146. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  41147. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  41148. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  41149. * * 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.
  41150. * * 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).
  41151. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  41152. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41153. * @param name defines the name of the mesh
  41154. * @param url defines the url to the height map
  41155. * @param options defines the options used to create the mesh
  41156. * @param scene defines the hosting scene
  41157. * @returns the ground mesh
  41158. * @see https://doc.babylonjs.com/babylon101/height_map
  41159. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  41160. */
  41161. static CreateGroundFromHeightMap(name: string, url: string, options: {
  41162. width?: number;
  41163. height?: number;
  41164. subdivisions?: number;
  41165. minHeight?: number;
  41166. maxHeight?: number;
  41167. colorFilter?: Color3;
  41168. alphaFilter?: number;
  41169. updatable?: boolean;
  41170. onReady?: (mesh: GroundMesh) => void;
  41171. }, scene?: Nullable<Scene>): GroundMesh;
  41172. }
  41173. }
  41174. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  41175. import { Vector4 } from "babylonjs/Maths/math";
  41176. import { Mesh } from "babylonjs/Meshes/mesh";
  41177. /**
  41178. * Class containing static functions to help procedurally build meshes
  41179. */
  41180. export class TorusBuilder {
  41181. /**
  41182. * Creates a torus mesh
  41183. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  41184. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  41185. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  41186. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41187. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41188. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41189. * @param name defines the name of the mesh
  41190. * @param options defines the options used to create the mesh
  41191. * @param scene defines the hosting scene
  41192. * @returns the torus mesh
  41193. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  41194. */
  41195. static CreateTorus(name: string, options: {
  41196. diameter?: number;
  41197. thickness?: number;
  41198. tessellation?: number;
  41199. updatable?: boolean;
  41200. sideOrientation?: number;
  41201. frontUVs?: Vector4;
  41202. backUVs?: Vector4;
  41203. }, scene: any): Mesh;
  41204. }
  41205. }
  41206. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  41207. import { Color4, Vector4 } from "babylonjs/Maths/math";
  41208. import { Mesh } from "babylonjs/Meshes/mesh";
  41209. /**
  41210. * Class containing static functions to help procedurally build meshes
  41211. */
  41212. export class CylinderBuilder {
  41213. /**
  41214. * Creates a cylinder or a cone mesh
  41215. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  41216. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  41217. * * 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.
  41218. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  41219. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  41220. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  41221. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  41222. * * The parameter `cap` sets the way the cylinder is capped. Possible values : BABYLON.Mesh.NO_CAP, BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL (default).
  41223. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  41224. * * 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).
  41225. * * 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
  41226. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  41227. * * 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
  41228. * * 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.
  41229. * * If `enclose` is false, a ring surface is one element.
  41230. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  41231. * * 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
  41232. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41233. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41234. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41235. * @param name defines the name of the mesh
  41236. * @param options defines the options used to create the mesh
  41237. * @param scene defines the hosting scene
  41238. * @returns the cylinder mesh
  41239. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  41240. */
  41241. static CreateCylinder(name: string, options: {
  41242. height?: number;
  41243. diameterTop?: number;
  41244. diameterBottom?: number;
  41245. diameter?: number;
  41246. tessellation?: number;
  41247. subdivisions?: number;
  41248. arc?: number;
  41249. faceColors?: Color4[];
  41250. faceUV?: Vector4[];
  41251. updatable?: boolean;
  41252. hasRings?: boolean;
  41253. enclose?: boolean;
  41254. cap?: number;
  41255. sideOrientation?: number;
  41256. frontUVs?: Vector4;
  41257. backUVs?: Vector4;
  41258. }, scene: any): Mesh;
  41259. }
  41260. }
  41261. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  41262. import { Observable } from "babylonjs/Misc/observable";
  41263. import { Nullable } from "babylonjs/types";
  41264. import { Camera } from "babylonjs/Cameras/camera";
  41265. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  41266. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41267. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  41268. import { Scene } from "babylonjs/scene";
  41269. import { Vector3, Color3 } from "babylonjs/Maths/math";
  41270. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  41271. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41272. import { Mesh } from "babylonjs/Meshes/mesh";
  41273. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  41274. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41275. import "babylonjs/Meshes/Builders/groundBuilder";
  41276. import "babylonjs/Meshes/Builders/torusBuilder";
  41277. import "babylonjs/Meshes/Builders/cylinderBuilder";
  41278. import "babylonjs/Gamepads/gamepadSceneComponent";
  41279. import "babylonjs/Animations/animatable";
  41280. /**
  41281. * Options to modify the vr teleportation behavior.
  41282. */
  41283. export interface VRTeleportationOptions {
  41284. /**
  41285. * The name of the mesh which should be used as the teleportation floor. (default: null)
  41286. */
  41287. floorMeshName?: string;
  41288. /**
  41289. * A list of meshes to be used as the teleportation floor. (default: empty)
  41290. */
  41291. floorMeshes?: Mesh[];
  41292. }
  41293. /**
  41294. * Options to modify the vr experience helper's behavior.
  41295. */
  41296. export interface VRExperienceHelperOptions extends WebVROptions {
  41297. /**
  41298. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  41299. */
  41300. createDeviceOrientationCamera?: boolean;
  41301. /**
  41302. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  41303. */
  41304. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  41305. /**
  41306. * Uses the main button on the controller to toggle the laser casted. (default: true)
  41307. */
  41308. laserToggle?: boolean;
  41309. /**
  41310. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  41311. */
  41312. floorMeshes?: Mesh[];
  41313. /**
  41314. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  41315. */
  41316. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  41317. }
  41318. /**
  41319. * Event containing information after VR has been entered
  41320. */
  41321. export class OnAfterEnteringVRObservableEvent {
  41322. /**
  41323. * If entering vr was successful
  41324. */
  41325. success: boolean;
  41326. }
  41327. /**
  41328. * Helps to quickly add VR support to an existing scene.
  41329. * See http://doc.babylonjs.com/how_to/webvr_helper
  41330. */
  41331. export class VRExperienceHelper {
  41332. /** Options to modify the vr experience helper's behavior. */
  41333. webVROptions: VRExperienceHelperOptions;
  41334. private _scene;
  41335. private _position;
  41336. private _btnVR;
  41337. private _btnVRDisplayed;
  41338. private _webVRsupported;
  41339. private _webVRready;
  41340. private _webVRrequesting;
  41341. private _webVRpresenting;
  41342. private _hasEnteredVR;
  41343. private _fullscreenVRpresenting;
  41344. private _canvas;
  41345. private _webVRCamera;
  41346. private _vrDeviceOrientationCamera;
  41347. private _deviceOrientationCamera;
  41348. private _existingCamera;
  41349. private _onKeyDown;
  41350. private _onVrDisplayPresentChange;
  41351. private _onVRDisplayChanged;
  41352. private _onVRRequestPresentStart;
  41353. private _onVRRequestPresentComplete;
  41354. /**
  41355. * Observable raised right before entering VR.
  41356. */
  41357. onEnteringVRObservable: Observable<VRExperienceHelper>;
  41358. /**
  41359. * Observable raised when entering VR has completed.
  41360. */
  41361. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  41362. /**
  41363. * Observable raised when exiting VR.
  41364. */
  41365. onExitingVRObservable: Observable<VRExperienceHelper>;
  41366. /**
  41367. * Observable raised when controller mesh is loaded.
  41368. */
  41369. onControllerMeshLoadedObservable: Observable<WebVRController>;
  41370. /** Return this.onEnteringVRObservable
  41371. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  41372. */
  41373. readonly onEnteringVR: Observable<VRExperienceHelper>;
  41374. /** Return this.onExitingVRObservable
  41375. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  41376. */
  41377. readonly onExitingVR: Observable<VRExperienceHelper>;
  41378. /** Return this.onControllerMeshLoadedObservable
  41379. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  41380. */
  41381. readonly onControllerMeshLoaded: Observable<WebVRController>;
  41382. private _rayLength;
  41383. private _useCustomVRButton;
  41384. private _teleportationRequested;
  41385. private _teleportActive;
  41386. private _floorMeshName;
  41387. private _floorMeshesCollection;
  41388. private _rotationAllowed;
  41389. private _teleportBackwardsVector;
  41390. private _teleportationTarget;
  41391. private _isDefaultTeleportationTarget;
  41392. private _postProcessMove;
  41393. private _teleportationFillColor;
  41394. private _teleportationBorderColor;
  41395. private _rotationAngle;
  41396. private _haloCenter;
  41397. private _cameraGazer;
  41398. private _padSensibilityUp;
  41399. private _padSensibilityDown;
  41400. private _leftController;
  41401. private _rightController;
  41402. /**
  41403. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  41404. */
  41405. onNewMeshSelected: Observable<AbstractMesh>;
  41406. /**
  41407. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  41408. */
  41409. onNewMeshPicked: Observable<PickingInfo>;
  41410. private _circleEase;
  41411. /**
  41412. * Observable raised before camera teleportation
  41413. */
  41414. onBeforeCameraTeleport: Observable<Vector3>;
  41415. /**
  41416. * Observable raised after camera teleportation
  41417. */
  41418. onAfterCameraTeleport: Observable<Vector3>;
  41419. /**
  41420. * Observable raised when current selected mesh gets unselected
  41421. */
  41422. onSelectedMeshUnselected: Observable<AbstractMesh>;
  41423. private _raySelectionPredicate;
  41424. /**
  41425. * To be optionaly changed by user to define custom ray selection
  41426. */
  41427. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  41428. /**
  41429. * To be optionaly changed by user to define custom selection logic (after ray selection)
  41430. */
  41431. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  41432. /**
  41433. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  41434. */
  41435. teleportationEnabled: boolean;
  41436. private _defaultHeight;
  41437. private _teleportationInitialized;
  41438. private _interactionsEnabled;
  41439. private _interactionsRequested;
  41440. private _displayGaze;
  41441. private _displayLaserPointer;
  41442. /**
  41443. * The mesh used to display where the user is going to teleport.
  41444. */
  41445. /**
  41446. * Sets the mesh to be used to display where the user is going to teleport.
  41447. */
  41448. teleportationTarget: Mesh;
  41449. /**
  41450. * 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
  41451. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  41452. * See http://doc.babylonjs.com/resources/baking_transformations
  41453. */
  41454. gazeTrackerMesh: Mesh;
  41455. /**
  41456. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  41457. */
  41458. updateGazeTrackerScale: boolean;
  41459. /**
  41460. * If the gaze trackers color should be updated when selecting meshes
  41461. */
  41462. updateGazeTrackerColor: boolean;
  41463. /**
  41464. * The gaze tracking mesh corresponding to the left controller
  41465. */
  41466. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  41467. /**
  41468. * The gaze tracking mesh corresponding to the right controller
  41469. */
  41470. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  41471. /**
  41472. * If the ray of the gaze should be displayed.
  41473. */
  41474. /**
  41475. * Sets if the ray of the gaze should be displayed.
  41476. */
  41477. displayGaze: boolean;
  41478. /**
  41479. * If the ray of the LaserPointer should be displayed.
  41480. */
  41481. /**
  41482. * Sets if the ray of the LaserPointer should be displayed.
  41483. */
  41484. displayLaserPointer: boolean;
  41485. /**
  41486. * The deviceOrientationCamera used as the camera when not in VR.
  41487. */
  41488. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  41489. /**
  41490. * Based on the current WebVR support, returns the current VR camera used.
  41491. */
  41492. readonly currentVRCamera: Nullable<Camera>;
  41493. /**
  41494. * The webVRCamera which is used when in VR.
  41495. */
  41496. readonly webVRCamera: WebVRFreeCamera;
  41497. /**
  41498. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  41499. */
  41500. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  41501. private readonly _teleportationRequestInitiated;
  41502. /**
  41503. * Defines wether or not Pointer lock should be requested when switching to
  41504. * full screen.
  41505. */
  41506. requestPointerLockOnFullScreen: boolean;
  41507. /**
  41508. * Instantiates a VRExperienceHelper.
  41509. * Helps to quickly add VR support to an existing scene.
  41510. * @param scene The scene the VRExperienceHelper belongs to.
  41511. * @param webVROptions Options to modify the vr experience helper's behavior.
  41512. */
  41513. constructor(scene: Scene,
  41514. /** Options to modify the vr experience helper's behavior. */
  41515. webVROptions?: VRExperienceHelperOptions);
  41516. private _onDefaultMeshLoaded;
  41517. private _onResize;
  41518. private _onFullscreenChange;
  41519. /**
  41520. * Gets a value indicating if we are currently in VR mode.
  41521. */
  41522. readonly isInVRMode: boolean;
  41523. private onVrDisplayPresentChange;
  41524. private onVRDisplayChanged;
  41525. private moveButtonToBottomRight;
  41526. private displayVRButton;
  41527. private updateButtonVisibility;
  41528. private _cachedAngularSensibility;
  41529. /**
  41530. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  41531. * Otherwise, will use the fullscreen API.
  41532. */
  41533. enterVR(): void;
  41534. /**
  41535. * Attempt to exit VR, or fullscreen.
  41536. */
  41537. exitVR(): void;
  41538. /**
  41539. * The position of the vr experience helper.
  41540. */
  41541. /**
  41542. * Sets the position of the vr experience helper.
  41543. */
  41544. position: Vector3;
  41545. /**
  41546. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  41547. */
  41548. enableInteractions(): void;
  41549. private readonly _noControllerIsActive;
  41550. private beforeRender;
  41551. private _isTeleportationFloor;
  41552. /**
  41553. * Adds a floor mesh to be used for teleportation.
  41554. * @param floorMesh the mesh to be used for teleportation.
  41555. */
  41556. addFloorMesh(floorMesh: Mesh): void;
  41557. /**
  41558. * Removes a floor mesh from being used for teleportation.
  41559. * @param floorMesh the mesh to be removed.
  41560. */
  41561. removeFloorMesh(floorMesh: Mesh): void;
  41562. /**
  41563. * Enables interactions and teleportation using the VR controllers and gaze.
  41564. * @param vrTeleportationOptions options to modify teleportation behavior.
  41565. */
  41566. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  41567. private _onNewGamepadConnected;
  41568. private _tryEnableInteractionOnController;
  41569. private _onNewGamepadDisconnected;
  41570. private _enableInteractionOnController;
  41571. private _checkTeleportWithRay;
  41572. private _checkRotate;
  41573. private _checkTeleportBackwards;
  41574. private _enableTeleportationOnController;
  41575. private _createTeleportationCircles;
  41576. private _displayTeleportationTarget;
  41577. private _hideTeleportationTarget;
  41578. private _rotateCamera;
  41579. private _moveTeleportationSelectorTo;
  41580. private _workingVector;
  41581. private _workingQuaternion;
  41582. private _workingMatrix;
  41583. /**
  41584. * Teleports the users feet to the desired location
  41585. * @param location The location where the user's feet should be placed
  41586. */
  41587. teleportCamera(location: Vector3): void;
  41588. private _convertNormalToDirectionOfRay;
  41589. private _castRayAndSelectObject;
  41590. private _notifySelectedMeshUnselected;
  41591. /**
  41592. * Sets the color of the laser ray from the vr controllers.
  41593. * @param color new color for the ray.
  41594. */
  41595. changeLaserColor(color: Color3): void;
  41596. /**
  41597. * Sets the color of the ray from the vr headsets gaze.
  41598. * @param color new color for the ray.
  41599. */
  41600. changeGazeColor(color: Color3): void;
  41601. /**
  41602. * Exits VR and disposes of the vr experience helper
  41603. */
  41604. dispose(): void;
  41605. /**
  41606. * Gets the name of the VRExperienceHelper class
  41607. * @returns "VRExperienceHelper"
  41608. */
  41609. getClassName(): string;
  41610. }
  41611. }
  41612. declare module "babylonjs/Cameras/VR/index" {
  41613. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  41614. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  41615. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41616. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  41617. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  41618. export * from "babylonjs/Cameras/VR/webVRCamera";
  41619. }
  41620. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  41621. import { Observable } from "babylonjs/Misc/observable";
  41622. import { Nullable } from "babylonjs/types";
  41623. import { IDisposable, Scene } from "babylonjs/scene";
  41624. import { Vector3 } from "babylonjs/Maths/math";
  41625. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41626. import { Ray } from "babylonjs/Culling/ray";
  41627. /**
  41628. * Manages an XRSession
  41629. * @see https://doc.babylonjs.com/how_to/webxr
  41630. */
  41631. export class WebXRSessionManager implements IDisposable {
  41632. private scene;
  41633. /**
  41634. * Fires every time a new xrFrame arrives which can be used to update the camera
  41635. */
  41636. onXRFrameObservable: Observable<any>;
  41637. /**
  41638. * Fires when the xr session is ended either by the device or manually done
  41639. */
  41640. onXRSessionEnded: Observable<any>;
  41641. /** @hidden */
  41642. _xrSession: XRSession;
  41643. /** @hidden */
  41644. _frameOfReference: XRFrameOfReference;
  41645. /** @hidden */
  41646. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  41647. /** @hidden */
  41648. _currentXRFrame: Nullable<XRFrame>;
  41649. private _xrNavigator;
  41650. private _xrDevice;
  41651. private _tmpMatrix;
  41652. /**
  41653. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  41654. * @param scene The scene which the session should be created for
  41655. */
  41656. constructor(scene: Scene);
  41657. /**
  41658. * Initializes the manager
  41659. * After initialization enterXR can be called to start an XR session
  41660. * @returns Promise which resolves after it is initialized
  41661. */
  41662. initializeAsync(): Promise<void>;
  41663. /**
  41664. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  41665. * @param sessionCreationOptions xr options to create the session with
  41666. * @param frameOfReferenceType option to configure how the xr pose is expressed
  41667. * @returns Promise which resolves after it enters XR
  41668. */
  41669. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  41670. /**
  41671. * Stops the xrSession and restores the renderloop
  41672. * @returns Promise which resolves after it exits XR
  41673. */
  41674. exitXRAsync(): Promise<void>;
  41675. /**
  41676. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  41677. * @param ray ray to cast into the environment
  41678. * @returns Promise which resolves with a collision point in the environment if it exists
  41679. */
  41680. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  41681. /**
  41682. * Checks if a session would be supported for the creation options specified
  41683. * @param options creation options to check if they are supported
  41684. * @returns true if supported
  41685. */
  41686. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  41687. /**
  41688. * @hidden
  41689. * Converts the render layer of xrSession to a render target
  41690. * @param session session to create render target for
  41691. * @param scene scene the new render target should be created for
  41692. */
  41693. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  41694. /**
  41695. * Disposes of the session manager
  41696. */
  41697. dispose(): void;
  41698. }
  41699. }
  41700. declare module "babylonjs/Cameras/XR/webXRCamera" {
  41701. import { Scene } from "babylonjs/scene";
  41702. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41703. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  41704. /**
  41705. * WebXR Camera which holds the views for the xrSession
  41706. * @see https://doc.babylonjs.com/how_to/webxr
  41707. */
  41708. export class WebXRCamera extends FreeCamera {
  41709. private static _TmpMatrix;
  41710. /**
  41711. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  41712. * @param name the name of the camera
  41713. * @param scene the scene to add the camera to
  41714. */
  41715. constructor(name: string, scene: Scene);
  41716. private _updateNumberOfRigCameras;
  41717. /** @hidden */
  41718. _updateForDualEyeDebugging(pupilDistance?: number): void;
  41719. /**
  41720. * Updates the cameras position from the current pose information of the XR session
  41721. * @param xrSessionManager the session containing pose information
  41722. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  41723. */
  41724. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  41725. }
  41726. }
  41727. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  41728. import { Nullable } from "babylonjs/types";
  41729. import { Observable } from "babylonjs/Misc/observable";
  41730. import { IDisposable, Scene } from "babylonjs/scene";
  41731. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  41732. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41733. import { Ray } from "babylonjs/Culling/ray";
  41734. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  41735. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  41736. /**
  41737. * States of the webXR experience
  41738. */
  41739. export enum WebXRState {
  41740. /**
  41741. * Transitioning to being in XR mode
  41742. */
  41743. ENTERING_XR = 0,
  41744. /**
  41745. * Transitioning to non XR mode
  41746. */
  41747. EXITING_XR = 1,
  41748. /**
  41749. * In XR mode and presenting
  41750. */
  41751. IN_XR = 2,
  41752. /**
  41753. * Not entered XR mode
  41754. */
  41755. NOT_IN_XR = 3
  41756. }
  41757. /**
  41758. * Helper class used to enable XR
  41759. * @see https://doc.babylonjs.com/how_to/webxr
  41760. */
  41761. export class WebXRExperienceHelper implements IDisposable {
  41762. private scene;
  41763. /**
  41764. * 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
  41765. */
  41766. container: AbstractMesh;
  41767. /**
  41768. * Camera used to render xr content
  41769. */
  41770. camera: WebXRCamera;
  41771. /**
  41772. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  41773. */
  41774. state: WebXRState;
  41775. private _setState;
  41776. private static _TmpVector;
  41777. /**
  41778. * Fires when the state of the experience helper has changed
  41779. */
  41780. onStateChangedObservable: Observable<WebXRState>;
  41781. /** @hidden */
  41782. _sessionManager: WebXRSessionManager;
  41783. private _nonVRCamera;
  41784. private _originalSceneAutoClear;
  41785. private _supported;
  41786. /**
  41787. * Creates the experience helper
  41788. * @param scene the scene to attach the experience helper to
  41789. * @returns a promise for the experience helper
  41790. */
  41791. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  41792. /**
  41793. * Creates a WebXRExperienceHelper
  41794. * @param scene The scene the helper should be created in
  41795. */
  41796. private constructor();
  41797. /**
  41798. * Exits XR mode and returns the scene to its original state
  41799. * @returns promise that resolves after xr mode has exited
  41800. */
  41801. exitXRAsync(): Promise<void>;
  41802. /**
  41803. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  41804. * @param sessionCreationOptions options for the XR session
  41805. * @param frameOfReference frame of reference of the XR session
  41806. * @returns promise that resolves after xr mode has entered
  41807. */
  41808. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  41809. /**
  41810. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  41811. * @param ray ray to cast into the environment
  41812. * @returns Promise which resolves with a collision point in the environment if it exists
  41813. */
  41814. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  41815. /**
  41816. * Updates the global position of the camera by moving the camera's container
  41817. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  41818. * @param position The desired global position of the camera
  41819. */
  41820. setPositionOfCameraUsingContainer(position: Vector3): void;
  41821. /**
  41822. * Rotates the xr camera by rotating the camera's container around the camera's position
  41823. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  41824. * @param rotation the desired quaternion rotation to apply to the camera
  41825. */
  41826. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  41827. /**
  41828. * Checks if the creation options are supported by the xr session
  41829. * @param options creation options
  41830. * @returns true if supported
  41831. */
  41832. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  41833. /**
  41834. * Disposes of the experience helper
  41835. */
  41836. dispose(): void;
  41837. }
  41838. }
  41839. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  41840. import { Nullable } from "babylonjs/types";
  41841. import { Observable } from "babylonjs/Misc/observable";
  41842. import { IDisposable, Scene } from "babylonjs/scene";
  41843. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41844. /**
  41845. * Button which can be used to enter a different mode of XR
  41846. */
  41847. export class WebXREnterExitUIButton {
  41848. /** button element */
  41849. element: HTMLElement;
  41850. /** XR initialization options for the button */
  41851. initializationOptions: XRSessionCreationOptions;
  41852. /**
  41853. * Creates a WebXREnterExitUIButton
  41854. * @param element button element
  41855. * @param initializationOptions XR initialization options for the button
  41856. */
  41857. constructor(
  41858. /** button element */
  41859. element: HTMLElement,
  41860. /** XR initialization options for the button */
  41861. initializationOptions: XRSessionCreationOptions);
  41862. /**
  41863. * Overwritable function which can be used to update the button's visuals when the state changes
  41864. * @param activeButton the current active button in the UI
  41865. */
  41866. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  41867. }
  41868. /**
  41869. * Options to create the webXR UI
  41870. */
  41871. export class WebXREnterExitUIOptions {
  41872. /**
  41873. * Context to enter xr with
  41874. */
  41875. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  41876. /**
  41877. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  41878. */
  41879. customButtons?: Array<WebXREnterExitUIButton>;
  41880. }
  41881. /**
  41882. * UI to allow the user to enter/exit XR mode
  41883. */
  41884. export class WebXREnterExitUI implements IDisposable {
  41885. private scene;
  41886. private _overlay;
  41887. private _buttons;
  41888. private _activeButton;
  41889. /**
  41890. * Fired every time the active button is changed.
  41891. *
  41892. * When xr is entered via a button that launches xr that button will be the callback parameter
  41893. *
  41894. * When exiting xr the callback parameter will be null)
  41895. */
  41896. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  41897. /**
  41898. * Creates UI to allow the user to enter/exit XR mode
  41899. * @param scene the scene to add the ui to
  41900. * @param helper the xr experience helper to enter/exit xr with
  41901. * @param options options to configure the UI
  41902. * @returns the created ui
  41903. */
  41904. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  41905. private constructor();
  41906. private _updateButtons;
  41907. /**
  41908. * Disposes of the object
  41909. */
  41910. dispose(): void;
  41911. }
  41912. }
  41913. declare module "babylonjs/Cameras/XR/webXRInput" {
  41914. import { IDisposable, Scene } from "babylonjs/scene";
  41915. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41916. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41917. /**
  41918. * Represents an XR input
  41919. */
  41920. export class WebXRController {
  41921. /**
  41922. * 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
  41923. */
  41924. grip?: AbstractMesh;
  41925. /**
  41926. * Pointer which can be used to select objects or attach a visible laser to
  41927. */
  41928. pointer: AbstractMesh;
  41929. /**
  41930. * Creates the controller
  41931. * @see https://doc.babylonjs.com/how_to/webxr
  41932. * @param scene the scene which the controller should be associated to
  41933. */
  41934. constructor(scene: Scene);
  41935. /**
  41936. * Disposes of the object
  41937. */
  41938. dispose(): void;
  41939. }
  41940. /**
  41941. * XR input used to track XR inputs such as controllers/rays
  41942. */
  41943. export class WebXRInput implements IDisposable {
  41944. private helper;
  41945. /**
  41946. * XR controllers being tracked
  41947. */
  41948. controllers: Array<WebXRController>;
  41949. private _tmpMatrix;
  41950. private _frameObserver;
  41951. /**
  41952. * Initializes the WebXRInput
  41953. * @param helper experience helper which the input should be created for
  41954. */
  41955. constructor(helper: WebXRExperienceHelper);
  41956. /**
  41957. * Disposes of the object
  41958. */
  41959. dispose(): void;
  41960. }
  41961. }
  41962. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  41963. import { Nullable } from "babylonjs/types";
  41964. import { IDisposable } from "babylonjs/scene";
  41965. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41966. /**
  41967. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  41968. */
  41969. export class WebXRManagedOutputCanvas implements IDisposable {
  41970. private _canvas;
  41971. /**
  41972. * xrpresent context of the canvas which can be used to display/mirror xr content
  41973. */
  41974. canvasContext: Nullable<WebGLRenderingContext>;
  41975. /**
  41976. * Initializes the canvas to be added/removed upon entering/exiting xr
  41977. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  41978. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  41979. */
  41980. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  41981. /**
  41982. * Disposes of the object
  41983. */
  41984. dispose(): void;
  41985. private _setManagedOutputCanvas;
  41986. private _addCanvas;
  41987. private _removeCanvas;
  41988. }
  41989. }
  41990. declare module "babylonjs/Cameras/XR/index" {
  41991. export * from "babylonjs/Cameras/XR/webXRCamera";
  41992. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  41993. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41994. export * from "babylonjs/Cameras/XR/webXRInput";
  41995. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  41996. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  41997. }
  41998. declare module "babylonjs/Cameras/RigModes/index" {
  41999. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42000. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  42001. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  42002. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  42003. }
  42004. declare module "babylonjs/Cameras/index" {
  42005. export * from "babylonjs/Cameras/Inputs/index";
  42006. export * from "babylonjs/Cameras/cameraInputsManager";
  42007. export * from "babylonjs/Cameras/camera";
  42008. export * from "babylonjs/Cameras/targetCamera";
  42009. export * from "babylonjs/Cameras/freeCamera";
  42010. export * from "babylonjs/Cameras/freeCameraInputsManager";
  42011. export * from "babylonjs/Cameras/touchCamera";
  42012. export * from "babylonjs/Cameras/arcRotateCamera";
  42013. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  42014. export * from "babylonjs/Cameras/deviceOrientationCamera";
  42015. export * from "babylonjs/Cameras/flyCamera";
  42016. export * from "babylonjs/Cameras/flyCameraInputsManager";
  42017. export * from "babylonjs/Cameras/followCamera";
  42018. export * from "babylonjs/Cameras/gamepadCamera";
  42019. export * from "babylonjs/Cameras/Stereoscopic/index";
  42020. export * from "babylonjs/Cameras/universalCamera";
  42021. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  42022. export * from "babylonjs/Cameras/VR/index";
  42023. export * from "babylonjs/Cameras/XR/index";
  42024. export * from "babylonjs/Cameras/RigModes/index";
  42025. }
  42026. declare module "babylonjs/Collisions/index" {
  42027. export * from "babylonjs/Collisions/collider";
  42028. export * from "babylonjs/Collisions/collisionCoordinator";
  42029. export * from "babylonjs/Collisions/pickingInfo";
  42030. export * from "babylonjs/Collisions/intersectionInfo";
  42031. export * from "babylonjs/Collisions/meshCollisionData";
  42032. }
  42033. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  42034. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  42035. import { Vector3, Plane } from "babylonjs/Maths/math";
  42036. import { Ray } from "babylonjs/Culling/ray";
  42037. /**
  42038. * Contains an array of blocks representing the octree
  42039. */
  42040. export interface IOctreeContainer<T> {
  42041. /**
  42042. * Blocks within the octree
  42043. */
  42044. blocks: Array<OctreeBlock<T>>;
  42045. }
  42046. /**
  42047. * Class used to store a cell in an octree
  42048. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42049. */
  42050. export class OctreeBlock<T> {
  42051. /**
  42052. * Gets the content of the current block
  42053. */
  42054. entries: T[];
  42055. /**
  42056. * Gets the list of block children
  42057. */
  42058. blocks: Array<OctreeBlock<T>>;
  42059. private _depth;
  42060. private _maxDepth;
  42061. private _capacity;
  42062. private _minPoint;
  42063. private _maxPoint;
  42064. private _boundingVectors;
  42065. private _creationFunc;
  42066. /**
  42067. * Creates a new block
  42068. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  42069. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  42070. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42071. * @param depth defines the current depth of this block in the octree
  42072. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  42073. * @param creationFunc defines a callback to call when an element is added to the block
  42074. */
  42075. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  42076. /**
  42077. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42078. */
  42079. readonly capacity: number;
  42080. /**
  42081. * Gets the minimum vector (in world space) of the block's bounding box
  42082. */
  42083. readonly minPoint: Vector3;
  42084. /**
  42085. * Gets the maximum vector (in world space) of the block's bounding box
  42086. */
  42087. readonly maxPoint: Vector3;
  42088. /**
  42089. * Add a new element to this block
  42090. * @param entry defines the element to add
  42091. */
  42092. addEntry(entry: T): void;
  42093. /**
  42094. * Remove an element from this block
  42095. * @param entry defines the element to remove
  42096. */
  42097. removeEntry(entry: T): void;
  42098. /**
  42099. * Add an array of elements to this block
  42100. * @param entries defines the array of elements to add
  42101. */
  42102. addEntries(entries: T[]): void;
  42103. /**
  42104. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  42105. * @param frustumPlanes defines the frustum planes to test
  42106. * @param selection defines the array to store current content if selection is positive
  42107. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42108. */
  42109. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42110. /**
  42111. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  42112. * @param sphereCenter defines the bounding sphere center
  42113. * @param sphereRadius defines the bounding sphere radius
  42114. * @param selection defines the array to store current content if selection is positive
  42115. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42116. */
  42117. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42118. /**
  42119. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  42120. * @param ray defines the ray to test with
  42121. * @param selection defines the array to store current content if selection is positive
  42122. */
  42123. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  42124. /**
  42125. * Subdivide the content into child blocks (this block will then be empty)
  42126. */
  42127. createInnerBlocks(): void;
  42128. /**
  42129. * @hidden
  42130. */
  42131. 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;
  42132. }
  42133. }
  42134. declare module "babylonjs/Culling/Octrees/octree" {
  42135. import { SmartArray } from "babylonjs/Misc/smartArray";
  42136. import { Vector3, Plane } from "babylonjs/Maths/math";
  42137. import { SubMesh } from "babylonjs/Meshes/subMesh";
  42138. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42139. import { Ray } from "babylonjs/Culling/ray";
  42140. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  42141. /**
  42142. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  42143. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42144. */
  42145. export class Octree<T> {
  42146. /** 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.) */
  42147. maxDepth: number;
  42148. /**
  42149. * Blocks within the octree containing objects
  42150. */
  42151. blocks: Array<OctreeBlock<T>>;
  42152. /**
  42153. * Content stored in the octree
  42154. */
  42155. dynamicContent: T[];
  42156. private _maxBlockCapacity;
  42157. private _selectionContent;
  42158. private _creationFunc;
  42159. /**
  42160. * Creates a octree
  42161. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42162. * @param creationFunc function to be used to instatiate the octree
  42163. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  42164. * @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.)
  42165. */
  42166. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  42167. /** 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.) */
  42168. maxDepth?: number);
  42169. /**
  42170. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  42171. * @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);
  42172. * @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);
  42173. * @param entries meshes to be added to the octree blocks
  42174. */
  42175. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  42176. /**
  42177. * Adds a mesh to the octree
  42178. * @param entry Mesh to add to the octree
  42179. */
  42180. addMesh(entry: T): void;
  42181. /**
  42182. * Remove an element from the octree
  42183. * @param entry defines the element to remove
  42184. */
  42185. removeMesh(entry: T): void;
  42186. /**
  42187. * Selects an array of meshes within the frustum
  42188. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  42189. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  42190. * @returns array of meshes within the frustum
  42191. */
  42192. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  42193. /**
  42194. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  42195. * @param sphereCenter defines the bounding sphere center
  42196. * @param sphereRadius defines the bounding sphere radius
  42197. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42198. * @returns an array of objects that intersect the sphere
  42199. */
  42200. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  42201. /**
  42202. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  42203. * @param ray defines the ray to test with
  42204. * @returns array of intersected objects
  42205. */
  42206. intersectsRay(ray: Ray): SmartArray<T>;
  42207. /**
  42208. * Adds a mesh into the octree block if it intersects the block
  42209. */
  42210. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  42211. /**
  42212. * Adds a submesh into the octree block if it intersects the block
  42213. */
  42214. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  42215. }
  42216. }
  42217. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  42218. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  42219. import { Scene } from "babylonjs/scene";
  42220. import { SubMesh } from "babylonjs/Meshes/subMesh";
  42221. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42222. import { Ray } from "babylonjs/Culling/ray";
  42223. import { Octree } from "babylonjs/Culling/Octrees/octree";
  42224. import { Collider } from "babylonjs/Collisions/collider";
  42225. module "babylonjs/scene" {
  42226. interface Scene {
  42227. /**
  42228. * @hidden
  42229. * Backing Filed
  42230. */
  42231. _selectionOctree: Octree<AbstractMesh>;
  42232. /**
  42233. * Gets the octree used to boost mesh selection (picking)
  42234. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42235. */
  42236. selectionOctree: Octree<AbstractMesh>;
  42237. /**
  42238. * Creates or updates the octree used to boost selection (picking)
  42239. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42240. * @param maxCapacity defines the maximum capacity per leaf
  42241. * @param maxDepth defines the maximum depth of the octree
  42242. * @returns an octree of AbstractMesh
  42243. */
  42244. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  42245. }
  42246. }
  42247. module "babylonjs/Meshes/abstractMesh" {
  42248. interface AbstractMesh {
  42249. /**
  42250. * @hidden
  42251. * Backing Field
  42252. */
  42253. _submeshesOctree: Octree<SubMesh>;
  42254. /**
  42255. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  42256. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  42257. * @param maxCapacity defines the maximum size of each block (64 by default)
  42258. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  42259. * @returns the new octree
  42260. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  42261. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42262. */
  42263. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  42264. }
  42265. }
  42266. /**
  42267. * Defines the octree scene component responsible to manage any octrees
  42268. * in a given scene.
  42269. */
  42270. export class OctreeSceneComponent {
  42271. /**
  42272. * The component name help to identify the component in the list of scene components.
  42273. */
  42274. readonly name: string;
  42275. /**
  42276. * The scene the component belongs to.
  42277. */
  42278. scene: Scene;
  42279. /**
  42280. * Indicates if the meshes have been checked to make sure they are isEnabled()
  42281. */
  42282. readonly checksIsEnabled: boolean;
  42283. /**
  42284. * Creates a new instance of the component for the given scene
  42285. * @param scene Defines the scene to register the component in
  42286. */
  42287. constructor(scene: Scene);
  42288. /**
  42289. * Registers the component in a given scene
  42290. */
  42291. register(): void;
  42292. /**
  42293. * Return the list of active meshes
  42294. * @returns the list of active meshes
  42295. */
  42296. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  42297. /**
  42298. * Return the list of active sub meshes
  42299. * @param mesh The mesh to get the candidates sub meshes from
  42300. * @returns the list of active sub meshes
  42301. */
  42302. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  42303. private _tempRay;
  42304. /**
  42305. * Return the list of sub meshes intersecting with a given local ray
  42306. * @param mesh defines the mesh to find the submesh for
  42307. * @param localRay defines the ray in local space
  42308. * @returns the list of intersecting sub meshes
  42309. */
  42310. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  42311. /**
  42312. * Return the list of sub meshes colliding with a collider
  42313. * @param mesh defines the mesh to find the submesh for
  42314. * @param collider defines the collider to evaluate the collision against
  42315. * @returns the list of colliding sub meshes
  42316. */
  42317. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  42318. /**
  42319. * Rebuilds the elements related to this component in case of
  42320. * context lost for instance.
  42321. */
  42322. rebuild(): void;
  42323. /**
  42324. * Disposes the component and the associated ressources.
  42325. */
  42326. dispose(): void;
  42327. }
  42328. }
  42329. declare module "babylonjs/Culling/Octrees/index" {
  42330. export * from "babylonjs/Culling/Octrees/octree";
  42331. export * from "babylonjs/Culling/Octrees/octreeBlock";
  42332. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  42333. }
  42334. declare module "babylonjs/Culling/index" {
  42335. export * from "babylonjs/Culling/boundingBox";
  42336. export * from "babylonjs/Culling/boundingInfo";
  42337. export * from "babylonjs/Culling/boundingSphere";
  42338. export * from "babylonjs/Culling/Octrees/index";
  42339. export * from "babylonjs/Culling/ray";
  42340. }
  42341. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  42342. import { IDisposable, Scene } from "babylonjs/scene";
  42343. import { Nullable } from "babylonjs/types";
  42344. import { Observable } from "babylonjs/Misc/observable";
  42345. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42346. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  42347. import { Camera } from "babylonjs/Cameras/camera";
  42348. /**
  42349. * Renders a layer on top of an existing scene
  42350. */
  42351. export class UtilityLayerRenderer implements IDisposable {
  42352. /** the original scene that will be rendered on top of */
  42353. originalScene: Scene;
  42354. private _pointerCaptures;
  42355. private _lastPointerEvents;
  42356. private static _DefaultUtilityLayer;
  42357. private static _DefaultKeepDepthUtilityLayer;
  42358. private _sharedGizmoLight;
  42359. private _renderCamera;
  42360. /**
  42361. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  42362. * @returns the camera that is used when rendering the utility layer
  42363. */
  42364. getRenderCamera(): Nullable<Camera>;
  42365. /**
  42366. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  42367. * @param cam the camera that should be used when rendering the utility layer
  42368. */
  42369. setRenderCamera(cam: Nullable<Camera>): void;
  42370. /**
  42371. * @hidden
  42372. * Light which used by gizmos to get light shading
  42373. */
  42374. _getSharedGizmoLight(): HemisphericLight;
  42375. /**
  42376. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  42377. */
  42378. pickUtilitySceneFirst: boolean;
  42379. /**
  42380. * 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)
  42381. */
  42382. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  42383. /**
  42384. * 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)
  42385. */
  42386. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  42387. /**
  42388. * The scene that is rendered on top of the original scene
  42389. */
  42390. utilityLayerScene: Scene;
  42391. /**
  42392. * If the utility layer should automatically be rendered on top of existing scene
  42393. */
  42394. shouldRender: boolean;
  42395. /**
  42396. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  42397. */
  42398. onlyCheckPointerDownEvents: boolean;
  42399. /**
  42400. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  42401. */
  42402. processAllEvents: boolean;
  42403. /**
  42404. * Observable raised when the pointer move from the utility layer scene to the main scene
  42405. */
  42406. onPointerOutObservable: Observable<number>;
  42407. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  42408. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  42409. private _afterRenderObserver;
  42410. private _sceneDisposeObserver;
  42411. private _originalPointerObserver;
  42412. /**
  42413. * Instantiates a UtilityLayerRenderer
  42414. * @param originalScene the original scene that will be rendered on top of
  42415. * @param handleEvents boolean indicating if the utility layer should handle events
  42416. */
  42417. constructor(
  42418. /** the original scene that will be rendered on top of */
  42419. originalScene: Scene, handleEvents?: boolean);
  42420. private _notifyObservers;
  42421. /**
  42422. * Renders the utility layers scene on top of the original scene
  42423. */
  42424. render(): void;
  42425. /**
  42426. * Disposes of the renderer
  42427. */
  42428. dispose(): void;
  42429. private _updateCamera;
  42430. }
  42431. }
  42432. declare module "babylonjs/Gizmos/gizmo" {
  42433. import { Nullable } from "babylonjs/types";
  42434. import { IDisposable } from "babylonjs/scene";
  42435. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42436. import { Mesh } from "babylonjs/Meshes/mesh";
  42437. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42438. /**
  42439. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  42440. */
  42441. export class Gizmo implements IDisposable {
  42442. /** The utility layer the gizmo will be added to */
  42443. gizmoLayer: UtilityLayerRenderer;
  42444. /**
  42445. * The root mesh of the gizmo
  42446. */
  42447. _rootMesh: Mesh;
  42448. private _attachedMesh;
  42449. /**
  42450. * Ratio for the scale of the gizmo (Default: 1)
  42451. */
  42452. scaleRatio: number;
  42453. /**
  42454. * If a custom mesh has been set (Default: false)
  42455. */
  42456. protected _customMeshSet: boolean;
  42457. /**
  42458. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  42459. * * When set, interactions will be enabled
  42460. */
  42461. attachedMesh: Nullable<AbstractMesh>;
  42462. /**
  42463. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42464. * @param mesh The mesh to replace the default mesh of the gizmo
  42465. */
  42466. setCustomMesh(mesh: Mesh): void;
  42467. /**
  42468. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  42469. */
  42470. updateGizmoRotationToMatchAttachedMesh: boolean;
  42471. /**
  42472. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  42473. */
  42474. updateGizmoPositionToMatchAttachedMesh: boolean;
  42475. /**
  42476. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  42477. */
  42478. protected _updateScale: boolean;
  42479. protected _interactionsEnabled: boolean;
  42480. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42481. private _beforeRenderObserver;
  42482. private _tempVector;
  42483. /**
  42484. * Creates a gizmo
  42485. * @param gizmoLayer The utility layer the gizmo will be added to
  42486. */
  42487. constructor(
  42488. /** The utility layer the gizmo will be added to */
  42489. gizmoLayer?: UtilityLayerRenderer);
  42490. /**
  42491. * Updates the gizmo to match the attached mesh's position/rotation
  42492. */
  42493. protected _update(): void;
  42494. /**
  42495. * Disposes of the gizmo
  42496. */
  42497. dispose(): void;
  42498. }
  42499. }
  42500. declare module "babylonjs/Gizmos/planeDragGizmo" {
  42501. import { Observable } from "babylonjs/Misc/observable";
  42502. import { Nullable } from "babylonjs/types";
  42503. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42504. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42505. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42506. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  42507. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42508. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42509. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  42510. import { Scene } from "babylonjs/scene";
  42511. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  42512. /**
  42513. * Single plane drag gizmo
  42514. */
  42515. export class PlaneDragGizmo extends Gizmo {
  42516. /**
  42517. * Drag behavior responsible for the gizmos dragging interactions
  42518. */
  42519. dragBehavior: PointerDragBehavior;
  42520. private _pointerObserver;
  42521. /**
  42522. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42523. */
  42524. snapDistance: number;
  42525. /**
  42526. * Event that fires each time the gizmo snaps to a new location.
  42527. * * snapDistance is the the change in distance
  42528. */
  42529. onSnapObservable: Observable<{
  42530. snapDistance: number;
  42531. }>;
  42532. private _plane;
  42533. private _coloredMaterial;
  42534. private _hoverMaterial;
  42535. private _isEnabled;
  42536. private _parent;
  42537. /** @hidden */
  42538. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  42539. /** @hidden */
  42540. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42541. /**
  42542. * Creates a PlaneDragGizmo
  42543. * @param gizmoLayer The utility layer the gizmo will be added to
  42544. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  42545. * @param color The color of the gizmo
  42546. */
  42547. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42548. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42549. /**
  42550. * If the gizmo is enabled
  42551. */
  42552. isEnabled: boolean;
  42553. /**
  42554. * Disposes of the gizmo
  42555. */
  42556. dispose(): void;
  42557. }
  42558. }
  42559. declare module "babylonjs/Gizmos/positionGizmo" {
  42560. import { Observable } from "babylonjs/Misc/observable";
  42561. import { Nullable } from "babylonjs/types";
  42562. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42563. import { Mesh } from "babylonjs/Meshes/mesh";
  42564. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42565. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  42566. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  42567. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42568. /**
  42569. * Gizmo that enables dragging a mesh along 3 axis
  42570. */
  42571. export class PositionGizmo extends Gizmo {
  42572. /**
  42573. * Internal gizmo used for interactions on the x axis
  42574. */
  42575. xGizmo: AxisDragGizmo;
  42576. /**
  42577. * Internal gizmo used for interactions on the y axis
  42578. */
  42579. yGizmo: AxisDragGizmo;
  42580. /**
  42581. * Internal gizmo used for interactions on the z axis
  42582. */
  42583. zGizmo: AxisDragGizmo;
  42584. /**
  42585. * Internal gizmo used for interactions on the yz plane
  42586. */
  42587. xPlaneGizmo: PlaneDragGizmo;
  42588. /**
  42589. * Internal gizmo used for interactions on the xz plane
  42590. */
  42591. yPlaneGizmo: PlaneDragGizmo;
  42592. /**
  42593. * Internal gizmo used for interactions on the xy plane
  42594. */
  42595. zPlaneGizmo: PlaneDragGizmo;
  42596. /**
  42597. * private variables
  42598. */
  42599. private _meshAttached;
  42600. private _updateGizmoRotationToMatchAttachedMesh;
  42601. private _snapDistance;
  42602. private _scaleRatio;
  42603. /** Fires an event when any of it's sub gizmos are dragged */
  42604. onDragStartObservable: Observable<{}>;
  42605. /** Fires an event when any of it's sub gizmos are released from dragging */
  42606. onDragEndObservable: Observable<{}>;
  42607. /**
  42608. * If set to true, planar drag is enabled
  42609. */
  42610. private _planarGizmoEnabled;
  42611. attachedMesh: Nullable<AbstractMesh>;
  42612. /**
  42613. * Creates a PositionGizmo
  42614. * @param gizmoLayer The utility layer the gizmo will be added to
  42615. */
  42616. constructor(gizmoLayer?: UtilityLayerRenderer);
  42617. /**
  42618. * If the planar drag gizmo is enabled
  42619. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  42620. */
  42621. planarGizmoEnabled: boolean;
  42622. updateGizmoRotationToMatchAttachedMesh: boolean;
  42623. /**
  42624. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42625. */
  42626. snapDistance: number;
  42627. /**
  42628. * Ratio for the scale of the gizmo (Default: 1)
  42629. */
  42630. scaleRatio: number;
  42631. /**
  42632. * Disposes of the gizmo
  42633. */
  42634. dispose(): void;
  42635. /**
  42636. * CustomMeshes are not supported by this gizmo
  42637. * @param mesh The mesh to replace the default mesh of the gizmo
  42638. */
  42639. setCustomMesh(mesh: Mesh): void;
  42640. }
  42641. }
  42642. declare module "babylonjs/Gizmos/axisDragGizmo" {
  42643. import { Observable } from "babylonjs/Misc/observable";
  42644. import { Nullable } from "babylonjs/types";
  42645. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42646. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42647. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42648. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  42649. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42650. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42651. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  42652. import { Scene } from "babylonjs/scene";
  42653. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  42654. /**
  42655. * Single axis drag gizmo
  42656. */
  42657. export class AxisDragGizmo extends Gizmo {
  42658. /**
  42659. * Drag behavior responsible for the gizmos dragging interactions
  42660. */
  42661. dragBehavior: PointerDragBehavior;
  42662. private _pointerObserver;
  42663. /**
  42664. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42665. */
  42666. snapDistance: number;
  42667. /**
  42668. * Event that fires each time the gizmo snaps to a new location.
  42669. * * snapDistance is the the change in distance
  42670. */
  42671. onSnapObservable: Observable<{
  42672. snapDistance: number;
  42673. }>;
  42674. private _isEnabled;
  42675. private _parent;
  42676. private _arrow;
  42677. private _coloredMaterial;
  42678. private _hoverMaterial;
  42679. /** @hidden */
  42680. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  42681. /** @hidden */
  42682. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42683. /**
  42684. * Creates an AxisDragGizmo
  42685. * @param gizmoLayer The utility layer the gizmo will be added to
  42686. * @param dragAxis The axis which the gizmo will be able to drag on
  42687. * @param color The color of the gizmo
  42688. */
  42689. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42690. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42691. /**
  42692. * If the gizmo is enabled
  42693. */
  42694. isEnabled: boolean;
  42695. /**
  42696. * Disposes of the gizmo
  42697. */
  42698. dispose(): void;
  42699. }
  42700. }
  42701. declare module "babylonjs/Debug/axesViewer" {
  42702. import { Vector3 } from "babylonjs/Maths/math";
  42703. import { Nullable } from "babylonjs/types";
  42704. import { Scene } from "babylonjs/scene";
  42705. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42706. /**
  42707. * The Axes viewer will show 3 axes in a specific point in space
  42708. */
  42709. export class AxesViewer {
  42710. private _xAxis;
  42711. private _yAxis;
  42712. private _zAxis;
  42713. private _scaleLinesFactor;
  42714. private _instanced;
  42715. /**
  42716. * Gets the hosting scene
  42717. */
  42718. scene: Scene;
  42719. /**
  42720. * Gets or sets a number used to scale line length
  42721. */
  42722. scaleLines: number;
  42723. /** Gets the node hierarchy used to render x-axis */
  42724. readonly xAxis: TransformNode;
  42725. /** Gets the node hierarchy used to render y-axis */
  42726. readonly yAxis: TransformNode;
  42727. /** Gets the node hierarchy used to render z-axis */
  42728. readonly zAxis: TransformNode;
  42729. /**
  42730. * Creates a new AxesViewer
  42731. * @param scene defines the hosting scene
  42732. * @param scaleLines defines a number used to scale line length (1 by default)
  42733. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  42734. * @param xAxis defines the node hierarchy used to render the x-axis
  42735. * @param yAxis defines the node hierarchy used to render the y-axis
  42736. * @param zAxis defines the node hierarchy used to render the z-axis
  42737. */
  42738. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  42739. /**
  42740. * Force the viewer to update
  42741. * @param position defines the position of the viewer
  42742. * @param xaxis defines the x axis of the viewer
  42743. * @param yaxis defines the y axis of the viewer
  42744. * @param zaxis defines the z axis of the viewer
  42745. */
  42746. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  42747. /**
  42748. * Creates an instance of this axes viewer.
  42749. * @returns a new axes viewer with instanced meshes
  42750. */
  42751. createInstance(): AxesViewer;
  42752. /** Releases resources */
  42753. dispose(): void;
  42754. private static _SetRenderingGroupId;
  42755. }
  42756. }
  42757. declare module "babylonjs/Debug/boneAxesViewer" {
  42758. import { Nullable } from "babylonjs/types";
  42759. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  42760. import { Vector3 } from "babylonjs/Maths/math";
  42761. import { Mesh } from "babylonjs/Meshes/mesh";
  42762. import { Bone } from "babylonjs/Bones/bone";
  42763. import { Scene } from "babylonjs/scene";
  42764. /**
  42765. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  42766. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  42767. */
  42768. export class BoneAxesViewer extends AxesViewer {
  42769. /**
  42770. * Gets or sets the target mesh where to display the axes viewer
  42771. */
  42772. mesh: Nullable<Mesh>;
  42773. /**
  42774. * Gets or sets the target bone where to display the axes viewer
  42775. */
  42776. bone: Nullable<Bone>;
  42777. /** Gets current position */
  42778. pos: Vector3;
  42779. /** Gets direction of X axis */
  42780. xaxis: Vector3;
  42781. /** Gets direction of Y axis */
  42782. yaxis: Vector3;
  42783. /** Gets direction of Z axis */
  42784. zaxis: Vector3;
  42785. /**
  42786. * Creates a new BoneAxesViewer
  42787. * @param scene defines the hosting scene
  42788. * @param bone defines the target bone
  42789. * @param mesh defines the target mesh
  42790. * @param scaleLines defines a scaling factor for line length (1 by default)
  42791. */
  42792. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  42793. /**
  42794. * Force the viewer to update
  42795. */
  42796. update(): void;
  42797. /** Releases resources */
  42798. dispose(): void;
  42799. }
  42800. }
  42801. declare module "babylonjs/Debug/debugLayer" {
  42802. import { Observable } from "babylonjs/Misc/observable";
  42803. import { Scene } from "babylonjs/scene";
  42804. /**
  42805. * Interface used to define scene explorer extensibility option
  42806. */
  42807. export interface IExplorerExtensibilityOption {
  42808. /**
  42809. * Define the option label
  42810. */
  42811. label: string;
  42812. /**
  42813. * Defines the action to execute on click
  42814. */
  42815. action: (entity: any) => void;
  42816. }
  42817. /**
  42818. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  42819. */
  42820. export interface IExplorerExtensibilityGroup {
  42821. /**
  42822. * Defines a predicate to test if a given type mut be extended
  42823. */
  42824. predicate: (entity: any) => boolean;
  42825. /**
  42826. * Gets the list of options added to a type
  42827. */
  42828. entries: IExplorerExtensibilityOption[];
  42829. }
  42830. /**
  42831. * Interface used to define the options to use to create the Inspector
  42832. */
  42833. export interface IInspectorOptions {
  42834. /**
  42835. * Display in overlay mode (default: false)
  42836. */
  42837. overlay?: boolean;
  42838. /**
  42839. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  42840. */
  42841. globalRoot?: HTMLElement;
  42842. /**
  42843. * Display the Scene explorer
  42844. */
  42845. showExplorer?: boolean;
  42846. /**
  42847. * Display the property inspector
  42848. */
  42849. showInspector?: boolean;
  42850. /**
  42851. * Display in embed mode (both panes on the right)
  42852. */
  42853. embedMode?: boolean;
  42854. /**
  42855. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  42856. */
  42857. handleResize?: boolean;
  42858. /**
  42859. * Allow the panes to popup (default: true)
  42860. */
  42861. enablePopup?: boolean;
  42862. /**
  42863. * Allow the panes to be closed by users (default: true)
  42864. */
  42865. enableClose?: boolean;
  42866. /**
  42867. * Optional list of extensibility entries
  42868. */
  42869. explorerExtensibility?: IExplorerExtensibilityGroup[];
  42870. /**
  42871. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  42872. */
  42873. inspectorURL?: string;
  42874. }
  42875. module "babylonjs/scene" {
  42876. interface Scene {
  42877. /**
  42878. * @hidden
  42879. * Backing field
  42880. */
  42881. _debugLayer: DebugLayer;
  42882. /**
  42883. * Gets the debug layer (aka Inspector) associated with the scene
  42884. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42885. */
  42886. debugLayer: DebugLayer;
  42887. }
  42888. }
  42889. /**
  42890. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42891. * what is happening in your scene
  42892. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42893. */
  42894. export class DebugLayer {
  42895. /**
  42896. * Define the url to get the inspector script from.
  42897. * By default it uses the babylonjs CDN.
  42898. * @ignoreNaming
  42899. */
  42900. static InspectorURL: string;
  42901. private _scene;
  42902. private BJSINSPECTOR;
  42903. /**
  42904. * Observable triggered when a property is changed through the inspector.
  42905. */
  42906. onPropertyChangedObservable: Observable<{
  42907. object: any;
  42908. property: string;
  42909. value: any;
  42910. initialValue: any;
  42911. }>;
  42912. /**
  42913. * Instantiates a new debug layer.
  42914. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42915. * what is happening in your scene
  42916. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42917. * @param scene Defines the scene to inspect
  42918. */
  42919. constructor(scene: Scene);
  42920. /** Creates the inspector window. */
  42921. private _createInspector;
  42922. /**
  42923. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  42924. * @param entity defines the entity to select
  42925. * @param lineContainerTitle defines the specific block to highlight
  42926. */
  42927. select(entity: any, lineContainerTitle?: string): void;
  42928. /** Get the inspector from bundle or global */
  42929. private _getGlobalInspector;
  42930. /**
  42931. * Get if the inspector is visible or not.
  42932. * @returns true if visible otherwise, false
  42933. */
  42934. isVisible(): boolean;
  42935. /**
  42936. * Hide the inspector and close its window.
  42937. */
  42938. hide(): void;
  42939. /**
  42940. * Launch the debugLayer.
  42941. * @param config Define the configuration of the inspector
  42942. * @return a promise fulfilled when the debug layer is visible
  42943. */
  42944. show(config?: IInspectorOptions): Promise<DebugLayer>;
  42945. }
  42946. }
  42947. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  42948. import { Nullable } from "babylonjs/types";
  42949. import { Scene } from "babylonjs/scene";
  42950. import { Vector4, Color4 } from "babylonjs/Maths/math";
  42951. import { Mesh } from "babylonjs/Meshes/mesh";
  42952. /**
  42953. * Class containing static functions to help procedurally build meshes
  42954. */
  42955. export class BoxBuilder {
  42956. /**
  42957. * Creates a box mesh
  42958. * * The parameter `size` sets the size (float) of each box side (default 1)
  42959. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  42960. * * 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)
  42961. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  42962. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42963. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42964. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42965. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  42966. * @param name defines the name of the mesh
  42967. * @param options defines the options used to create the mesh
  42968. * @param scene defines the hosting scene
  42969. * @returns the box mesh
  42970. */
  42971. static CreateBox(name: string, options: {
  42972. size?: number;
  42973. width?: number;
  42974. height?: number;
  42975. depth?: number;
  42976. faceUV?: Vector4[];
  42977. faceColors?: Color4[];
  42978. sideOrientation?: number;
  42979. frontUVs?: Vector4;
  42980. backUVs?: Vector4;
  42981. wrap?: boolean;
  42982. topBaseAt?: number;
  42983. bottomBaseAt?: number;
  42984. updatable?: boolean;
  42985. }, scene?: Nullable<Scene>): Mesh;
  42986. }
  42987. }
  42988. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  42989. import { Vector4 } from "babylonjs/Maths/math";
  42990. import { Mesh } from "babylonjs/Meshes/mesh";
  42991. /**
  42992. * Class containing static functions to help procedurally build meshes
  42993. */
  42994. export class SphereBuilder {
  42995. /**
  42996. * Creates a sphere mesh
  42997. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  42998. * * 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`)
  42999. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  43000. * * 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
  43001. * * 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)
  43002. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43003. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43004. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43005. * @param name defines the name of the mesh
  43006. * @param options defines the options used to create the mesh
  43007. * @param scene defines the hosting scene
  43008. * @returns the sphere mesh
  43009. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  43010. */
  43011. static CreateSphere(name: string, options: {
  43012. segments?: number;
  43013. diameter?: number;
  43014. diameterX?: number;
  43015. diameterY?: number;
  43016. diameterZ?: number;
  43017. arc?: number;
  43018. slice?: number;
  43019. sideOrientation?: number;
  43020. frontUVs?: Vector4;
  43021. backUVs?: Vector4;
  43022. updatable?: boolean;
  43023. }, scene: any): Mesh;
  43024. }
  43025. }
  43026. declare module "babylonjs/Debug/physicsViewer" {
  43027. import { Nullable } from "babylonjs/types";
  43028. import { Scene } from "babylonjs/scene";
  43029. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43030. import { Mesh } from "babylonjs/Meshes/mesh";
  43031. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  43032. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  43033. /**
  43034. * Used to show the physics impostor around the specific mesh
  43035. */
  43036. export class PhysicsViewer {
  43037. /** @hidden */
  43038. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  43039. /** @hidden */
  43040. protected _meshes: Array<Nullable<AbstractMesh>>;
  43041. /** @hidden */
  43042. protected _scene: Nullable<Scene>;
  43043. /** @hidden */
  43044. protected _numMeshes: number;
  43045. /** @hidden */
  43046. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  43047. private _renderFunction;
  43048. private _utilityLayer;
  43049. private _debugBoxMesh;
  43050. private _debugSphereMesh;
  43051. private _debugCylinderMesh;
  43052. private _debugMaterial;
  43053. private _debugMeshMeshes;
  43054. /**
  43055. * Creates a new PhysicsViewer
  43056. * @param scene defines the hosting scene
  43057. */
  43058. constructor(scene: Scene);
  43059. /** @hidden */
  43060. protected _updateDebugMeshes(): void;
  43061. /**
  43062. * Renders a specified physic impostor
  43063. * @param impostor defines the impostor to render
  43064. * @param targetMesh defines the mesh represented by the impostor
  43065. * @returns the new debug mesh used to render the impostor
  43066. */
  43067. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  43068. /**
  43069. * Hides a specified physic impostor
  43070. * @param impostor defines the impostor to hide
  43071. */
  43072. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  43073. private _getDebugMaterial;
  43074. private _getDebugBoxMesh;
  43075. private _getDebugSphereMesh;
  43076. private _getDebugCylinderMesh;
  43077. private _getDebugMeshMesh;
  43078. private _getDebugMesh;
  43079. /** Releases all resources */
  43080. dispose(): void;
  43081. }
  43082. }
  43083. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  43084. import { Vector3, Color4 } from "babylonjs/Maths/math";
  43085. import { Nullable } from "babylonjs/types";
  43086. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  43087. import { Scene } from "babylonjs/scene";
  43088. /**
  43089. * Class containing static functions to help procedurally build meshes
  43090. */
  43091. export class LinesBuilder {
  43092. /**
  43093. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  43094. * * 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
  43095. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  43096. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  43097. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  43098. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  43099. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  43100. * * 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
  43101. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  43102. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43103. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  43104. * @param name defines the name of the new line system
  43105. * @param options defines the options used to create the line system
  43106. * @param scene defines the hosting scene
  43107. * @returns a new line system mesh
  43108. */
  43109. static CreateLineSystem(name: string, options: {
  43110. lines: Vector3[][];
  43111. updatable?: boolean;
  43112. instance?: Nullable<LinesMesh>;
  43113. colors?: Nullable<Color4[][]>;
  43114. useVertexAlpha?: boolean;
  43115. }, scene: Nullable<Scene>): LinesMesh;
  43116. /**
  43117. * Creates a line mesh
  43118. * 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
  43119. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43120. * * The parameter `points` is an array successive Vector3
  43121. * * 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
  43122. * * The optional parameter `colors` is an array of successive Color4, one per line point
  43123. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  43124. * * When updating an instance, remember that only point positions can change, not the number of points
  43125. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43126. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  43127. * @param name defines the name of the new line system
  43128. * @param options defines the options used to create the line system
  43129. * @param scene defines the hosting scene
  43130. * @returns a new line mesh
  43131. */
  43132. static CreateLines(name: string, options: {
  43133. points: Vector3[];
  43134. updatable?: boolean;
  43135. instance?: Nullable<LinesMesh>;
  43136. colors?: Color4[];
  43137. useVertexAlpha?: boolean;
  43138. }, scene?: Nullable<Scene>): LinesMesh;
  43139. /**
  43140. * Creates a dashed line mesh
  43141. * * 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
  43142. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43143. * * The parameter `points` is an array successive Vector3
  43144. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  43145. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  43146. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  43147. * * 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
  43148. * * When updating an instance, remember that only point positions can change, not the number of points
  43149. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43150. * @param name defines the name of the mesh
  43151. * @param options defines the options used to create the mesh
  43152. * @param scene defines the hosting scene
  43153. * @returns the dashed line mesh
  43154. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  43155. */
  43156. static CreateDashedLines(name: string, options: {
  43157. points: Vector3[];
  43158. dashSize?: number;
  43159. gapSize?: number;
  43160. dashNb?: number;
  43161. updatable?: boolean;
  43162. instance?: LinesMesh;
  43163. }, scene?: Nullable<Scene>): LinesMesh;
  43164. }
  43165. }
  43166. declare module "babylonjs/Debug/rayHelper" {
  43167. import { Nullable } from "babylonjs/types";
  43168. import { Ray } from "babylonjs/Culling/ray";
  43169. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43170. import { Scene } from "babylonjs/scene";
  43171. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43172. import "babylonjs/Meshes/Builders/linesBuilder";
  43173. /**
  43174. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43175. * in order to better appreciate the issue one might have.
  43176. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43177. */
  43178. export class RayHelper {
  43179. /**
  43180. * Defines the ray we are currently tryin to visualize.
  43181. */
  43182. ray: Nullable<Ray>;
  43183. private _renderPoints;
  43184. private _renderLine;
  43185. private _renderFunction;
  43186. private _scene;
  43187. private _updateToMeshFunction;
  43188. private _attachedToMesh;
  43189. private _meshSpaceDirection;
  43190. private _meshSpaceOrigin;
  43191. /**
  43192. * Helper function to create a colored helper in a scene in one line.
  43193. * @param ray Defines the ray we are currently tryin to visualize
  43194. * @param scene Defines the scene the ray is used in
  43195. * @param color Defines the color we want to see the ray in
  43196. * @returns The newly created ray helper.
  43197. */
  43198. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  43199. /**
  43200. * Instantiate a new ray helper.
  43201. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43202. * in order to better appreciate the issue one might have.
  43203. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43204. * @param ray Defines the ray we are currently tryin to visualize
  43205. */
  43206. constructor(ray: Ray);
  43207. /**
  43208. * Shows the ray we are willing to debug.
  43209. * @param scene Defines the scene the ray needs to be rendered in
  43210. * @param color Defines the color the ray needs to be rendered in
  43211. */
  43212. show(scene: Scene, color?: Color3): void;
  43213. /**
  43214. * Hides the ray we are debugging.
  43215. */
  43216. hide(): void;
  43217. private _render;
  43218. /**
  43219. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  43220. * @param mesh Defines the mesh we want the helper attached to
  43221. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  43222. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  43223. * @param length Defines the length of the ray
  43224. */
  43225. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  43226. /**
  43227. * Detach the ray helper from the mesh it has previously been attached to.
  43228. */
  43229. detachFromMesh(): void;
  43230. private _updateToMesh;
  43231. /**
  43232. * Dispose the helper and release its associated resources.
  43233. */
  43234. dispose(): void;
  43235. }
  43236. }
  43237. declare module "babylonjs/Debug/skeletonViewer" {
  43238. import { Color3 } from "babylonjs/Maths/math";
  43239. import { Scene } from "babylonjs/scene";
  43240. import { Nullable } from "babylonjs/types";
  43241. import { Skeleton } from "babylonjs/Bones/skeleton";
  43242. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43243. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  43244. /**
  43245. * Class used to render a debug view of a given skeleton
  43246. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  43247. */
  43248. export class SkeletonViewer {
  43249. /** defines the skeleton to render */
  43250. skeleton: Skeleton;
  43251. /** defines the mesh attached to the skeleton */
  43252. mesh: AbstractMesh;
  43253. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43254. autoUpdateBonesMatrices: boolean;
  43255. /** defines the rendering group id to use with the viewer */
  43256. renderingGroupId: number;
  43257. /** Gets or sets the color used to render the skeleton */
  43258. color: Color3;
  43259. private _scene;
  43260. private _debugLines;
  43261. private _debugMesh;
  43262. private _isEnabled;
  43263. private _renderFunction;
  43264. private _utilityLayer;
  43265. /**
  43266. * Returns the mesh used to render the bones
  43267. */
  43268. readonly debugMesh: Nullable<LinesMesh>;
  43269. /**
  43270. * Creates a new SkeletonViewer
  43271. * @param skeleton defines the skeleton to render
  43272. * @param mesh defines the mesh attached to the skeleton
  43273. * @param scene defines the hosting scene
  43274. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  43275. * @param renderingGroupId defines the rendering group id to use with the viewer
  43276. */
  43277. constructor(
  43278. /** defines the skeleton to render */
  43279. skeleton: Skeleton,
  43280. /** defines the mesh attached to the skeleton */
  43281. mesh: AbstractMesh, scene: Scene,
  43282. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43283. autoUpdateBonesMatrices?: boolean,
  43284. /** defines the rendering group id to use with the viewer */
  43285. renderingGroupId?: number);
  43286. /** Gets or sets a boolean indicating if the viewer is enabled */
  43287. isEnabled: boolean;
  43288. private _getBonePosition;
  43289. private _getLinesForBonesWithLength;
  43290. private _getLinesForBonesNoLength;
  43291. /** Update the viewer to sync with current skeleton state */
  43292. update(): void;
  43293. /** Release associated resources */
  43294. dispose(): void;
  43295. }
  43296. }
  43297. declare module "babylonjs/Debug/index" {
  43298. export * from "babylonjs/Debug/axesViewer";
  43299. export * from "babylonjs/Debug/boneAxesViewer";
  43300. export * from "babylonjs/Debug/debugLayer";
  43301. export * from "babylonjs/Debug/physicsViewer";
  43302. export * from "babylonjs/Debug/rayHelper";
  43303. export * from "babylonjs/Debug/skeletonViewer";
  43304. }
  43305. declare module "babylonjs/Engines/nullEngine" {
  43306. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  43307. import { Scene } from "babylonjs/scene";
  43308. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  43309. import { Engine } from "babylonjs/Engines/engine";
  43310. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  43311. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  43312. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  43313. import { Effect } from "babylonjs/Materials/effect";
  43314. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  43315. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  43316. /**
  43317. * Options to create the null engine
  43318. */
  43319. export class NullEngineOptions {
  43320. /**
  43321. * Render width (Default: 512)
  43322. */
  43323. renderWidth: number;
  43324. /**
  43325. * Render height (Default: 256)
  43326. */
  43327. renderHeight: number;
  43328. /**
  43329. * Texture size (Default: 512)
  43330. */
  43331. textureSize: number;
  43332. /**
  43333. * If delta time between frames should be constant
  43334. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43335. */
  43336. deterministicLockstep: boolean;
  43337. /**
  43338. * Maximum about of steps between frames (Default: 4)
  43339. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43340. */
  43341. lockstepMaxSteps: number;
  43342. }
  43343. /**
  43344. * The null engine class provides support for headless version of babylon.js.
  43345. * This can be used in server side scenario or for testing purposes
  43346. */
  43347. export class NullEngine extends Engine {
  43348. private _options;
  43349. /**
  43350. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43351. */
  43352. isDeterministicLockStep(): boolean;
  43353. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  43354. getLockstepMaxSteps(): number;
  43355. /**
  43356. * Sets hardware scaling, used to save performance if needed
  43357. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  43358. */
  43359. getHardwareScalingLevel(): number;
  43360. constructor(options?: NullEngineOptions);
  43361. createVertexBuffer(vertices: FloatArray): DataBuffer;
  43362. createIndexBuffer(indices: IndicesArray): DataBuffer;
  43363. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  43364. getRenderWidth(useScreen?: boolean): number;
  43365. getRenderHeight(useScreen?: boolean): number;
  43366. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  43367. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  43368. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  43369. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  43370. bindSamplers(effect: Effect): void;
  43371. enableEffect(effect: Effect): void;
  43372. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  43373. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  43374. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  43375. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  43376. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  43377. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  43378. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  43379. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  43380. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  43381. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  43382. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  43383. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  43384. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  43385. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  43386. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  43387. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43388. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43389. setFloat(uniform: WebGLUniformLocation, value: number): void;
  43390. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  43391. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  43392. setBool(uniform: WebGLUniformLocation, bool: number): void;
  43393. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  43394. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  43395. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  43396. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  43397. bindBuffers(vertexBuffers: {
  43398. [key: string]: VertexBuffer;
  43399. }, indexBuffer: DataBuffer, effect: Effect): void;
  43400. wipeCaches(bruteForce?: boolean): void;
  43401. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  43402. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  43403. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  43404. /** @hidden */
  43405. _createTexture(): WebGLTexture;
  43406. /** @hidden */
  43407. _releaseTexture(texture: InternalTexture): void;
  43408. 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;
  43409. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  43410. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  43411. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  43412. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  43413. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  43414. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  43415. areAllEffectsReady(): boolean;
  43416. /**
  43417. * @hidden
  43418. * Get the current error code of the webGL context
  43419. * @returns the error code
  43420. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  43421. */
  43422. getError(): number;
  43423. /** @hidden */
  43424. _getUnpackAlignement(): number;
  43425. /** @hidden */
  43426. _unpackFlipY(value: boolean): void;
  43427. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  43428. /**
  43429. * Updates a dynamic vertex buffer.
  43430. * @param vertexBuffer the vertex buffer to update
  43431. * @param data the data used to update the vertex buffer
  43432. * @param byteOffset the byte offset of the data (optional)
  43433. * @param byteLength the byte length of the data (optional)
  43434. */
  43435. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  43436. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  43437. /** @hidden */
  43438. _bindTexture(channel: number, texture: InternalTexture): void;
  43439. /** @hidden */
  43440. _releaseBuffer(buffer: DataBuffer): boolean;
  43441. releaseEffects(): void;
  43442. displayLoadingUI(): void;
  43443. hideLoadingUI(): void;
  43444. /** @hidden */
  43445. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43446. /** @hidden */
  43447. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43448. /** @hidden */
  43449. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43450. /** @hidden */
  43451. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  43452. }
  43453. }
  43454. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  43455. import { Nullable, int } from "babylonjs/types";
  43456. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  43457. /** @hidden */
  43458. export class _OcclusionDataStorage {
  43459. /** @hidden */
  43460. occlusionInternalRetryCounter: number;
  43461. /** @hidden */
  43462. isOcclusionQueryInProgress: boolean;
  43463. /** @hidden */
  43464. isOccluded: boolean;
  43465. /** @hidden */
  43466. occlusionRetryCount: number;
  43467. /** @hidden */
  43468. occlusionType: number;
  43469. /** @hidden */
  43470. occlusionQueryAlgorithmType: number;
  43471. }
  43472. module "babylonjs/Engines/engine" {
  43473. interface Engine {
  43474. /**
  43475. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  43476. * @return the new query
  43477. */
  43478. createQuery(): WebGLQuery;
  43479. /**
  43480. * Delete and release a webGL query
  43481. * @param query defines the query to delete
  43482. * @return the current engine
  43483. */
  43484. deleteQuery(query: WebGLQuery): Engine;
  43485. /**
  43486. * Check if a given query has resolved and got its value
  43487. * @param query defines the query to check
  43488. * @returns true if the query got its value
  43489. */
  43490. isQueryResultAvailable(query: WebGLQuery): boolean;
  43491. /**
  43492. * Gets the value of a given query
  43493. * @param query defines the query to check
  43494. * @returns the value of the query
  43495. */
  43496. getQueryResult(query: WebGLQuery): number;
  43497. /**
  43498. * Initiates an occlusion query
  43499. * @param algorithmType defines the algorithm to use
  43500. * @param query defines the query to use
  43501. * @returns the current engine
  43502. * @see http://doc.babylonjs.com/features/occlusionquery
  43503. */
  43504. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  43505. /**
  43506. * Ends an occlusion query
  43507. * @see http://doc.babylonjs.com/features/occlusionquery
  43508. * @param algorithmType defines the algorithm to use
  43509. * @returns the current engine
  43510. */
  43511. endOcclusionQuery(algorithmType: number): Engine;
  43512. /**
  43513. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  43514. * Please note that only one query can be issued at a time
  43515. * @returns a time token used to track the time span
  43516. */
  43517. startTimeQuery(): Nullable<_TimeToken>;
  43518. /**
  43519. * Ends a time query
  43520. * @param token defines the token used to measure the time span
  43521. * @returns the time spent (in ns)
  43522. */
  43523. endTimeQuery(token: _TimeToken): int;
  43524. /** @hidden */
  43525. _currentNonTimestampToken: Nullable<_TimeToken>;
  43526. /** @hidden */
  43527. _createTimeQuery(): WebGLQuery;
  43528. /** @hidden */
  43529. _deleteTimeQuery(query: WebGLQuery): void;
  43530. /** @hidden */
  43531. _getGlAlgorithmType(algorithmType: number): number;
  43532. /** @hidden */
  43533. _getTimeQueryResult(query: WebGLQuery): any;
  43534. /** @hidden */
  43535. _getTimeQueryAvailability(query: WebGLQuery): any;
  43536. }
  43537. }
  43538. module "babylonjs/Meshes/abstractMesh" {
  43539. interface AbstractMesh {
  43540. /**
  43541. * Backing filed
  43542. * @hidden
  43543. */
  43544. __occlusionDataStorage: _OcclusionDataStorage;
  43545. /**
  43546. * Access property
  43547. * @hidden
  43548. */
  43549. _occlusionDataStorage: _OcclusionDataStorage;
  43550. /**
  43551. * 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.
  43552. * The default value is -1 which means don't break the query and wait till the result
  43553. * @see http://doc.babylonjs.com/features/occlusionquery
  43554. */
  43555. occlusionRetryCount: number;
  43556. /**
  43557. * 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:
  43558. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  43559. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  43560. * * 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.
  43561. * @see http://doc.babylonjs.com/features/occlusionquery
  43562. */
  43563. occlusionType: number;
  43564. /**
  43565. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  43566. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  43567. * * 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.
  43568. * @see http://doc.babylonjs.com/features/occlusionquery
  43569. */
  43570. occlusionQueryAlgorithmType: number;
  43571. /**
  43572. * 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
  43573. * @see http://doc.babylonjs.com/features/occlusionquery
  43574. */
  43575. isOccluded: boolean;
  43576. /**
  43577. * Flag to check the progress status of the query
  43578. * @see http://doc.babylonjs.com/features/occlusionquery
  43579. */
  43580. isOcclusionQueryInProgress: boolean;
  43581. }
  43582. }
  43583. }
  43584. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  43585. import { Nullable } from "babylonjs/types";
  43586. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  43587. /** @hidden */
  43588. export var _forceTransformFeedbackToBundle: boolean;
  43589. module "babylonjs/Engines/engine" {
  43590. interface Engine {
  43591. /**
  43592. * Creates a webGL transform feedback object
  43593. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  43594. * @returns the webGL transform feedback object
  43595. */
  43596. createTransformFeedback(): WebGLTransformFeedback;
  43597. /**
  43598. * Delete a webGL transform feedback object
  43599. * @param value defines the webGL transform feedback object to delete
  43600. */
  43601. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  43602. /**
  43603. * Bind a webGL transform feedback object to the webgl context
  43604. * @param value defines the webGL transform feedback object to bind
  43605. */
  43606. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  43607. /**
  43608. * Begins a transform feedback operation
  43609. * @param usePoints defines if points or triangles must be used
  43610. */
  43611. beginTransformFeedback(usePoints: boolean): void;
  43612. /**
  43613. * Ends a transform feedback operation
  43614. */
  43615. endTransformFeedback(): void;
  43616. /**
  43617. * Specify the varyings to use with transform feedback
  43618. * @param program defines the associated webGL program
  43619. * @param value defines the list of strings representing the varying names
  43620. */
  43621. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  43622. /**
  43623. * Bind a webGL buffer for a transform feedback operation
  43624. * @param value defines the webGL buffer to bind
  43625. */
  43626. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  43627. }
  43628. }
  43629. }
  43630. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  43631. import { Scene } from "babylonjs/scene";
  43632. import { Engine } from "babylonjs/Engines/engine";
  43633. import { Texture } from "babylonjs/Materials/Textures/texture";
  43634. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  43635. import "babylonjs/Engines/Extensions/engine.multiRender";
  43636. /**
  43637. * Creation options of the multi render target texture.
  43638. */
  43639. export interface IMultiRenderTargetOptions {
  43640. /**
  43641. * Define if the texture needs to create mip maps after render.
  43642. */
  43643. generateMipMaps?: boolean;
  43644. /**
  43645. * Define the types of all the draw buffers we want to create
  43646. */
  43647. types?: number[];
  43648. /**
  43649. * Define the sampling modes of all the draw buffers we want to create
  43650. */
  43651. samplingModes?: number[];
  43652. /**
  43653. * Define if a depth buffer is required
  43654. */
  43655. generateDepthBuffer?: boolean;
  43656. /**
  43657. * Define if a stencil buffer is required
  43658. */
  43659. generateStencilBuffer?: boolean;
  43660. /**
  43661. * Define if a depth texture is required instead of a depth buffer
  43662. */
  43663. generateDepthTexture?: boolean;
  43664. /**
  43665. * Define the number of desired draw buffers
  43666. */
  43667. textureCount?: number;
  43668. /**
  43669. * Define if aspect ratio should be adapted to the texture or stay the scene one
  43670. */
  43671. doNotChangeAspectRatio?: boolean;
  43672. /**
  43673. * Define the default type of the buffers we are creating
  43674. */
  43675. defaultType?: number;
  43676. }
  43677. /**
  43678. * A multi render target, like a render target provides the ability to render to a texture.
  43679. * Unlike the render target, it can render to several draw buffers in one draw.
  43680. * This is specially interesting in deferred rendering or for any effects requiring more than
  43681. * just one color from a single pass.
  43682. */
  43683. export class MultiRenderTarget extends RenderTargetTexture {
  43684. private _internalTextures;
  43685. private _textures;
  43686. private _multiRenderTargetOptions;
  43687. /**
  43688. * Get if draw buffers are currently supported by the used hardware and browser.
  43689. */
  43690. readonly isSupported: boolean;
  43691. /**
  43692. * Get the list of textures generated by the multi render target.
  43693. */
  43694. readonly textures: Texture[];
  43695. /**
  43696. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  43697. */
  43698. readonly depthTexture: Texture;
  43699. /**
  43700. * Set the wrapping mode on U of all the textures we are rendering to.
  43701. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43702. */
  43703. wrapU: number;
  43704. /**
  43705. * Set the wrapping mode on V of all the textures we are rendering to.
  43706. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43707. */
  43708. wrapV: number;
  43709. /**
  43710. * Instantiate a new multi render target texture.
  43711. * A multi render target, like a render target provides the ability to render to a texture.
  43712. * Unlike the render target, it can render to several draw buffers in one draw.
  43713. * This is specially interesting in deferred rendering or for any effects requiring more than
  43714. * just one color from a single pass.
  43715. * @param name Define the name of the texture
  43716. * @param size Define the size of the buffers to render to
  43717. * @param count Define the number of target we are rendering into
  43718. * @param scene Define the scene the texture belongs to
  43719. * @param options Define the options used to create the multi render target
  43720. */
  43721. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  43722. /** @hidden */
  43723. _rebuild(): void;
  43724. private _createInternalTextures;
  43725. private _createTextures;
  43726. /**
  43727. * Define the number of samples used if MSAA is enabled.
  43728. */
  43729. samples: number;
  43730. /**
  43731. * Resize all the textures in the multi render target.
  43732. * Be carrefull as it will recreate all the data in the new texture.
  43733. * @param size Define the new size
  43734. */
  43735. resize(size: any): void;
  43736. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  43737. /**
  43738. * Dispose the render targets and their associated resources
  43739. */
  43740. dispose(): void;
  43741. /**
  43742. * Release all the underlying texture used as draw buffers.
  43743. */
  43744. releaseInternalTextures(): void;
  43745. }
  43746. }
  43747. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  43748. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  43749. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  43750. import { Nullable } from "babylonjs/types";
  43751. module "babylonjs/Engines/engine" {
  43752. interface Engine {
  43753. /**
  43754. * Unbind a list of render target textures from the webGL context
  43755. * This is used only when drawBuffer extension or webGL2 are active
  43756. * @param textures defines the render target textures to unbind
  43757. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  43758. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  43759. */
  43760. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  43761. /**
  43762. * Create a multi render target texture
  43763. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  43764. * @param size defines the size of the texture
  43765. * @param options defines the creation options
  43766. * @returns the cube texture as an InternalTexture
  43767. */
  43768. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  43769. /**
  43770. * Update the sample count for a given multiple render target texture
  43771. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  43772. * @param textures defines the textures to update
  43773. * @param samples defines the sample count to set
  43774. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  43775. */
  43776. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  43777. }
  43778. }
  43779. }
  43780. declare module "babylonjs/Engines/Extensions/index" {
  43781. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  43782. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  43783. export * from "babylonjs/Engines/Extensions/engine.multiview";
  43784. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  43785. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  43786. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  43787. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  43788. export * from "babylonjs/Engines/Extensions/engine.webVR";
  43789. }
  43790. declare module "babylonjs/Engines/index" {
  43791. export * from "babylonjs/Engines/constants";
  43792. export * from "babylonjs/Engines/engine";
  43793. export * from "babylonjs/Engines/engineStore";
  43794. export * from "babylonjs/Engines/nullEngine";
  43795. export * from "babylonjs/Engines/Extensions/index";
  43796. export * from "babylonjs/Engines/IPipelineContext";
  43797. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  43798. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  43799. }
  43800. declare module "babylonjs/Events/clipboardEvents" {
  43801. /**
  43802. * Gather the list of clipboard event types as constants.
  43803. */
  43804. export class ClipboardEventTypes {
  43805. /**
  43806. * The clipboard event is fired when a copy command is active (pressed).
  43807. */
  43808. static readonly COPY: number;
  43809. /**
  43810. * The clipboard event is fired when a cut command is active (pressed).
  43811. */
  43812. static readonly CUT: number;
  43813. /**
  43814. * The clipboard event is fired when a paste command is active (pressed).
  43815. */
  43816. static readonly PASTE: number;
  43817. }
  43818. /**
  43819. * This class is used to store clipboard related info for the onClipboardObservable event.
  43820. */
  43821. export class ClipboardInfo {
  43822. /**
  43823. * Defines the type of event (BABYLON.ClipboardEventTypes)
  43824. */
  43825. type: number;
  43826. /**
  43827. * Defines the related dom event
  43828. */
  43829. event: ClipboardEvent;
  43830. /**
  43831. *Creates an instance of ClipboardInfo.
  43832. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  43833. * @param event Defines the related dom event
  43834. */
  43835. constructor(
  43836. /**
  43837. * Defines the type of event (BABYLON.ClipboardEventTypes)
  43838. */
  43839. type: number,
  43840. /**
  43841. * Defines the related dom event
  43842. */
  43843. event: ClipboardEvent);
  43844. /**
  43845. * Get the clipboard event's type from the keycode.
  43846. * @param keyCode Defines the keyCode for the current keyboard event.
  43847. * @return {number}
  43848. */
  43849. static GetTypeFromCharacter(keyCode: number): number;
  43850. }
  43851. }
  43852. declare module "babylonjs/Events/index" {
  43853. export * from "babylonjs/Events/keyboardEvents";
  43854. export * from "babylonjs/Events/pointerEvents";
  43855. export * from "babylonjs/Events/clipboardEvents";
  43856. }
  43857. declare module "babylonjs/Loading/sceneLoader" {
  43858. import { Observable } from "babylonjs/Misc/observable";
  43859. import { Nullable } from "babylonjs/types";
  43860. import { Scene } from "babylonjs/scene";
  43861. import { Engine } from "babylonjs/Engines/engine";
  43862. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43863. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43864. import { AssetContainer } from "babylonjs/assetContainer";
  43865. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43866. import { Skeleton } from "babylonjs/Bones/skeleton";
  43867. /**
  43868. * Class used to represent data loading progression
  43869. */
  43870. export class SceneLoaderProgressEvent {
  43871. /** defines if data length to load can be evaluated */
  43872. readonly lengthComputable: boolean;
  43873. /** defines the loaded data length */
  43874. readonly loaded: number;
  43875. /** defines the data length to load */
  43876. readonly total: number;
  43877. /**
  43878. * Create a new progress event
  43879. * @param lengthComputable defines if data length to load can be evaluated
  43880. * @param loaded defines the loaded data length
  43881. * @param total defines the data length to load
  43882. */
  43883. constructor(
  43884. /** defines if data length to load can be evaluated */
  43885. lengthComputable: boolean,
  43886. /** defines the loaded data length */
  43887. loaded: number,
  43888. /** defines the data length to load */
  43889. total: number);
  43890. /**
  43891. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43892. * @param event defines the source event
  43893. * @returns a new SceneLoaderProgressEvent
  43894. */
  43895. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43896. }
  43897. /**
  43898. * Interface used by SceneLoader plugins to define supported file extensions
  43899. */
  43900. export interface ISceneLoaderPluginExtensions {
  43901. /**
  43902. * Defines the list of supported extensions
  43903. */
  43904. [extension: string]: {
  43905. isBinary: boolean;
  43906. };
  43907. }
  43908. /**
  43909. * Interface used by SceneLoader plugin factory
  43910. */
  43911. export interface ISceneLoaderPluginFactory {
  43912. /**
  43913. * Defines the name of the factory
  43914. */
  43915. name: string;
  43916. /**
  43917. * Function called to create a new plugin
  43918. * @return the new plugin
  43919. */
  43920. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43921. /**
  43922. * Boolean indicating if the plugin can direct load specific data
  43923. */
  43924. canDirectLoad?: (data: string) => boolean;
  43925. }
  43926. /**
  43927. * Interface used to define a SceneLoader plugin
  43928. */
  43929. export interface ISceneLoaderPlugin {
  43930. /**
  43931. * The friendly name of this plugin.
  43932. */
  43933. name: string;
  43934. /**
  43935. * The file extensions supported by this plugin.
  43936. */
  43937. extensions: string | ISceneLoaderPluginExtensions;
  43938. /**
  43939. * Import meshes into a scene.
  43940. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43941. * @param scene The scene to import into
  43942. * @param data The data to import
  43943. * @param rootUrl The root url for scene and resources
  43944. * @param meshes The meshes array to import into
  43945. * @param particleSystems The particle systems array to import into
  43946. * @param skeletons The skeletons array to import into
  43947. * @param onError The callback when import fails
  43948. * @returns True if successful or false otherwise
  43949. */
  43950. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43951. /**
  43952. * Load into a scene.
  43953. * @param scene The scene to load into
  43954. * @param data The data to import
  43955. * @param rootUrl The root url for scene and resources
  43956. * @param onError The callback when import fails
  43957. * @returns true if successful or false otherwise
  43958. */
  43959. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43960. /**
  43961. * The callback that returns true if the data can be directly loaded.
  43962. */
  43963. canDirectLoad?: (data: string) => boolean;
  43964. /**
  43965. * The callback that allows custom handling of the root url based on the response url.
  43966. */
  43967. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43968. /**
  43969. * Load into an asset container.
  43970. * @param scene The scene to load into
  43971. * @param data The data to import
  43972. * @param rootUrl The root url for scene and resources
  43973. * @param onError The callback when import fails
  43974. * @returns The loaded asset container
  43975. */
  43976. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43977. }
  43978. /**
  43979. * Interface used to define an async SceneLoader plugin
  43980. */
  43981. export interface ISceneLoaderPluginAsync {
  43982. /**
  43983. * The friendly name of this plugin.
  43984. */
  43985. name: string;
  43986. /**
  43987. * The file extensions supported by this plugin.
  43988. */
  43989. extensions: string | ISceneLoaderPluginExtensions;
  43990. /**
  43991. * Import meshes into a scene.
  43992. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43993. * @param scene The scene to import into
  43994. * @param data The data to import
  43995. * @param rootUrl The root url for scene and resources
  43996. * @param onProgress The callback when the load progresses
  43997. * @param fileName Defines the name of the file to load
  43998. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43999. */
  44000. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  44001. meshes: AbstractMesh[];
  44002. particleSystems: IParticleSystem[];
  44003. skeletons: Skeleton[];
  44004. animationGroups: AnimationGroup[];
  44005. }>;
  44006. /**
  44007. * Load into a scene.
  44008. * @param scene The scene to load into
  44009. * @param data The data to import
  44010. * @param rootUrl The root url for scene and resources
  44011. * @param onProgress The callback when the load progresses
  44012. * @param fileName Defines the name of the file to load
  44013. * @returns Nothing
  44014. */
  44015. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  44016. /**
  44017. * The callback that returns true if the data can be directly loaded.
  44018. */
  44019. canDirectLoad?: (data: string) => boolean;
  44020. /**
  44021. * The callback that allows custom handling of the root url based on the response url.
  44022. */
  44023. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  44024. /**
  44025. * Load into an asset container.
  44026. * @param scene The scene to load into
  44027. * @param data The data to import
  44028. * @param rootUrl The root url for scene and resources
  44029. * @param onProgress The callback when the load progresses
  44030. * @param fileName Defines the name of the file to load
  44031. * @returns The loaded asset container
  44032. */
  44033. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  44034. }
  44035. /**
  44036. * Class used to load scene from various file formats using registered plugins
  44037. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  44038. */
  44039. export class SceneLoader {
  44040. /**
  44041. * No logging while loading
  44042. */
  44043. static readonly NO_LOGGING: number;
  44044. /**
  44045. * Minimal logging while loading
  44046. */
  44047. static readonly MINIMAL_LOGGING: number;
  44048. /**
  44049. * Summary logging while loading
  44050. */
  44051. static readonly SUMMARY_LOGGING: number;
  44052. /**
  44053. * Detailled logging while loading
  44054. */
  44055. static readonly DETAILED_LOGGING: number;
  44056. /**
  44057. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  44058. */
  44059. static ForceFullSceneLoadingForIncremental: boolean;
  44060. /**
  44061. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  44062. */
  44063. static ShowLoadingScreen: boolean;
  44064. /**
  44065. * Defines the current logging level (while loading the scene)
  44066. * @ignorenaming
  44067. */
  44068. static loggingLevel: number;
  44069. /**
  44070. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  44071. */
  44072. static CleanBoneMatrixWeights: boolean;
  44073. /**
  44074. * Event raised when a plugin is used to load a scene
  44075. */
  44076. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  44077. private static _registeredPlugins;
  44078. private static _getDefaultPlugin;
  44079. private static _getPluginForExtension;
  44080. private static _getPluginForDirectLoad;
  44081. private static _getPluginForFilename;
  44082. private static _getDirectLoad;
  44083. private static _loadData;
  44084. private static _getFileInfo;
  44085. /**
  44086. * Gets a plugin that can load the given extension
  44087. * @param extension defines the extension to load
  44088. * @returns a plugin or null if none works
  44089. */
  44090. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  44091. /**
  44092. * Gets a boolean indicating that the given extension can be loaded
  44093. * @param extension defines the extension to load
  44094. * @returns true if the extension is supported
  44095. */
  44096. static IsPluginForExtensionAvailable(extension: string): boolean;
  44097. /**
  44098. * Adds a new plugin to the list of registered plugins
  44099. * @param plugin defines the plugin to add
  44100. */
  44101. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  44102. /**
  44103. * Import meshes into a scene
  44104. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44105. * @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)
  44106. * @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)
  44107. * @param scene the instance of BABYLON.Scene to append to
  44108. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  44109. * @param onProgress a callback with a progress event for each file being loaded
  44110. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44111. * @param pluginExtension the extension used to determine the plugin
  44112. * @returns The loaded plugin
  44113. */
  44114. 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>;
  44115. /**
  44116. * Import meshes into a scene
  44117. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44118. * @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)
  44119. * @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)
  44120. * @param scene the instance of BABYLON.Scene to append to
  44121. * @param onProgress a callback with a progress event for each file being loaded
  44122. * @param pluginExtension the extension used to determine the plugin
  44123. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  44124. */
  44125. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  44126. meshes: AbstractMesh[];
  44127. particleSystems: IParticleSystem[];
  44128. skeletons: Skeleton[];
  44129. animationGroups: AnimationGroup[];
  44130. }>;
  44131. /**
  44132. * Load a scene
  44133. * @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)
  44134. * @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)
  44135. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44136. * @param onSuccess a callback with the scene when import succeeds
  44137. * @param onProgress a callback with a progress event for each file being loaded
  44138. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44139. * @param pluginExtension the extension used to determine the plugin
  44140. * @returns The loaded plugin
  44141. */
  44142. 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>;
  44143. /**
  44144. * Load a scene
  44145. * @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)
  44146. * @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)
  44147. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44148. * @param onProgress a callback with a progress event for each file being loaded
  44149. * @param pluginExtension the extension used to determine the plugin
  44150. * @returns The loaded scene
  44151. */
  44152. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44153. /**
  44154. * Append a scene
  44155. * @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)
  44156. * @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)
  44157. * @param scene is the instance of BABYLON.Scene to append to
  44158. * @param onSuccess a callback with the scene when import succeeds
  44159. * @param onProgress a callback with a progress event for each file being loaded
  44160. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44161. * @param pluginExtension the extension used to determine the plugin
  44162. * @returns The loaded plugin
  44163. */
  44164. 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>;
  44165. /**
  44166. * Append a scene
  44167. * @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)
  44168. * @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)
  44169. * @param scene is the instance of BABYLON.Scene to append to
  44170. * @param onProgress a callback with a progress event for each file being loaded
  44171. * @param pluginExtension the extension used to determine the plugin
  44172. * @returns The given scene
  44173. */
  44174. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44175. /**
  44176. * Load a scene into an asset container
  44177. * @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)
  44178. * @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)
  44179. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44180. * @param onSuccess a callback with the scene when import succeeds
  44181. * @param onProgress a callback with a progress event for each file being loaded
  44182. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44183. * @param pluginExtension the extension used to determine the plugin
  44184. * @returns The loaded plugin
  44185. */
  44186. 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>;
  44187. /**
  44188. * Load a scene into an asset container
  44189. * @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)
  44190. * @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)
  44191. * @param scene is the instance of Scene to append to
  44192. * @param onProgress a callback with a progress event for each file being loaded
  44193. * @param pluginExtension the extension used to determine the plugin
  44194. * @returns The loaded asset container
  44195. */
  44196. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  44197. }
  44198. }
  44199. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  44200. import { Scene } from "babylonjs/scene";
  44201. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44202. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44203. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44204. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44205. /**
  44206. * Google Daydream controller
  44207. */
  44208. export class DaydreamController extends WebVRController {
  44209. /**
  44210. * Base Url for the controller model.
  44211. */
  44212. static MODEL_BASE_URL: string;
  44213. /**
  44214. * File name for the controller model.
  44215. */
  44216. static MODEL_FILENAME: string;
  44217. /**
  44218. * Gamepad Id prefix used to identify Daydream Controller.
  44219. */
  44220. static readonly GAMEPAD_ID_PREFIX: string;
  44221. /**
  44222. * Creates a new DaydreamController from a gamepad
  44223. * @param vrGamepad the gamepad that the controller should be created from
  44224. */
  44225. constructor(vrGamepad: any);
  44226. /**
  44227. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44228. * @param scene scene in which to add meshes
  44229. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44230. */
  44231. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44232. /**
  44233. * Called once for each button that changed state since the last frame
  44234. * @param buttonIdx Which button index changed
  44235. * @param state New state of the button
  44236. * @param changes Which properties on the state changed since last frame
  44237. */
  44238. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44239. }
  44240. }
  44241. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  44242. import { Scene } from "babylonjs/scene";
  44243. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44244. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44245. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44246. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44247. /**
  44248. * Gear VR Controller
  44249. */
  44250. export class GearVRController extends WebVRController {
  44251. /**
  44252. * Base Url for the controller model.
  44253. */
  44254. static MODEL_BASE_URL: string;
  44255. /**
  44256. * File name for the controller model.
  44257. */
  44258. static MODEL_FILENAME: string;
  44259. /**
  44260. * Gamepad Id prefix used to identify this controller.
  44261. */
  44262. static readonly GAMEPAD_ID_PREFIX: string;
  44263. private readonly _buttonIndexToObservableNameMap;
  44264. /**
  44265. * Creates a new GearVRController from a gamepad
  44266. * @param vrGamepad the gamepad that the controller should be created from
  44267. */
  44268. constructor(vrGamepad: any);
  44269. /**
  44270. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44271. * @param scene scene in which to add meshes
  44272. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44273. */
  44274. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44275. /**
  44276. * Called once for each button that changed state since the last frame
  44277. * @param buttonIdx Which button index changed
  44278. * @param state New state of the button
  44279. * @param changes Which properties on the state changed since last frame
  44280. */
  44281. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44282. }
  44283. }
  44284. declare module "babylonjs/Gamepads/Controllers/genericController" {
  44285. import { Scene } from "babylonjs/scene";
  44286. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44287. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44288. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44289. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44290. /**
  44291. * Generic Controller
  44292. */
  44293. export class GenericController extends WebVRController {
  44294. /**
  44295. * Base Url for the controller model.
  44296. */
  44297. static readonly MODEL_BASE_URL: string;
  44298. /**
  44299. * File name for the controller model.
  44300. */
  44301. static readonly MODEL_FILENAME: string;
  44302. /**
  44303. * Creates a new GenericController from a gamepad
  44304. * @param vrGamepad the gamepad that the controller should be created from
  44305. */
  44306. constructor(vrGamepad: any);
  44307. /**
  44308. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44309. * @param scene scene in which to add meshes
  44310. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44311. */
  44312. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44313. /**
  44314. * Called once for each button that changed state since the last frame
  44315. * @param buttonIdx Which button index changed
  44316. * @param state New state of the button
  44317. * @param changes Which properties on the state changed since last frame
  44318. */
  44319. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44320. }
  44321. }
  44322. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  44323. import { Observable } from "babylonjs/Misc/observable";
  44324. import { Scene } from "babylonjs/scene";
  44325. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44326. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44327. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44328. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44329. /**
  44330. * Oculus Touch Controller
  44331. */
  44332. export class OculusTouchController extends WebVRController {
  44333. /**
  44334. * Base Url for the controller model.
  44335. */
  44336. static MODEL_BASE_URL: string;
  44337. /**
  44338. * File name for the left controller model.
  44339. */
  44340. static MODEL_LEFT_FILENAME: string;
  44341. /**
  44342. * File name for the right controller model.
  44343. */
  44344. static MODEL_RIGHT_FILENAME: string;
  44345. /**
  44346. * Fired when the secondary trigger on this controller is modified
  44347. */
  44348. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  44349. /**
  44350. * Fired when the thumb rest on this controller is modified
  44351. */
  44352. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  44353. /**
  44354. * Creates a new OculusTouchController from a gamepad
  44355. * @param vrGamepad the gamepad that the controller should be created from
  44356. */
  44357. constructor(vrGamepad: any);
  44358. /**
  44359. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44360. * @param scene scene in which to add meshes
  44361. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44362. */
  44363. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44364. /**
  44365. * Fired when the A button on this controller is modified
  44366. */
  44367. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44368. /**
  44369. * Fired when the B button on this controller is modified
  44370. */
  44371. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44372. /**
  44373. * Fired when the X button on this controller is modified
  44374. */
  44375. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44376. /**
  44377. * Fired when the Y button on this controller is modified
  44378. */
  44379. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44380. /**
  44381. * Called once for each button that changed state since the last frame
  44382. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  44383. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  44384. * 2) secondary trigger (same)
  44385. * 3) A (right) X (left), touch, pressed = value
  44386. * 4) B / Y
  44387. * 5) thumb rest
  44388. * @param buttonIdx Which button index changed
  44389. * @param state New state of the button
  44390. * @param changes Which properties on the state changed since last frame
  44391. */
  44392. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44393. }
  44394. }
  44395. declare module "babylonjs/Gamepads/Controllers/viveController" {
  44396. import { Scene } from "babylonjs/scene";
  44397. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44398. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44399. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44400. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44401. import { Observable } from "babylonjs/Misc/observable";
  44402. /**
  44403. * Vive Controller
  44404. */
  44405. export class ViveController extends WebVRController {
  44406. /**
  44407. * Base Url for the controller model.
  44408. */
  44409. static MODEL_BASE_URL: string;
  44410. /**
  44411. * File name for the controller model.
  44412. */
  44413. static MODEL_FILENAME: string;
  44414. /**
  44415. * Creates a new ViveController from a gamepad
  44416. * @param vrGamepad the gamepad that the controller should be created from
  44417. */
  44418. constructor(vrGamepad: any);
  44419. /**
  44420. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44421. * @param scene scene in which to add meshes
  44422. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44423. */
  44424. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44425. /**
  44426. * Fired when the left button on this controller is modified
  44427. */
  44428. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44429. /**
  44430. * Fired when the right button on this controller is modified
  44431. */
  44432. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44433. /**
  44434. * Fired when the menu button on this controller is modified
  44435. */
  44436. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44437. /**
  44438. * Called once for each button that changed state since the last frame
  44439. * Vive mapping:
  44440. * 0: touchpad
  44441. * 1: trigger
  44442. * 2: left AND right buttons
  44443. * 3: menu button
  44444. * @param buttonIdx Which button index changed
  44445. * @param state New state of the button
  44446. * @param changes Which properties on the state changed since last frame
  44447. */
  44448. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44449. }
  44450. }
  44451. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  44452. import { Observable } from "babylonjs/Misc/observable";
  44453. import { Scene } from "babylonjs/scene";
  44454. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44455. import { Ray } from "babylonjs/Culling/ray";
  44456. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44457. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44458. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44459. /**
  44460. * Defines the WindowsMotionController object that the state of the windows motion controller
  44461. */
  44462. export class WindowsMotionController extends WebVRController {
  44463. /**
  44464. * The base url used to load the left and right controller models
  44465. */
  44466. static MODEL_BASE_URL: string;
  44467. /**
  44468. * The name of the left controller model file
  44469. */
  44470. static MODEL_LEFT_FILENAME: string;
  44471. /**
  44472. * The name of the right controller model file
  44473. */
  44474. static MODEL_RIGHT_FILENAME: string;
  44475. /**
  44476. * The controller name prefix for this controller type
  44477. */
  44478. static readonly GAMEPAD_ID_PREFIX: string;
  44479. /**
  44480. * The controller id pattern for this controller type
  44481. */
  44482. private static readonly GAMEPAD_ID_PATTERN;
  44483. private _loadedMeshInfo;
  44484. private readonly _mapping;
  44485. /**
  44486. * Fired when the trackpad on this controller is clicked
  44487. */
  44488. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44489. /**
  44490. * Fired when the trackpad on this controller is modified
  44491. */
  44492. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44493. /**
  44494. * The current x and y values of this controller's trackpad
  44495. */
  44496. trackpad: StickValues;
  44497. /**
  44498. * Creates a new WindowsMotionController from a gamepad
  44499. * @param vrGamepad the gamepad that the controller should be created from
  44500. */
  44501. constructor(vrGamepad: any);
  44502. /**
  44503. * Fired when the trigger on this controller is modified
  44504. */
  44505. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44506. /**
  44507. * Fired when the menu button on this controller is modified
  44508. */
  44509. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44510. /**
  44511. * Fired when the grip button on this controller is modified
  44512. */
  44513. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44514. /**
  44515. * Fired when the thumbstick button on this controller is modified
  44516. */
  44517. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44518. /**
  44519. * Fired when the touchpad button on this controller is modified
  44520. */
  44521. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44522. /**
  44523. * Fired when the touchpad values on this controller are modified
  44524. */
  44525. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  44526. private _updateTrackpad;
  44527. /**
  44528. * Called once per frame by the engine.
  44529. */
  44530. update(): void;
  44531. /**
  44532. * Called once for each button that changed state since the last frame
  44533. * @param buttonIdx Which button index changed
  44534. * @param state New state of the button
  44535. * @param changes Which properties on the state changed since last frame
  44536. */
  44537. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44538. /**
  44539. * Moves the buttons on the controller mesh based on their current state
  44540. * @param buttonName the name of the button to move
  44541. * @param buttonValue the value of the button which determines the buttons new position
  44542. */
  44543. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  44544. /**
  44545. * Moves the axis on the controller mesh based on its current state
  44546. * @param axis the index of the axis
  44547. * @param axisValue the value of the axis which determines the meshes new position
  44548. * @hidden
  44549. */
  44550. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  44551. /**
  44552. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44553. * @param scene scene in which to add meshes
  44554. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44555. */
  44556. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  44557. /**
  44558. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  44559. * can be transformed by button presses and axes values, based on this._mapping.
  44560. *
  44561. * @param scene scene in which the meshes exist
  44562. * @param meshes list of meshes that make up the controller model to process
  44563. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  44564. */
  44565. private processModel;
  44566. private createMeshInfo;
  44567. /**
  44568. * Gets the ray of the controller in the direction the controller is pointing
  44569. * @param length the length the resulting ray should be
  44570. * @returns a ray in the direction the controller is pointing
  44571. */
  44572. getForwardRay(length?: number): Ray;
  44573. /**
  44574. * Disposes of the controller
  44575. */
  44576. dispose(): void;
  44577. }
  44578. }
  44579. declare module "babylonjs/Gamepads/Controllers/index" {
  44580. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  44581. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  44582. export * from "babylonjs/Gamepads/Controllers/genericController";
  44583. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  44584. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44585. export * from "babylonjs/Gamepads/Controllers/viveController";
  44586. export * from "babylonjs/Gamepads/Controllers/webVRController";
  44587. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  44588. }
  44589. declare module "babylonjs/Gamepads/index" {
  44590. export * from "babylonjs/Gamepads/Controllers/index";
  44591. export * from "babylonjs/Gamepads/gamepad";
  44592. export * from "babylonjs/Gamepads/gamepadManager";
  44593. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  44594. export * from "babylonjs/Gamepads/xboxGamepad";
  44595. }
  44596. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  44597. import { Scene } from "babylonjs/scene";
  44598. import { Color4, Vector4 } from "babylonjs/Maths/math";
  44599. import { Mesh } from "babylonjs/Meshes/mesh";
  44600. import { Nullable } from "babylonjs/types";
  44601. /**
  44602. * Class containing static functions to help procedurally build meshes
  44603. */
  44604. export class PolyhedronBuilder {
  44605. /**
  44606. * Creates a polyhedron mesh
  44607. * * 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
  44608. * * The parameter `size` (positive float, default 1) sets the polygon size
  44609. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  44610. * * 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`
  44611. * * 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
  44612. * * 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)`)
  44613. * * 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
  44614. * * 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
  44615. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44616. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44617. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44618. * @param name defines the name of the mesh
  44619. * @param options defines the options used to create the mesh
  44620. * @param scene defines the hosting scene
  44621. * @returns the polyhedron mesh
  44622. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  44623. */
  44624. static CreatePolyhedron(name: string, options: {
  44625. type?: number;
  44626. size?: number;
  44627. sizeX?: number;
  44628. sizeY?: number;
  44629. sizeZ?: number;
  44630. custom?: any;
  44631. faceUV?: Vector4[];
  44632. faceColors?: Color4[];
  44633. flat?: boolean;
  44634. updatable?: boolean;
  44635. sideOrientation?: number;
  44636. frontUVs?: Vector4;
  44637. backUVs?: Vector4;
  44638. }, scene?: Nullable<Scene>): Mesh;
  44639. }
  44640. }
  44641. declare module "babylonjs/Gizmos/scaleGizmo" {
  44642. import { Observable } from "babylonjs/Misc/observable";
  44643. import { Nullable } from "babylonjs/types";
  44644. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44645. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44646. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  44647. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44648. /**
  44649. * Gizmo that enables scaling a mesh along 3 axis
  44650. */
  44651. export class ScaleGizmo extends Gizmo {
  44652. /**
  44653. * Internal gizmo used for interactions on the x axis
  44654. */
  44655. xGizmo: AxisScaleGizmo;
  44656. /**
  44657. * Internal gizmo used for interactions on the y axis
  44658. */
  44659. yGizmo: AxisScaleGizmo;
  44660. /**
  44661. * Internal gizmo used for interactions on the z axis
  44662. */
  44663. zGizmo: AxisScaleGizmo;
  44664. /**
  44665. * Internal gizmo used to scale all axis equally
  44666. */
  44667. uniformScaleGizmo: AxisScaleGizmo;
  44668. private _meshAttached;
  44669. private _updateGizmoRotationToMatchAttachedMesh;
  44670. private _snapDistance;
  44671. private _scaleRatio;
  44672. private _uniformScalingMesh;
  44673. private _octahedron;
  44674. /** Fires an event when any of it's sub gizmos are dragged */
  44675. onDragStartObservable: Observable<{}>;
  44676. /** Fires an event when any of it's sub gizmos are released from dragging */
  44677. onDragEndObservable: Observable<{}>;
  44678. attachedMesh: Nullable<AbstractMesh>;
  44679. /**
  44680. * Creates a ScaleGizmo
  44681. * @param gizmoLayer The utility layer the gizmo will be added to
  44682. */
  44683. constructor(gizmoLayer?: UtilityLayerRenderer);
  44684. updateGizmoRotationToMatchAttachedMesh: boolean;
  44685. /**
  44686. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44687. */
  44688. snapDistance: number;
  44689. /**
  44690. * Ratio for the scale of the gizmo (Default: 1)
  44691. */
  44692. scaleRatio: number;
  44693. /**
  44694. * Disposes of the gizmo
  44695. */
  44696. dispose(): void;
  44697. }
  44698. }
  44699. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  44700. import { Observable } from "babylonjs/Misc/observable";
  44701. import { Nullable } from "babylonjs/types";
  44702. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44703. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44704. import { Mesh } from "babylonjs/Meshes/mesh";
  44705. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44706. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44707. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44708. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  44709. /**
  44710. * Single axis scale gizmo
  44711. */
  44712. export class AxisScaleGizmo extends Gizmo {
  44713. /**
  44714. * Drag behavior responsible for the gizmos dragging interactions
  44715. */
  44716. dragBehavior: PointerDragBehavior;
  44717. private _pointerObserver;
  44718. /**
  44719. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44720. */
  44721. snapDistance: number;
  44722. /**
  44723. * Event that fires each time the gizmo snaps to a new location.
  44724. * * snapDistance is the the change in distance
  44725. */
  44726. onSnapObservable: Observable<{
  44727. snapDistance: number;
  44728. }>;
  44729. /**
  44730. * If the scaling operation should be done on all axis (default: false)
  44731. */
  44732. uniformScaling: boolean;
  44733. private _isEnabled;
  44734. private _parent;
  44735. private _arrow;
  44736. private _coloredMaterial;
  44737. private _hoverMaterial;
  44738. /**
  44739. * Creates an AxisScaleGizmo
  44740. * @param gizmoLayer The utility layer the gizmo will be added to
  44741. * @param dragAxis The axis which the gizmo will be able to scale on
  44742. * @param color The color of the gizmo
  44743. */
  44744. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  44745. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44746. /**
  44747. * If the gizmo is enabled
  44748. */
  44749. isEnabled: boolean;
  44750. /**
  44751. * Disposes of the gizmo
  44752. */
  44753. dispose(): void;
  44754. /**
  44755. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44756. * @param mesh The mesh to replace the default mesh of the gizmo
  44757. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  44758. */
  44759. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  44760. }
  44761. }
  44762. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  44763. import { Observable } from "babylonjs/Misc/observable";
  44764. import { Nullable } from "babylonjs/types";
  44765. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44766. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44767. import { Mesh } from "babylonjs/Meshes/mesh";
  44768. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44769. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44770. import "babylonjs/Meshes/Builders/boxBuilder";
  44771. /**
  44772. * Bounding box gizmo
  44773. */
  44774. export class BoundingBoxGizmo extends Gizmo {
  44775. private _lineBoundingBox;
  44776. private _rotateSpheresParent;
  44777. private _scaleBoxesParent;
  44778. private _boundingDimensions;
  44779. private _renderObserver;
  44780. private _pointerObserver;
  44781. private _scaleDragSpeed;
  44782. private _tmpQuaternion;
  44783. private _tmpVector;
  44784. private _tmpRotationMatrix;
  44785. /**
  44786. * 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)
  44787. */
  44788. ignoreChildren: boolean;
  44789. /**
  44790. * 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)
  44791. */
  44792. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  44793. /**
  44794. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  44795. */
  44796. rotationSphereSize: number;
  44797. /**
  44798. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  44799. */
  44800. scaleBoxSize: number;
  44801. /**
  44802. * 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)
  44803. */
  44804. fixedDragMeshScreenSize: boolean;
  44805. /**
  44806. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  44807. */
  44808. fixedDragMeshScreenSizeDistanceFactor: number;
  44809. /**
  44810. * Fired when a rotation sphere or scale box is dragged
  44811. */
  44812. onDragStartObservable: Observable<{}>;
  44813. /**
  44814. * Fired when a scale box is dragged
  44815. */
  44816. onScaleBoxDragObservable: Observable<{}>;
  44817. /**
  44818. * Fired when a scale box drag is ended
  44819. */
  44820. onScaleBoxDragEndObservable: Observable<{}>;
  44821. /**
  44822. * Fired when a rotation sphere is dragged
  44823. */
  44824. onRotationSphereDragObservable: Observable<{}>;
  44825. /**
  44826. * Fired when a rotation sphere drag is ended
  44827. */
  44828. onRotationSphereDragEndObservable: Observable<{}>;
  44829. /**
  44830. * 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)
  44831. */
  44832. scalePivot: Nullable<Vector3>;
  44833. /**
  44834. * Mesh used as a pivot to rotate the attached mesh
  44835. */
  44836. private _anchorMesh;
  44837. private _existingMeshScale;
  44838. private _dragMesh;
  44839. private pointerDragBehavior;
  44840. private coloredMaterial;
  44841. private hoverColoredMaterial;
  44842. /**
  44843. * Sets the color of the bounding box gizmo
  44844. * @param color the color to set
  44845. */
  44846. setColor(color: Color3): void;
  44847. /**
  44848. * Creates an BoundingBoxGizmo
  44849. * @param gizmoLayer The utility layer the gizmo will be added to
  44850. * @param color The color of the gizmo
  44851. */
  44852. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  44853. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44854. private _selectNode;
  44855. /**
  44856. * Updates the bounding box information for the Gizmo
  44857. */
  44858. updateBoundingBox(): void;
  44859. private _updateRotationSpheres;
  44860. private _updateScaleBoxes;
  44861. /**
  44862. * Enables rotation on the specified axis and disables rotation on the others
  44863. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  44864. */
  44865. setEnabledRotationAxis(axis: string): void;
  44866. /**
  44867. * Enables/disables scaling
  44868. * @param enable if scaling should be enabled
  44869. */
  44870. setEnabledScaling(enable: boolean): void;
  44871. private _updateDummy;
  44872. /**
  44873. * Enables a pointer drag behavior on the bounding box of the gizmo
  44874. */
  44875. enableDragBehavior(): void;
  44876. /**
  44877. * Disposes of the gizmo
  44878. */
  44879. dispose(): void;
  44880. /**
  44881. * 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)
  44882. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  44883. * @returns the bounding box mesh with the passed in mesh as a child
  44884. */
  44885. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  44886. /**
  44887. * CustomMeshes are not supported by this gizmo
  44888. * @param mesh The mesh to replace the default mesh of the gizmo
  44889. */
  44890. setCustomMesh(mesh: Mesh): void;
  44891. }
  44892. }
  44893. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  44894. import { Observable } from "babylonjs/Misc/observable";
  44895. import { Nullable } from "babylonjs/types";
  44896. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44897. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44898. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44899. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44900. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44901. import "babylonjs/Meshes/Builders/linesBuilder";
  44902. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  44903. /**
  44904. * Single plane rotation gizmo
  44905. */
  44906. export class PlaneRotationGizmo extends Gizmo {
  44907. /**
  44908. * Drag behavior responsible for the gizmos dragging interactions
  44909. */
  44910. dragBehavior: PointerDragBehavior;
  44911. private _pointerObserver;
  44912. /**
  44913. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  44914. */
  44915. snapDistance: number;
  44916. /**
  44917. * Event that fires each time the gizmo snaps to a new location.
  44918. * * snapDistance is the the change in distance
  44919. */
  44920. onSnapObservable: Observable<{
  44921. snapDistance: number;
  44922. }>;
  44923. private _isEnabled;
  44924. private _parent;
  44925. /**
  44926. * Creates a PlaneRotationGizmo
  44927. * @param gizmoLayer The utility layer the gizmo will be added to
  44928. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  44929. * @param color The color of the gizmo
  44930. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44931. */
  44932. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>);
  44933. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44934. /**
  44935. * If the gizmo is enabled
  44936. */
  44937. isEnabled: boolean;
  44938. /**
  44939. * Disposes of the gizmo
  44940. */
  44941. dispose(): void;
  44942. }
  44943. }
  44944. declare module "babylonjs/Gizmos/rotationGizmo" {
  44945. import { Observable } from "babylonjs/Misc/observable";
  44946. import { Nullable } from "babylonjs/types";
  44947. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44948. import { Mesh } from "babylonjs/Meshes/mesh";
  44949. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44950. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  44951. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44952. /**
  44953. * Gizmo that enables rotating a mesh along 3 axis
  44954. */
  44955. export class RotationGizmo extends Gizmo {
  44956. /**
  44957. * Internal gizmo used for interactions on the x axis
  44958. */
  44959. xGizmo: PlaneRotationGizmo;
  44960. /**
  44961. * Internal gizmo used for interactions on the y axis
  44962. */
  44963. yGizmo: PlaneRotationGizmo;
  44964. /**
  44965. * Internal gizmo used for interactions on the z axis
  44966. */
  44967. zGizmo: PlaneRotationGizmo;
  44968. /** Fires an event when any of it's sub gizmos are dragged */
  44969. onDragStartObservable: Observable<{}>;
  44970. /** Fires an event when any of it's sub gizmos are released from dragging */
  44971. onDragEndObservable: Observable<{}>;
  44972. private _meshAttached;
  44973. attachedMesh: Nullable<AbstractMesh>;
  44974. /**
  44975. * Creates a RotationGizmo
  44976. * @param gizmoLayer The utility layer the gizmo will be added to
  44977. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44978. */
  44979. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  44980. updateGizmoRotationToMatchAttachedMesh: boolean;
  44981. /**
  44982. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44983. */
  44984. snapDistance: number;
  44985. /**
  44986. * Ratio for the scale of the gizmo (Default: 1)
  44987. */
  44988. scaleRatio: number;
  44989. /**
  44990. * Disposes of the gizmo
  44991. */
  44992. dispose(): void;
  44993. /**
  44994. * CustomMeshes are not supported by this gizmo
  44995. * @param mesh The mesh to replace the default mesh of the gizmo
  44996. */
  44997. setCustomMesh(mesh: Mesh): void;
  44998. }
  44999. }
  45000. declare module "babylonjs/Gizmos/gizmoManager" {
  45001. import { Observable } from "babylonjs/Misc/observable";
  45002. import { Nullable } from "babylonjs/types";
  45003. import { Scene, IDisposable } from "babylonjs/scene";
  45004. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45005. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45006. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  45007. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  45008. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  45009. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  45010. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  45011. /**
  45012. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  45013. */
  45014. export class GizmoManager implements IDisposable {
  45015. private scene;
  45016. /**
  45017. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  45018. */
  45019. gizmos: {
  45020. positionGizmo: Nullable<PositionGizmo>;
  45021. rotationGizmo: Nullable<RotationGizmo>;
  45022. scaleGizmo: Nullable<ScaleGizmo>;
  45023. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  45024. };
  45025. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  45026. clearGizmoOnEmptyPointerEvent: boolean;
  45027. /** Fires an event when the manager is attached to a mesh */
  45028. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  45029. private _gizmosEnabled;
  45030. private _pointerObserver;
  45031. private _attachedMesh;
  45032. private _boundingBoxColor;
  45033. private _defaultUtilityLayer;
  45034. private _defaultKeepDepthUtilityLayer;
  45035. /**
  45036. * When bounding box gizmo is enabled, this can be used to track drag/end events
  45037. */
  45038. boundingBoxDragBehavior: SixDofDragBehavior;
  45039. /**
  45040. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  45041. */
  45042. attachableMeshes: Nullable<Array<AbstractMesh>>;
  45043. /**
  45044. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  45045. */
  45046. usePointerToAttachGizmos: boolean;
  45047. /**
  45048. * Utility layer that the bounding box gizmo belongs to
  45049. */
  45050. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  45051. /**
  45052. * Utility layer that all gizmos besides bounding box belong to
  45053. */
  45054. readonly utilityLayer: UtilityLayerRenderer;
  45055. /**
  45056. * Instatiates a gizmo manager
  45057. * @param scene the scene to overlay the gizmos on top of
  45058. */
  45059. constructor(scene: Scene);
  45060. /**
  45061. * Attaches a set of gizmos to the specified mesh
  45062. * @param mesh The mesh the gizmo's should be attached to
  45063. */
  45064. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  45065. /**
  45066. * If the position gizmo is enabled
  45067. */
  45068. positionGizmoEnabled: boolean;
  45069. /**
  45070. * If the rotation gizmo is enabled
  45071. */
  45072. rotationGizmoEnabled: boolean;
  45073. /**
  45074. * If the scale gizmo is enabled
  45075. */
  45076. scaleGizmoEnabled: boolean;
  45077. /**
  45078. * If the boundingBox gizmo is enabled
  45079. */
  45080. boundingBoxGizmoEnabled: boolean;
  45081. /**
  45082. * Disposes of the gizmo manager
  45083. */
  45084. dispose(): void;
  45085. }
  45086. }
  45087. declare module "babylonjs/Lights/directionalLight" {
  45088. import { Camera } from "babylonjs/Cameras/camera";
  45089. import { Scene } from "babylonjs/scene";
  45090. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  45091. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45092. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  45093. import { Effect } from "babylonjs/Materials/effect";
  45094. /**
  45095. * A directional light is defined by a direction (what a surprise!).
  45096. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  45097. * 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.
  45098. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45099. */
  45100. export class DirectionalLight extends ShadowLight {
  45101. private _shadowFrustumSize;
  45102. /**
  45103. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  45104. */
  45105. /**
  45106. * Specifies a fix frustum size for the shadow generation.
  45107. */
  45108. shadowFrustumSize: number;
  45109. private _shadowOrthoScale;
  45110. /**
  45111. * Gets the shadow projection scale against the optimal computed one.
  45112. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45113. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45114. */
  45115. /**
  45116. * Sets the shadow projection scale against the optimal computed one.
  45117. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45118. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45119. */
  45120. shadowOrthoScale: number;
  45121. /**
  45122. * Automatically compute the projection matrix to best fit (including all the casters)
  45123. * on each frame.
  45124. */
  45125. autoUpdateExtends: boolean;
  45126. private _orthoLeft;
  45127. private _orthoRight;
  45128. private _orthoTop;
  45129. private _orthoBottom;
  45130. /**
  45131. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  45132. * The directional light is emitted from everywhere in the given direction.
  45133. * It can cast shadows.
  45134. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45135. * @param name The friendly name of the light
  45136. * @param direction The direction of the light
  45137. * @param scene The scene the light belongs to
  45138. */
  45139. constructor(name: string, direction: Vector3, scene: Scene);
  45140. /**
  45141. * Returns the string "DirectionalLight".
  45142. * @return The class name
  45143. */
  45144. getClassName(): string;
  45145. /**
  45146. * Returns the integer 1.
  45147. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45148. */
  45149. getTypeID(): number;
  45150. /**
  45151. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  45152. * Returns the DirectionalLight Shadow projection matrix.
  45153. */
  45154. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45155. /**
  45156. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  45157. * Returns the DirectionalLight Shadow projection matrix.
  45158. */
  45159. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  45160. /**
  45161. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  45162. * Returns the DirectionalLight Shadow projection matrix.
  45163. */
  45164. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45165. protected _buildUniformLayout(): void;
  45166. /**
  45167. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  45168. * @param effect The effect to update
  45169. * @param lightIndex The index of the light in the effect to update
  45170. * @returns The directional light
  45171. */
  45172. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  45173. /**
  45174. * Gets the minZ used for shadow according to both the scene and the light.
  45175. *
  45176. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45177. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45178. * @param activeCamera The camera we are returning the min for
  45179. * @returns the depth min z
  45180. */
  45181. getDepthMinZ(activeCamera: Camera): number;
  45182. /**
  45183. * Gets the maxZ used for shadow according to both the scene and the light.
  45184. *
  45185. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45186. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45187. * @param activeCamera The camera we are returning the max for
  45188. * @returns the depth max z
  45189. */
  45190. getDepthMaxZ(activeCamera: Camera): number;
  45191. /**
  45192. * Prepares the list of defines specific to the light type.
  45193. * @param defines the list of defines
  45194. * @param lightIndex defines the index of the light for the effect
  45195. */
  45196. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45197. }
  45198. }
  45199. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  45200. import { Mesh } from "babylonjs/Meshes/mesh";
  45201. /**
  45202. * Class containing static functions to help procedurally build meshes
  45203. */
  45204. export class HemisphereBuilder {
  45205. /**
  45206. * Creates a hemisphere mesh
  45207. * @param name defines the name of the mesh
  45208. * @param options defines the options used to create the mesh
  45209. * @param scene defines the hosting scene
  45210. * @returns the hemisphere mesh
  45211. */
  45212. static CreateHemisphere(name: string, options: {
  45213. segments?: number;
  45214. diameter?: number;
  45215. sideOrientation?: number;
  45216. }, scene: any): Mesh;
  45217. }
  45218. }
  45219. declare module "babylonjs/Lights/spotLight" {
  45220. import { Nullable } from "babylonjs/types";
  45221. import { Scene } from "babylonjs/scene";
  45222. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  45223. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45224. import { Effect } from "babylonjs/Materials/effect";
  45225. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45226. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  45227. /**
  45228. * A spot light is defined by a position, a direction, an angle, and an exponent.
  45229. * These values define a cone of light starting from the position, emitting toward the direction.
  45230. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  45231. * and the exponent defines the speed of the decay of the light with distance (reach).
  45232. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45233. */
  45234. export class SpotLight extends ShadowLight {
  45235. private _angle;
  45236. private _innerAngle;
  45237. private _cosHalfAngle;
  45238. private _lightAngleScale;
  45239. private _lightAngleOffset;
  45240. /**
  45241. * Gets the cone angle of the spot light in Radians.
  45242. */
  45243. /**
  45244. * Sets the cone angle of the spot light in Radians.
  45245. */
  45246. angle: number;
  45247. /**
  45248. * Only used in gltf falloff mode, this defines the angle where
  45249. * the directional falloff will start before cutting at angle which could be seen
  45250. * as outer angle.
  45251. */
  45252. /**
  45253. * Only used in gltf falloff mode, this defines the angle where
  45254. * the directional falloff will start before cutting at angle which could be seen
  45255. * as outer angle.
  45256. */
  45257. innerAngle: number;
  45258. private _shadowAngleScale;
  45259. /**
  45260. * Allows scaling the angle of the light for shadow generation only.
  45261. */
  45262. /**
  45263. * Allows scaling the angle of the light for shadow generation only.
  45264. */
  45265. shadowAngleScale: number;
  45266. /**
  45267. * The light decay speed with the distance from the emission spot.
  45268. */
  45269. exponent: number;
  45270. private _projectionTextureMatrix;
  45271. /**
  45272. * Allows reading the projecton texture
  45273. */
  45274. readonly projectionTextureMatrix: Matrix;
  45275. protected _projectionTextureLightNear: number;
  45276. /**
  45277. * Gets the near clip of the Spotlight for texture projection.
  45278. */
  45279. /**
  45280. * Sets the near clip of the Spotlight for texture projection.
  45281. */
  45282. projectionTextureLightNear: number;
  45283. protected _projectionTextureLightFar: number;
  45284. /**
  45285. * Gets the far clip of the Spotlight for texture projection.
  45286. */
  45287. /**
  45288. * Sets the far clip of the Spotlight for texture projection.
  45289. */
  45290. projectionTextureLightFar: number;
  45291. protected _projectionTextureUpDirection: Vector3;
  45292. /**
  45293. * Gets the Up vector of the Spotlight for texture projection.
  45294. */
  45295. /**
  45296. * Sets the Up vector of the Spotlight for texture projection.
  45297. */
  45298. projectionTextureUpDirection: Vector3;
  45299. private _projectionTexture;
  45300. /**
  45301. * Gets the projection texture of the light.
  45302. */
  45303. /**
  45304. * Sets the projection texture of the light.
  45305. */
  45306. projectionTexture: Nullable<BaseTexture>;
  45307. private _projectionTextureViewLightDirty;
  45308. private _projectionTextureProjectionLightDirty;
  45309. private _projectionTextureDirty;
  45310. private _projectionTextureViewTargetVector;
  45311. private _projectionTextureViewLightMatrix;
  45312. private _projectionTextureProjectionLightMatrix;
  45313. private _projectionTextureScalingMatrix;
  45314. /**
  45315. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  45316. * It can cast shadows.
  45317. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45318. * @param name The light friendly name
  45319. * @param position The position of the spot light in the scene
  45320. * @param direction The direction of the light in the scene
  45321. * @param angle The cone angle of the light in Radians
  45322. * @param exponent The light decay speed with the distance from the emission spot
  45323. * @param scene The scene the lights belongs to
  45324. */
  45325. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  45326. /**
  45327. * Returns the string "SpotLight".
  45328. * @returns the class name
  45329. */
  45330. getClassName(): string;
  45331. /**
  45332. * Returns the integer 2.
  45333. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45334. */
  45335. getTypeID(): number;
  45336. /**
  45337. * Overrides the direction setter to recompute the projection texture view light Matrix.
  45338. */
  45339. protected _setDirection(value: Vector3): void;
  45340. /**
  45341. * Overrides the position setter to recompute the projection texture view light Matrix.
  45342. */
  45343. protected _setPosition(value: Vector3): void;
  45344. /**
  45345. * 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.
  45346. * Returns the SpotLight.
  45347. */
  45348. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45349. protected _computeProjectionTextureViewLightMatrix(): void;
  45350. protected _computeProjectionTextureProjectionLightMatrix(): void;
  45351. /**
  45352. * Main function for light texture projection matrix computing.
  45353. */
  45354. protected _computeProjectionTextureMatrix(): void;
  45355. protected _buildUniformLayout(): void;
  45356. private _computeAngleValues;
  45357. /**
  45358. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  45359. * @param effect The effect to update
  45360. * @param lightIndex The index of the light in the effect to update
  45361. * @returns The spot light
  45362. */
  45363. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  45364. /**
  45365. * Disposes the light and the associated resources.
  45366. */
  45367. dispose(): void;
  45368. /**
  45369. * Prepares the list of defines specific to the light type.
  45370. * @param defines the list of defines
  45371. * @param lightIndex defines the index of the light for the effect
  45372. */
  45373. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45374. }
  45375. }
  45376. declare module "babylonjs/Gizmos/lightGizmo" {
  45377. import { Nullable } from "babylonjs/types";
  45378. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45379. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45380. import { Light } from "babylonjs/Lights/light";
  45381. /**
  45382. * Gizmo that enables viewing a light
  45383. */
  45384. export class LightGizmo extends Gizmo {
  45385. private _lightMesh;
  45386. private _material;
  45387. private cachedPosition;
  45388. private cachedForward;
  45389. /**
  45390. * Creates a LightGizmo
  45391. * @param gizmoLayer The utility layer the gizmo will be added to
  45392. */
  45393. constructor(gizmoLayer?: UtilityLayerRenderer);
  45394. private _light;
  45395. /**
  45396. * The light that the gizmo is attached to
  45397. */
  45398. light: Nullable<Light>;
  45399. /**
  45400. * @hidden
  45401. * Updates the gizmo to match the attached mesh's position/rotation
  45402. */
  45403. protected _update(): void;
  45404. private static _Scale;
  45405. /**
  45406. * Creates the lines for a light mesh
  45407. */
  45408. private static _createLightLines;
  45409. /**
  45410. * Disposes of the light gizmo
  45411. */
  45412. dispose(): void;
  45413. private static _CreateHemisphericLightMesh;
  45414. private static _CreatePointLightMesh;
  45415. private static _CreateSpotLightMesh;
  45416. private static _CreateDirectionalLightMesh;
  45417. }
  45418. }
  45419. declare module "babylonjs/Gizmos/index" {
  45420. export * from "babylonjs/Gizmos/axisDragGizmo";
  45421. export * from "babylonjs/Gizmos/axisScaleGizmo";
  45422. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  45423. export * from "babylonjs/Gizmos/gizmo";
  45424. export * from "babylonjs/Gizmos/gizmoManager";
  45425. export * from "babylonjs/Gizmos/planeRotationGizmo";
  45426. export * from "babylonjs/Gizmos/positionGizmo";
  45427. export * from "babylonjs/Gizmos/rotationGizmo";
  45428. export * from "babylonjs/Gizmos/scaleGizmo";
  45429. export * from "babylonjs/Gizmos/lightGizmo";
  45430. }
  45431. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  45432. /** @hidden */
  45433. export var backgroundFragmentDeclaration: {
  45434. name: string;
  45435. shader: string;
  45436. };
  45437. }
  45438. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  45439. /** @hidden */
  45440. export var backgroundUboDeclaration: {
  45441. name: string;
  45442. shader: string;
  45443. };
  45444. }
  45445. declare module "babylonjs/Shaders/background.fragment" {
  45446. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  45447. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  45448. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  45449. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  45450. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  45451. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  45452. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45453. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  45454. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  45455. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  45456. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  45457. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  45458. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  45459. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  45460. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  45461. /** @hidden */
  45462. export var backgroundPixelShader: {
  45463. name: string;
  45464. shader: string;
  45465. };
  45466. }
  45467. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  45468. /** @hidden */
  45469. export var backgroundVertexDeclaration: {
  45470. name: string;
  45471. shader: string;
  45472. };
  45473. }
  45474. declare module "babylonjs/Shaders/background.vertex" {
  45475. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  45476. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  45477. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45478. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  45479. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  45480. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  45481. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  45482. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  45483. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  45484. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  45485. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  45486. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  45487. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  45488. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  45489. /** @hidden */
  45490. export var backgroundVertexShader: {
  45491. name: string;
  45492. shader: string;
  45493. };
  45494. }
  45495. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  45496. import { Nullable, int, float } from "babylonjs/types";
  45497. import { Scene } from "babylonjs/scene";
  45498. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  45499. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45500. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45501. import { Mesh } from "babylonjs/Meshes/mesh";
  45502. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  45503. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  45504. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  45505. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45506. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  45507. import "babylonjs/Shaders/background.fragment";
  45508. import "babylonjs/Shaders/background.vertex";
  45509. /**
  45510. * Background material used to create an efficient environement around your scene.
  45511. */
  45512. export class BackgroundMaterial extends PushMaterial {
  45513. /**
  45514. * Standard reflectance value at parallel view angle.
  45515. */
  45516. static StandardReflectance0: number;
  45517. /**
  45518. * Standard reflectance value at grazing angle.
  45519. */
  45520. static StandardReflectance90: number;
  45521. protected _primaryColor: Color3;
  45522. /**
  45523. * Key light Color (multiply against the environement texture)
  45524. */
  45525. primaryColor: Color3;
  45526. protected __perceptualColor: Nullable<Color3>;
  45527. /**
  45528. * Experimental Internal Use Only.
  45529. *
  45530. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  45531. * This acts as a helper to set the primary color to a more "human friendly" value.
  45532. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  45533. * output color as close as possible from the chosen value.
  45534. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  45535. * part of lighting setup.)
  45536. */
  45537. _perceptualColor: Nullable<Color3>;
  45538. protected _primaryColorShadowLevel: float;
  45539. /**
  45540. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  45541. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  45542. */
  45543. primaryColorShadowLevel: float;
  45544. protected _primaryColorHighlightLevel: float;
  45545. /**
  45546. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  45547. * The primary color is used at the level chosen to define what the white area would look.
  45548. */
  45549. primaryColorHighlightLevel: float;
  45550. protected _reflectionTexture: Nullable<BaseTexture>;
  45551. /**
  45552. * Reflection Texture used in the material.
  45553. * Should be author in a specific way for the best result (refer to the documentation).
  45554. */
  45555. reflectionTexture: Nullable<BaseTexture>;
  45556. protected _reflectionBlur: float;
  45557. /**
  45558. * Reflection Texture level of blur.
  45559. *
  45560. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  45561. * texture twice.
  45562. */
  45563. reflectionBlur: float;
  45564. protected _diffuseTexture: Nullable<BaseTexture>;
  45565. /**
  45566. * Diffuse Texture used in the material.
  45567. * Should be author in a specific way for the best result (refer to the documentation).
  45568. */
  45569. diffuseTexture: Nullable<BaseTexture>;
  45570. protected _shadowLights: Nullable<IShadowLight[]>;
  45571. /**
  45572. * Specify the list of lights casting shadow on the material.
  45573. * All scene shadow lights will be included if null.
  45574. */
  45575. shadowLights: Nullable<IShadowLight[]>;
  45576. protected _shadowLevel: float;
  45577. /**
  45578. * Helps adjusting the shadow to a softer level if required.
  45579. * 0 means black shadows and 1 means no shadows.
  45580. */
  45581. shadowLevel: float;
  45582. protected _sceneCenter: Vector3;
  45583. /**
  45584. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  45585. * It is usually zero but might be interesting to modify according to your setup.
  45586. */
  45587. sceneCenter: Vector3;
  45588. protected _opacityFresnel: boolean;
  45589. /**
  45590. * This helps specifying that the material is falling off to the sky box at grazing angle.
  45591. * This helps ensuring a nice transition when the camera goes under the ground.
  45592. */
  45593. opacityFresnel: boolean;
  45594. protected _reflectionFresnel: boolean;
  45595. /**
  45596. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  45597. * This helps adding a mirror texture on the ground.
  45598. */
  45599. reflectionFresnel: boolean;
  45600. protected _reflectionFalloffDistance: number;
  45601. /**
  45602. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  45603. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  45604. */
  45605. reflectionFalloffDistance: number;
  45606. protected _reflectionAmount: number;
  45607. /**
  45608. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  45609. */
  45610. reflectionAmount: number;
  45611. protected _reflectionReflectance0: number;
  45612. /**
  45613. * This specifies the weight of the reflection at grazing angle.
  45614. */
  45615. reflectionReflectance0: number;
  45616. protected _reflectionReflectance90: number;
  45617. /**
  45618. * This specifies the weight of the reflection at a perpendicular point of view.
  45619. */
  45620. reflectionReflectance90: number;
  45621. /**
  45622. * Sets the reflection reflectance fresnel values according to the default standard
  45623. * empirically know to work well :-)
  45624. */
  45625. reflectionStandardFresnelWeight: number;
  45626. protected _useRGBColor: boolean;
  45627. /**
  45628. * Helps to directly use the maps channels instead of their level.
  45629. */
  45630. useRGBColor: boolean;
  45631. protected _enableNoise: boolean;
  45632. /**
  45633. * This helps reducing the banding effect that could occur on the background.
  45634. */
  45635. enableNoise: boolean;
  45636. /**
  45637. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45638. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  45639. * Recommended to be keep at 1.0 except for special cases.
  45640. */
  45641. fovMultiplier: number;
  45642. private _fovMultiplier;
  45643. /**
  45644. * Enable the FOV adjustment feature controlled by fovMultiplier.
  45645. */
  45646. useEquirectangularFOV: boolean;
  45647. private _maxSimultaneousLights;
  45648. /**
  45649. * Number of Simultaneous lights allowed on the material.
  45650. */
  45651. maxSimultaneousLights: int;
  45652. /**
  45653. * Default configuration related to image processing available in the Background Material.
  45654. */
  45655. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45656. /**
  45657. * Keep track of the image processing observer to allow dispose and replace.
  45658. */
  45659. private _imageProcessingObserver;
  45660. /**
  45661. * Attaches a new image processing configuration to the PBR Material.
  45662. * @param configuration (if null the scene configuration will be use)
  45663. */
  45664. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45665. /**
  45666. * Gets the image processing configuration used either in this material.
  45667. */
  45668. /**
  45669. * Sets the Default image processing configuration used either in the this material.
  45670. *
  45671. * If sets to null, the scene one is in use.
  45672. */
  45673. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  45674. /**
  45675. * Gets wether the color curves effect is enabled.
  45676. */
  45677. /**
  45678. * Sets wether the color curves effect is enabled.
  45679. */
  45680. cameraColorCurvesEnabled: boolean;
  45681. /**
  45682. * Gets wether the color grading effect is enabled.
  45683. */
  45684. /**
  45685. * Gets wether the color grading effect is enabled.
  45686. */
  45687. cameraColorGradingEnabled: boolean;
  45688. /**
  45689. * Gets wether tonemapping is enabled or not.
  45690. */
  45691. /**
  45692. * Sets wether tonemapping is enabled or not
  45693. */
  45694. cameraToneMappingEnabled: boolean;
  45695. /**
  45696. * The camera exposure used on this material.
  45697. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45698. * This corresponds to a photographic exposure.
  45699. */
  45700. /**
  45701. * The camera exposure used on this material.
  45702. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45703. * This corresponds to a photographic exposure.
  45704. */
  45705. cameraExposure: float;
  45706. /**
  45707. * Gets The camera contrast used on this material.
  45708. */
  45709. /**
  45710. * Sets The camera contrast used on this material.
  45711. */
  45712. cameraContrast: float;
  45713. /**
  45714. * Gets the Color Grading 2D Lookup Texture.
  45715. */
  45716. /**
  45717. * Sets the Color Grading 2D Lookup Texture.
  45718. */
  45719. cameraColorGradingTexture: Nullable<BaseTexture>;
  45720. /**
  45721. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45722. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45723. * 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;
  45724. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45725. */
  45726. /**
  45727. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45728. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45729. * 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;
  45730. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45731. */
  45732. cameraColorCurves: Nullable<ColorCurves>;
  45733. /**
  45734. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  45735. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  45736. */
  45737. switchToBGR: boolean;
  45738. private _renderTargets;
  45739. private _reflectionControls;
  45740. private _white;
  45741. private _primaryShadowColor;
  45742. private _primaryHighlightColor;
  45743. /**
  45744. * Instantiates a Background Material in the given scene
  45745. * @param name The friendly name of the material
  45746. * @param scene The scene to add the material to
  45747. */
  45748. constructor(name: string, scene: Scene);
  45749. /**
  45750. * Gets a boolean indicating that current material needs to register RTT
  45751. */
  45752. readonly hasRenderTargetTextures: boolean;
  45753. /**
  45754. * The entire material has been created in order to prevent overdraw.
  45755. * @returns false
  45756. */
  45757. needAlphaTesting(): boolean;
  45758. /**
  45759. * The entire material has been created in order to prevent overdraw.
  45760. * @returns true if blending is enable
  45761. */
  45762. needAlphaBlending(): boolean;
  45763. /**
  45764. * Checks wether the material is ready to be rendered for a given mesh.
  45765. * @param mesh The mesh to render
  45766. * @param subMesh The submesh to check against
  45767. * @param useInstances Specify wether or not the material is used with instances
  45768. * @returns true if all the dependencies are ready (Textures, Effects...)
  45769. */
  45770. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45771. /**
  45772. * Compute the primary color according to the chosen perceptual color.
  45773. */
  45774. private _computePrimaryColorFromPerceptualColor;
  45775. /**
  45776. * Compute the highlights and shadow colors according to their chosen levels.
  45777. */
  45778. private _computePrimaryColors;
  45779. /**
  45780. * Build the uniform buffer used in the material.
  45781. */
  45782. buildUniformLayout(): void;
  45783. /**
  45784. * Unbind the material.
  45785. */
  45786. unbind(): void;
  45787. /**
  45788. * Bind only the world matrix to the material.
  45789. * @param world The world matrix to bind.
  45790. */
  45791. bindOnlyWorldMatrix(world: Matrix): void;
  45792. /**
  45793. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  45794. * @param world The world matrix to bind.
  45795. * @param subMesh The submesh to bind for.
  45796. */
  45797. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45798. /**
  45799. * Dispose the material.
  45800. * @param forceDisposeEffect Force disposal of the associated effect.
  45801. * @param forceDisposeTextures Force disposal of the associated textures.
  45802. */
  45803. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45804. /**
  45805. * Clones the material.
  45806. * @param name The cloned name.
  45807. * @returns The cloned material.
  45808. */
  45809. clone(name: string): BackgroundMaterial;
  45810. /**
  45811. * Serializes the current material to its JSON representation.
  45812. * @returns The JSON representation.
  45813. */
  45814. serialize(): any;
  45815. /**
  45816. * Gets the class name of the material
  45817. * @returns "BackgroundMaterial"
  45818. */
  45819. getClassName(): string;
  45820. /**
  45821. * Parse a JSON input to create back a background material.
  45822. * @param source The JSON data to parse
  45823. * @param scene The scene to create the parsed material in
  45824. * @param rootUrl The root url of the assets the material depends upon
  45825. * @returns the instantiated BackgroundMaterial.
  45826. */
  45827. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  45828. }
  45829. }
  45830. declare module "babylonjs/Helpers/environmentHelper" {
  45831. import { Observable } from "babylonjs/Misc/observable";
  45832. import { Nullable } from "babylonjs/types";
  45833. import { Scene } from "babylonjs/scene";
  45834. import { Vector3, Color3 } from "babylonjs/Maths/math";
  45835. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45836. import { Mesh } from "babylonjs/Meshes/mesh";
  45837. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45838. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  45839. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  45840. import "babylonjs/Meshes/Builders/planeBuilder";
  45841. import "babylonjs/Meshes/Builders/boxBuilder";
  45842. /**
  45843. * Represents the different options available during the creation of
  45844. * a Environment helper.
  45845. *
  45846. * This can control the default ground, skybox and image processing setup of your scene.
  45847. */
  45848. export interface IEnvironmentHelperOptions {
  45849. /**
  45850. * Specifies wether or not to create a ground.
  45851. * True by default.
  45852. */
  45853. createGround: boolean;
  45854. /**
  45855. * Specifies the ground size.
  45856. * 15 by default.
  45857. */
  45858. groundSize: number;
  45859. /**
  45860. * The texture used on the ground for the main color.
  45861. * Comes from the BabylonJS CDN by default.
  45862. *
  45863. * Remarks: Can be either a texture or a url.
  45864. */
  45865. groundTexture: string | BaseTexture;
  45866. /**
  45867. * The color mixed in the ground texture by default.
  45868. * BabylonJS clearColor by default.
  45869. */
  45870. groundColor: Color3;
  45871. /**
  45872. * Specifies the ground opacity.
  45873. * 1 by default.
  45874. */
  45875. groundOpacity: number;
  45876. /**
  45877. * Enables the ground to receive shadows.
  45878. * True by default.
  45879. */
  45880. enableGroundShadow: boolean;
  45881. /**
  45882. * Helps preventing the shadow to be fully black on the ground.
  45883. * 0.5 by default.
  45884. */
  45885. groundShadowLevel: number;
  45886. /**
  45887. * Creates a mirror texture attach to the ground.
  45888. * false by default.
  45889. */
  45890. enableGroundMirror: boolean;
  45891. /**
  45892. * Specifies the ground mirror size ratio.
  45893. * 0.3 by default as the default kernel is 64.
  45894. */
  45895. groundMirrorSizeRatio: number;
  45896. /**
  45897. * Specifies the ground mirror blur kernel size.
  45898. * 64 by default.
  45899. */
  45900. groundMirrorBlurKernel: number;
  45901. /**
  45902. * Specifies the ground mirror visibility amount.
  45903. * 1 by default
  45904. */
  45905. groundMirrorAmount: number;
  45906. /**
  45907. * Specifies the ground mirror reflectance weight.
  45908. * This uses the standard weight of the background material to setup the fresnel effect
  45909. * of the mirror.
  45910. * 1 by default.
  45911. */
  45912. groundMirrorFresnelWeight: number;
  45913. /**
  45914. * Specifies the ground mirror Falloff distance.
  45915. * This can helps reducing the size of the reflection.
  45916. * 0 by Default.
  45917. */
  45918. groundMirrorFallOffDistance: number;
  45919. /**
  45920. * Specifies the ground mirror texture type.
  45921. * Unsigned Int by Default.
  45922. */
  45923. groundMirrorTextureType: number;
  45924. /**
  45925. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  45926. * the shown objects.
  45927. */
  45928. groundYBias: number;
  45929. /**
  45930. * Specifies wether or not to create a skybox.
  45931. * True by default.
  45932. */
  45933. createSkybox: boolean;
  45934. /**
  45935. * Specifies the skybox size.
  45936. * 20 by default.
  45937. */
  45938. skyboxSize: number;
  45939. /**
  45940. * The texture used on the skybox for the main color.
  45941. * Comes from the BabylonJS CDN by default.
  45942. *
  45943. * Remarks: Can be either a texture or a url.
  45944. */
  45945. skyboxTexture: string | BaseTexture;
  45946. /**
  45947. * The color mixed in the skybox texture by default.
  45948. * BabylonJS clearColor by default.
  45949. */
  45950. skyboxColor: Color3;
  45951. /**
  45952. * The background rotation around the Y axis of the scene.
  45953. * This helps aligning the key lights of your scene with the background.
  45954. * 0 by default.
  45955. */
  45956. backgroundYRotation: number;
  45957. /**
  45958. * Compute automatically the size of the elements to best fit with the scene.
  45959. */
  45960. sizeAuto: boolean;
  45961. /**
  45962. * Default position of the rootMesh if autoSize is not true.
  45963. */
  45964. rootPosition: Vector3;
  45965. /**
  45966. * Sets up the image processing in the scene.
  45967. * true by default.
  45968. */
  45969. setupImageProcessing: boolean;
  45970. /**
  45971. * The texture used as your environment texture in the scene.
  45972. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  45973. *
  45974. * Remarks: Can be either a texture or a url.
  45975. */
  45976. environmentTexture: string | BaseTexture;
  45977. /**
  45978. * The value of the exposure to apply to the scene.
  45979. * 0.6 by default if setupImageProcessing is true.
  45980. */
  45981. cameraExposure: number;
  45982. /**
  45983. * The value of the contrast to apply to the scene.
  45984. * 1.6 by default if setupImageProcessing is true.
  45985. */
  45986. cameraContrast: number;
  45987. /**
  45988. * Specifies wether or not tonemapping should be enabled in the scene.
  45989. * true by default if setupImageProcessing is true.
  45990. */
  45991. toneMappingEnabled: boolean;
  45992. }
  45993. /**
  45994. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  45995. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  45996. * It also helps with the default setup of your imageProcessing configuration.
  45997. */
  45998. export class EnvironmentHelper {
  45999. /**
  46000. * Default ground texture URL.
  46001. */
  46002. private static _groundTextureCDNUrl;
  46003. /**
  46004. * Default skybox texture URL.
  46005. */
  46006. private static _skyboxTextureCDNUrl;
  46007. /**
  46008. * Default environment texture URL.
  46009. */
  46010. private static _environmentTextureCDNUrl;
  46011. /**
  46012. * Creates the default options for the helper.
  46013. */
  46014. private static _getDefaultOptions;
  46015. private _rootMesh;
  46016. /**
  46017. * Gets the root mesh created by the helper.
  46018. */
  46019. readonly rootMesh: Mesh;
  46020. private _skybox;
  46021. /**
  46022. * Gets the skybox created by the helper.
  46023. */
  46024. readonly skybox: Nullable<Mesh>;
  46025. private _skyboxTexture;
  46026. /**
  46027. * Gets the skybox texture created by the helper.
  46028. */
  46029. readonly skyboxTexture: Nullable<BaseTexture>;
  46030. private _skyboxMaterial;
  46031. /**
  46032. * Gets the skybox material created by the helper.
  46033. */
  46034. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  46035. private _ground;
  46036. /**
  46037. * Gets the ground mesh created by the helper.
  46038. */
  46039. readonly ground: Nullable<Mesh>;
  46040. private _groundTexture;
  46041. /**
  46042. * Gets the ground texture created by the helper.
  46043. */
  46044. readonly groundTexture: Nullable<BaseTexture>;
  46045. private _groundMirror;
  46046. /**
  46047. * Gets the ground mirror created by the helper.
  46048. */
  46049. readonly groundMirror: Nullable<MirrorTexture>;
  46050. /**
  46051. * Gets the ground mirror render list to helps pushing the meshes
  46052. * you wish in the ground reflection.
  46053. */
  46054. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  46055. private _groundMaterial;
  46056. /**
  46057. * Gets the ground material created by the helper.
  46058. */
  46059. readonly groundMaterial: Nullable<BackgroundMaterial>;
  46060. /**
  46061. * Stores the creation options.
  46062. */
  46063. private readonly _scene;
  46064. private _options;
  46065. /**
  46066. * This observable will be notified with any error during the creation of the environment,
  46067. * mainly texture creation errors.
  46068. */
  46069. onErrorObservable: Observable<{
  46070. message?: string;
  46071. exception?: any;
  46072. }>;
  46073. /**
  46074. * constructor
  46075. * @param options Defines the options we want to customize the helper
  46076. * @param scene The scene to add the material to
  46077. */
  46078. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  46079. /**
  46080. * Updates the background according to the new options
  46081. * @param options
  46082. */
  46083. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  46084. /**
  46085. * Sets the primary color of all the available elements.
  46086. * @param color the main color to affect to the ground and the background
  46087. */
  46088. setMainColor(color: Color3): void;
  46089. /**
  46090. * Setup the image processing according to the specified options.
  46091. */
  46092. private _setupImageProcessing;
  46093. /**
  46094. * Setup the environment texture according to the specified options.
  46095. */
  46096. private _setupEnvironmentTexture;
  46097. /**
  46098. * Setup the background according to the specified options.
  46099. */
  46100. private _setupBackground;
  46101. /**
  46102. * Get the scene sizes according to the setup.
  46103. */
  46104. private _getSceneSize;
  46105. /**
  46106. * Setup the ground according to the specified options.
  46107. */
  46108. private _setupGround;
  46109. /**
  46110. * Setup the ground material according to the specified options.
  46111. */
  46112. private _setupGroundMaterial;
  46113. /**
  46114. * Setup the ground diffuse texture according to the specified options.
  46115. */
  46116. private _setupGroundDiffuseTexture;
  46117. /**
  46118. * Setup the ground mirror texture according to the specified options.
  46119. */
  46120. private _setupGroundMirrorTexture;
  46121. /**
  46122. * Setup the ground to receive the mirror texture.
  46123. */
  46124. private _setupMirrorInGroundMaterial;
  46125. /**
  46126. * Setup the skybox according to the specified options.
  46127. */
  46128. private _setupSkybox;
  46129. /**
  46130. * Setup the skybox material according to the specified options.
  46131. */
  46132. private _setupSkyboxMaterial;
  46133. /**
  46134. * Setup the skybox reflection texture according to the specified options.
  46135. */
  46136. private _setupSkyboxReflectionTexture;
  46137. private _errorHandler;
  46138. /**
  46139. * Dispose all the elements created by the Helper.
  46140. */
  46141. dispose(): void;
  46142. }
  46143. }
  46144. declare module "babylonjs/Helpers/photoDome" {
  46145. import { Observable } from "babylonjs/Misc/observable";
  46146. import { Nullable } from "babylonjs/types";
  46147. import { Scene } from "babylonjs/scene";
  46148. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46149. import { Mesh } from "babylonjs/Meshes/mesh";
  46150. import { Texture } from "babylonjs/Materials/Textures/texture";
  46151. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  46152. import "babylonjs/Meshes/Builders/sphereBuilder";
  46153. /**
  46154. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  46155. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  46156. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  46157. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  46158. */
  46159. export class PhotoDome extends TransformNode {
  46160. /**
  46161. * Define the image as a Monoscopic panoramic 360 image.
  46162. */
  46163. static readonly MODE_MONOSCOPIC: number;
  46164. /**
  46165. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  46166. */
  46167. static readonly MODE_TOPBOTTOM: number;
  46168. /**
  46169. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  46170. */
  46171. static readonly MODE_SIDEBYSIDE: number;
  46172. private _useDirectMapping;
  46173. /**
  46174. * The texture being displayed on the sphere
  46175. */
  46176. protected _photoTexture: Texture;
  46177. /**
  46178. * Gets or sets the texture being displayed on the sphere
  46179. */
  46180. photoTexture: Texture;
  46181. /**
  46182. * Observable raised when an error occured while loading the 360 image
  46183. */
  46184. onLoadErrorObservable: Observable<string>;
  46185. /**
  46186. * The skybox material
  46187. */
  46188. protected _material: BackgroundMaterial;
  46189. /**
  46190. * The surface used for the skybox
  46191. */
  46192. protected _mesh: Mesh;
  46193. /**
  46194. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46195. * Also see the options.resolution property.
  46196. */
  46197. fovMultiplier: number;
  46198. private _imageMode;
  46199. /**
  46200. * Gets or set the current video mode for the video. It can be:
  46201. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  46202. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  46203. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  46204. */
  46205. imageMode: number;
  46206. /**
  46207. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  46208. * @param name Element's name, child elements will append suffixes for their own names.
  46209. * @param urlsOfPhoto defines the url of the photo to display
  46210. * @param options defines an object containing optional or exposed sub element properties
  46211. * @param onError defines a callback called when an error occured while loading the texture
  46212. */
  46213. constructor(name: string, urlOfPhoto: string, options: {
  46214. resolution?: number;
  46215. size?: number;
  46216. useDirectMapping?: boolean;
  46217. faceForward?: boolean;
  46218. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  46219. private _onBeforeCameraRenderObserver;
  46220. private _changeImageMode;
  46221. /**
  46222. * Releases resources associated with this node.
  46223. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  46224. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  46225. */
  46226. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  46227. }
  46228. }
  46229. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  46230. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46231. /** @hidden */
  46232. export var rgbdDecodePixelShader: {
  46233. name: string;
  46234. shader: string;
  46235. };
  46236. }
  46237. declare module "babylonjs/Misc/brdfTextureTools" {
  46238. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46239. import { Scene } from "babylonjs/scene";
  46240. import "babylonjs/Shaders/rgbdDecode.fragment";
  46241. /**
  46242. * Class used to host texture specific utilities
  46243. */
  46244. export class BRDFTextureTools {
  46245. /**
  46246. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  46247. * @param texture the texture to expand.
  46248. */
  46249. private static _ExpandDefaultBRDFTexture;
  46250. /**
  46251. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  46252. * @param scene defines the hosting scene
  46253. * @returns the environment BRDF texture
  46254. */
  46255. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  46256. private static _environmentBRDFBase64Texture;
  46257. }
  46258. }
  46259. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  46260. import { Nullable } from "babylonjs/types";
  46261. import { IAnimatable } from "babylonjs/Misc/tools";
  46262. import { Color3 } from "babylonjs/Maths/math";
  46263. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46264. import { EffectFallbacks } from "babylonjs/Materials/effect";
  46265. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46266. import { Engine } from "babylonjs/Engines/engine";
  46267. import { Scene } from "babylonjs/scene";
  46268. /**
  46269. * @hidden
  46270. */
  46271. export interface IMaterialClearCoatDefines {
  46272. CLEARCOAT: boolean;
  46273. CLEARCOAT_DEFAULTIOR: boolean;
  46274. CLEARCOAT_TEXTURE: boolean;
  46275. CLEARCOAT_TEXTUREDIRECTUV: number;
  46276. CLEARCOAT_BUMP: boolean;
  46277. CLEARCOAT_BUMPDIRECTUV: number;
  46278. CLEARCOAT_TINT: boolean;
  46279. CLEARCOAT_TINT_TEXTURE: boolean;
  46280. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46281. /** @hidden */
  46282. _areTexturesDirty: boolean;
  46283. }
  46284. /**
  46285. * Define the code related to the clear coat parameters of the pbr material.
  46286. */
  46287. export class PBRClearCoatConfiguration {
  46288. /**
  46289. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  46290. * The default fits with a polyurethane material.
  46291. */
  46292. private static readonly _DefaultIndexOfRefraction;
  46293. private _isEnabled;
  46294. /**
  46295. * Defines if the clear coat is enabled in the material.
  46296. */
  46297. isEnabled: boolean;
  46298. /**
  46299. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  46300. */
  46301. intensity: number;
  46302. /**
  46303. * Defines the clear coat layer roughness.
  46304. */
  46305. roughness: number;
  46306. private _indexOfRefraction;
  46307. /**
  46308. * Defines the index of refraction of the clear coat.
  46309. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  46310. * The default fits with a polyurethane material.
  46311. * Changing the default value is more performance intensive.
  46312. */
  46313. indexOfRefraction: number;
  46314. private _texture;
  46315. /**
  46316. * Stores the clear coat values in a texture.
  46317. */
  46318. texture: Nullable<BaseTexture>;
  46319. private _bumpTexture;
  46320. /**
  46321. * Define the clear coat specific bump texture.
  46322. */
  46323. bumpTexture: Nullable<BaseTexture>;
  46324. private _isTintEnabled;
  46325. /**
  46326. * Defines if the clear coat tint is enabled in the material.
  46327. */
  46328. isTintEnabled: boolean;
  46329. /**
  46330. * Defines the clear coat tint of the material.
  46331. * This is only use if tint is enabled
  46332. */
  46333. tintColor: Color3;
  46334. /**
  46335. * Defines the distance at which the tint color should be found in the
  46336. * clear coat media.
  46337. * This is only use if tint is enabled
  46338. */
  46339. tintColorAtDistance: number;
  46340. /**
  46341. * Defines the clear coat layer thickness.
  46342. * This is only use if tint is enabled
  46343. */
  46344. tintThickness: number;
  46345. private _tintTexture;
  46346. /**
  46347. * Stores the clear tint values in a texture.
  46348. * rgb is tint
  46349. * a is a thickness factor
  46350. */
  46351. tintTexture: Nullable<BaseTexture>;
  46352. /** @hidden */
  46353. private _internalMarkAllSubMeshesAsTexturesDirty;
  46354. /** @hidden */
  46355. _markAllSubMeshesAsTexturesDirty(): void;
  46356. /**
  46357. * Instantiate a new istance of clear coat configuration.
  46358. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46359. */
  46360. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46361. /**
  46362. * Gets wehter the submesh is ready to be used or not.
  46363. * @param defines the list of "defines" to update.
  46364. * @param scene defines the scene the material belongs to.
  46365. * @param engine defines the engine the material belongs to.
  46366. * @param disableBumpMap defines wether the material disables bump or not.
  46367. * @returns - boolean indicating that the submesh is ready or not.
  46368. */
  46369. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  46370. /**
  46371. * Checks to see if a texture is used in the material.
  46372. * @param defines the list of "defines" to update.
  46373. * @param scene defines the scene to the material belongs to.
  46374. */
  46375. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  46376. /**
  46377. * Binds the material data.
  46378. * @param uniformBuffer defines the Uniform buffer to fill in.
  46379. * @param scene defines the scene the material belongs to.
  46380. * @param engine defines the engine the material belongs to.
  46381. * @param disableBumpMap defines wether the material disables bump or not.
  46382. * @param isFrozen defines wether the material is frozen or not.
  46383. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  46384. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  46385. */
  46386. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  46387. /**
  46388. * Checks to see if a texture is used in the material.
  46389. * @param texture - Base texture to use.
  46390. * @returns - Boolean specifying if a texture is used in the material.
  46391. */
  46392. hasTexture(texture: BaseTexture): boolean;
  46393. /**
  46394. * Returns an array of the actively used textures.
  46395. * @param activeTextures Array of BaseTextures
  46396. */
  46397. getActiveTextures(activeTextures: BaseTexture[]): void;
  46398. /**
  46399. * Returns the animatable textures.
  46400. * @param animatables Array of animatable textures.
  46401. */
  46402. getAnimatables(animatables: IAnimatable[]): void;
  46403. /**
  46404. * Disposes the resources of the material.
  46405. * @param forceDisposeTextures - Forces the disposal of all textures.
  46406. */
  46407. dispose(forceDisposeTextures?: boolean): void;
  46408. /**
  46409. * Get the current class name of the texture useful for serialization or dynamic coding.
  46410. * @returns "PBRClearCoatConfiguration"
  46411. */
  46412. getClassName(): string;
  46413. /**
  46414. * Add fallbacks to the effect fallbacks list.
  46415. * @param defines defines the Base texture to use.
  46416. * @param fallbacks defines the current fallback list.
  46417. * @param currentRank defines the current fallback rank.
  46418. * @returns the new fallback rank.
  46419. */
  46420. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46421. /**
  46422. * Add the required uniforms to the current list.
  46423. * @param uniforms defines the current uniform list.
  46424. */
  46425. static AddUniforms(uniforms: string[]): void;
  46426. /**
  46427. * Add the required samplers to the current list.
  46428. * @param samplers defines the current sampler list.
  46429. */
  46430. static AddSamplers(samplers: string[]): void;
  46431. /**
  46432. * Add the required uniforms to the current buffer.
  46433. * @param uniformBuffer defines the current uniform buffer.
  46434. */
  46435. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46436. /**
  46437. * Makes a duplicate of the current configuration into another one.
  46438. * @param clearCoatConfiguration define the config where to copy the info
  46439. */
  46440. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  46441. /**
  46442. * Serializes this clear coat configuration.
  46443. * @returns - An object with the serialized config.
  46444. */
  46445. serialize(): any;
  46446. /**
  46447. * Parses a Clear Coat Configuration from a serialized object.
  46448. * @param source - Serialized object.
  46449. */
  46450. parse(source: any): void;
  46451. }
  46452. }
  46453. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  46454. import { EffectFallbacks } from "babylonjs/Materials/effect";
  46455. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46456. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46457. import { Vector2 } from "babylonjs/Maths/math";
  46458. import { Scene } from "babylonjs/scene";
  46459. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46460. import { IAnimatable } from "babylonjs/Misc/tools";
  46461. import { Nullable } from "babylonjs/types";
  46462. /**
  46463. * @hidden
  46464. */
  46465. export interface IMaterialAnisotropicDefines {
  46466. ANISOTROPIC: boolean;
  46467. ANISOTROPIC_TEXTURE: boolean;
  46468. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46469. MAINUV1: boolean;
  46470. _areTexturesDirty: boolean;
  46471. _needUVs: boolean;
  46472. }
  46473. /**
  46474. * Define the code related to the anisotropic parameters of the pbr material.
  46475. */
  46476. export class PBRAnisotropicConfiguration {
  46477. private _isEnabled;
  46478. /**
  46479. * Defines if the anisotropy is enabled in the material.
  46480. */
  46481. isEnabled: boolean;
  46482. /**
  46483. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  46484. */
  46485. intensity: number;
  46486. /**
  46487. * Defines if the effect is along the tangents, bitangents or in between.
  46488. * By default, the effect is "strectching" the highlights along the tangents.
  46489. */
  46490. direction: Vector2;
  46491. private _texture;
  46492. /**
  46493. * Stores the anisotropy values in a texture.
  46494. * rg is direction (like normal from -1 to 1)
  46495. * b is a intensity
  46496. */
  46497. texture: Nullable<BaseTexture>;
  46498. /** @hidden */
  46499. private _internalMarkAllSubMeshesAsTexturesDirty;
  46500. /** @hidden */
  46501. _markAllSubMeshesAsTexturesDirty(): void;
  46502. /**
  46503. * Instantiate a new istance of anisotropy configuration.
  46504. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46505. */
  46506. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46507. /**
  46508. * Specifies that the submesh is ready to be used.
  46509. * @param defines the list of "defines" to update.
  46510. * @param scene defines the scene the material belongs to.
  46511. * @returns - boolean indicating that the submesh is ready or not.
  46512. */
  46513. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  46514. /**
  46515. * Checks to see if a texture is used in the material.
  46516. * @param defines the list of "defines" to update.
  46517. * @param mesh the mesh we are preparing the defines for.
  46518. * @param scene defines the scene the material belongs to.
  46519. */
  46520. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  46521. /**
  46522. * Binds the material data.
  46523. * @param uniformBuffer defines the Uniform buffer to fill in.
  46524. * @param scene defines the scene the material belongs to.
  46525. * @param isFrozen defines wether the material is frozen or not.
  46526. */
  46527. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46528. /**
  46529. * Checks to see if a texture is used in the material.
  46530. * @param texture - Base texture to use.
  46531. * @returns - Boolean specifying if a texture is used in the material.
  46532. */
  46533. hasTexture(texture: BaseTexture): boolean;
  46534. /**
  46535. * Returns an array of the actively used textures.
  46536. * @param activeTextures Array of BaseTextures
  46537. */
  46538. getActiveTextures(activeTextures: BaseTexture[]): void;
  46539. /**
  46540. * Returns the animatable textures.
  46541. * @param animatables Array of animatable textures.
  46542. */
  46543. getAnimatables(animatables: IAnimatable[]): void;
  46544. /**
  46545. * Disposes the resources of the material.
  46546. * @param forceDisposeTextures - Forces the disposal of all textures.
  46547. */
  46548. dispose(forceDisposeTextures?: boolean): void;
  46549. /**
  46550. * Get the current class name of the texture useful for serialization or dynamic coding.
  46551. * @returns "PBRAnisotropicConfiguration"
  46552. */
  46553. getClassName(): string;
  46554. /**
  46555. * Add fallbacks to the effect fallbacks list.
  46556. * @param defines defines the Base texture to use.
  46557. * @param fallbacks defines the current fallback list.
  46558. * @param currentRank defines the current fallback rank.
  46559. * @returns the new fallback rank.
  46560. */
  46561. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46562. /**
  46563. * Add the required uniforms to the current list.
  46564. * @param uniforms defines the current uniform list.
  46565. */
  46566. static AddUniforms(uniforms: string[]): void;
  46567. /**
  46568. * Add the required uniforms to the current buffer.
  46569. * @param uniformBuffer defines the current uniform buffer.
  46570. */
  46571. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46572. /**
  46573. * Add the required samplers to the current list.
  46574. * @param samplers defines the current sampler list.
  46575. */
  46576. static AddSamplers(samplers: string[]): void;
  46577. /**
  46578. * Makes a duplicate of the current configuration into another one.
  46579. * @param anisotropicConfiguration define the config where to copy the info
  46580. */
  46581. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  46582. /**
  46583. * Serializes this anisotropy configuration.
  46584. * @returns - An object with the serialized config.
  46585. */
  46586. serialize(): any;
  46587. /**
  46588. * Parses a anisotropy Configuration from a serialized object.
  46589. * @param source - Serialized object.
  46590. */
  46591. parse(source: any): void;
  46592. }
  46593. }
  46594. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  46595. /**
  46596. * @hidden
  46597. */
  46598. export interface IMaterialBRDFDefines {
  46599. BRDF_V_HEIGHT_CORRELATED: boolean;
  46600. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46601. SPHERICAL_HARMONICS: boolean;
  46602. /** @hidden */
  46603. _areMiscDirty: boolean;
  46604. }
  46605. /**
  46606. * Define the code related to the BRDF parameters of the pbr material.
  46607. */
  46608. export class PBRBRDFConfiguration {
  46609. /**
  46610. * Default value used for the energy conservation.
  46611. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46612. */
  46613. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  46614. /**
  46615. * Default value used for the Smith Visibility Height Correlated mode.
  46616. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46617. */
  46618. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  46619. /**
  46620. * Default value used for the IBL diffuse part.
  46621. * This can help switching back to the polynomials mode globally which is a tiny bit
  46622. * less GPU intensive at the drawback of a lower quality.
  46623. */
  46624. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  46625. private _useEnergyConservation;
  46626. /**
  46627. * Defines if the material uses energy conservation.
  46628. */
  46629. useEnergyConservation: boolean;
  46630. private _useSmithVisibilityHeightCorrelated;
  46631. /**
  46632. * LEGACY Mode set to false
  46633. * Defines if the material uses height smith correlated visibility term.
  46634. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  46635. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  46636. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  46637. * Not relying on height correlated will also disable energy conservation.
  46638. */
  46639. useSmithVisibilityHeightCorrelated: boolean;
  46640. private _useSphericalHarmonics;
  46641. /**
  46642. * LEGACY Mode set to false
  46643. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  46644. * diffuse part of the IBL.
  46645. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  46646. * to the ground truth.
  46647. */
  46648. useSphericalHarmonics: boolean;
  46649. /** @hidden */
  46650. private _internalMarkAllSubMeshesAsMiscDirty;
  46651. /** @hidden */
  46652. _markAllSubMeshesAsMiscDirty(): void;
  46653. /**
  46654. * Instantiate a new istance of clear coat configuration.
  46655. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  46656. */
  46657. constructor(markAllSubMeshesAsMiscDirty: () => void);
  46658. /**
  46659. * Checks to see if a texture is used in the material.
  46660. * @param defines the list of "defines" to update.
  46661. */
  46662. prepareDefines(defines: IMaterialBRDFDefines): void;
  46663. /**
  46664. * Get the current class name of the texture useful for serialization or dynamic coding.
  46665. * @returns "PBRClearCoatConfiguration"
  46666. */
  46667. getClassName(): string;
  46668. /**
  46669. * Makes a duplicate of the current configuration into another one.
  46670. * @param brdfConfiguration define the config where to copy the info
  46671. */
  46672. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  46673. /**
  46674. * Serializes this BRDF configuration.
  46675. * @returns - An object with the serialized config.
  46676. */
  46677. serialize(): any;
  46678. /**
  46679. * Parses a BRDF Configuration from a serialized object.
  46680. * @param source - Serialized object.
  46681. */
  46682. parse(source: any): void;
  46683. }
  46684. }
  46685. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  46686. import { EffectFallbacks } from "babylonjs/Materials/effect";
  46687. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46688. import { Color3 } from "babylonjs/Maths/math";
  46689. import { Scene } from "babylonjs/scene";
  46690. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46691. import { IAnimatable } from "babylonjs/Misc/tools";
  46692. import { Nullable } from "babylonjs/types";
  46693. /**
  46694. * @hidden
  46695. */
  46696. export interface IMaterialSheenDefines {
  46697. SHEEN: boolean;
  46698. SHEEN_TEXTURE: boolean;
  46699. SHEEN_TEXTUREDIRECTUV: number;
  46700. SHEEN_LINKWITHALBEDO: boolean;
  46701. /** @hidden */
  46702. _areTexturesDirty: boolean;
  46703. }
  46704. /**
  46705. * Define the code related to the Sheen parameters of the pbr material.
  46706. */
  46707. export class PBRSheenConfiguration {
  46708. private _isEnabled;
  46709. /**
  46710. * Defines if the material uses sheen.
  46711. */
  46712. isEnabled: boolean;
  46713. private _linkSheenWithAlbedo;
  46714. /**
  46715. * Defines if the sheen is linked to the sheen color.
  46716. */
  46717. linkSheenWithAlbedo: boolean;
  46718. /**
  46719. * Defines the sheen intensity.
  46720. */
  46721. intensity: number;
  46722. /**
  46723. * Defines the sheen color.
  46724. */
  46725. color: Color3;
  46726. private _texture;
  46727. /**
  46728. * Stores the sheen tint values in a texture.
  46729. * rgb is tint
  46730. * a is a intensity
  46731. */
  46732. texture: Nullable<BaseTexture>;
  46733. /** @hidden */
  46734. private _internalMarkAllSubMeshesAsTexturesDirty;
  46735. /** @hidden */
  46736. _markAllSubMeshesAsTexturesDirty(): void;
  46737. /**
  46738. * Instantiate a new istance of clear coat configuration.
  46739. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46740. */
  46741. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46742. /**
  46743. * Specifies that the submesh is ready to be used.
  46744. * @param defines the list of "defines" to update.
  46745. * @param scene defines the scene the material belongs to.
  46746. * @returns - boolean indicating that the submesh is ready or not.
  46747. */
  46748. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  46749. /**
  46750. * Checks to see if a texture is used in the material.
  46751. * @param defines the list of "defines" to update.
  46752. * @param scene defines the scene the material belongs to.
  46753. */
  46754. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  46755. /**
  46756. * Binds the material data.
  46757. * @param uniformBuffer defines the Uniform buffer to fill in.
  46758. * @param scene defines the scene the material belongs to.
  46759. * @param isFrozen defines wether the material is frozen or not.
  46760. */
  46761. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46762. /**
  46763. * Checks to see if a texture is used in the material.
  46764. * @param texture - Base texture to use.
  46765. * @returns - Boolean specifying if a texture is used in the material.
  46766. */
  46767. hasTexture(texture: BaseTexture): boolean;
  46768. /**
  46769. * Returns an array of the actively used textures.
  46770. * @param activeTextures Array of BaseTextures
  46771. */
  46772. getActiveTextures(activeTextures: BaseTexture[]): void;
  46773. /**
  46774. * Returns the animatable textures.
  46775. * @param animatables Array of animatable textures.
  46776. */
  46777. getAnimatables(animatables: IAnimatable[]): void;
  46778. /**
  46779. * Disposes the resources of the material.
  46780. * @param forceDisposeTextures - Forces the disposal of all textures.
  46781. */
  46782. dispose(forceDisposeTextures?: boolean): void;
  46783. /**
  46784. * Get the current class name of the texture useful for serialization or dynamic coding.
  46785. * @returns "PBRSheenConfiguration"
  46786. */
  46787. getClassName(): string;
  46788. /**
  46789. * Add fallbacks to the effect fallbacks list.
  46790. * @param defines defines the Base texture to use.
  46791. * @param fallbacks defines the current fallback list.
  46792. * @param currentRank defines the current fallback rank.
  46793. * @returns the new fallback rank.
  46794. */
  46795. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46796. /**
  46797. * Add the required uniforms to the current list.
  46798. * @param uniforms defines the current uniform list.
  46799. */
  46800. static AddUniforms(uniforms: string[]): void;
  46801. /**
  46802. * Add the required uniforms to the current buffer.
  46803. * @param uniformBuffer defines the current uniform buffer.
  46804. */
  46805. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46806. /**
  46807. * Add the required samplers to the current list.
  46808. * @param samplers defines the current sampler list.
  46809. */
  46810. static AddSamplers(samplers: string[]): void;
  46811. /**
  46812. * Makes a duplicate of the current configuration into another one.
  46813. * @param sheenConfiguration define the config where to copy the info
  46814. */
  46815. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  46816. /**
  46817. * Serializes this BRDF configuration.
  46818. * @returns - An object with the serialized config.
  46819. */
  46820. serialize(): any;
  46821. /**
  46822. * Parses a Sheen Configuration from a serialized object.
  46823. * @param source - Serialized object.
  46824. */
  46825. parse(source: any): void;
  46826. }
  46827. }
  46828. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  46829. import { Nullable } from "babylonjs/types";
  46830. import { IAnimatable } from "babylonjs/Misc/tools";
  46831. import { Color3 } from "babylonjs/Maths/math";
  46832. import { SmartArray } from "babylonjs/Misc/smartArray";
  46833. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46834. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  46835. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  46836. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46837. import { Engine } from "babylonjs/Engines/engine";
  46838. import { Scene } from "babylonjs/scene";
  46839. /**
  46840. * @hidden
  46841. */
  46842. export interface IMaterialSubSurfaceDefines {
  46843. SUBSURFACE: boolean;
  46844. SS_REFRACTION: boolean;
  46845. SS_TRANSLUCENCY: boolean;
  46846. SS_SCATERRING: boolean;
  46847. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46848. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46849. SS_REFRACTIONMAP_3D: boolean;
  46850. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46851. SS_LODINREFRACTIONALPHA: boolean;
  46852. SS_GAMMAREFRACTION: boolean;
  46853. SS_RGBDREFRACTION: boolean;
  46854. SS_LINEARSPECULARREFRACTION: boolean;
  46855. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  46856. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  46857. /** @hidden */
  46858. _areTexturesDirty: boolean;
  46859. }
  46860. /**
  46861. * Define the code related to the sub surface parameters of the pbr material.
  46862. */
  46863. export class PBRSubSurfaceConfiguration {
  46864. private _isRefractionEnabled;
  46865. /**
  46866. * Defines if the refraction is enabled in the material.
  46867. */
  46868. isRefractionEnabled: boolean;
  46869. private _isTranslucencyEnabled;
  46870. /**
  46871. * Defines if the translucency is enabled in the material.
  46872. */
  46873. isTranslucencyEnabled: boolean;
  46874. private _isScatteringEnabled;
  46875. /**
  46876. * Defines the refraction intensity of the material.
  46877. * The refraction when enabled replaces the Diffuse part of the material.
  46878. * The intensity helps transitionning between diffuse and refraction.
  46879. */
  46880. refractionIntensity: number;
  46881. /**
  46882. * Defines the translucency intensity of the material.
  46883. * When translucency has been enabled, this defines how much of the "translucency"
  46884. * is addded to the diffuse part of the material.
  46885. */
  46886. translucencyIntensity: number;
  46887. /**
  46888. * Defines the scattering intensity of the material.
  46889. * When scattering has been enabled, this defines how much of the "scattered light"
  46890. * is addded to the diffuse part of the material.
  46891. */
  46892. scatteringIntensity: number;
  46893. private _thicknessTexture;
  46894. /**
  46895. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  46896. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  46897. * 0 would mean minimumThickness
  46898. * 1 would mean maximumThickness
  46899. * The other channels might be use as a mask to vary the different effects intensity.
  46900. */
  46901. thicknessTexture: Nullable<BaseTexture>;
  46902. private _refractionTexture;
  46903. /**
  46904. * Defines the texture to use for refraction.
  46905. */
  46906. refractionTexture: Nullable<BaseTexture>;
  46907. private _indexOfRefraction;
  46908. /**
  46909. * Defines the index of refraction used in the material.
  46910. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  46911. */
  46912. indexOfRefraction: number;
  46913. private _invertRefractionY;
  46914. /**
  46915. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  46916. */
  46917. invertRefractionY: boolean;
  46918. private _linkRefractionWithTransparency;
  46919. /**
  46920. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  46921. * Materials half opaque for instance using refraction could benefit from this control.
  46922. */
  46923. linkRefractionWithTransparency: boolean;
  46924. /**
  46925. * Defines the minimum thickness stored in the thickness map.
  46926. * If no thickness map is defined, this value will be used to simulate thickness.
  46927. */
  46928. minimumThickness: number;
  46929. /**
  46930. * Defines the maximum thickness stored in the thickness map.
  46931. */
  46932. maximumThickness: number;
  46933. /**
  46934. * Defines the volume tint of the material.
  46935. * This is used for both translucency and scattering.
  46936. */
  46937. tintColor: Color3;
  46938. /**
  46939. * Defines the distance at which the tint color should be found in the media.
  46940. * This is used for refraction only.
  46941. */
  46942. tintColorAtDistance: number;
  46943. /**
  46944. * Defines how far each channel transmit through the media.
  46945. * It is defined as a color to simplify it selection.
  46946. */
  46947. diffusionDistance: Color3;
  46948. private _useMaskFromThicknessTexture;
  46949. /**
  46950. * Stores the intensity of the different subsurface effects in the thickness texture.
  46951. * * the green channel is the translucency intensity.
  46952. * * the blue channel is the scattering intensity.
  46953. * * the alpha channel is the refraction intensity.
  46954. */
  46955. useMaskFromThicknessTexture: boolean;
  46956. /** @hidden */
  46957. private _internalMarkAllSubMeshesAsTexturesDirty;
  46958. /** @hidden */
  46959. _markAllSubMeshesAsTexturesDirty(): void;
  46960. /**
  46961. * Instantiate a new istance of sub surface configuration.
  46962. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46963. */
  46964. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46965. /**
  46966. * Gets wehter the submesh is ready to be used or not.
  46967. * @param defines the list of "defines" to update.
  46968. * @param scene defines the scene the material belongs to.
  46969. * @returns - boolean indicating that the submesh is ready or not.
  46970. */
  46971. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  46972. /**
  46973. * Checks to see if a texture is used in the material.
  46974. * @param defines the list of "defines" to update.
  46975. * @param scene defines the scene to the material belongs to.
  46976. */
  46977. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  46978. /**
  46979. * Binds the material data.
  46980. * @param uniformBuffer defines the Uniform buffer to fill in.
  46981. * @param scene defines the scene the material belongs to.
  46982. * @param engine defines the engine the material belongs to.
  46983. * @param isFrozen defines wether the material is frozen or not.
  46984. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  46985. */
  46986. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  46987. /**
  46988. * Unbinds the material from the mesh.
  46989. * @param activeEffect defines the effect that should be unbound from.
  46990. * @returns true if unbound, otherwise false
  46991. */
  46992. unbind(activeEffect: Effect): boolean;
  46993. /**
  46994. * Returns the texture used for refraction or null if none is used.
  46995. * @param scene defines the scene the material belongs to.
  46996. * @returns - Refraction texture if present. If no refraction texture and refraction
  46997. * is linked with transparency, returns environment texture. Otherwise, returns null.
  46998. */
  46999. private _getRefractionTexture;
  47000. /**
  47001. * Returns true if alpha blending should be disabled.
  47002. */
  47003. readonly disableAlphaBlending: boolean;
  47004. /**
  47005. * Fills the list of render target textures.
  47006. * @param renderTargets the list of render targets to update
  47007. */
  47008. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  47009. /**
  47010. * Checks to see if a texture is used in the material.
  47011. * @param texture - Base texture to use.
  47012. * @returns - Boolean specifying if a texture is used in the material.
  47013. */
  47014. hasTexture(texture: BaseTexture): boolean;
  47015. /**
  47016. * Gets a boolean indicating that current material needs to register RTT
  47017. * @returns true if this uses a render target otherwise false.
  47018. */
  47019. hasRenderTargetTextures(): boolean;
  47020. /**
  47021. * Returns an array of the actively used textures.
  47022. * @param activeTextures Array of BaseTextures
  47023. */
  47024. getActiveTextures(activeTextures: BaseTexture[]): void;
  47025. /**
  47026. * Returns the animatable textures.
  47027. * @param animatables Array of animatable textures.
  47028. */
  47029. getAnimatables(animatables: IAnimatable[]): void;
  47030. /**
  47031. * Disposes the resources of the material.
  47032. * @param forceDisposeTextures - Forces the disposal of all textures.
  47033. */
  47034. dispose(forceDisposeTextures?: boolean): void;
  47035. /**
  47036. * Get the current class name of the texture useful for serialization or dynamic coding.
  47037. * @returns "PBRSubSurfaceConfiguration"
  47038. */
  47039. getClassName(): string;
  47040. /**
  47041. * Add fallbacks to the effect fallbacks list.
  47042. * @param defines defines the Base texture to use.
  47043. * @param fallbacks defines the current fallback list.
  47044. * @param currentRank defines the current fallback rank.
  47045. * @returns the new fallback rank.
  47046. */
  47047. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47048. /**
  47049. * Add the required uniforms to the current list.
  47050. * @param uniforms defines the current uniform list.
  47051. */
  47052. static AddUniforms(uniforms: string[]): void;
  47053. /**
  47054. * Add the required samplers to the current list.
  47055. * @param samplers defines the current sampler list.
  47056. */
  47057. static AddSamplers(samplers: string[]): void;
  47058. /**
  47059. * Add the required uniforms to the current buffer.
  47060. * @param uniformBuffer defines the current uniform buffer.
  47061. */
  47062. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47063. /**
  47064. * Makes a duplicate of the current configuration into another one.
  47065. * @param configuration define the config where to copy the info
  47066. */
  47067. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  47068. /**
  47069. * Serializes this Sub Surface configuration.
  47070. * @returns - An object with the serialized config.
  47071. */
  47072. serialize(): any;
  47073. /**
  47074. * Parses a Sub Surface Configuration from a serialized object.
  47075. * @param source - Serialized object.
  47076. */
  47077. parse(source: any): void;
  47078. }
  47079. }
  47080. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  47081. /** @hidden */
  47082. export var pbrFragmentDeclaration: {
  47083. name: string;
  47084. shader: string;
  47085. };
  47086. }
  47087. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  47088. /** @hidden */
  47089. export var pbrUboDeclaration: {
  47090. name: string;
  47091. shader: string;
  47092. };
  47093. }
  47094. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  47095. /** @hidden */
  47096. export var pbrFragmentExtraDeclaration: {
  47097. name: string;
  47098. shader: string;
  47099. };
  47100. }
  47101. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  47102. /** @hidden */
  47103. export var pbrFragmentSamplersDeclaration: {
  47104. name: string;
  47105. shader: string;
  47106. };
  47107. }
  47108. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  47109. /** @hidden */
  47110. export var pbrHelperFunctions: {
  47111. name: string;
  47112. shader: string;
  47113. };
  47114. }
  47115. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  47116. /** @hidden */
  47117. export var harmonicsFunctions: {
  47118. name: string;
  47119. shader: string;
  47120. };
  47121. }
  47122. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  47123. /** @hidden */
  47124. export var pbrDirectLightingSetupFunctions: {
  47125. name: string;
  47126. shader: string;
  47127. };
  47128. }
  47129. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  47130. /** @hidden */
  47131. export var pbrDirectLightingFalloffFunctions: {
  47132. name: string;
  47133. shader: string;
  47134. };
  47135. }
  47136. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  47137. /** @hidden */
  47138. export var pbrBRDFFunctions: {
  47139. name: string;
  47140. shader: string;
  47141. };
  47142. }
  47143. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  47144. /** @hidden */
  47145. export var pbrDirectLightingFunctions: {
  47146. name: string;
  47147. shader: string;
  47148. };
  47149. }
  47150. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  47151. /** @hidden */
  47152. export var pbrIBLFunctions: {
  47153. name: string;
  47154. shader: string;
  47155. };
  47156. }
  47157. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  47158. /** @hidden */
  47159. export var pbrDebug: {
  47160. name: string;
  47161. shader: string;
  47162. };
  47163. }
  47164. declare module "babylonjs/Shaders/pbr.fragment" {
  47165. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  47166. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  47167. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  47168. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47169. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47170. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  47171. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  47172. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  47173. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  47174. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  47175. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47176. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  47177. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  47178. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  47179. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  47180. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  47181. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  47182. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  47183. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  47184. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  47185. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  47186. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  47187. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  47188. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  47189. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  47190. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  47191. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  47192. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  47193. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  47194. /** @hidden */
  47195. export var pbrPixelShader: {
  47196. name: string;
  47197. shader: string;
  47198. };
  47199. }
  47200. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  47201. /** @hidden */
  47202. export var pbrVertexDeclaration: {
  47203. name: string;
  47204. shader: string;
  47205. };
  47206. }
  47207. declare module "babylonjs/Shaders/pbr.vertex" {
  47208. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  47209. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  47210. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47211. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  47212. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  47213. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  47214. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  47215. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  47216. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  47217. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47218. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47219. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  47220. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  47221. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  47222. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  47223. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  47224. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  47225. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  47226. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  47227. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  47228. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  47229. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  47230. /** @hidden */
  47231. export var pbrVertexShader: {
  47232. name: string;
  47233. shader: string;
  47234. };
  47235. }
  47236. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  47237. import { IAnimatable } from "babylonjs/Misc/tools";
  47238. import { Nullable } from "babylonjs/types";
  47239. import { Scene } from "babylonjs/scene";
  47240. import { Matrix, Color3 } from "babylonjs/Maths/math";
  47241. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47242. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47243. import { Mesh } from "babylonjs/Meshes/mesh";
  47244. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  47245. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  47246. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  47247. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  47248. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  47249. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  47250. import { Material } from "babylonjs/Materials/material";
  47251. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  47252. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  47253. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47254. import "babylonjs/Shaders/pbr.fragment";
  47255. import "babylonjs/Shaders/pbr.vertex";
  47256. /**
  47257. * Manages the defines for the PBR Material.
  47258. * @hidden
  47259. */
  47260. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  47261. PBR: boolean;
  47262. MAINUV1: boolean;
  47263. MAINUV2: boolean;
  47264. UV1: boolean;
  47265. UV2: boolean;
  47266. ALBEDO: boolean;
  47267. ALBEDODIRECTUV: number;
  47268. VERTEXCOLOR: boolean;
  47269. AMBIENT: boolean;
  47270. AMBIENTDIRECTUV: number;
  47271. AMBIENTINGRAYSCALE: boolean;
  47272. OPACITY: boolean;
  47273. VERTEXALPHA: boolean;
  47274. OPACITYDIRECTUV: number;
  47275. OPACITYRGB: boolean;
  47276. ALPHATEST: boolean;
  47277. DEPTHPREPASS: boolean;
  47278. ALPHABLEND: boolean;
  47279. ALPHAFROMALBEDO: boolean;
  47280. ALPHATESTVALUE: string;
  47281. SPECULAROVERALPHA: boolean;
  47282. RADIANCEOVERALPHA: boolean;
  47283. ALPHAFRESNEL: boolean;
  47284. LINEARALPHAFRESNEL: boolean;
  47285. PREMULTIPLYALPHA: boolean;
  47286. EMISSIVE: boolean;
  47287. EMISSIVEDIRECTUV: number;
  47288. REFLECTIVITY: boolean;
  47289. REFLECTIVITYDIRECTUV: number;
  47290. SPECULARTERM: boolean;
  47291. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  47292. MICROSURFACEAUTOMATIC: boolean;
  47293. LODBASEDMICROSFURACE: boolean;
  47294. MICROSURFACEMAP: boolean;
  47295. MICROSURFACEMAPDIRECTUV: number;
  47296. METALLICWORKFLOW: boolean;
  47297. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  47298. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  47299. METALLNESSSTOREINMETALMAPBLUE: boolean;
  47300. AOSTOREINMETALMAPRED: boolean;
  47301. ENVIRONMENTBRDF: boolean;
  47302. ENVIRONMENTBRDF_RGBD: boolean;
  47303. NORMAL: boolean;
  47304. TANGENT: boolean;
  47305. BUMP: boolean;
  47306. BUMPDIRECTUV: number;
  47307. OBJECTSPACE_NORMALMAP: boolean;
  47308. PARALLAX: boolean;
  47309. PARALLAXOCCLUSION: boolean;
  47310. NORMALXYSCALE: boolean;
  47311. LIGHTMAP: boolean;
  47312. LIGHTMAPDIRECTUV: number;
  47313. USELIGHTMAPASSHADOWMAP: boolean;
  47314. GAMMALIGHTMAP: boolean;
  47315. REFLECTION: boolean;
  47316. REFLECTIONMAP_3D: boolean;
  47317. REFLECTIONMAP_SPHERICAL: boolean;
  47318. REFLECTIONMAP_PLANAR: boolean;
  47319. REFLECTIONMAP_CUBIC: boolean;
  47320. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  47321. REFLECTIONMAP_PROJECTION: boolean;
  47322. REFLECTIONMAP_SKYBOX: boolean;
  47323. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  47324. REFLECTIONMAP_EXPLICIT: boolean;
  47325. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  47326. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  47327. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  47328. INVERTCUBICMAP: boolean;
  47329. USESPHERICALFROMREFLECTIONMAP: boolean;
  47330. USEIRRADIANCEMAP: boolean;
  47331. SPHERICAL_HARMONICS: boolean;
  47332. USESPHERICALINVERTEX: boolean;
  47333. REFLECTIONMAP_OPPOSITEZ: boolean;
  47334. LODINREFLECTIONALPHA: boolean;
  47335. GAMMAREFLECTION: boolean;
  47336. RGBDREFLECTION: boolean;
  47337. LINEARSPECULARREFLECTION: boolean;
  47338. RADIANCEOCCLUSION: boolean;
  47339. HORIZONOCCLUSION: boolean;
  47340. INSTANCES: boolean;
  47341. NUM_BONE_INFLUENCERS: number;
  47342. BonesPerMesh: number;
  47343. BONETEXTURE: boolean;
  47344. NONUNIFORMSCALING: boolean;
  47345. MORPHTARGETS: boolean;
  47346. MORPHTARGETS_NORMAL: boolean;
  47347. MORPHTARGETS_TANGENT: boolean;
  47348. NUM_MORPH_INFLUENCERS: number;
  47349. IMAGEPROCESSING: boolean;
  47350. VIGNETTE: boolean;
  47351. VIGNETTEBLENDMODEMULTIPLY: boolean;
  47352. VIGNETTEBLENDMODEOPAQUE: boolean;
  47353. TONEMAPPING: boolean;
  47354. TONEMAPPING_ACES: boolean;
  47355. CONTRAST: boolean;
  47356. COLORCURVES: boolean;
  47357. COLORGRADING: boolean;
  47358. COLORGRADING3D: boolean;
  47359. SAMPLER3DGREENDEPTH: boolean;
  47360. SAMPLER3DBGRMAP: boolean;
  47361. IMAGEPROCESSINGPOSTPROCESS: boolean;
  47362. EXPOSURE: boolean;
  47363. MULTIVIEW: boolean;
  47364. USEPHYSICALLIGHTFALLOFF: boolean;
  47365. USEGLTFLIGHTFALLOFF: boolean;
  47366. TWOSIDEDLIGHTING: boolean;
  47367. SHADOWFLOAT: boolean;
  47368. CLIPPLANE: boolean;
  47369. CLIPPLANE2: boolean;
  47370. CLIPPLANE3: boolean;
  47371. CLIPPLANE4: boolean;
  47372. POINTSIZE: boolean;
  47373. FOG: boolean;
  47374. LOGARITHMICDEPTH: boolean;
  47375. FORCENORMALFORWARD: boolean;
  47376. SPECULARAA: boolean;
  47377. CLEARCOAT: boolean;
  47378. CLEARCOAT_DEFAULTIOR: boolean;
  47379. CLEARCOAT_TEXTURE: boolean;
  47380. CLEARCOAT_TEXTUREDIRECTUV: number;
  47381. CLEARCOAT_BUMP: boolean;
  47382. CLEARCOAT_BUMPDIRECTUV: number;
  47383. CLEARCOAT_TINT: boolean;
  47384. CLEARCOAT_TINT_TEXTURE: boolean;
  47385. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  47386. ANISOTROPIC: boolean;
  47387. ANISOTROPIC_TEXTURE: boolean;
  47388. ANISOTROPIC_TEXTUREDIRECTUV: number;
  47389. BRDF_V_HEIGHT_CORRELATED: boolean;
  47390. MS_BRDF_ENERGY_CONSERVATION: boolean;
  47391. SHEEN: boolean;
  47392. SHEEN_TEXTURE: boolean;
  47393. SHEEN_TEXTUREDIRECTUV: number;
  47394. SHEEN_LINKWITHALBEDO: boolean;
  47395. SUBSURFACE: boolean;
  47396. SS_REFRACTION: boolean;
  47397. SS_TRANSLUCENCY: boolean;
  47398. SS_SCATERRING: boolean;
  47399. SS_THICKNESSANDMASK_TEXTURE: boolean;
  47400. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  47401. SS_REFRACTIONMAP_3D: boolean;
  47402. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  47403. SS_LODINREFRACTIONALPHA: boolean;
  47404. SS_GAMMAREFRACTION: boolean;
  47405. SS_RGBDREFRACTION: boolean;
  47406. SS_LINEARSPECULARREFRACTION: boolean;
  47407. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  47408. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  47409. UNLIT: boolean;
  47410. DEBUGMODE: number;
  47411. /**
  47412. * Initializes the PBR Material defines.
  47413. */
  47414. constructor();
  47415. /**
  47416. * Resets the PBR Material defines.
  47417. */
  47418. reset(): void;
  47419. }
  47420. /**
  47421. * The Physically based material base class of BJS.
  47422. *
  47423. * This offers the main features of a standard PBR material.
  47424. * For more information, please refer to the documentation :
  47425. * https://doc.babylonjs.com/how_to/physically_based_rendering
  47426. */
  47427. export abstract class PBRBaseMaterial extends PushMaterial {
  47428. /**
  47429. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47430. */
  47431. static readonly PBRMATERIAL_OPAQUE: number;
  47432. /**
  47433. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47434. */
  47435. static readonly PBRMATERIAL_ALPHATEST: number;
  47436. /**
  47437. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47438. */
  47439. static readonly PBRMATERIAL_ALPHABLEND: number;
  47440. /**
  47441. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47442. * They are also discarded below the alpha cutoff threshold to improve performances.
  47443. */
  47444. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47445. /**
  47446. * Defines the default value of how much AO map is occluding the analytical lights
  47447. * (point spot...).
  47448. */
  47449. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47450. /**
  47451. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  47452. */
  47453. static readonly LIGHTFALLOFF_PHYSICAL: number;
  47454. /**
  47455. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  47456. * to enhance interoperability with other engines.
  47457. */
  47458. static readonly LIGHTFALLOFF_GLTF: number;
  47459. /**
  47460. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  47461. * to enhance interoperability with other materials.
  47462. */
  47463. static readonly LIGHTFALLOFF_STANDARD: number;
  47464. /**
  47465. * Intensity of the direct lights e.g. the four lights available in your scene.
  47466. * This impacts both the direct diffuse and specular highlights.
  47467. */
  47468. protected _directIntensity: number;
  47469. /**
  47470. * Intensity of the emissive part of the material.
  47471. * This helps controlling the emissive effect without modifying the emissive color.
  47472. */
  47473. protected _emissiveIntensity: number;
  47474. /**
  47475. * Intensity of the environment e.g. how much the environment will light the object
  47476. * either through harmonics for rough material or through the refelction for shiny ones.
  47477. */
  47478. protected _environmentIntensity: number;
  47479. /**
  47480. * This is a special control allowing the reduction of the specular highlights coming from the
  47481. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47482. */
  47483. protected _specularIntensity: number;
  47484. /**
  47485. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  47486. */
  47487. private _lightingInfos;
  47488. /**
  47489. * Debug Control allowing disabling the bump map on this material.
  47490. */
  47491. protected _disableBumpMap: boolean;
  47492. /**
  47493. * AKA Diffuse Texture in standard nomenclature.
  47494. */
  47495. protected _albedoTexture: Nullable<BaseTexture>;
  47496. /**
  47497. * AKA Occlusion Texture in other nomenclature.
  47498. */
  47499. protected _ambientTexture: Nullable<BaseTexture>;
  47500. /**
  47501. * AKA Occlusion Texture Intensity in other nomenclature.
  47502. */
  47503. protected _ambientTextureStrength: number;
  47504. /**
  47505. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47506. * 1 means it completely occludes it
  47507. * 0 mean it has no impact
  47508. */
  47509. protected _ambientTextureImpactOnAnalyticalLights: number;
  47510. /**
  47511. * Stores the alpha values in a texture.
  47512. */
  47513. protected _opacityTexture: Nullable<BaseTexture>;
  47514. /**
  47515. * Stores the reflection values in a texture.
  47516. */
  47517. protected _reflectionTexture: Nullable<BaseTexture>;
  47518. /**
  47519. * Stores the emissive values in a texture.
  47520. */
  47521. protected _emissiveTexture: Nullable<BaseTexture>;
  47522. /**
  47523. * AKA Specular texture in other nomenclature.
  47524. */
  47525. protected _reflectivityTexture: Nullable<BaseTexture>;
  47526. /**
  47527. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47528. */
  47529. protected _metallicTexture: Nullable<BaseTexture>;
  47530. /**
  47531. * Specifies the metallic scalar of the metallic/roughness workflow.
  47532. * Can also be used to scale the metalness values of the metallic texture.
  47533. */
  47534. protected _metallic: Nullable<number>;
  47535. /**
  47536. * Specifies the roughness scalar of the metallic/roughness workflow.
  47537. * Can also be used to scale the roughness values of the metallic texture.
  47538. */
  47539. protected _roughness: Nullable<number>;
  47540. /**
  47541. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47542. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47543. */
  47544. protected _microSurfaceTexture: Nullable<BaseTexture>;
  47545. /**
  47546. * Stores surface normal data used to displace a mesh in a texture.
  47547. */
  47548. protected _bumpTexture: Nullable<BaseTexture>;
  47549. /**
  47550. * Stores the pre-calculated light information of a mesh in a texture.
  47551. */
  47552. protected _lightmapTexture: Nullable<BaseTexture>;
  47553. /**
  47554. * The color of a material in ambient lighting.
  47555. */
  47556. protected _ambientColor: Color3;
  47557. /**
  47558. * AKA Diffuse Color in other nomenclature.
  47559. */
  47560. protected _albedoColor: Color3;
  47561. /**
  47562. * AKA Specular Color in other nomenclature.
  47563. */
  47564. protected _reflectivityColor: Color3;
  47565. /**
  47566. * The color applied when light is reflected from a material.
  47567. */
  47568. protected _reflectionColor: Color3;
  47569. /**
  47570. * The color applied when light is emitted from a material.
  47571. */
  47572. protected _emissiveColor: Color3;
  47573. /**
  47574. * AKA Glossiness in other nomenclature.
  47575. */
  47576. protected _microSurface: number;
  47577. /**
  47578. * Specifies that the material will use the light map as a show map.
  47579. */
  47580. protected _useLightmapAsShadowmap: boolean;
  47581. /**
  47582. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47583. * makes the reflect vector face the model (under horizon).
  47584. */
  47585. protected _useHorizonOcclusion: boolean;
  47586. /**
  47587. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47588. * too much the area relying on ambient texture to define their ambient occlusion.
  47589. */
  47590. protected _useRadianceOcclusion: boolean;
  47591. /**
  47592. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47593. */
  47594. protected _useAlphaFromAlbedoTexture: boolean;
  47595. /**
  47596. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  47597. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47598. */
  47599. protected _useSpecularOverAlpha: boolean;
  47600. /**
  47601. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47602. */
  47603. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47604. /**
  47605. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47606. */
  47607. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  47608. /**
  47609. * Specifies if the metallic texture contains the roughness information in its green channel.
  47610. */
  47611. protected _useRoughnessFromMetallicTextureGreen: boolean;
  47612. /**
  47613. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47614. */
  47615. protected _useMetallnessFromMetallicTextureBlue: boolean;
  47616. /**
  47617. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47618. */
  47619. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  47620. /**
  47621. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47622. */
  47623. protected _useAmbientInGrayScale: boolean;
  47624. /**
  47625. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47626. * The material will try to infer what glossiness each pixel should be.
  47627. */
  47628. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  47629. /**
  47630. * Defines the falloff type used in this material.
  47631. * It by default is Physical.
  47632. */
  47633. protected _lightFalloff: number;
  47634. /**
  47635. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47636. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47637. */
  47638. protected _useRadianceOverAlpha: boolean;
  47639. /**
  47640. * Allows using an object space normal map (instead of tangent space).
  47641. */
  47642. protected _useObjectSpaceNormalMap: boolean;
  47643. /**
  47644. * Allows using the bump map in parallax mode.
  47645. */
  47646. protected _useParallax: boolean;
  47647. /**
  47648. * Allows using the bump map in parallax occlusion mode.
  47649. */
  47650. protected _useParallaxOcclusion: boolean;
  47651. /**
  47652. * Controls the scale bias of the parallax mode.
  47653. */
  47654. protected _parallaxScaleBias: number;
  47655. /**
  47656. * If sets to true, disables all the lights affecting the material.
  47657. */
  47658. protected _disableLighting: boolean;
  47659. /**
  47660. * Number of Simultaneous lights allowed on the material.
  47661. */
  47662. protected _maxSimultaneousLights: number;
  47663. /**
  47664. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  47665. */
  47666. protected _invertNormalMapX: boolean;
  47667. /**
  47668. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  47669. */
  47670. protected _invertNormalMapY: boolean;
  47671. /**
  47672. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47673. */
  47674. protected _twoSidedLighting: boolean;
  47675. /**
  47676. * Defines the alpha limits in alpha test mode.
  47677. */
  47678. protected _alphaCutOff: number;
  47679. /**
  47680. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47681. */
  47682. protected _forceAlphaTest: boolean;
  47683. /**
  47684. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47685. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47686. */
  47687. protected _useAlphaFresnel: boolean;
  47688. /**
  47689. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47690. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47691. */
  47692. protected _useLinearAlphaFresnel: boolean;
  47693. /**
  47694. * The transparency mode of the material.
  47695. */
  47696. protected _transparencyMode: Nullable<number>;
  47697. /**
  47698. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  47699. * from cos thetav and roughness:
  47700. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  47701. */
  47702. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  47703. /**
  47704. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47705. */
  47706. protected _forceIrradianceInFragment: boolean;
  47707. /**
  47708. * Force normal to face away from face.
  47709. */
  47710. protected _forceNormalForward: boolean;
  47711. /**
  47712. * Enables specular anti aliasing in the PBR shader.
  47713. * It will both interacts on the Geometry for analytical and IBL lighting.
  47714. * It also prefilter the roughness map based on the bump values.
  47715. */
  47716. protected _enableSpecularAntiAliasing: boolean;
  47717. /**
  47718. * Default configuration related to image processing available in the PBR Material.
  47719. */
  47720. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47721. /**
  47722. * Keep track of the image processing observer to allow dispose and replace.
  47723. */
  47724. private _imageProcessingObserver;
  47725. /**
  47726. * Attaches a new image processing configuration to the PBR Material.
  47727. * @param configuration
  47728. */
  47729. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47730. /**
  47731. * Stores the available render targets.
  47732. */
  47733. private _renderTargets;
  47734. /**
  47735. * Sets the global ambient color for the material used in lighting calculations.
  47736. */
  47737. private _globalAmbientColor;
  47738. /**
  47739. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  47740. */
  47741. private _useLogarithmicDepth;
  47742. /**
  47743. * If set to true, no lighting calculations will be applied.
  47744. */
  47745. private _unlit;
  47746. private _debugMode;
  47747. /**
  47748. * @hidden
  47749. * This is reserved for the inspector.
  47750. * Defines the material debug mode.
  47751. * It helps seeing only some components of the material while troubleshooting.
  47752. */
  47753. debugMode: number;
  47754. /**
  47755. * @hidden
  47756. * This is reserved for the inspector.
  47757. * Specify from where on screen the debug mode should start.
  47758. * The value goes from -1 (full screen) to 1 (not visible)
  47759. * It helps with side by side comparison against the final render
  47760. * This defaults to -1
  47761. */
  47762. private debugLimit;
  47763. /**
  47764. * @hidden
  47765. * This is reserved for the inspector.
  47766. * As the default viewing range might not be enough (if the ambient is really small for instance)
  47767. * You can use the factor to better multiply the final value.
  47768. */
  47769. private debugFactor;
  47770. /**
  47771. * Defines the clear coat layer parameters for the material.
  47772. */
  47773. readonly clearCoat: PBRClearCoatConfiguration;
  47774. /**
  47775. * Defines the anisotropic parameters for the material.
  47776. */
  47777. readonly anisotropy: PBRAnisotropicConfiguration;
  47778. /**
  47779. * Defines the BRDF parameters for the material.
  47780. */
  47781. readonly brdf: PBRBRDFConfiguration;
  47782. /**
  47783. * Defines the Sheen parameters for the material.
  47784. */
  47785. readonly sheen: PBRSheenConfiguration;
  47786. /**
  47787. * Defines the SubSurface parameters for the material.
  47788. */
  47789. readonly subSurface: PBRSubSurfaceConfiguration;
  47790. /**
  47791. * Custom callback helping to override the default shader used in the material.
  47792. */
  47793. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  47794. /**
  47795. * Instantiates a new PBRMaterial instance.
  47796. *
  47797. * @param name The material name
  47798. * @param scene The scene the material will be use in.
  47799. */
  47800. constructor(name: string, scene: Scene);
  47801. /**
  47802. * Gets a boolean indicating that current material needs to register RTT
  47803. */
  47804. readonly hasRenderTargetTextures: boolean;
  47805. /**
  47806. * Gets the name of the material class.
  47807. */
  47808. getClassName(): string;
  47809. /**
  47810. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47811. */
  47812. /**
  47813. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47814. */
  47815. useLogarithmicDepth: boolean;
  47816. /**
  47817. * Gets the current transparency mode.
  47818. */
  47819. /**
  47820. * Sets the transparency mode of the material.
  47821. *
  47822. * | Value | Type | Description |
  47823. * | ----- | ----------------------------------- | ----------- |
  47824. * | 0 | OPAQUE | |
  47825. * | 1 | ALPHATEST | |
  47826. * | 2 | ALPHABLEND | |
  47827. * | 3 | ALPHATESTANDBLEND | |
  47828. *
  47829. */
  47830. transparencyMode: Nullable<number>;
  47831. /**
  47832. * Returns true if alpha blending should be disabled.
  47833. */
  47834. private readonly _disableAlphaBlending;
  47835. /**
  47836. * Specifies whether or not this material should be rendered in alpha blend mode.
  47837. */
  47838. needAlphaBlending(): boolean;
  47839. /**
  47840. * Specifies if the mesh will require alpha blending.
  47841. * @param mesh - BJS mesh.
  47842. */
  47843. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  47844. /**
  47845. * Specifies whether or not this material should be rendered in alpha test mode.
  47846. */
  47847. needAlphaTesting(): boolean;
  47848. /**
  47849. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  47850. */
  47851. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  47852. /**
  47853. * Gets the texture used for the alpha test.
  47854. */
  47855. getAlphaTestTexture(): Nullable<BaseTexture>;
  47856. /**
  47857. * Specifies that the submesh is ready to be used.
  47858. * @param mesh - BJS mesh.
  47859. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  47860. * @param useInstances - Specifies that instances should be used.
  47861. * @returns - boolean indicating that the submesh is ready or not.
  47862. */
  47863. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  47864. /**
  47865. * Specifies if the material uses metallic roughness workflow.
  47866. * @returns boolean specifiying if the material uses metallic roughness workflow.
  47867. */
  47868. isMetallicWorkflow(): boolean;
  47869. private _prepareEffect;
  47870. private _prepareDefines;
  47871. /**
  47872. * Force shader compilation
  47873. */
  47874. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  47875. clipPlane: boolean;
  47876. }>): void;
  47877. /**
  47878. * Initializes the uniform buffer layout for the shader.
  47879. */
  47880. buildUniformLayout(): void;
  47881. /**
  47882. * Unbinds the material from the mesh
  47883. */
  47884. unbind(): void;
  47885. /**
  47886. * Binds the submesh data.
  47887. * @param world - The world matrix.
  47888. * @param mesh - The BJS mesh.
  47889. * @param subMesh - A submesh of the BJS mesh.
  47890. */
  47891. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  47892. /**
  47893. * Returns the animatable textures.
  47894. * @returns - Array of animatable textures.
  47895. */
  47896. getAnimatables(): IAnimatable[];
  47897. /**
  47898. * Returns the texture used for reflections.
  47899. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  47900. */
  47901. private _getReflectionTexture;
  47902. /**
  47903. * Returns an array of the actively used textures.
  47904. * @returns - Array of BaseTextures
  47905. */
  47906. getActiveTextures(): BaseTexture[];
  47907. /**
  47908. * Checks to see if a texture is used in the material.
  47909. * @param texture - Base texture to use.
  47910. * @returns - Boolean specifying if a texture is used in the material.
  47911. */
  47912. hasTexture(texture: BaseTexture): boolean;
  47913. /**
  47914. * Disposes the resources of the material.
  47915. * @param forceDisposeEffect - Forces the disposal of effects.
  47916. * @param forceDisposeTextures - Forces the disposal of all textures.
  47917. */
  47918. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  47919. }
  47920. }
  47921. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  47922. import { Nullable } from "babylonjs/types";
  47923. import { Scene } from "babylonjs/scene";
  47924. import { Color3 } from "babylonjs/Maths/math";
  47925. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  47926. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  47927. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47928. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  47929. /**
  47930. * The Physically based material of BJS.
  47931. *
  47932. * This offers the main features of a standard PBR material.
  47933. * For more information, please refer to the documentation :
  47934. * https://doc.babylonjs.com/how_to/physically_based_rendering
  47935. */
  47936. export class PBRMaterial extends PBRBaseMaterial {
  47937. /**
  47938. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47939. */
  47940. static readonly PBRMATERIAL_OPAQUE: number;
  47941. /**
  47942. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47943. */
  47944. static readonly PBRMATERIAL_ALPHATEST: number;
  47945. /**
  47946. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47947. */
  47948. static readonly PBRMATERIAL_ALPHABLEND: number;
  47949. /**
  47950. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47951. * They are also discarded below the alpha cutoff threshold to improve performances.
  47952. */
  47953. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47954. /**
  47955. * Defines the default value of how much AO map is occluding the analytical lights
  47956. * (point spot...).
  47957. */
  47958. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47959. /**
  47960. * Intensity of the direct lights e.g. the four lights available in your scene.
  47961. * This impacts both the direct diffuse and specular highlights.
  47962. */
  47963. directIntensity: number;
  47964. /**
  47965. * Intensity of the emissive part of the material.
  47966. * This helps controlling the emissive effect without modifying the emissive color.
  47967. */
  47968. emissiveIntensity: number;
  47969. /**
  47970. * Intensity of the environment e.g. how much the environment will light the object
  47971. * either through harmonics for rough material or through the refelction for shiny ones.
  47972. */
  47973. environmentIntensity: number;
  47974. /**
  47975. * This is a special control allowing the reduction of the specular highlights coming from the
  47976. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47977. */
  47978. specularIntensity: number;
  47979. /**
  47980. * Debug Control allowing disabling the bump map on this material.
  47981. */
  47982. disableBumpMap: boolean;
  47983. /**
  47984. * AKA Diffuse Texture in standard nomenclature.
  47985. */
  47986. albedoTexture: BaseTexture;
  47987. /**
  47988. * AKA Occlusion Texture in other nomenclature.
  47989. */
  47990. ambientTexture: BaseTexture;
  47991. /**
  47992. * AKA Occlusion Texture Intensity in other nomenclature.
  47993. */
  47994. ambientTextureStrength: number;
  47995. /**
  47996. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47997. * 1 means it completely occludes it
  47998. * 0 mean it has no impact
  47999. */
  48000. ambientTextureImpactOnAnalyticalLights: number;
  48001. /**
  48002. * Stores the alpha values in a texture.
  48003. */
  48004. opacityTexture: BaseTexture;
  48005. /**
  48006. * Stores the reflection values in a texture.
  48007. */
  48008. reflectionTexture: Nullable<BaseTexture>;
  48009. /**
  48010. * Stores the emissive values in a texture.
  48011. */
  48012. emissiveTexture: BaseTexture;
  48013. /**
  48014. * AKA Specular texture in other nomenclature.
  48015. */
  48016. reflectivityTexture: BaseTexture;
  48017. /**
  48018. * Used to switch from specular/glossiness to metallic/roughness workflow.
  48019. */
  48020. metallicTexture: BaseTexture;
  48021. /**
  48022. * Specifies the metallic scalar of the metallic/roughness workflow.
  48023. * Can also be used to scale the metalness values of the metallic texture.
  48024. */
  48025. metallic: Nullable<number>;
  48026. /**
  48027. * Specifies the roughness scalar of the metallic/roughness workflow.
  48028. * Can also be used to scale the roughness values of the metallic texture.
  48029. */
  48030. roughness: Nullable<number>;
  48031. /**
  48032. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  48033. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  48034. */
  48035. microSurfaceTexture: BaseTexture;
  48036. /**
  48037. * Stores surface normal data used to displace a mesh in a texture.
  48038. */
  48039. bumpTexture: BaseTexture;
  48040. /**
  48041. * Stores the pre-calculated light information of a mesh in a texture.
  48042. */
  48043. lightmapTexture: BaseTexture;
  48044. /**
  48045. * Stores the refracted light information in a texture.
  48046. */
  48047. refractionTexture: Nullable<BaseTexture>;
  48048. /**
  48049. * The color of a material in ambient lighting.
  48050. */
  48051. ambientColor: Color3;
  48052. /**
  48053. * AKA Diffuse Color in other nomenclature.
  48054. */
  48055. albedoColor: Color3;
  48056. /**
  48057. * AKA Specular Color in other nomenclature.
  48058. */
  48059. reflectivityColor: Color3;
  48060. /**
  48061. * The color reflected from the material.
  48062. */
  48063. reflectionColor: Color3;
  48064. /**
  48065. * The color emitted from the material.
  48066. */
  48067. emissiveColor: Color3;
  48068. /**
  48069. * AKA Glossiness in other nomenclature.
  48070. */
  48071. microSurface: number;
  48072. /**
  48073. * source material index of refraction (IOR)' / 'destination material IOR.
  48074. */
  48075. indexOfRefraction: number;
  48076. /**
  48077. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  48078. */
  48079. invertRefractionY: boolean;
  48080. /**
  48081. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  48082. * Materials half opaque for instance using refraction could benefit from this control.
  48083. */
  48084. linkRefractionWithTransparency: boolean;
  48085. /**
  48086. * If true, the light map contains occlusion information instead of lighting info.
  48087. */
  48088. useLightmapAsShadowmap: boolean;
  48089. /**
  48090. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  48091. */
  48092. useAlphaFromAlbedoTexture: boolean;
  48093. /**
  48094. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  48095. */
  48096. forceAlphaTest: boolean;
  48097. /**
  48098. * Defines the alpha limits in alpha test mode.
  48099. */
  48100. alphaCutOff: number;
  48101. /**
  48102. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  48103. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  48104. */
  48105. useSpecularOverAlpha: boolean;
  48106. /**
  48107. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  48108. */
  48109. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  48110. /**
  48111. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  48112. */
  48113. useRoughnessFromMetallicTextureAlpha: boolean;
  48114. /**
  48115. * Specifies if the metallic texture contains the roughness information in its green channel.
  48116. */
  48117. useRoughnessFromMetallicTextureGreen: boolean;
  48118. /**
  48119. * Specifies if the metallic texture contains the metallness information in its blue channel.
  48120. */
  48121. useMetallnessFromMetallicTextureBlue: boolean;
  48122. /**
  48123. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  48124. */
  48125. useAmbientOcclusionFromMetallicTextureRed: boolean;
  48126. /**
  48127. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  48128. */
  48129. useAmbientInGrayScale: boolean;
  48130. /**
  48131. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  48132. * The material will try to infer what glossiness each pixel should be.
  48133. */
  48134. useAutoMicroSurfaceFromReflectivityMap: boolean;
  48135. /**
  48136. * BJS is using an harcoded light falloff based on a manually sets up range.
  48137. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  48138. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  48139. */
  48140. /**
  48141. * BJS is using an harcoded light falloff based on a manually sets up range.
  48142. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  48143. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  48144. */
  48145. usePhysicalLightFalloff: boolean;
  48146. /**
  48147. * In order to support the falloff compatibility with gltf, a special mode has been added
  48148. * to reproduce the gltf light falloff.
  48149. */
  48150. /**
  48151. * In order to support the falloff compatibility with gltf, a special mode has been added
  48152. * to reproduce the gltf light falloff.
  48153. */
  48154. useGLTFLightFalloff: boolean;
  48155. /**
  48156. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  48157. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  48158. */
  48159. useRadianceOverAlpha: boolean;
  48160. /**
  48161. * Allows using an object space normal map (instead of tangent space).
  48162. */
  48163. useObjectSpaceNormalMap: boolean;
  48164. /**
  48165. * Allows using the bump map in parallax mode.
  48166. */
  48167. useParallax: boolean;
  48168. /**
  48169. * Allows using the bump map in parallax occlusion mode.
  48170. */
  48171. useParallaxOcclusion: boolean;
  48172. /**
  48173. * Controls the scale bias of the parallax mode.
  48174. */
  48175. parallaxScaleBias: number;
  48176. /**
  48177. * If sets to true, disables all the lights affecting the material.
  48178. */
  48179. disableLighting: boolean;
  48180. /**
  48181. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  48182. */
  48183. forceIrradianceInFragment: boolean;
  48184. /**
  48185. * Number of Simultaneous lights allowed on the material.
  48186. */
  48187. maxSimultaneousLights: number;
  48188. /**
  48189. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  48190. */
  48191. invertNormalMapX: boolean;
  48192. /**
  48193. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  48194. */
  48195. invertNormalMapY: boolean;
  48196. /**
  48197. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48198. */
  48199. twoSidedLighting: boolean;
  48200. /**
  48201. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48202. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  48203. */
  48204. useAlphaFresnel: boolean;
  48205. /**
  48206. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48207. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  48208. */
  48209. useLinearAlphaFresnel: boolean;
  48210. /**
  48211. * Let user defines the brdf lookup texture used for IBL.
  48212. * A default 8bit version is embedded but you could point at :
  48213. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  48214. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  48215. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  48216. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  48217. */
  48218. environmentBRDFTexture: Nullable<BaseTexture>;
  48219. /**
  48220. * Force normal to face away from face.
  48221. */
  48222. forceNormalForward: boolean;
  48223. /**
  48224. * Enables specular anti aliasing in the PBR shader.
  48225. * It will both interacts on the Geometry for analytical and IBL lighting.
  48226. * It also prefilter the roughness map based on the bump values.
  48227. */
  48228. enableSpecularAntiAliasing: boolean;
  48229. /**
  48230. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  48231. * makes the reflect vector face the model (under horizon).
  48232. */
  48233. useHorizonOcclusion: boolean;
  48234. /**
  48235. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  48236. * too much the area relying on ambient texture to define their ambient occlusion.
  48237. */
  48238. useRadianceOcclusion: boolean;
  48239. /**
  48240. * If set to true, no lighting calculations will be applied.
  48241. */
  48242. unlit: boolean;
  48243. /**
  48244. * Gets the image processing configuration used either in this material.
  48245. */
  48246. /**
  48247. * Sets the Default image processing configuration used either in the this material.
  48248. *
  48249. * If sets to null, the scene one is in use.
  48250. */
  48251. imageProcessingConfiguration: ImageProcessingConfiguration;
  48252. /**
  48253. * Gets wether the color curves effect is enabled.
  48254. */
  48255. /**
  48256. * Sets wether the color curves effect is enabled.
  48257. */
  48258. cameraColorCurvesEnabled: boolean;
  48259. /**
  48260. * Gets wether the color grading effect is enabled.
  48261. */
  48262. /**
  48263. * Gets wether the color grading effect is enabled.
  48264. */
  48265. cameraColorGradingEnabled: boolean;
  48266. /**
  48267. * Gets wether tonemapping is enabled or not.
  48268. */
  48269. /**
  48270. * Sets wether tonemapping is enabled or not
  48271. */
  48272. cameraToneMappingEnabled: boolean;
  48273. /**
  48274. * The camera exposure used on this material.
  48275. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48276. * This corresponds to a photographic exposure.
  48277. */
  48278. /**
  48279. * The camera exposure used on this material.
  48280. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48281. * This corresponds to a photographic exposure.
  48282. */
  48283. cameraExposure: number;
  48284. /**
  48285. * Gets The camera contrast used on this material.
  48286. */
  48287. /**
  48288. * Sets The camera contrast used on this material.
  48289. */
  48290. cameraContrast: number;
  48291. /**
  48292. * Gets the Color Grading 2D Lookup Texture.
  48293. */
  48294. /**
  48295. * Sets the Color Grading 2D Lookup Texture.
  48296. */
  48297. cameraColorGradingTexture: Nullable<BaseTexture>;
  48298. /**
  48299. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48300. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48301. * 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;
  48302. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48303. */
  48304. /**
  48305. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48306. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48307. * 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;
  48308. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48309. */
  48310. cameraColorCurves: Nullable<ColorCurves>;
  48311. /**
  48312. * Instantiates a new PBRMaterial instance.
  48313. *
  48314. * @param name The material name
  48315. * @param scene The scene the material will be use in.
  48316. */
  48317. constructor(name: string, scene: Scene);
  48318. /**
  48319. * Returns the name of this material class.
  48320. */
  48321. getClassName(): string;
  48322. /**
  48323. * Makes a duplicate of the current material.
  48324. * @param name - name to use for the new material.
  48325. */
  48326. clone(name: string): PBRMaterial;
  48327. /**
  48328. * Serializes this PBR Material.
  48329. * @returns - An object with the serialized material.
  48330. */
  48331. serialize(): any;
  48332. /**
  48333. * Parses a PBR Material from a serialized object.
  48334. * @param source - Serialized object.
  48335. * @param scene - BJS scene instance.
  48336. * @param rootUrl - url for the scene object
  48337. * @returns - PBRMaterial
  48338. */
  48339. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  48340. }
  48341. }
  48342. declare module "babylonjs/Misc/dds" {
  48343. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48344. import { Engine } from "babylonjs/Engines/engine";
  48345. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48346. import { Nullable } from "babylonjs/types";
  48347. import { Scene } from "babylonjs/scene";
  48348. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  48349. /**
  48350. * Direct draw surface info
  48351. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  48352. */
  48353. export interface DDSInfo {
  48354. /**
  48355. * Width of the texture
  48356. */
  48357. width: number;
  48358. /**
  48359. * Width of the texture
  48360. */
  48361. height: number;
  48362. /**
  48363. * Number of Mipmaps for the texture
  48364. * @see https://en.wikipedia.org/wiki/Mipmap
  48365. */
  48366. mipmapCount: number;
  48367. /**
  48368. * If the textures format is a known fourCC format
  48369. * @see https://www.fourcc.org/
  48370. */
  48371. isFourCC: boolean;
  48372. /**
  48373. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  48374. */
  48375. isRGB: boolean;
  48376. /**
  48377. * If the texture is a lumincance format
  48378. */
  48379. isLuminance: boolean;
  48380. /**
  48381. * If this is a cube texture
  48382. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  48383. */
  48384. isCube: boolean;
  48385. /**
  48386. * If the texture is a compressed format eg. FOURCC_DXT1
  48387. */
  48388. isCompressed: boolean;
  48389. /**
  48390. * The dxgiFormat of the texture
  48391. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  48392. */
  48393. dxgiFormat: number;
  48394. /**
  48395. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  48396. */
  48397. textureType: number;
  48398. /**
  48399. * Sphericle polynomial created for the dds texture
  48400. */
  48401. sphericalPolynomial?: SphericalPolynomial;
  48402. }
  48403. /**
  48404. * Class used to provide DDS decompression tools
  48405. */
  48406. export class DDSTools {
  48407. /**
  48408. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  48409. */
  48410. static StoreLODInAlphaChannel: boolean;
  48411. /**
  48412. * Gets DDS information from an array buffer
  48413. * @param arrayBuffer defines the array buffer to read data from
  48414. * @returns the DDS information
  48415. */
  48416. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  48417. private static _FloatView;
  48418. private static _Int32View;
  48419. private static _ToHalfFloat;
  48420. private static _FromHalfFloat;
  48421. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  48422. private static _GetHalfFloatRGBAArrayBuffer;
  48423. private static _GetFloatRGBAArrayBuffer;
  48424. private static _GetFloatAsUIntRGBAArrayBuffer;
  48425. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  48426. private static _GetRGBAArrayBuffer;
  48427. private static _ExtractLongWordOrder;
  48428. private static _GetRGBArrayBuffer;
  48429. private static _GetLuminanceArrayBuffer;
  48430. /**
  48431. * Uploads DDS Levels to a Babylon Texture
  48432. * @hidden
  48433. */
  48434. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  48435. }
  48436. module "babylonjs/Engines/engine" {
  48437. interface Engine {
  48438. /**
  48439. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  48440. * @param rootUrl defines the url where the file to load is located
  48441. * @param scene defines the current scene
  48442. * @param lodScale defines scale to apply to the mip map selection
  48443. * @param lodOffset defines offset to apply to the mip map selection
  48444. * @param onLoad defines an optional callback raised when the texture is loaded
  48445. * @param onError defines an optional callback raised if there is an issue to load the texture
  48446. * @param format defines the format of the data
  48447. * @param forcedExtension defines the extension to use to pick the right loader
  48448. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  48449. * @returns the cube texture as an InternalTexture
  48450. */
  48451. 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;
  48452. }
  48453. }
  48454. }
  48455. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  48456. import { Nullable } from "babylonjs/types";
  48457. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48458. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48459. /**
  48460. * Implementation of the DDS Texture Loader.
  48461. * @hidden
  48462. */
  48463. export class _DDSTextureLoader implements IInternalTextureLoader {
  48464. /**
  48465. * Defines wether the loader supports cascade loading the different faces.
  48466. */
  48467. readonly supportCascades: boolean;
  48468. /**
  48469. * This returns if the loader support the current file information.
  48470. * @param extension defines the file extension of the file being loaded
  48471. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48472. * @param fallback defines the fallback internal texture if any
  48473. * @param isBase64 defines whether the texture is encoded as a base64
  48474. * @param isBuffer defines whether the texture data are stored as a buffer
  48475. * @returns true if the loader can load the specified file
  48476. */
  48477. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48478. /**
  48479. * Transform the url before loading if required.
  48480. * @param rootUrl the url of the texture
  48481. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48482. * @returns the transformed texture
  48483. */
  48484. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48485. /**
  48486. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48487. * @param rootUrl the url of the texture
  48488. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48489. * @returns the fallback texture
  48490. */
  48491. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48492. /**
  48493. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48494. * @param data contains the texture data
  48495. * @param texture defines the BabylonJS internal texture
  48496. * @param createPolynomials will be true if polynomials have been requested
  48497. * @param onLoad defines the callback to trigger once the texture is ready
  48498. * @param onError defines the callback to trigger in case of error
  48499. */
  48500. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48501. /**
  48502. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48503. * @param data contains the texture data
  48504. * @param texture defines the BabylonJS internal texture
  48505. * @param callback defines the method to call once ready to upload
  48506. */
  48507. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48508. }
  48509. }
  48510. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  48511. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48512. /** @hidden */
  48513. export var rgbdEncodePixelShader: {
  48514. name: string;
  48515. shader: string;
  48516. };
  48517. }
  48518. declare module "babylonjs/Misc/environmentTextureTools" {
  48519. import { Nullable } from "babylonjs/types";
  48520. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48521. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48522. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  48523. import "babylonjs/Engines/Extensions/engine.renderTarget";
  48524. import "babylonjs/Shaders/rgbdEncode.fragment";
  48525. import "babylonjs/Shaders/rgbdDecode.fragment";
  48526. /**
  48527. * Raw texture data and descriptor sufficient for WebGL texture upload
  48528. */
  48529. export interface EnvironmentTextureInfo {
  48530. /**
  48531. * Version of the environment map
  48532. */
  48533. version: number;
  48534. /**
  48535. * Width of image
  48536. */
  48537. width: number;
  48538. /**
  48539. * Irradiance information stored in the file.
  48540. */
  48541. irradiance: any;
  48542. /**
  48543. * Specular information stored in the file.
  48544. */
  48545. specular: any;
  48546. }
  48547. /**
  48548. * Sets of helpers addressing the serialization and deserialization of environment texture
  48549. * stored in a BabylonJS env file.
  48550. * Those files are usually stored as .env files.
  48551. */
  48552. export class EnvironmentTextureTools {
  48553. /**
  48554. * Magic number identifying the env file.
  48555. */
  48556. private static _MagicBytes;
  48557. /**
  48558. * Gets the environment info from an env file.
  48559. * @param data The array buffer containing the .env bytes.
  48560. * @returns the environment file info (the json header) if successfully parsed.
  48561. */
  48562. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  48563. /**
  48564. * Creates an environment texture from a loaded cube texture.
  48565. * @param texture defines the cube texture to convert in env file
  48566. * @return a promise containing the environment data if succesfull.
  48567. */
  48568. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  48569. /**
  48570. * Creates a JSON representation of the spherical data.
  48571. * @param texture defines the texture containing the polynomials
  48572. * @return the JSON representation of the spherical info
  48573. */
  48574. private static _CreateEnvTextureIrradiance;
  48575. /**
  48576. * Uploads the texture info contained in the env file to the GPU.
  48577. * @param texture defines the internal texture to upload to
  48578. * @param arrayBuffer defines the buffer cotaining the data to load
  48579. * @param info defines the texture info retrieved through the GetEnvInfo method
  48580. * @returns a promise
  48581. */
  48582. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  48583. /**
  48584. * Uploads the levels of image data to the GPU.
  48585. * @param texture defines the internal texture to upload to
  48586. * @param imageData defines the array buffer views of image data [mipmap][face]
  48587. * @returns a promise
  48588. */
  48589. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  48590. /**
  48591. * Uploads spherical polynomials information to the texture.
  48592. * @param texture defines the texture we are trying to upload the information to
  48593. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  48594. */
  48595. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  48596. /** @hidden */
  48597. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48598. }
  48599. }
  48600. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  48601. import { Nullable } from "babylonjs/types";
  48602. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48603. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48604. /**
  48605. * Implementation of the ENV Texture Loader.
  48606. * @hidden
  48607. */
  48608. export class _ENVTextureLoader implements IInternalTextureLoader {
  48609. /**
  48610. * Defines wether the loader supports cascade loading the different faces.
  48611. */
  48612. readonly supportCascades: boolean;
  48613. /**
  48614. * This returns if the loader support the current file information.
  48615. * @param extension defines the file extension of the file being loaded
  48616. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48617. * @param fallback defines the fallback internal texture if any
  48618. * @param isBase64 defines whether the texture is encoded as a base64
  48619. * @param isBuffer defines whether the texture data are stored as a buffer
  48620. * @returns true if the loader can load the specified file
  48621. */
  48622. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48623. /**
  48624. * Transform the url before loading if required.
  48625. * @param rootUrl the url of the texture
  48626. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48627. * @returns the transformed texture
  48628. */
  48629. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48630. /**
  48631. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48632. * @param rootUrl the url of the texture
  48633. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48634. * @returns the fallback texture
  48635. */
  48636. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48637. /**
  48638. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48639. * @param data contains the texture data
  48640. * @param texture defines the BabylonJS internal texture
  48641. * @param createPolynomials will be true if polynomials have been requested
  48642. * @param onLoad defines the callback to trigger once the texture is ready
  48643. * @param onError defines the callback to trigger in case of error
  48644. */
  48645. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48646. /**
  48647. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48648. * @param data contains the texture data
  48649. * @param texture defines the BabylonJS internal texture
  48650. * @param callback defines the method to call once ready to upload
  48651. */
  48652. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48653. }
  48654. }
  48655. declare module "babylonjs/Misc/khronosTextureContainer" {
  48656. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48657. /**
  48658. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  48659. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  48660. */
  48661. export class KhronosTextureContainer {
  48662. /** contents of the KTX container file */
  48663. arrayBuffer: any;
  48664. private static HEADER_LEN;
  48665. private static COMPRESSED_2D;
  48666. private static COMPRESSED_3D;
  48667. private static TEX_2D;
  48668. private static TEX_3D;
  48669. /**
  48670. * Gets the openGL type
  48671. */
  48672. glType: number;
  48673. /**
  48674. * Gets the openGL type size
  48675. */
  48676. glTypeSize: number;
  48677. /**
  48678. * Gets the openGL format
  48679. */
  48680. glFormat: number;
  48681. /**
  48682. * Gets the openGL internal format
  48683. */
  48684. glInternalFormat: number;
  48685. /**
  48686. * Gets the base internal format
  48687. */
  48688. glBaseInternalFormat: number;
  48689. /**
  48690. * Gets image width in pixel
  48691. */
  48692. pixelWidth: number;
  48693. /**
  48694. * Gets image height in pixel
  48695. */
  48696. pixelHeight: number;
  48697. /**
  48698. * Gets image depth in pixels
  48699. */
  48700. pixelDepth: number;
  48701. /**
  48702. * Gets the number of array elements
  48703. */
  48704. numberOfArrayElements: number;
  48705. /**
  48706. * Gets the number of faces
  48707. */
  48708. numberOfFaces: number;
  48709. /**
  48710. * Gets the number of mipmap levels
  48711. */
  48712. numberOfMipmapLevels: number;
  48713. /**
  48714. * Gets the bytes of key value data
  48715. */
  48716. bytesOfKeyValueData: number;
  48717. /**
  48718. * Gets the load type
  48719. */
  48720. loadType: number;
  48721. /**
  48722. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  48723. */
  48724. isInvalid: boolean;
  48725. /**
  48726. * Creates a new KhronosTextureContainer
  48727. * @param arrayBuffer contents of the KTX container file
  48728. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  48729. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  48730. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  48731. */
  48732. constructor(
  48733. /** contents of the KTX container file */
  48734. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  48735. /**
  48736. * Uploads KTX content to a Babylon Texture.
  48737. * It is assumed that the texture has already been created & is currently bound
  48738. * @hidden
  48739. */
  48740. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  48741. private _upload2DCompressedLevels;
  48742. }
  48743. }
  48744. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  48745. import { Nullable } from "babylonjs/types";
  48746. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48747. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48748. /**
  48749. * Implementation of the KTX Texture Loader.
  48750. * @hidden
  48751. */
  48752. export class _KTXTextureLoader implements IInternalTextureLoader {
  48753. /**
  48754. * Defines wether the loader supports cascade loading the different faces.
  48755. */
  48756. readonly supportCascades: boolean;
  48757. /**
  48758. * This returns if the loader support the current file information.
  48759. * @param extension defines the file extension of the file being loaded
  48760. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48761. * @param fallback defines the fallback internal texture if any
  48762. * @param isBase64 defines whether the texture is encoded as a base64
  48763. * @param isBuffer defines whether the texture data are stored as a buffer
  48764. * @returns true if the loader can load the specified file
  48765. */
  48766. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48767. /**
  48768. * Transform the url before loading if required.
  48769. * @param rootUrl the url of the texture
  48770. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48771. * @returns the transformed texture
  48772. */
  48773. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48774. /**
  48775. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48776. * @param rootUrl the url of the texture
  48777. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48778. * @returns the fallback texture
  48779. */
  48780. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48781. /**
  48782. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48783. * @param data contains the texture data
  48784. * @param texture defines the BabylonJS internal texture
  48785. * @param createPolynomials will be true if polynomials have been requested
  48786. * @param onLoad defines the callback to trigger once the texture is ready
  48787. * @param onError defines the callback to trigger in case of error
  48788. */
  48789. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48790. /**
  48791. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48792. * @param data contains the texture data
  48793. * @param texture defines the BabylonJS internal texture
  48794. * @param callback defines the method to call once ready to upload
  48795. */
  48796. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  48797. }
  48798. }
  48799. declare module "babylonjs/Helpers/sceneHelpers" {
  48800. import { Nullable } from "babylonjs/types";
  48801. import { Mesh } from "babylonjs/Meshes/mesh";
  48802. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48803. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  48804. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  48805. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  48806. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  48807. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  48808. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  48809. import "babylonjs/Meshes/Builders/boxBuilder";
  48810. /** @hidden */
  48811. export var _forceSceneHelpersToBundle: boolean;
  48812. module "babylonjs/scene" {
  48813. interface Scene {
  48814. /**
  48815. * Creates a default light for the scene.
  48816. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  48817. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  48818. */
  48819. createDefaultLight(replace?: boolean): void;
  48820. /**
  48821. * Creates a default camera for the scene.
  48822. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  48823. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48824. * @param replace has default false, when true replaces the active camera in the scene
  48825. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  48826. */
  48827. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48828. /**
  48829. * Creates a default camera and a default light.
  48830. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  48831. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48832. * @param replace has the default false, when true replaces the active camera/light in the scene
  48833. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  48834. */
  48835. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48836. /**
  48837. * Creates a new sky box
  48838. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  48839. * @param environmentTexture defines the texture to use as environment texture
  48840. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  48841. * @param scale defines the overall scale of the skybox
  48842. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  48843. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  48844. * @returns a new mesh holding the sky box
  48845. */
  48846. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  48847. /**
  48848. * Creates a new environment
  48849. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  48850. * @param options defines the options you can use to configure the environment
  48851. * @returns the new EnvironmentHelper
  48852. */
  48853. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  48854. /**
  48855. * Creates a new VREXperienceHelper
  48856. * @see http://doc.babylonjs.com/how_to/webvr_helper
  48857. * @param webVROptions defines the options used to create the new VREXperienceHelper
  48858. * @returns a new VREXperienceHelper
  48859. */
  48860. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  48861. /**
  48862. * Creates a new XREXperienceHelper
  48863. * @see http://doc.babylonjs.com/how_to/webxr
  48864. * @returns a promise for a new XREXperienceHelper
  48865. */
  48866. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  48867. }
  48868. }
  48869. }
  48870. declare module "babylonjs/Helpers/videoDome" {
  48871. import { Scene } from "babylonjs/scene";
  48872. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48873. import { Mesh } from "babylonjs/Meshes/mesh";
  48874. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  48875. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  48876. import "babylonjs/Meshes/Builders/sphereBuilder";
  48877. /**
  48878. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  48879. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  48880. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  48881. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48882. */
  48883. export class VideoDome extends TransformNode {
  48884. /**
  48885. * Define the video source as a Monoscopic panoramic 360 video.
  48886. */
  48887. static readonly MODE_MONOSCOPIC: number;
  48888. /**
  48889. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48890. */
  48891. static readonly MODE_TOPBOTTOM: number;
  48892. /**
  48893. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48894. */
  48895. static readonly MODE_SIDEBYSIDE: number;
  48896. private _useDirectMapping;
  48897. /**
  48898. * The video texture being displayed on the sphere
  48899. */
  48900. protected _videoTexture: VideoTexture;
  48901. /**
  48902. * Gets the video texture being displayed on the sphere
  48903. */
  48904. readonly videoTexture: VideoTexture;
  48905. /**
  48906. * The skybox material
  48907. */
  48908. protected _material: BackgroundMaterial;
  48909. /**
  48910. * The surface used for the skybox
  48911. */
  48912. protected _mesh: Mesh;
  48913. /**
  48914. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48915. * Also see the options.resolution property.
  48916. */
  48917. fovMultiplier: number;
  48918. private _videoMode;
  48919. /**
  48920. * Gets or set the current video mode for the video. It can be:
  48921. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  48922. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48923. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48924. */
  48925. videoMode: number;
  48926. /**
  48927. * Oberserver used in Stereoscopic VR Mode.
  48928. */
  48929. private _onBeforeCameraRenderObserver;
  48930. /**
  48931. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  48932. * @param name Element's name, child elements will append suffixes for their own names.
  48933. * @param urlsOrVideo defines the url(s) or the video element to use
  48934. * @param options An object containing optional or exposed sub element properties
  48935. */
  48936. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  48937. resolution?: number;
  48938. clickToPlay?: boolean;
  48939. autoPlay?: boolean;
  48940. loop?: boolean;
  48941. size?: number;
  48942. poster?: string;
  48943. faceForward?: boolean;
  48944. useDirectMapping?: boolean;
  48945. }, scene: Scene);
  48946. private _changeVideoMode;
  48947. /**
  48948. * Releases resources associated with this node.
  48949. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48950. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48951. */
  48952. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48953. }
  48954. }
  48955. declare module "babylonjs/Helpers/index" {
  48956. export * from "babylonjs/Helpers/environmentHelper";
  48957. export * from "babylonjs/Helpers/photoDome";
  48958. export * from "babylonjs/Helpers/sceneHelpers";
  48959. export * from "babylonjs/Helpers/videoDome";
  48960. }
  48961. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  48962. import { PerfCounter } from "babylonjs/Misc/tools";
  48963. import { IDisposable } from "babylonjs/scene";
  48964. import { Engine } from "babylonjs/Engines/engine";
  48965. /**
  48966. * This class can be used to get instrumentation data from a Babylon engine
  48967. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48968. */
  48969. export class EngineInstrumentation implements IDisposable {
  48970. /**
  48971. * Define the instrumented engine.
  48972. */
  48973. engine: Engine;
  48974. private _captureGPUFrameTime;
  48975. private _gpuFrameTimeToken;
  48976. private _gpuFrameTime;
  48977. private _captureShaderCompilationTime;
  48978. private _shaderCompilationTime;
  48979. private _onBeginFrameObserver;
  48980. private _onEndFrameObserver;
  48981. private _onBeforeShaderCompilationObserver;
  48982. private _onAfterShaderCompilationObserver;
  48983. /**
  48984. * Gets the perf counter used for GPU frame time
  48985. */
  48986. readonly gpuFrameTimeCounter: PerfCounter;
  48987. /**
  48988. * Gets the GPU frame time capture status
  48989. */
  48990. /**
  48991. * Enable or disable the GPU frame time capture
  48992. */
  48993. captureGPUFrameTime: boolean;
  48994. /**
  48995. * Gets the perf counter used for shader compilation time
  48996. */
  48997. readonly shaderCompilationTimeCounter: PerfCounter;
  48998. /**
  48999. * Gets the shader compilation time capture status
  49000. */
  49001. /**
  49002. * Enable or disable the shader compilation time capture
  49003. */
  49004. captureShaderCompilationTime: boolean;
  49005. /**
  49006. * Instantiates a new engine instrumentation.
  49007. * This class can be used to get instrumentation data from a Babylon engine
  49008. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  49009. * @param engine Defines the engine to instrument
  49010. */
  49011. constructor(
  49012. /**
  49013. * Define the instrumented engine.
  49014. */
  49015. engine: Engine);
  49016. /**
  49017. * Dispose and release associated resources.
  49018. */
  49019. dispose(): void;
  49020. }
  49021. }
  49022. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  49023. import { PerfCounter } from "babylonjs/Misc/tools";
  49024. import { Scene, IDisposable } from "babylonjs/scene";
  49025. /**
  49026. * This class can be used to get instrumentation data from a Babylon engine
  49027. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  49028. */
  49029. export class SceneInstrumentation implements IDisposable {
  49030. /**
  49031. * Defines the scene to instrument
  49032. */
  49033. scene: Scene;
  49034. private _captureActiveMeshesEvaluationTime;
  49035. private _activeMeshesEvaluationTime;
  49036. private _captureRenderTargetsRenderTime;
  49037. private _renderTargetsRenderTime;
  49038. private _captureFrameTime;
  49039. private _frameTime;
  49040. private _captureRenderTime;
  49041. private _renderTime;
  49042. private _captureInterFrameTime;
  49043. private _interFrameTime;
  49044. private _captureParticlesRenderTime;
  49045. private _particlesRenderTime;
  49046. private _captureSpritesRenderTime;
  49047. private _spritesRenderTime;
  49048. private _capturePhysicsTime;
  49049. private _physicsTime;
  49050. private _captureAnimationsTime;
  49051. private _animationsTime;
  49052. private _captureCameraRenderTime;
  49053. private _cameraRenderTime;
  49054. private _onBeforeActiveMeshesEvaluationObserver;
  49055. private _onAfterActiveMeshesEvaluationObserver;
  49056. private _onBeforeRenderTargetsRenderObserver;
  49057. private _onAfterRenderTargetsRenderObserver;
  49058. private _onAfterRenderObserver;
  49059. private _onBeforeDrawPhaseObserver;
  49060. private _onAfterDrawPhaseObserver;
  49061. private _onBeforeAnimationsObserver;
  49062. private _onBeforeParticlesRenderingObserver;
  49063. private _onAfterParticlesRenderingObserver;
  49064. private _onBeforeSpritesRenderingObserver;
  49065. private _onAfterSpritesRenderingObserver;
  49066. private _onBeforePhysicsObserver;
  49067. private _onAfterPhysicsObserver;
  49068. private _onAfterAnimationsObserver;
  49069. private _onBeforeCameraRenderObserver;
  49070. private _onAfterCameraRenderObserver;
  49071. /**
  49072. * Gets the perf counter used for active meshes evaluation time
  49073. */
  49074. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  49075. /**
  49076. * Gets the active meshes evaluation time capture status
  49077. */
  49078. /**
  49079. * Enable or disable the active meshes evaluation time capture
  49080. */
  49081. captureActiveMeshesEvaluationTime: boolean;
  49082. /**
  49083. * Gets the perf counter used for render targets render time
  49084. */
  49085. readonly renderTargetsRenderTimeCounter: PerfCounter;
  49086. /**
  49087. * Gets the render targets render time capture status
  49088. */
  49089. /**
  49090. * Enable or disable the render targets render time capture
  49091. */
  49092. captureRenderTargetsRenderTime: boolean;
  49093. /**
  49094. * Gets the perf counter used for particles render time
  49095. */
  49096. readonly particlesRenderTimeCounter: PerfCounter;
  49097. /**
  49098. * Gets the particles render time capture status
  49099. */
  49100. /**
  49101. * Enable or disable the particles render time capture
  49102. */
  49103. captureParticlesRenderTime: boolean;
  49104. /**
  49105. * Gets the perf counter used for sprites render time
  49106. */
  49107. readonly spritesRenderTimeCounter: PerfCounter;
  49108. /**
  49109. * Gets the sprites render time capture status
  49110. */
  49111. /**
  49112. * Enable or disable the sprites render time capture
  49113. */
  49114. captureSpritesRenderTime: boolean;
  49115. /**
  49116. * Gets the perf counter used for physics time
  49117. */
  49118. readonly physicsTimeCounter: PerfCounter;
  49119. /**
  49120. * Gets the physics time capture status
  49121. */
  49122. /**
  49123. * Enable or disable the physics time capture
  49124. */
  49125. capturePhysicsTime: boolean;
  49126. /**
  49127. * Gets the perf counter used for animations time
  49128. */
  49129. readonly animationsTimeCounter: PerfCounter;
  49130. /**
  49131. * Gets the animations time capture status
  49132. */
  49133. /**
  49134. * Enable or disable the animations time capture
  49135. */
  49136. captureAnimationsTime: boolean;
  49137. /**
  49138. * Gets the perf counter used for frame time capture
  49139. */
  49140. readonly frameTimeCounter: PerfCounter;
  49141. /**
  49142. * Gets the frame time capture status
  49143. */
  49144. /**
  49145. * Enable or disable the frame time capture
  49146. */
  49147. captureFrameTime: boolean;
  49148. /**
  49149. * Gets the perf counter used for inter-frames time capture
  49150. */
  49151. readonly interFrameTimeCounter: PerfCounter;
  49152. /**
  49153. * Gets the inter-frames time capture status
  49154. */
  49155. /**
  49156. * Enable or disable the inter-frames time capture
  49157. */
  49158. captureInterFrameTime: boolean;
  49159. /**
  49160. * Gets the perf counter used for render time capture
  49161. */
  49162. readonly renderTimeCounter: PerfCounter;
  49163. /**
  49164. * Gets the render time capture status
  49165. */
  49166. /**
  49167. * Enable or disable the render time capture
  49168. */
  49169. captureRenderTime: boolean;
  49170. /**
  49171. * Gets the perf counter used for camera render time capture
  49172. */
  49173. readonly cameraRenderTimeCounter: PerfCounter;
  49174. /**
  49175. * Gets the camera render time capture status
  49176. */
  49177. /**
  49178. * Enable or disable the camera render time capture
  49179. */
  49180. captureCameraRenderTime: boolean;
  49181. /**
  49182. * Gets the perf counter used for draw calls
  49183. */
  49184. readonly drawCallsCounter: PerfCounter;
  49185. /**
  49186. * Instantiates a new scene instrumentation.
  49187. * This class can be used to get instrumentation data from a Babylon engine
  49188. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  49189. * @param scene Defines the scene to instrument
  49190. */
  49191. constructor(
  49192. /**
  49193. * Defines the scene to instrument
  49194. */
  49195. scene: Scene);
  49196. /**
  49197. * Dispose and release associated resources.
  49198. */
  49199. dispose(): void;
  49200. }
  49201. }
  49202. declare module "babylonjs/Instrumentation/index" {
  49203. export * from "babylonjs/Instrumentation/engineInstrumentation";
  49204. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  49205. export * from "babylonjs/Instrumentation/timeToken";
  49206. }
  49207. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  49208. /** @hidden */
  49209. export var glowMapGenerationPixelShader: {
  49210. name: string;
  49211. shader: string;
  49212. };
  49213. }
  49214. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  49215. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  49216. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  49217. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  49218. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  49219. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  49220. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  49221. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  49222. /** @hidden */
  49223. export var glowMapGenerationVertexShader: {
  49224. name: string;
  49225. shader: string;
  49226. };
  49227. }
  49228. declare module "babylonjs/Layers/effectLayer" {
  49229. import { Observable } from "babylonjs/Misc/observable";
  49230. import { Nullable } from "babylonjs/types";
  49231. import { Camera } from "babylonjs/Cameras/camera";
  49232. import { Scene } from "babylonjs/scene";
  49233. import { Color4, ISize } from "babylonjs/Maths/math";
  49234. import { Engine } from "babylonjs/Engines/engine";
  49235. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49236. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49237. import { Mesh } from "babylonjs/Meshes/mesh";
  49238. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  49239. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49240. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49241. import { Effect } from "babylonjs/Materials/effect";
  49242. import { Material } from "babylonjs/Materials/material";
  49243. import "babylonjs/Shaders/glowMapGeneration.fragment";
  49244. import "babylonjs/Shaders/glowMapGeneration.vertex";
  49245. /**
  49246. * Effect layer options. This helps customizing the behaviour
  49247. * of the effect layer.
  49248. */
  49249. export interface IEffectLayerOptions {
  49250. /**
  49251. * Multiplication factor apply to the canvas size to compute the render target size
  49252. * used to generated the objects (the smaller the faster).
  49253. */
  49254. mainTextureRatio: number;
  49255. /**
  49256. * Enforces a fixed size texture to ensure effect stability across devices.
  49257. */
  49258. mainTextureFixedSize?: number;
  49259. /**
  49260. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  49261. */
  49262. alphaBlendingMode: number;
  49263. /**
  49264. * The camera attached to the layer.
  49265. */
  49266. camera: Nullable<Camera>;
  49267. /**
  49268. * The rendering group to draw the layer in.
  49269. */
  49270. renderingGroupId: number;
  49271. }
  49272. /**
  49273. * The effect layer Helps adding post process effect blended with the main pass.
  49274. *
  49275. * This can be for instance use to generate glow or higlight effects on the scene.
  49276. *
  49277. * The effect layer class can not be used directly and is intented to inherited from to be
  49278. * customized per effects.
  49279. */
  49280. export abstract class EffectLayer {
  49281. private _vertexBuffers;
  49282. private _indexBuffer;
  49283. private _cachedDefines;
  49284. private _effectLayerMapGenerationEffect;
  49285. private _effectLayerOptions;
  49286. private _mergeEffect;
  49287. protected _scene: Scene;
  49288. protected _engine: Engine;
  49289. protected _maxSize: number;
  49290. protected _mainTextureDesiredSize: ISize;
  49291. protected _mainTexture: RenderTargetTexture;
  49292. protected _shouldRender: boolean;
  49293. protected _postProcesses: PostProcess[];
  49294. protected _textures: BaseTexture[];
  49295. protected _emissiveTextureAndColor: {
  49296. texture: Nullable<BaseTexture>;
  49297. color: Color4;
  49298. };
  49299. /**
  49300. * The name of the layer
  49301. */
  49302. name: string;
  49303. /**
  49304. * The clear color of the texture used to generate the glow map.
  49305. */
  49306. neutralColor: Color4;
  49307. /**
  49308. * Specifies wether the highlight layer is enabled or not.
  49309. */
  49310. isEnabled: boolean;
  49311. /**
  49312. * Gets the camera attached to the layer.
  49313. */
  49314. readonly camera: Nullable<Camera>;
  49315. /**
  49316. * Gets the rendering group id the layer should render in.
  49317. */
  49318. readonly renderingGroupId: number;
  49319. /**
  49320. * An event triggered when the effect layer has been disposed.
  49321. */
  49322. onDisposeObservable: Observable<EffectLayer>;
  49323. /**
  49324. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  49325. */
  49326. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  49327. /**
  49328. * An event triggered when the generated texture is being merged in the scene.
  49329. */
  49330. onBeforeComposeObservable: Observable<EffectLayer>;
  49331. /**
  49332. * An event triggered when the generated texture has been merged in the scene.
  49333. */
  49334. onAfterComposeObservable: Observable<EffectLayer>;
  49335. /**
  49336. * An event triggered when the efffect layer changes its size.
  49337. */
  49338. onSizeChangedObservable: Observable<EffectLayer>;
  49339. /** @hidden */
  49340. static _SceneComponentInitialization: (scene: Scene) => void;
  49341. /**
  49342. * Instantiates a new effect Layer and references it in the scene.
  49343. * @param name The name of the layer
  49344. * @param scene The scene to use the layer in
  49345. */
  49346. constructor(
  49347. /** The Friendly of the effect in the scene */
  49348. name: string, scene: Scene);
  49349. /**
  49350. * Get the effect name of the layer.
  49351. * @return The effect name
  49352. */
  49353. abstract getEffectName(): string;
  49354. /**
  49355. * Checks for the readiness of the element composing the layer.
  49356. * @param subMesh the mesh to check for
  49357. * @param useInstances specify wether or not to use instances to render the mesh
  49358. * @return true if ready otherwise, false
  49359. */
  49360. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49361. /**
  49362. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49363. * @returns true if the effect requires stencil during the main canvas render pass.
  49364. */
  49365. abstract needStencil(): boolean;
  49366. /**
  49367. * Create the merge effect. This is the shader use to blit the information back
  49368. * to the main canvas at the end of the scene rendering.
  49369. * @returns The effect containing the shader used to merge the effect on the main canvas
  49370. */
  49371. protected abstract _createMergeEffect(): Effect;
  49372. /**
  49373. * Creates the render target textures and post processes used in the effect layer.
  49374. */
  49375. protected abstract _createTextureAndPostProcesses(): void;
  49376. /**
  49377. * Implementation specific of rendering the generating effect on the main canvas.
  49378. * @param effect The effect used to render through
  49379. */
  49380. protected abstract _internalRender(effect: Effect): void;
  49381. /**
  49382. * Sets the required values for both the emissive texture and and the main color.
  49383. */
  49384. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49385. /**
  49386. * Free any resources and references associated to a mesh.
  49387. * Internal use
  49388. * @param mesh The mesh to free.
  49389. */
  49390. abstract _disposeMesh(mesh: Mesh): void;
  49391. /**
  49392. * Serializes this layer (Glow or Highlight for example)
  49393. * @returns a serialized layer object
  49394. */
  49395. abstract serialize?(): any;
  49396. /**
  49397. * Initializes the effect layer with the required options.
  49398. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  49399. */
  49400. protected _init(options: Partial<IEffectLayerOptions>): void;
  49401. /**
  49402. * Generates the index buffer of the full screen quad blending to the main canvas.
  49403. */
  49404. private _generateIndexBuffer;
  49405. /**
  49406. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  49407. */
  49408. private _generateVertexBuffer;
  49409. /**
  49410. * Sets the main texture desired size which is the closest power of two
  49411. * of the engine canvas size.
  49412. */
  49413. private _setMainTextureSize;
  49414. /**
  49415. * Creates the main texture for the effect layer.
  49416. */
  49417. protected _createMainTexture(): void;
  49418. /**
  49419. * Adds specific effects defines.
  49420. * @param defines The defines to add specifics to.
  49421. */
  49422. protected _addCustomEffectDefines(defines: string[]): void;
  49423. /**
  49424. * Checks for the readiness of the element composing the layer.
  49425. * @param subMesh the mesh to check for
  49426. * @param useInstances specify wether or not to use instances to render the mesh
  49427. * @param emissiveTexture the associated emissive texture used to generate the glow
  49428. * @return true if ready otherwise, false
  49429. */
  49430. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  49431. /**
  49432. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  49433. */
  49434. render(): void;
  49435. /**
  49436. * Determine if a given mesh will be used in the current effect.
  49437. * @param mesh mesh to test
  49438. * @returns true if the mesh will be used
  49439. */
  49440. hasMesh(mesh: AbstractMesh): boolean;
  49441. /**
  49442. * Returns true if the layer contains information to display, otherwise false.
  49443. * @returns true if the glow layer should be rendered
  49444. */
  49445. shouldRender(): boolean;
  49446. /**
  49447. * Returns true if the mesh should render, otherwise false.
  49448. * @param mesh The mesh to render
  49449. * @returns true if it should render otherwise false
  49450. */
  49451. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  49452. /**
  49453. * Returns true if the mesh can be rendered, otherwise false.
  49454. * @param mesh The mesh to render
  49455. * @param material The material used on the mesh
  49456. * @returns true if it can be rendered otherwise false
  49457. */
  49458. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49459. /**
  49460. * Returns true if the mesh should render, otherwise false.
  49461. * @param mesh The mesh to render
  49462. * @returns true if it should render otherwise false
  49463. */
  49464. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  49465. /**
  49466. * Renders the submesh passed in parameter to the generation map.
  49467. */
  49468. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  49469. /**
  49470. * Rebuild the required buffers.
  49471. * @hidden Internal use only.
  49472. */
  49473. _rebuild(): void;
  49474. /**
  49475. * Dispose only the render target textures and post process.
  49476. */
  49477. private _disposeTextureAndPostProcesses;
  49478. /**
  49479. * Dispose the highlight layer and free resources.
  49480. */
  49481. dispose(): void;
  49482. /**
  49483. * Gets the class name of the effect layer
  49484. * @returns the string with the class name of the effect layer
  49485. */
  49486. getClassName(): string;
  49487. /**
  49488. * Creates an effect layer from parsed effect layer data
  49489. * @param parsedEffectLayer defines effect layer data
  49490. * @param scene defines the current scene
  49491. * @param rootUrl defines the root URL containing the effect layer information
  49492. * @returns a parsed effect Layer
  49493. */
  49494. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  49495. }
  49496. }
  49497. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  49498. import { Scene } from "babylonjs/scene";
  49499. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  49500. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  49501. import { AbstractScene } from "babylonjs/abstractScene";
  49502. module "babylonjs/abstractScene" {
  49503. interface AbstractScene {
  49504. /**
  49505. * The list of effect layers (highlights/glow) added to the scene
  49506. * @see http://doc.babylonjs.com/how_to/highlight_layer
  49507. * @see http://doc.babylonjs.com/how_to/glow_layer
  49508. */
  49509. effectLayers: Array<EffectLayer>;
  49510. /**
  49511. * Removes the given effect layer from this scene.
  49512. * @param toRemove defines the effect layer to remove
  49513. * @returns the index of the removed effect layer
  49514. */
  49515. removeEffectLayer(toRemove: EffectLayer): number;
  49516. /**
  49517. * Adds the given effect layer to this scene
  49518. * @param newEffectLayer defines the effect layer to add
  49519. */
  49520. addEffectLayer(newEffectLayer: EffectLayer): void;
  49521. }
  49522. }
  49523. /**
  49524. * Defines the layer scene component responsible to manage any effect layers
  49525. * in a given scene.
  49526. */
  49527. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  49528. /**
  49529. * The component name helpfull to identify the component in the list of scene components.
  49530. */
  49531. readonly name: string;
  49532. /**
  49533. * The scene the component belongs to.
  49534. */
  49535. scene: Scene;
  49536. private _engine;
  49537. private _renderEffects;
  49538. private _needStencil;
  49539. private _previousStencilState;
  49540. /**
  49541. * Creates a new instance of the component for the given scene
  49542. * @param scene Defines the scene to register the component in
  49543. */
  49544. constructor(scene: Scene);
  49545. /**
  49546. * Registers the component in a given scene
  49547. */
  49548. register(): void;
  49549. /**
  49550. * Rebuilds the elements related to this component in case of
  49551. * context lost for instance.
  49552. */
  49553. rebuild(): void;
  49554. /**
  49555. * Serializes the component data to the specified json object
  49556. * @param serializationObject The object to serialize to
  49557. */
  49558. serialize(serializationObject: any): void;
  49559. /**
  49560. * Adds all the elements from the container to the scene
  49561. * @param container the container holding the elements
  49562. */
  49563. addFromContainer(container: AbstractScene): void;
  49564. /**
  49565. * Removes all the elements in the container from the scene
  49566. * @param container contains the elements to remove
  49567. * @param dispose if the removed element should be disposed (default: false)
  49568. */
  49569. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49570. /**
  49571. * Disposes the component and the associated ressources.
  49572. */
  49573. dispose(): void;
  49574. private _isReadyForMesh;
  49575. private _renderMainTexture;
  49576. private _setStencil;
  49577. private _setStencilBack;
  49578. private _draw;
  49579. private _drawCamera;
  49580. private _drawRenderingGroup;
  49581. }
  49582. }
  49583. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  49584. /** @hidden */
  49585. export var glowMapMergePixelShader: {
  49586. name: string;
  49587. shader: string;
  49588. };
  49589. }
  49590. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  49591. /** @hidden */
  49592. export var glowMapMergeVertexShader: {
  49593. name: string;
  49594. shader: string;
  49595. };
  49596. }
  49597. declare module "babylonjs/Layers/glowLayer" {
  49598. import { Nullable } from "babylonjs/types";
  49599. import { Camera } from "babylonjs/Cameras/camera";
  49600. import { Scene } from "babylonjs/scene";
  49601. import { Color4 } from "babylonjs/Maths/math";
  49602. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49603. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49604. import { Mesh } from "babylonjs/Meshes/mesh";
  49605. import { Texture } from "babylonjs/Materials/Textures/texture";
  49606. import { Effect } from "babylonjs/Materials/effect";
  49607. import { Material } from "babylonjs/Materials/material";
  49608. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  49609. import "babylonjs/Shaders/glowMapMerge.fragment";
  49610. import "babylonjs/Shaders/glowMapMerge.vertex";
  49611. import "babylonjs/Layers/effectLayerSceneComponent";
  49612. module "babylonjs/abstractScene" {
  49613. interface AbstractScene {
  49614. /**
  49615. * Return a the first highlight layer of the scene with a given name.
  49616. * @param name The name of the highlight layer to look for.
  49617. * @return The highlight layer if found otherwise null.
  49618. */
  49619. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  49620. }
  49621. }
  49622. /**
  49623. * Glow layer options. This helps customizing the behaviour
  49624. * of the glow layer.
  49625. */
  49626. export interface IGlowLayerOptions {
  49627. /**
  49628. * Multiplication factor apply to the canvas size to compute the render target size
  49629. * used to generated the glowing objects (the smaller the faster).
  49630. */
  49631. mainTextureRatio: number;
  49632. /**
  49633. * Enforces a fixed size texture to ensure resize independant blur.
  49634. */
  49635. mainTextureFixedSize?: number;
  49636. /**
  49637. * How big is the kernel of the blur texture.
  49638. */
  49639. blurKernelSize: number;
  49640. /**
  49641. * The camera attached to the layer.
  49642. */
  49643. camera: Nullable<Camera>;
  49644. /**
  49645. * Enable MSAA by chosing the number of samples.
  49646. */
  49647. mainTextureSamples?: number;
  49648. /**
  49649. * The rendering group to draw the layer in.
  49650. */
  49651. renderingGroupId: number;
  49652. }
  49653. /**
  49654. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  49655. *
  49656. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49657. * glowy meshes to your scene.
  49658. *
  49659. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  49660. */
  49661. export class GlowLayer extends EffectLayer {
  49662. /**
  49663. * Effect Name of the layer.
  49664. */
  49665. static readonly EffectName: string;
  49666. /**
  49667. * The default blur kernel size used for the glow.
  49668. */
  49669. static DefaultBlurKernelSize: number;
  49670. /**
  49671. * The default texture size ratio used for the glow.
  49672. */
  49673. static DefaultTextureRatio: number;
  49674. /**
  49675. * Sets the kernel size of the blur.
  49676. */
  49677. /**
  49678. * Gets the kernel size of the blur.
  49679. */
  49680. blurKernelSize: number;
  49681. /**
  49682. * Sets the glow intensity.
  49683. */
  49684. /**
  49685. * Gets the glow intensity.
  49686. */
  49687. intensity: number;
  49688. private _options;
  49689. private _intensity;
  49690. private _horizontalBlurPostprocess1;
  49691. private _verticalBlurPostprocess1;
  49692. private _horizontalBlurPostprocess2;
  49693. private _verticalBlurPostprocess2;
  49694. private _blurTexture1;
  49695. private _blurTexture2;
  49696. private _postProcesses1;
  49697. private _postProcesses2;
  49698. private _includedOnlyMeshes;
  49699. private _excludedMeshes;
  49700. /**
  49701. * Callback used to let the user override the color selection on a per mesh basis
  49702. */
  49703. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  49704. /**
  49705. * Callback used to let the user override the texture selection on a per mesh basis
  49706. */
  49707. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  49708. /**
  49709. * Instantiates a new glow Layer and references it to the scene.
  49710. * @param name The name of the layer
  49711. * @param scene The scene to use the layer in
  49712. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  49713. */
  49714. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  49715. /**
  49716. * Get the effect name of the layer.
  49717. * @return The effect name
  49718. */
  49719. getEffectName(): string;
  49720. /**
  49721. * Create the merge effect. This is the shader use to blit the information back
  49722. * to the main canvas at the end of the scene rendering.
  49723. */
  49724. protected _createMergeEffect(): Effect;
  49725. /**
  49726. * Creates the render target textures and post processes used in the glow layer.
  49727. */
  49728. protected _createTextureAndPostProcesses(): void;
  49729. /**
  49730. * Checks for the readiness of the element composing the layer.
  49731. * @param subMesh the mesh to check for
  49732. * @param useInstances specify wether or not to use instances to render the mesh
  49733. * @param emissiveTexture the associated emissive texture used to generate the glow
  49734. * @return true if ready otherwise, false
  49735. */
  49736. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49737. /**
  49738. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49739. */
  49740. needStencil(): boolean;
  49741. /**
  49742. * Returns true if the mesh can be rendered, otherwise false.
  49743. * @param mesh The mesh to render
  49744. * @param material The material used on the mesh
  49745. * @returns true if it can be rendered otherwise false
  49746. */
  49747. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49748. /**
  49749. * Implementation specific of rendering the generating effect on the main canvas.
  49750. * @param effect The effect used to render through
  49751. */
  49752. protected _internalRender(effect: Effect): void;
  49753. /**
  49754. * Sets the required values for both the emissive texture and and the main color.
  49755. */
  49756. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49757. /**
  49758. * Returns true if the mesh should render, otherwise false.
  49759. * @param mesh The mesh to render
  49760. * @returns true if it should render otherwise false
  49761. */
  49762. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49763. /**
  49764. * Adds specific effects defines.
  49765. * @param defines The defines to add specifics to.
  49766. */
  49767. protected _addCustomEffectDefines(defines: string[]): void;
  49768. /**
  49769. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  49770. * @param mesh The mesh to exclude from the glow layer
  49771. */
  49772. addExcludedMesh(mesh: Mesh): void;
  49773. /**
  49774. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  49775. * @param mesh The mesh to remove
  49776. */
  49777. removeExcludedMesh(mesh: Mesh): void;
  49778. /**
  49779. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  49780. * @param mesh The mesh to include in the glow layer
  49781. */
  49782. addIncludedOnlyMesh(mesh: Mesh): void;
  49783. /**
  49784. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  49785. * @param mesh The mesh to remove
  49786. */
  49787. removeIncludedOnlyMesh(mesh: Mesh): void;
  49788. /**
  49789. * Determine if a given mesh will be used in the glow layer
  49790. * @param mesh The mesh to test
  49791. * @returns true if the mesh will be highlighted by the current glow layer
  49792. */
  49793. hasMesh(mesh: AbstractMesh): boolean;
  49794. /**
  49795. * Free any resources and references associated to a mesh.
  49796. * Internal use
  49797. * @param mesh The mesh to free.
  49798. * @hidden
  49799. */
  49800. _disposeMesh(mesh: Mesh): void;
  49801. /**
  49802. * Gets the class name of the effect layer
  49803. * @returns the string with the class name of the effect layer
  49804. */
  49805. getClassName(): string;
  49806. /**
  49807. * Serializes this glow layer
  49808. * @returns a serialized glow layer object
  49809. */
  49810. serialize(): any;
  49811. /**
  49812. * Creates a Glow Layer from parsed glow layer data
  49813. * @param parsedGlowLayer defines glow layer data
  49814. * @param scene defines the current scene
  49815. * @param rootUrl defines the root URL containing the glow layer information
  49816. * @returns a parsed Glow Layer
  49817. */
  49818. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  49819. }
  49820. }
  49821. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  49822. /** @hidden */
  49823. export var glowBlurPostProcessPixelShader: {
  49824. name: string;
  49825. shader: string;
  49826. };
  49827. }
  49828. declare module "babylonjs/Layers/highlightLayer" {
  49829. import { Observable } from "babylonjs/Misc/observable";
  49830. import { Nullable } from "babylonjs/types";
  49831. import { Camera } from "babylonjs/Cameras/camera";
  49832. import { Scene } from "babylonjs/scene";
  49833. import { Color3, Color4 } from "babylonjs/Maths/math";
  49834. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49835. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49836. import { Mesh } from "babylonjs/Meshes/mesh";
  49837. import { Effect } from "babylonjs/Materials/effect";
  49838. import { Material } from "babylonjs/Materials/material";
  49839. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  49840. import "babylonjs/Shaders/glowMapMerge.fragment";
  49841. import "babylonjs/Shaders/glowMapMerge.vertex";
  49842. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  49843. module "babylonjs/abstractScene" {
  49844. interface AbstractScene {
  49845. /**
  49846. * Return a the first highlight layer of the scene with a given name.
  49847. * @param name The name of the highlight layer to look for.
  49848. * @return The highlight layer if found otherwise null.
  49849. */
  49850. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  49851. }
  49852. }
  49853. /**
  49854. * Highlight layer options. This helps customizing the behaviour
  49855. * of the highlight layer.
  49856. */
  49857. export interface IHighlightLayerOptions {
  49858. /**
  49859. * Multiplication factor apply to the canvas size to compute the render target size
  49860. * used to generated the glowing objects (the smaller the faster).
  49861. */
  49862. mainTextureRatio: number;
  49863. /**
  49864. * Enforces a fixed size texture to ensure resize independant blur.
  49865. */
  49866. mainTextureFixedSize?: number;
  49867. /**
  49868. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  49869. * of the picture to blur (the smaller the faster).
  49870. */
  49871. blurTextureSizeRatio: number;
  49872. /**
  49873. * How big in texel of the blur texture is the vertical blur.
  49874. */
  49875. blurVerticalSize: number;
  49876. /**
  49877. * How big in texel of the blur texture is the horizontal blur.
  49878. */
  49879. blurHorizontalSize: number;
  49880. /**
  49881. * Alpha blending mode used to apply the blur. Default is combine.
  49882. */
  49883. alphaBlendingMode: number;
  49884. /**
  49885. * The camera attached to the layer.
  49886. */
  49887. camera: Nullable<Camera>;
  49888. /**
  49889. * Should we display highlight as a solid stroke?
  49890. */
  49891. isStroke?: boolean;
  49892. /**
  49893. * The rendering group to draw the layer in.
  49894. */
  49895. renderingGroupId: number;
  49896. }
  49897. /**
  49898. * The highlight layer Helps adding a glow effect around a mesh.
  49899. *
  49900. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49901. * glowy meshes to your scene.
  49902. *
  49903. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  49904. */
  49905. export class HighlightLayer extends EffectLayer {
  49906. name: string;
  49907. /**
  49908. * Effect Name of the highlight layer.
  49909. */
  49910. static readonly EffectName: string;
  49911. /**
  49912. * The neutral color used during the preparation of the glow effect.
  49913. * This is black by default as the blend operation is a blend operation.
  49914. */
  49915. static NeutralColor: Color4;
  49916. /**
  49917. * Stencil value used for glowing meshes.
  49918. */
  49919. static GlowingMeshStencilReference: number;
  49920. /**
  49921. * Stencil value used for the other meshes in the scene.
  49922. */
  49923. static NormalMeshStencilReference: number;
  49924. /**
  49925. * Specifies whether or not the inner glow is ACTIVE in the layer.
  49926. */
  49927. innerGlow: boolean;
  49928. /**
  49929. * Specifies whether or not the outer glow is ACTIVE in the layer.
  49930. */
  49931. outerGlow: boolean;
  49932. /**
  49933. * Specifies the horizontal size of the blur.
  49934. */
  49935. /**
  49936. * Gets the horizontal size of the blur.
  49937. */
  49938. blurHorizontalSize: number;
  49939. /**
  49940. * Specifies the vertical size of the blur.
  49941. */
  49942. /**
  49943. * Gets the vertical size of the blur.
  49944. */
  49945. blurVerticalSize: number;
  49946. /**
  49947. * An event triggered when the highlight layer is being blurred.
  49948. */
  49949. onBeforeBlurObservable: Observable<HighlightLayer>;
  49950. /**
  49951. * An event triggered when the highlight layer has been blurred.
  49952. */
  49953. onAfterBlurObservable: Observable<HighlightLayer>;
  49954. private _instanceGlowingMeshStencilReference;
  49955. private _options;
  49956. private _downSamplePostprocess;
  49957. private _horizontalBlurPostprocess;
  49958. private _verticalBlurPostprocess;
  49959. private _blurTexture;
  49960. private _meshes;
  49961. private _excludedMeshes;
  49962. /**
  49963. * Instantiates a new highlight Layer and references it to the scene..
  49964. * @param name The name of the layer
  49965. * @param scene The scene to use the layer in
  49966. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  49967. */
  49968. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  49969. /**
  49970. * Get the effect name of the layer.
  49971. * @return The effect name
  49972. */
  49973. getEffectName(): string;
  49974. /**
  49975. * Create the merge effect. This is the shader use to blit the information back
  49976. * to the main canvas at the end of the scene rendering.
  49977. */
  49978. protected _createMergeEffect(): Effect;
  49979. /**
  49980. * Creates the render target textures and post processes used in the highlight layer.
  49981. */
  49982. protected _createTextureAndPostProcesses(): void;
  49983. /**
  49984. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49985. */
  49986. needStencil(): boolean;
  49987. /**
  49988. * Checks for the readiness of the element composing the layer.
  49989. * @param subMesh the mesh to check for
  49990. * @param useInstances specify wether or not to use instances to render the mesh
  49991. * @param emissiveTexture the associated emissive texture used to generate the glow
  49992. * @return true if ready otherwise, false
  49993. */
  49994. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49995. /**
  49996. * Implementation specific of rendering the generating effect on the main canvas.
  49997. * @param effect The effect used to render through
  49998. */
  49999. protected _internalRender(effect: Effect): void;
  50000. /**
  50001. * Returns true if the layer contains information to display, otherwise false.
  50002. */
  50003. shouldRender(): boolean;
  50004. /**
  50005. * Returns true if the mesh should render, otherwise false.
  50006. * @param mesh The mesh to render
  50007. * @returns true if it should render otherwise false
  50008. */
  50009. protected _shouldRenderMesh(mesh: Mesh): boolean;
  50010. /**
  50011. * Sets the required values for both the emissive texture and and the main color.
  50012. */
  50013. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  50014. /**
  50015. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  50016. * @param mesh The mesh to exclude from the highlight layer
  50017. */
  50018. addExcludedMesh(mesh: Mesh): void;
  50019. /**
  50020. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  50021. * @param mesh The mesh to highlight
  50022. */
  50023. removeExcludedMesh(mesh: Mesh): void;
  50024. /**
  50025. * Determine if a given mesh will be highlighted by the current HighlightLayer
  50026. * @param mesh mesh to test
  50027. * @returns true if the mesh will be highlighted by the current HighlightLayer
  50028. */
  50029. hasMesh(mesh: AbstractMesh): boolean;
  50030. /**
  50031. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  50032. * @param mesh The mesh to highlight
  50033. * @param color The color of the highlight
  50034. * @param glowEmissiveOnly Extract the glow from the emissive texture
  50035. */
  50036. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  50037. /**
  50038. * Remove a mesh from the highlight layer in order to make it stop glowing.
  50039. * @param mesh The mesh to highlight
  50040. */
  50041. removeMesh(mesh: Mesh): void;
  50042. /**
  50043. * Force the stencil to the normal expected value for none glowing parts
  50044. */
  50045. private _defaultStencilReference;
  50046. /**
  50047. * Free any resources and references associated to a mesh.
  50048. * Internal use
  50049. * @param mesh The mesh to free.
  50050. * @hidden
  50051. */
  50052. _disposeMesh(mesh: Mesh): void;
  50053. /**
  50054. * Dispose the highlight layer and free resources.
  50055. */
  50056. dispose(): void;
  50057. /**
  50058. * Gets the class name of the effect layer
  50059. * @returns the string with the class name of the effect layer
  50060. */
  50061. getClassName(): string;
  50062. /**
  50063. * Serializes this Highlight layer
  50064. * @returns a serialized Highlight layer object
  50065. */
  50066. serialize(): any;
  50067. /**
  50068. * Creates a Highlight layer from parsed Highlight layer data
  50069. * @param parsedHightlightLayer defines the Highlight layer data
  50070. * @param scene defines the current scene
  50071. * @param rootUrl defines the root URL containing the Highlight layer information
  50072. * @returns a parsed Highlight layer
  50073. */
  50074. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  50075. }
  50076. }
  50077. declare module "babylonjs/Layers/layerSceneComponent" {
  50078. import { Scene } from "babylonjs/scene";
  50079. import { ISceneComponent } from "babylonjs/sceneComponent";
  50080. import { Layer } from "babylonjs/Layers/layer";
  50081. import { AbstractScene } from "babylonjs/abstractScene";
  50082. module "babylonjs/abstractScene" {
  50083. interface AbstractScene {
  50084. /**
  50085. * The list of layers (background and foreground) of the scene
  50086. */
  50087. layers: Array<Layer>;
  50088. }
  50089. }
  50090. /**
  50091. * Defines the layer scene component responsible to manage any layers
  50092. * in a given scene.
  50093. */
  50094. export class LayerSceneComponent implements ISceneComponent {
  50095. /**
  50096. * The component name helpfull to identify the component in the list of scene components.
  50097. */
  50098. readonly name: string;
  50099. /**
  50100. * The scene the component belongs to.
  50101. */
  50102. scene: Scene;
  50103. private _engine;
  50104. /**
  50105. * Creates a new instance of the component for the given scene
  50106. * @param scene Defines the scene to register the component in
  50107. */
  50108. constructor(scene: Scene);
  50109. /**
  50110. * Registers the component in a given scene
  50111. */
  50112. register(): void;
  50113. /**
  50114. * Rebuilds the elements related to this component in case of
  50115. * context lost for instance.
  50116. */
  50117. rebuild(): void;
  50118. /**
  50119. * Disposes the component and the associated ressources.
  50120. */
  50121. dispose(): void;
  50122. private _draw;
  50123. private _drawCameraPredicate;
  50124. private _drawCameraBackground;
  50125. private _drawCameraForeground;
  50126. private _drawRenderTargetPredicate;
  50127. private _drawRenderTargetBackground;
  50128. private _drawRenderTargetForeground;
  50129. /**
  50130. * Adds all the elements from the container to the scene
  50131. * @param container the container holding the elements
  50132. */
  50133. addFromContainer(container: AbstractScene): void;
  50134. /**
  50135. * Removes all the elements in the container from the scene
  50136. * @param container contains the elements to remove
  50137. * @param dispose if the removed element should be disposed (default: false)
  50138. */
  50139. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50140. }
  50141. }
  50142. declare module "babylonjs/Shaders/layer.fragment" {
  50143. /** @hidden */
  50144. export var layerPixelShader: {
  50145. name: string;
  50146. shader: string;
  50147. };
  50148. }
  50149. declare module "babylonjs/Shaders/layer.vertex" {
  50150. /** @hidden */
  50151. export var layerVertexShader: {
  50152. name: string;
  50153. shader: string;
  50154. };
  50155. }
  50156. declare module "babylonjs/Layers/layer" {
  50157. import { Observable } from "babylonjs/Misc/observable";
  50158. import { Nullable } from "babylonjs/types";
  50159. import { Scene } from "babylonjs/scene";
  50160. import { Vector2, Color4 } from "babylonjs/Maths/math";
  50161. import { Texture } from "babylonjs/Materials/Textures/texture";
  50162. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50163. import "babylonjs/Shaders/layer.fragment";
  50164. import "babylonjs/Shaders/layer.vertex";
  50165. /**
  50166. * This represents a full screen 2d layer.
  50167. * This can be useful to display a picture in the background of your scene for instance.
  50168. * @see https://www.babylonjs-playground.com/#08A2BS#1
  50169. */
  50170. export class Layer {
  50171. /**
  50172. * Define the name of the layer.
  50173. */
  50174. name: string;
  50175. /**
  50176. * Define the texture the layer should display.
  50177. */
  50178. texture: Nullable<Texture>;
  50179. /**
  50180. * Is the layer in background or foreground.
  50181. */
  50182. isBackground: boolean;
  50183. /**
  50184. * Define the color of the layer (instead of texture).
  50185. */
  50186. color: Color4;
  50187. /**
  50188. * Define the scale of the layer in order to zoom in out of the texture.
  50189. */
  50190. scale: Vector2;
  50191. /**
  50192. * Define an offset for the layer in order to shift the texture.
  50193. */
  50194. offset: Vector2;
  50195. /**
  50196. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  50197. */
  50198. alphaBlendingMode: number;
  50199. /**
  50200. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  50201. * Alpha test will not mix with the background color in case of transparency.
  50202. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  50203. */
  50204. alphaTest: boolean;
  50205. /**
  50206. * Define a mask to restrict the layer to only some of the scene cameras.
  50207. */
  50208. layerMask: number;
  50209. /**
  50210. * Define the list of render target the layer is visible into.
  50211. */
  50212. renderTargetTextures: RenderTargetTexture[];
  50213. /**
  50214. * Define if the layer is only used in renderTarget or if it also
  50215. * renders in the main frame buffer of the canvas.
  50216. */
  50217. renderOnlyInRenderTargetTextures: boolean;
  50218. private _scene;
  50219. private _vertexBuffers;
  50220. private _indexBuffer;
  50221. private _effect;
  50222. private _alphaTestEffect;
  50223. /**
  50224. * An event triggered when the layer is disposed.
  50225. */
  50226. onDisposeObservable: Observable<Layer>;
  50227. private _onDisposeObserver;
  50228. /**
  50229. * Back compatibility with callback before the onDisposeObservable existed.
  50230. * The set callback will be triggered when the layer has been disposed.
  50231. */
  50232. onDispose: () => void;
  50233. /**
  50234. * An event triggered before rendering the scene
  50235. */
  50236. onBeforeRenderObservable: Observable<Layer>;
  50237. private _onBeforeRenderObserver;
  50238. /**
  50239. * Back compatibility with callback before the onBeforeRenderObservable existed.
  50240. * The set callback will be triggered just before rendering the layer.
  50241. */
  50242. onBeforeRender: () => void;
  50243. /**
  50244. * An event triggered after rendering the scene
  50245. */
  50246. onAfterRenderObservable: Observable<Layer>;
  50247. private _onAfterRenderObserver;
  50248. /**
  50249. * Back compatibility with callback before the onAfterRenderObservable existed.
  50250. * The set callback will be triggered just after rendering the layer.
  50251. */
  50252. onAfterRender: () => void;
  50253. /**
  50254. * Instantiates a new layer.
  50255. * This represents a full screen 2d layer.
  50256. * This can be useful to display a picture in the background of your scene for instance.
  50257. * @see https://www.babylonjs-playground.com/#08A2BS#1
  50258. * @param name Define the name of the layer in the scene
  50259. * @param imgUrl Define the url of the texture to display in the layer
  50260. * @param scene Define the scene the layer belongs to
  50261. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  50262. * @param color Defines a color for the layer
  50263. */
  50264. constructor(
  50265. /**
  50266. * Define the name of the layer.
  50267. */
  50268. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  50269. private _createIndexBuffer;
  50270. /** @hidden */
  50271. _rebuild(): void;
  50272. /**
  50273. * Renders the layer in the scene.
  50274. */
  50275. render(): void;
  50276. /**
  50277. * Disposes and releases the associated ressources.
  50278. */
  50279. dispose(): void;
  50280. }
  50281. }
  50282. declare module "babylonjs/Layers/index" {
  50283. export * from "babylonjs/Layers/effectLayer";
  50284. export * from "babylonjs/Layers/effectLayerSceneComponent";
  50285. export * from "babylonjs/Layers/glowLayer";
  50286. export * from "babylonjs/Layers/highlightLayer";
  50287. export * from "babylonjs/Layers/layer";
  50288. export * from "babylonjs/Layers/layerSceneComponent";
  50289. }
  50290. declare module "babylonjs/Shaders/lensFlare.fragment" {
  50291. /** @hidden */
  50292. export var lensFlarePixelShader: {
  50293. name: string;
  50294. shader: string;
  50295. };
  50296. }
  50297. declare module "babylonjs/Shaders/lensFlare.vertex" {
  50298. /** @hidden */
  50299. export var lensFlareVertexShader: {
  50300. name: string;
  50301. shader: string;
  50302. };
  50303. }
  50304. declare module "babylonjs/LensFlares/lensFlareSystem" {
  50305. import { Scene } from "babylonjs/scene";
  50306. import { Vector3, Viewport } from "babylonjs/Maths/math";
  50307. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50308. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  50309. import "babylonjs/Shaders/lensFlare.fragment";
  50310. import "babylonjs/Shaders/lensFlare.vertex";
  50311. /**
  50312. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  50313. * It is usually composed of several `lensFlare`.
  50314. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50315. */
  50316. export class LensFlareSystem {
  50317. /**
  50318. * Define the name of the lens flare system
  50319. */
  50320. name: string;
  50321. /**
  50322. * List of lens flares used in this system.
  50323. */
  50324. lensFlares: LensFlare[];
  50325. /**
  50326. * Define a limit from the border the lens flare can be visible.
  50327. */
  50328. borderLimit: number;
  50329. /**
  50330. * Define a viewport border we do not want to see the lens flare in.
  50331. */
  50332. viewportBorder: number;
  50333. /**
  50334. * Define a predicate which could limit the list of meshes able to occlude the effect.
  50335. */
  50336. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  50337. /**
  50338. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  50339. */
  50340. layerMask: number;
  50341. /**
  50342. * Define the id of the lens flare system in the scene.
  50343. * (equal to name by default)
  50344. */
  50345. id: string;
  50346. private _scene;
  50347. private _emitter;
  50348. private _vertexBuffers;
  50349. private _indexBuffer;
  50350. private _effect;
  50351. private _positionX;
  50352. private _positionY;
  50353. private _isEnabled;
  50354. /** @hidden */
  50355. static _SceneComponentInitialization: (scene: Scene) => void;
  50356. /**
  50357. * Instantiates a lens flare system.
  50358. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  50359. * It is usually composed of several `lensFlare`.
  50360. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50361. * @param name Define the name of the lens flare system in the scene
  50362. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  50363. * @param scene Define the scene the lens flare system belongs to
  50364. */
  50365. constructor(
  50366. /**
  50367. * Define the name of the lens flare system
  50368. */
  50369. name: string, emitter: any, scene: Scene);
  50370. /**
  50371. * Define if the lens flare system is enabled.
  50372. */
  50373. isEnabled: boolean;
  50374. /**
  50375. * Get the scene the effects belongs to.
  50376. * @returns the scene holding the lens flare system
  50377. */
  50378. getScene(): Scene;
  50379. /**
  50380. * Get the emitter of the lens flare system.
  50381. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  50382. * @returns the emitter of the lens flare system
  50383. */
  50384. getEmitter(): any;
  50385. /**
  50386. * Set the emitter of the lens flare system.
  50387. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  50388. * @param newEmitter Define the new emitter of the system
  50389. */
  50390. setEmitter(newEmitter: any): void;
  50391. /**
  50392. * Get the lens flare system emitter position.
  50393. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  50394. * @returns the position
  50395. */
  50396. getEmitterPosition(): Vector3;
  50397. /**
  50398. * @hidden
  50399. */
  50400. computeEffectivePosition(globalViewport: Viewport): boolean;
  50401. /** @hidden */
  50402. _isVisible(): boolean;
  50403. /**
  50404. * @hidden
  50405. */
  50406. render(): boolean;
  50407. /**
  50408. * Dispose and release the lens flare with its associated resources.
  50409. */
  50410. dispose(): void;
  50411. /**
  50412. * Parse a lens flare system from a JSON repressentation
  50413. * @param parsedLensFlareSystem Define the JSON to parse
  50414. * @param scene Define the scene the parsed system should be instantiated in
  50415. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  50416. * @returns the parsed system
  50417. */
  50418. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  50419. /**
  50420. * Serialize the current Lens Flare System into a JSON representation.
  50421. * @returns the serialized JSON
  50422. */
  50423. serialize(): any;
  50424. }
  50425. }
  50426. declare module "babylonjs/LensFlares/lensFlare" {
  50427. import { Nullable } from "babylonjs/types";
  50428. import { Color3 } from "babylonjs/Maths/math";
  50429. import { Texture } from "babylonjs/Materials/Textures/texture";
  50430. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  50431. /**
  50432. * This represents one of the lens effect in a `lensFlareSystem`.
  50433. * It controls one of the indiviual texture used in the effect.
  50434. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50435. */
  50436. export class LensFlare {
  50437. /**
  50438. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  50439. */
  50440. size: number;
  50441. /**
  50442. * 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.
  50443. */
  50444. position: number;
  50445. /**
  50446. * Define the lens color.
  50447. */
  50448. color: Color3;
  50449. /**
  50450. * Define the lens texture.
  50451. */
  50452. texture: Nullable<Texture>;
  50453. /**
  50454. * Define the alpha mode to render this particular lens.
  50455. */
  50456. alphaMode: number;
  50457. private _system;
  50458. /**
  50459. * Creates a new Lens Flare.
  50460. * This represents one of the lens effect in a `lensFlareSystem`.
  50461. * It controls one of the indiviual texture used in the effect.
  50462. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50463. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  50464. * @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.
  50465. * @param color Define the lens color
  50466. * @param imgUrl Define the lens texture url
  50467. * @param system Define the `lensFlareSystem` this flare is part of
  50468. * @returns The newly created Lens Flare
  50469. */
  50470. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  50471. /**
  50472. * Instantiates a new Lens Flare.
  50473. * This represents one of the lens effect in a `lensFlareSystem`.
  50474. * It controls one of the indiviual texture used in the effect.
  50475. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50476. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  50477. * @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.
  50478. * @param color Define the lens color
  50479. * @param imgUrl Define the lens texture url
  50480. * @param system Define the `lensFlareSystem` this flare is part of
  50481. */
  50482. constructor(
  50483. /**
  50484. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  50485. */
  50486. size: number,
  50487. /**
  50488. * 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.
  50489. */
  50490. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  50491. /**
  50492. * Dispose and release the lens flare with its associated resources.
  50493. */
  50494. dispose(): void;
  50495. }
  50496. }
  50497. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  50498. import { Nullable } from "babylonjs/types";
  50499. import { Scene } from "babylonjs/scene";
  50500. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  50501. import { AbstractScene } from "babylonjs/abstractScene";
  50502. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  50503. module "babylonjs/abstractScene" {
  50504. interface AbstractScene {
  50505. /**
  50506. * The list of lens flare system added to the scene
  50507. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50508. */
  50509. lensFlareSystems: Array<LensFlareSystem>;
  50510. /**
  50511. * Removes the given lens flare system from this scene.
  50512. * @param toRemove The lens flare system to remove
  50513. * @returns The index of the removed lens flare system
  50514. */
  50515. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  50516. /**
  50517. * Adds the given lens flare system to this scene
  50518. * @param newLensFlareSystem The lens flare system to add
  50519. */
  50520. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  50521. /**
  50522. * Gets a lens flare system using its name
  50523. * @param name defines the name to look for
  50524. * @returns the lens flare system or null if not found
  50525. */
  50526. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  50527. /**
  50528. * Gets a lens flare system using its id
  50529. * @param id defines the id to look for
  50530. * @returns the lens flare system or null if not found
  50531. */
  50532. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  50533. }
  50534. }
  50535. /**
  50536. * Defines the lens flare scene component responsible to manage any lens flares
  50537. * in a given scene.
  50538. */
  50539. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  50540. /**
  50541. * The component name helpfull to identify the component in the list of scene components.
  50542. */
  50543. readonly name: string;
  50544. /**
  50545. * The scene the component belongs to.
  50546. */
  50547. scene: Scene;
  50548. /**
  50549. * Creates a new instance of the component for the given scene
  50550. * @param scene Defines the scene to register the component in
  50551. */
  50552. constructor(scene: Scene);
  50553. /**
  50554. * Registers the component in a given scene
  50555. */
  50556. register(): void;
  50557. /**
  50558. * Rebuilds the elements related to this component in case of
  50559. * context lost for instance.
  50560. */
  50561. rebuild(): void;
  50562. /**
  50563. * Adds all the elements from the container to the scene
  50564. * @param container the container holding the elements
  50565. */
  50566. addFromContainer(container: AbstractScene): void;
  50567. /**
  50568. * Removes all the elements in the container from the scene
  50569. * @param container contains the elements to remove
  50570. * @param dispose if the removed element should be disposed (default: false)
  50571. */
  50572. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50573. /**
  50574. * Serializes the component data to the specified json object
  50575. * @param serializationObject The object to serialize to
  50576. */
  50577. serialize(serializationObject: any): void;
  50578. /**
  50579. * Disposes the component and the associated ressources.
  50580. */
  50581. dispose(): void;
  50582. private _draw;
  50583. }
  50584. }
  50585. declare module "babylonjs/LensFlares/index" {
  50586. export * from "babylonjs/LensFlares/lensFlare";
  50587. export * from "babylonjs/LensFlares/lensFlareSystem";
  50588. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  50589. }
  50590. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  50591. import { Scene } from "babylonjs/scene";
  50592. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  50593. import { AbstractScene } from "babylonjs/abstractScene";
  50594. /**
  50595. * Defines the shadow generator component responsible to manage any shadow generators
  50596. * in a given scene.
  50597. */
  50598. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  50599. /**
  50600. * The component name helpfull to identify the component in the list of scene components.
  50601. */
  50602. readonly name: string;
  50603. /**
  50604. * The scene the component belongs to.
  50605. */
  50606. scene: Scene;
  50607. /**
  50608. * Creates a new instance of the component for the given scene
  50609. * @param scene Defines the scene to register the component in
  50610. */
  50611. constructor(scene: Scene);
  50612. /**
  50613. * Registers the component in a given scene
  50614. */
  50615. register(): void;
  50616. /**
  50617. * Rebuilds the elements related to this component in case of
  50618. * context lost for instance.
  50619. */
  50620. rebuild(): void;
  50621. /**
  50622. * Serializes the component data to the specified json object
  50623. * @param serializationObject The object to serialize to
  50624. */
  50625. serialize(serializationObject: any): void;
  50626. /**
  50627. * Adds all the elements from the container to the scene
  50628. * @param container the container holding the elements
  50629. */
  50630. addFromContainer(container: AbstractScene): void;
  50631. /**
  50632. * Removes all the elements in the container from the scene
  50633. * @param container contains the elements to remove
  50634. * @param dispose if the removed element should be disposed (default: false)
  50635. */
  50636. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50637. /**
  50638. * Rebuilds the elements related to this component in case of
  50639. * context lost for instance.
  50640. */
  50641. dispose(): void;
  50642. private _gatherRenderTargets;
  50643. }
  50644. }
  50645. declare module "babylonjs/Lights/Shadows/index" {
  50646. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  50647. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  50648. }
  50649. declare module "babylonjs/Lights/pointLight" {
  50650. import { Scene } from "babylonjs/scene";
  50651. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  50652. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50653. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  50654. import { Effect } from "babylonjs/Materials/effect";
  50655. /**
  50656. * A point light is a light defined by an unique point in world space.
  50657. * The light is emitted in every direction from this point.
  50658. * A good example of a point light is a standard light bulb.
  50659. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50660. */
  50661. export class PointLight extends ShadowLight {
  50662. private _shadowAngle;
  50663. /**
  50664. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50665. * This specifies what angle the shadow will use to be created.
  50666. *
  50667. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50668. */
  50669. /**
  50670. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50671. * This specifies what angle the shadow will use to be created.
  50672. *
  50673. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50674. */
  50675. shadowAngle: number;
  50676. /**
  50677. * Gets the direction if it has been set.
  50678. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50679. */
  50680. /**
  50681. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50682. */
  50683. direction: Vector3;
  50684. /**
  50685. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  50686. * A PointLight emits the light in every direction.
  50687. * It can cast shadows.
  50688. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  50689. * ```javascript
  50690. * var pointLight = new PointLight("pl", camera.position, scene);
  50691. * ```
  50692. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50693. * @param name The light friendly name
  50694. * @param position The position of the point light in the scene
  50695. * @param scene The scene the lights belongs to
  50696. */
  50697. constructor(name: string, position: Vector3, scene: Scene);
  50698. /**
  50699. * Returns the string "PointLight"
  50700. * @returns the class name
  50701. */
  50702. getClassName(): string;
  50703. /**
  50704. * Returns the integer 0.
  50705. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50706. */
  50707. getTypeID(): number;
  50708. /**
  50709. * Specifies wether or not the shadowmap should be a cube texture.
  50710. * @returns true if the shadowmap needs to be a cube texture.
  50711. */
  50712. needCube(): boolean;
  50713. /**
  50714. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  50715. * @param faceIndex The index of the face we are computed the direction to generate shadow
  50716. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  50717. */
  50718. getShadowDirection(faceIndex?: number): Vector3;
  50719. /**
  50720. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  50721. * - fov = PI / 2
  50722. * - aspect ratio : 1.0
  50723. * - z-near and far equal to the active camera minZ and maxZ.
  50724. * Returns the PointLight.
  50725. */
  50726. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50727. protected _buildUniformLayout(): void;
  50728. /**
  50729. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  50730. * @param effect The effect to update
  50731. * @param lightIndex The index of the light in the effect to update
  50732. * @returns The point light
  50733. */
  50734. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  50735. /**
  50736. * Prepares the list of defines specific to the light type.
  50737. * @param defines the list of defines
  50738. * @param lightIndex defines the index of the light for the effect
  50739. */
  50740. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50741. }
  50742. }
  50743. declare module "babylonjs/Lights/index" {
  50744. export * from "babylonjs/Lights/light";
  50745. export * from "babylonjs/Lights/shadowLight";
  50746. export * from "babylonjs/Lights/Shadows/index";
  50747. export * from "babylonjs/Lights/directionalLight";
  50748. export * from "babylonjs/Lights/hemisphericLight";
  50749. export * from "babylonjs/Lights/pointLight";
  50750. export * from "babylonjs/Lights/spotLight";
  50751. }
  50752. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  50753. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  50754. /**
  50755. * Header information of HDR texture files.
  50756. */
  50757. export interface HDRInfo {
  50758. /**
  50759. * The height of the texture in pixels.
  50760. */
  50761. height: number;
  50762. /**
  50763. * The width of the texture in pixels.
  50764. */
  50765. width: number;
  50766. /**
  50767. * The index of the beginning of the data in the binary file.
  50768. */
  50769. dataPosition: number;
  50770. }
  50771. /**
  50772. * This groups tools to convert HDR texture to native colors array.
  50773. */
  50774. export class HDRTools {
  50775. private static Ldexp;
  50776. private static Rgbe2float;
  50777. private static readStringLine;
  50778. /**
  50779. * Reads header information from an RGBE texture stored in a native array.
  50780. * More information on this format are available here:
  50781. * https://en.wikipedia.org/wiki/RGBE_image_format
  50782. *
  50783. * @param uint8array The binary file stored in native array.
  50784. * @return The header information.
  50785. */
  50786. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  50787. /**
  50788. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  50789. * This RGBE texture needs to store the information as a panorama.
  50790. *
  50791. * More information on this format are available here:
  50792. * https://en.wikipedia.org/wiki/RGBE_image_format
  50793. *
  50794. * @param buffer The binary file stored in an array buffer.
  50795. * @param size The expected size of the extracted cubemap.
  50796. * @return The Cube Map information.
  50797. */
  50798. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  50799. /**
  50800. * Returns the pixels data extracted from an RGBE texture.
  50801. * This pixels will be stored left to right up to down in the R G B order in one array.
  50802. *
  50803. * More information on this format are available here:
  50804. * https://en.wikipedia.org/wiki/RGBE_image_format
  50805. *
  50806. * @param uint8array The binary file stored in an array buffer.
  50807. * @param hdrInfo The header information of the file.
  50808. * @return The pixels data in RGB right to left up to down order.
  50809. */
  50810. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  50811. private static RGBE_ReadPixels_RLE;
  50812. }
  50813. }
  50814. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  50815. import { Nullable } from "babylonjs/types";
  50816. import { Scene } from "babylonjs/scene";
  50817. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  50818. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50819. import "babylonjs/Engines/Extensions/engine.rawTexture";
  50820. /**
  50821. * This represents a texture coming from an HDR input.
  50822. *
  50823. * The only supported format is currently panorama picture stored in RGBE format.
  50824. * Example of such files can be found on HDRLib: http://hdrlib.com/
  50825. */
  50826. export class HDRCubeTexture extends BaseTexture {
  50827. private static _facesMapping;
  50828. private _generateHarmonics;
  50829. private _noMipmap;
  50830. private _textureMatrix;
  50831. private _size;
  50832. private _onLoad;
  50833. private _onError;
  50834. /**
  50835. * The texture URL.
  50836. */
  50837. url: string;
  50838. /**
  50839. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  50840. */
  50841. coordinatesMode: number;
  50842. protected _isBlocking: boolean;
  50843. /**
  50844. * Sets wether or not the texture is blocking during loading.
  50845. */
  50846. /**
  50847. * Gets wether or not the texture is blocking during loading.
  50848. */
  50849. isBlocking: boolean;
  50850. protected _rotationY: number;
  50851. /**
  50852. * Sets texture matrix rotation angle around Y axis in radians.
  50853. */
  50854. /**
  50855. * Gets texture matrix rotation angle around Y axis radians.
  50856. */
  50857. rotationY: number;
  50858. /**
  50859. * Gets or sets the center of the bounding box associated with the cube texture
  50860. * It must define where the camera used to render the texture was set
  50861. */
  50862. boundingBoxPosition: Vector3;
  50863. private _boundingBoxSize;
  50864. /**
  50865. * Gets or sets the size of the bounding box associated with the cube texture
  50866. * When defined, the cubemap will switch to local mode
  50867. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  50868. * @example https://www.babylonjs-playground.com/#RNASML
  50869. */
  50870. boundingBoxSize: Vector3;
  50871. /**
  50872. * Instantiates an HDRTexture from the following parameters.
  50873. *
  50874. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  50875. * @param scene The scene the texture will be used in
  50876. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  50877. * @param noMipmap Forces to not generate the mipmap if true
  50878. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  50879. * @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)
  50880. * @param reserved Reserved flag for internal use.
  50881. */
  50882. 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>);
  50883. /**
  50884. * Get the current class name of the texture useful for serialization or dynamic coding.
  50885. * @returns "HDRCubeTexture"
  50886. */
  50887. getClassName(): string;
  50888. /**
  50889. * Occurs when the file is raw .hdr file.
  50890. */
  50891. private loadTexture;
  50892. clone(): HDRCubeTexture;
  50893. delayLoad(): void;
  50894. /**
  50895. * Get the texture reflection matrix used to rotate/transform the reflection.
  50896. * @returns the reflection matrix
  50897. */
  50898. getReflectionTextureMatrix(): Matrix;
  50899. /**
  50900. * Set the texture reflection matrix used to rotate/transform the reflection.
  50901. * @param value Define the reflection matrix to set
  50902. */
  50903. setReflectionTextureMatrix(value: Matrix): void;
  50904. /**
  50905. * Parses a JSON representation of an HDR Texture in order to create the texture
  50906. * @param parsedTexture Define the JSON representation
  50907. * @param scene Define the scene the texture should be created in
  50908. * @param rootUrl Define the root url in case we need to load relative dependencies
  50909. * @returns the newly created texture after parsing
  50910. */
  50911. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  50912. serialize(): any;
  50913. }
  50914. }
  50915. declare module "babylonjs/Physics/physicsEngine" {
  50916. import { Nullable } from "babylonjs/types";
  50917. import { Vector3 } from "babylonjs/Maths/math";
  50918. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  50919. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  50920. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  50921. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  50922. /**
  50923. * Class used to control physics engine
  50924. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  50925. */
  50926. export class PhysicsEngine implements IPhysicsEngine {
  50927. private _physicsPlugin;
  50928. /**
  50929. * Global value used to control the smallest number supported by the simulation
  50930. */
  50931. static Epsilon: number;
  50932. private _impostors;
  50933. private _joints;
  50934. /**
  50935. * Gets the gravity vector used by the simulation
  50936. */
  50937. gravity: Vector3;
  50938. /**
  50939. * Factory used to create the default physics plugin.
  50940. * @returns The default physics plugin
  50941. */
  50942. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  50943. /**
  50944. * Creates a new Physics Engine
  50945. * @param gravity defines the gravity vector used by the simulation
  50946. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  50947. */
  50948. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  50949. /**
  50950. * Sets the gravity vector used by the simulation
  50951. * @param gravity defines the gravity vector to use
  50952. */
  50953. setGravity(gravity: Vector3): void;
  50954. /**
  50955. * Set the time step of the physics engine.
  50956. * Default is 1/60.
  50957. * To slow it down, enter 1/600 for example.
  50958. * To speed it up, 1/30
  50959. * @param newTimeStep defines the new timestep to apply to this world.
  50960. */
  50961. setTimeStep(newTimeStep?: number): void;
  50962. /**
  50963. * Get the time step of the physics engine.
  50964. * @returns the current time step
  50965. */
  50966. getTimeStep(): number;
  50967. /**
  50968. * Release all resources
  50969. */
  50970. dispose(): void;
  50971. /**
  50972. * Gets the name of the current physics plugin
  50973. * @returns the name of the plugin
  50974. */
  50975. getPhysicsPluginName(): string;
  50976. /**
  50977. * Adding a new impostor for the impostor tracking.
  50978. * This will be done by the impostor itself.
  50979. * @param impostor the impostor to add
  50980. */
  50981. addImpostor(impostor: PhysicsImpostor): void;
  50982. /**
  50983. * Remove an impostor from the engine.
  50984. * This impostor and its mesh will not longer be updated by the physics engine.
  50985. * @param impostor the impostor to remove
  50986. */
  50987. removeImpostor(impostor: PhysicsImpostor): void;
  50988. /**
  50989. * Add a joint to the physics engine
  50990. * @param mainImpostor defines the main impostor to which the joint is added.
  50991. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  50992. * @param joint defines the joint that will connect both impostors.
  50993. */
  50994. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50995. /**
  50996. * Removes a joint from the simulation
  50997. * @param mainImpostor defines the impostor used with the joint
  50998. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  50999. * @param joint defines the joint to remove
  51000. */
  51001. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  51002. /**
  51003. * Called by the scene. No need to call it.
  51004. * @param delta defines the timespam between frames
  51005. */
  51006. _step(delta: number): void;
  51007. /**
  51008. * Gets the current plugin used to run the simulation
  51009. * @returns current plugin
  51010. */
  51011. getPhysicsPlugin(): IPhysicsEnginePlugin;
  51012. /**
  51013. * Gets the list of physic impostors
  51014. * @returns an array of PhysicsImpostor
  51015. */
  51016. getImpostors(): Array<PhysicsImpostor>;
  51017. /**
  51018. * Gets the impostor for a physics enabled object
  51019. * @param object defines the object impersonated by the impostor
  51020. * @returns the PhysicsImpostor or null if not found
  51021. */
  51022. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  51023. /**
  51024. * Gets the impostor for a physics body object
  51025. * @param body defines physics body used by the impostor
  51026. * @returns the PhysicsImpostor or null if not found
  51027. */
  51028. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  51029. /**
  51030. * Does a raycast in the physics world
  51031. * @param from when should the ray start?
  51032. * @param to when should the ray end?
  51033. * @returns PhysicsRaycastResult
  51034. */
  51035. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51036. }
  51037. }
  51038. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  51039. import { Nullable } from "babylonjs/types";
  51040. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  51041. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51042. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  51043. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51044. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  51045. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  51046. /** @hidden */
  51047. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  51048. private _useDeltaForWorldStep;
  51049. world: any;
  51050. name: string;
  51051. private _physicsMaterials;
  51052. private _fixedTimeStep;
  51053. private _cannonRaycastResult;
  51054. private _raycastResult;
  51055. private _removeAfterStep;
  51056. BJSCANNON: any;
  51057. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  51058. setGravity(gravity: Vector3): void;
  51059. setTimeStep(timeStep: number): void;
  51060. getTimeStep(): number;
  51061. executeStep(delta: number): void;
  51062. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51063. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51064. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51065. private _processChildMeshes;
  51066. removePhysicsBody(impostor: PhysicsImpostor): void;
  51067. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51068. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51069. private _addMaterial;
  51070. private _checkWithEpsilon;
  51071. private _createShape;
  51072. private _createHeightmap;
  51073. private _minus90X;
  51074. private _plus90X;
  51075. private _tmpPosition;
  51076. private _tmpDeltaPosition;
  51077. private _tmpUnityRotation;
  51078. private _updatePhysicsBodyTransformation;
  51079. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51080. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51081. isSupported(): boolean;
  51082. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51083. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51084. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51085. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51086. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51087. getBodyMass(impostor: PhysicsImpostor): number;
  51088. getBodyFriction(impostor: PhysicsImpostor): number;
  51089. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51090. getBodyRestitution(impostor: PhysicsImpostor): number;
  51091. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51092. sleepBody(impostor: PhysicsImpostor): void;
  51093. wakeUpBody(impostor: PhysicsImpostor): void;
  51094. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  51095. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  51096. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  51097. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51098. getRadius(impostor: PhysicsImpostor): number;
  51099. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51100. dispose(): void;
  51101. private _extendNamespace;
  51102. /**
  51103. * Does a raycast in the physics world
  51104. * @param from when should the ray start?
  51105. * @param to when should the ray end?
  51106. * @returns PhysicsRaycastResult
  51107. */
  51108. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51109. }
  51110. }
  51111. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  51112. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  51113. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51114. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  51115. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51116. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  51117. import { Nullable } from "babylonjs/types";
  51118. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  51119. /** @hidden */
  51120. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  51121. world: any;
  51122. name: string;
  51123. BJSOIMO: any;
  51124. private _raycastResult;
  51125. constructor(iterations?: number, oimoInjection?: any);
  51126. setGravity(gravity: Vector3): void;
  51127. setTimeStep(timeStep: number): void;
  51128. getTimeStep(): number;
  51129. private _tmpImpostorsArray;
  51130. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  51131. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51132. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51133. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51134. private _tmpPositionVector;
  51135. removePhysicsBody(impostor: PhysicsImpostor): void;
  51136. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51137. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51138. isSupported(): boolean;
  51139. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51140. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51141. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51142. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51143. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51144. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51145. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51146. getBodyMass(impostor: PhysicsImpostor): number;
  51147. getBodyFriction(impostor: PhysicsImpostor): number;
  51148. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51149. getBodyRestitution(impostor: PhysicsImpostor): number;
  51150. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51151. sleepBody(impostor: PhysicsImpostor): void;
  51152. wakeUpBody(impostor: PhysicsImpostor): void;
  51153. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51154. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  51155. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  51156. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51157. getRadius(impostor: PhysicsImpostor): number;
  51158. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51159. dispose(): void;
  51160. /**
  51161. * Does a raycast in the physics world
  51162. * @param from when should the ray start?
  51163. * @param to when should the ray end?
  51164. * @returns PhysicsRaycastResult
  51165. */
  51166. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51167. }
  51168. }
  51169. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  51170. import { Nullable } from "babylonjs/types";
  51171. import { Scene } from "babylonjs/scene";
  51172. import { Vector3, Vector2, Color4, Vector4 } from "babylonjs/Maths/math";
  51173. import { Mesh } from "babylonjs/Meshes/mesh";
  51174. /**
  51175. * Class containing static functions to help procedurally build meshes
  51176. */
  51177. export class RibbonBuilder {
  51178. /**
  51179. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51180. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  51181. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  51182. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  51183. * * 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
  51184. * * 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
  51185. * * 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
  51186. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51187. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51188. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51189. * * 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
  51190. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  51191. * * 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
  51192. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  51193. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51194. * @param name defines the name of the mesh
  51195. * @param options defines the options used to create the mesh
  51196. * @param scene defines the hosting scene
  51197. * @returns the ribbon mesh
  51198. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  51199. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51200. */
  51201. static CreateRibbon(name: string, options: {
  51202. pathArray: Vector3[][];
  51203. closeArray?: boolean;
  51204. closePath?: boolean;
  51205. offset?: number;
  51206. updatable?: boolean;
  51207. sideOrientation?: number;
  51208. frontUVs?: Vector4;
  51209. backUVs?: Vector4;
  51210. instance?: Mesh;
  51211. invertUV?: boolean;
  51212. uvs?: Vector2[];
  51213. colors?: Color4[];
  51214. }, scene?: Nullable<Scene>): Mesh;
  51215. }
  51216. }
  51217. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  51218. import { Nullable } from "babylonjs/types";
  51219. import { Scene } from "babylonjs/scene";
  51220. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  51221. import { Mesh } from "babylonjs/Meshes/mesh";
  51222. /**
  51223. * Class containing static functions to help procedurally build meshes
  51224. */
  51225. export class ShapeBuilder {
  51226. /**
  51227. * 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.
  51228. * * 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.
  51229. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51230. * * 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.
  51231. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  51232. * * 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
  51233. * * 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
  51234. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  51235. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51236. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51237. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  51238. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51239. * @param name defines the name of the mesh
  51240. * @param options defines the options used to create the mesh
  51241. * @param scene defines the hosting scene
  51242. * @returns the extruded shape mesh
  51243. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51244. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51245. */
  51246. static ExtrudeShape(name: string, options: {
  51247. shape: Vector3[];
  51248. path: Vector3[];
  51249. scale?: number;
  51250. rotation?: number;
  51251. cap?: number;
  51252. updatable?: boolean;
  51253. sideOrientation?: number;
  51254. frontUVs?: Vector4;
  51255. backUVs?: Vector4;
  51256. instance?: Mesh;
  51257. invertUV?: boolean;
  51258. }, scene?: Nullable<Scene>): Mesh;
  51259. /**
  51260. * Creates an custom extruded shape mesh.
  51261. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  51262. * * 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.
  51263. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51264. * * 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
  51265. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  51266. * * 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
  51267. * * It must returns a float value that will be the scale value applied to the shape on each path point
  51268. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  51269. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  51270. * * 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
  51271. * * 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
  51272. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  51273. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51274. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51275. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51276. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51277. * @param name defines the name of the mesh
  51278. * @param options defines the options used to create the mesh
  51279. * @param scene defines the hosting scene
  51280. * @returns the custom extruded shape mesh
  51281. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  51282. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51283. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51284. */
  51285. static ExtrudeShapeCustom(name: string, options: {
  51286. shape: Vector3[];
  51287. path: Vector3[];
  51288. scaleFunction?: any;
  51289. rotationFunction?: any;
  51290. ribbonCloseArray?: boolean;
  51291. ribbonClosePath?: boolean;
  51292. cap?: number;
  51293. updatable?: boolean;
  51294. sideOrientation?: number;
  51295. frontUVs?: Vector4;
  51296. backUVs?: Vector4;
  51297. instance?: Mesh;
  51298. invertUV?: boolean;
  51299. }, scene?: Nullable<Scene>): Mesh;
  51300. private static _ExtrudeShapeGeneric;
  51301. }
  51302. }
  51303. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  51304. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  51305. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  51306. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51307. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  51308. import { Nullable } from "babylonjs/types";
  51309. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51310. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  51311. /**
  51312. * AmmoJS Physics plugin
  51313. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51314. * @see https://github.com/kripken/ammo.js/
  51315. */
  51316. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  51317. private _useDeltaForWorldStep;
  51318. /**
  51319. * Reference to the Ammo library
  51320. */
  51321. bjsAMMO: any;
  51322. /**
  51323. * Created ammoJS world which physics bodies are added to
  51324. */
  51325. world: any;
  51326. /**
  51327. * Name of the plugin
  51328. */
  51329. name: string;
  51330. private _timeStep;
  51331. private _fixedTimeStep;
  51332. private _maxSteps;
  51333. private _tmpQuaternion;
  51334. private _tmpAmmoTransform;
  51335. private _tmpAmmoQuaternion;
  51336. private _tmpAmmoConcreteContactResultCallback;
  51337. private _collisionConfiguration;
  51338. private _dispatcher;
  51339. private _overlappingPairCache;
  51340. private _solver;
  51341. private _softBodySolver;
  51342. private _tmpAmmoVectorA;
  51343. private _tmpAmmoVectorB;
  51344. private _tmpAmmoVectorC;
  51345. private _tmpAmmoVectorD;
  51346. private _tmpContactCallbackResult;
  51347. private _tmpAmmoVectorRCA;
  51348. private _tmpAmmoVectorRCB;
  51349. private _raycastResult;
  51350. private static readonly DISABLE_COLLISION_FLAG;
  51351. private static readonly KINEMATIC_FLAG;
  51352. private static readonly DISABLE_DEACTIVATION_FLAG;
  51353. /**
  51354. * Initializes the ammoJS plugin
  51355. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  51356. * @param ammoInjection can be used to inject your own ammo reference
  51357. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  51358. */
  51359. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  51360. /**
  51361. * Sets the gravity of the physics world (m/(s^2))
  51362. * @param gravity Gravity to set
  51363. */
  51364. setGravity(gravity: Vector3): void;
  51365. /**
  51366. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  51367. * @param timeStep timestep to use in seconds
  51368. */
  51369. setTimeStep(timeStep: number): void;
  51370. /**
  51371. * 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)
  51372. * @param fixedTimeStep fixedTimeStep to use in seconds
  51373. */
  51374. setFixedTimeStep(fixedTimeStep: number): void;
  51375. /**
  51376. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  51377. * @param maxSteps the maximum number of steps by the physics engine per frame
  51378. */
  51379. setMaxSteps(maxSteps: number): void;
  51380. /**
  51381. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  51382. * @returns the current timestep in seconds
  51383. */
  51384. getTimeStep(): number;
  51385. private _isImpostorInContact;
  51386. private _isImpostorPairInContact;
  51387. private _stepSimulation;
  51388. /**
  51389. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  51390. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  51391. * After the step the babylon meshes are set to the position of the physics imposters
  51392. * @param delta amount of time to step forward
  51393. * @param impostors array of imposters to update before/after the step
  51394. */
  51395. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  51396. /**
  51397. * Update babylon mesh to match physics world object
  51398. * @param impostor imposter to match
  51399. */
  51400. private _afterSoftStep;
  51401. /**
  51402. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  51403. * @param impostor imposter to match
  51404. */
  51405. private _ropeStep;
  51406. /**
  51407. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  51408. * @param impostor imposter to match
  51409. */
  51410. private _softbodyOrClothStep;
  51411. private _tmpVector;
  51412. private _tmpMatrix;
  51413. /**
  51414. * Applies an impulse on the imposter
  51415. * @param impostor imposter to apply impulse to
  51416. * @param force amount of force to be applied to the imposter
  51417. * @param contactPoint the location to apply the impulse on the imposter
  51418. */
  51419. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51420. /**
  51421. * Applies a force on the imposter
  51422. * @param impostor imposter to apply force
  51423. * @param force amount of force to be applied to the imposter
  51424. * @param contactPoint the location to apply the force on the imposter
  51425. */
  51426. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51427. /**
  51428. * Creates a physics body using the plugin
  51429. * @param impostor the imposter to create the physics body on
  51430. */
  51431. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51432. /**
  51433. * Removes the physics body from the imposter and disposes of the body's memory
  51434. * @param impostor imposter to remove the physics body from
  51435. */
  51436. removePhysicsBody(impostor: PhysicsImpostor): void;
  51437. /**
  51438. * Generates a joint
  51439. * @param impostorJoint the imposter joint to create the joint with
  51440. */
  51441. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51442. /**
  51443. * Removes a joint
  51444. * @param impostorJoint the imposter joint to remove the joint from
  51445. */
  51446. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51447. private _addMeshVerts;
  51448. /**
  51449. * Initialise the soft body vertices to match its object's (mesh) vertices
  51450. * Softbody vertices (nodes) are in world space and to match this
  51451. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  51452. * @param impostor to create the softbody for
  51453. */
  51454. private _softVertexData;
  51455. /**
  51456. * Create an impostor's soft body
  51457. * @param impostor to create the softbody for
  51458. */
  51459. private _createSoftbody;
  51460. /**
  51461. * Create cloth for an impostor
  51462. * @param impostor to create the softbody for
  51463. */
  51464. private _createCloth;
  51465. /**
  51466. * Create rope for an impostor
  51467. * @param impostor to create the softbody for
  51468. */
  51469. private _createRope;
  51470. private _addHullVerts;
  51471. private _createShape;
  51472. /**
  51473. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  51474. * @param impostor imposter containing the physics body and babylon object
  51475. */
  51476. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51477. /**
  51478. * Sets the babylon object's position/rotation from the physics body's position/rotation
  51479. * @param impostor imposter containing the physics body and babylon object
  51480. * @param newPosition new position
  51481. * @param newRotation new rotation
  51482. */
  51483. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51484. /**
  51485. * If this plugin is supported
  51486. * @returns true if its supported
  51487. */
  51488. isSupported(): boolean;
  51489. /**
  51490. * Sets the linear velocity of the physics body
  51491. * @param impostor imposter to set the velocity on
  51492. * @param velocity velocity to set
  51493. */
  51494. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51495. /**
  51496. * Sets the angular velocity of the physics body
  51497. * @param impostor imposter to set the velocity on
  51498. * @param velocity velocity to set
  51499. */
  51500. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51501. /**
  51502. * gets the linear velocity
  51503. * @param impostor imposter to get linear velocity from
  51504. * @returns linear velocity
  51505. */
  51506. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51507. /**
  51508. * gets the angular velocity
  51509. * @param impostor imposter to get angular velocity from
  51510. * @returns angular velocity
  51511. */
  51512. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51513. /**
  51514. * Sets the mass of physics body
  51515. * @param impostor imposter to set the mass on
  51516. * @param mass mass to set
  51517. */
  51518. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51519. /**
  51520. * Gets the mass of the physics body
  51521. * @param impostor imposter to get the mass from
  51522. * @returns mass
  51523. */
  51524. getBodyMass(impostor: PhysicsImpostor): number;
  51525. /**
  51526. * Gets friction of the impostor
  51527. * @param impostor impostor to get friction from
  51528. * @returns friction value
  51529. */
  51530. getBodyFriction(impostor: PhysicsImpostor): number;
  51531. /**
  51532. * Sets friction of the impostor
  51533. * @param impostor impostor to set friction on
  51534. * @param friction friction value
  51535. */
  51536. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51537. /**
  51538. * Gets restitution of the impostor
  51539. * @param impostor impostor to get restitution from
  51540. * @returns restitution value
  51541. */
  51542. getBodyRestitution(impostor: PhysicsImpostor): number;
  51543. /**
  51544. * Sets resitution of the impostor
  51545. * @param impostor impostor to set resitution on
  51546. * @param restitution resitution value
  51547. */
  51548. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51549. /**
  51550. * Gets pressure inside the impostor
  51551. * @param impostor impostor to get pressure from
  51552. * @returns pressure value
  51553. */
  51554. getBodyPressure(impostor: PhysicsImpostor): number;
  51555. /**
  51556. * Sets pressure inside a soft body impostor
  51557. * Cloth and rope must remain 0 pressure
  51558. * @param impostor impostor to set pressure on
  51559. * @param pressure pressure value
  51560. */
  51561. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  51562. /**
  51563. * Gets stiffness of the impostor
  51564. * @param impostor impostor to get stiffness from
  51565. * @returns pressure value
  51566. */
  51567. getBodyStiffness(impostor: PhysicsImpostor): number;
  51568. /**
  51569. * Sets stiffness of the impostor
  51570. * @param impostor impostor to set stiffness on
  51571. * @param stiffness stiffness value from 0 to 1
  51572. */
  51573. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  51574. /**
  51575. * Gets velocityIterations of the impostor
  51576. * @param impostor impostor to get velocity iterations from
  51577. * @returns velocityIterations value
  51578. */
  51579. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  51580. /**
  51581. * Sets velocityIterations of the impostor
  51582. * @param impostor impostor to set velocity iterations on
  51583. * @param velocityIterations velocityIterations value
  51584. */
  51585. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  51586. /**
  51587. * Gets positionIterations of the impostor
  51588. * @param impostor impostor to get position iterations from
  51589. * @returns positionIterations value
  51590. */
  51591. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  51592. /**
  51593. * Sets positionIterations of the impostor
  51594. * @param impostor impostor to set position on
  51595. * @param positionIterations positionIterations value
  51596. */
  51597. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  51598. /**
  51599. * Append an anchor to a cloth object
  51600. * @param impostor is the cloth impostor to add anchor to
  51601. * @param otherImpostor is the rigid impostor to anchor to
  51602. * @param width ratio across width from 0 to 1
  51603. * @param height ratio up height from 0 to 1
  51604. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  51605. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  51606. */
  51607. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  51608. /**
  51609. * Append an hook to a rope object
  51610. * @param impostor is the rope impostor to add hook to
  51611. * @param otherImpostor is the rigid impostor to hook to
  51612. * @param length ratio along the rope from 0 to 1
  51613. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  51614. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  51615. */
  51616. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  51617. /**
  51618. * Sleeps the physics body and stops it from being active
  51619. * @param impostor impostor to sleep
  51620. */
  51621. sleepBody(impostor: PhysicsImpostor): void;
  51622. /**
  51623. * Activates the physics body
  51624. * @param impostor impostor to activate
  51625. */
  51626. wakeUpBody(impostor: PhysicsImpostor): void;
  51627. /**
  51628. * Updates the distance parameters of the joint
  51629. * @param joint joint to update
  51630. * @param maxDistance maximum distance of the joint
  51631. * @param minDistance minimum distance of the joint
  51632. */
  51633. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51634. /**
  51635. * Sets a motor on the joint
  51636. * @param joint joint to set motor on
  51637. * @param speed speed of the motor
  51638. * @param maxForce maximum force of the motor
  51639. * @param motorIndex index of the motor
  51640. */
  51641. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  51642. /**
  51643. * Sets the motors limit
  51644. * @param joint joint to set limit on
  51645. * @param upperLimit upper limit
  51646. * @param lowerLimit lower limit
  51647. */
  51648. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  51649. /**
  51650. * Syncs the position and rotation of a mesh with the impostor
  51651. * @param mesh mesh to sync
  51652. * @param impostor impostor to update the mesh with
  51653. */
  51654. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51655. /**
  51656. * Gets the radius of the impostor
  51657. * @param impostor impostor to get radius from
  51658. * @returns the radius
  51659. */
  51660. getRadius(impostor: PhysicsImpostor): number;
  51661. /**
  51662. * Gets the box size of the impostor
  51663. * @param impostor impostor to get box size from
  51664. * @param result the resulting box size
  51665. */
  51666. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51667. /**
  51668. * Disposes of the impostor
  51669. */
  51670. dispose(): void;
  51671. /**
  51672. * Does a raycast in the physics world
  51673. * @param from when should the ray start?
  51674. * @param to when should the ray end?
  51675. * @returns PhysicsRaycastResult
  51676. */
  51677. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51678. }
  51679. }
  51680. declare module "babylonjs/Probes/reflectionProbe" {
  51681. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51682. import { Vector3 } from "babylonjs/Maths/math";
  51683. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51684. import { Nullable } from "babylonjs/types";
  51685. import { Scene } from "babylonjs/scene";
  51686. module "babylonjs/abstractScene" {
  51687. interface AbstractScene {
  51688. /**
  51689. * The list of reflection probes added to the scene
  51690. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51691. */
  51692. reflectionProbes: Array<ReflectionProbe>;
  51693. /**
  51694. * Removes the given reflection probe from this scene.
  51695. * @param toRemove The reflection probe to remove
  51696. * @returns The index of the removed reflection probe
  51697. */
  51698. removeReflectionProbe(toRemove: ReflectionProbe): number;
  51699. /**
  51700. * Adds the given reflection probe to this scene.
  51701. * @param newReflectionProbe The reflection probe to add
  51702. */
  51703. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  51704. }
  51705. }
  51706. /**
  51707. * Class used to generate realtime reflection / refraction cube textures
  51708. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51709. */
  51710. export class ReflectionProbe {
  51711. /** defines the name of the probe */
  51712. name: string;
  51713. private _scene;
  51714. private _renderTargetTexture;
  51715. private _projectionMatrix;
  51716. private _viewMatrix;
  51717. private _target;
  51718. private _add;
  51719. private _attachedMesh;
  51720. private _invertYAxis;
  51721. /** Gets or sets probe position (center of the cube map) */
  51722. position: Vector3;
  51723. /**
  51724. * Creates a new reflection probe
  51725. * @param name defines the name of the probe
  51726. * @param size defines the texture resolution (for each face)
  51727. * @param scene defines the hosting scene
  51728. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  51729. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  51730. */
  51731. constructor(
  51732. /** defines the name of the probe */
  51733. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  51734. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  51735. samples: number;
  51736. /** Gets or sets the refresh rate to use (on every frame by default) */
  51737. refreshRate: number;
  51738. /**
  51739. * Gets the hosting scene
  51740. * @returns a Scene
  51741. */
  51742. getScene(): Scene;
  51743. /** Gets the internal CubeTexture used to render to */
  51744. readonly cubeTexture: RenderTargetTexture;
  51745. /** Gets the list of meshes to render */
  51746. readonly renderList: Nullable<AbstractMesh[]>;
  51747. /**
  51748. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  51749. * @param mesh defines the mesh to attach to
  51750. */
  51751. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  51752. /**
  51753. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  51754. * @param renderingGroupId The rendering group id corresponding to its index
  51755. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  51756. */
  51757. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  51758. /**
  51759. * Clean all associated resources
  51760. */
  51761. dispose(): void;
  51762. /**
  51763. * Converts the reflection probe information to a readable string for debug purpose.
  51764. * @param fullDetails Supports for multiple levels of logging within scene loading
  51765. * @returns the human readable reflection probe info
  51766. */
  51767. toString(fullDetails?: boolean): string;
  51768. /**
  51769. * Get the class name of the relfection probe.
  51770. * @returns "ReflectionProbe"
  51771. */
  51772. getClassName(): string;
  51773. /**
  51774. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  51775. * @returns The JSON representation of the texture
  51776. */
  51777. serialize(): any;
  51778. /**
  51779. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  51780. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  51781. * @param scene Define the scene the parsed reflection probe should be instantiated in
  51782. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  51783. * @returns The parsed reflection probe if successful
  51784. */
  51785. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  51786. }
  51787. }
  51788. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  51789. /** @hidden */
  51790. export var _BabylonLoaderRegistered: boolean;
  51791. }
  51792. declare module "babylonjs/Loading/Plugins/index" {
  51793. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  51794. }
  51795. declare module "babylonjs/Loading/index" {
  51796. export * from "babylonjs/Loading/loadingScreen";
  51797. export * from "babylonjs/Loading/Plugins/index";
  51798. export * from "babylonjs/Loading/sceneLoader";
  51799. export * from "babylonjs/Loading/sceneLoaderFlags";
  51800. }
  51801. declare module "babylonjs/Materials/Background/index" {
  51802. export * from "babylonjs/Materials/Background/backgroundMaterial";
  51803. }
  51804. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  51805. import { Scene } from "babylonjs/scene";
  51806. import { Color3 } from "babylonjs/Maths/math";
  51807. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  51808. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51809. /**
  51810. * The Physically based simple base material of BJS.
  51811. *
  51812. * This enables better naming and convention enforcements on top of the pbrMaterial.
  51813. * It is used as the base class for both the specGloss and metalRough conventions.
  51814. */
  51815. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  51816. /**
  51817. * Number of Simultaneous lights allowed on the material.
  51818. */
  51819. maxSimultaneousLights: number;
  51820. /**
  51821. * If sets to true, disables all the lights affecting the material.
  51822. */
  51823. disableLighting: boolean;
  51824. /**
  51825. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  51826. */
  51827. environmentTexture: BaseTexture;
  51828. /**
  51829. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51830. */
  51831. invertNormalMapX: boolean;
  51832. /**
  51833. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51834. */
  51835. invertNormalMapY: boolean;
  51836. /**
  51837. * Normal map used in the model.
  51838. */
  51839. normalTexture: BaseTexture;
  51840. /**
  51841. * Emissivie color used to self-illuminate the model.
  51842. */
  51843. emissiveColor: Color3;
  51844. /**
  51845. * Emissivie texture used to self-illuminate the model.
  51846. */
  51847. emissiveTexture: BaseTexture;
  51848. /**
  51849. * Occlusion Channel Strenght.
  51850. */
  51851. occlusionStrength: number;
  51852. /**
  51853. * Occlusion Texture of the material (adding extra occlusion effects).
  51854. */
  51855. occlusionTexture: BaseTexture;
  51856. /**
  51857. * Defines the alpha limits in alpha test mode.
  51858. */
  51859. alphaCutOff: number;
  51860. /**
  51861. * Gets the current double sided mode.
  51862. */
  51863. /**
  51864. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51865. */
  51866. doubleSided: boolean;
  51867. /**
  51868. * Stores the pre-calculated light information of a mesh in a texture.
  51869. */
  51870. lightmapTexture: BaseTexture;
  51871. /**
  51872. * If true, the light map contains occlusion information instead of lighting info.
  51873. */
  51874. useLightmapAsShadowmap: boolean;
  51875. /**
  51876. * Instantiates a new PBRMaterial instance.
  51877. *
  51878. * @param name The material name
  51879. * @param scene The scene the material will be use in.
  51880. */
  51881. constructor(name: string, scene: Scene);
  51882. getClassName(): string;
  51883. }
  51884. }
  51885. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  51886. import { Scene } from "babylonjs/scene";
  51887. import { Color3 } from "babylonjs/Maths/math";
  51888. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51889. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  51890. /**
  51891. * The PBR material of BJS following the metal roughness convention.
  51892. *
  51893. * This fits to the PBR convention in the GLTF definition:
  51894. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  51895. */
  51896. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  51897. /**
  51898. * The base color has two different interpretations depending on the value of metalness.
  51899. * When the material is a metal, the base color is the specific measured reflectance value
  51900. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  51901. * of the material.
  51902. */
  51903. baseColor: Color3;
  51904. /**
  51905. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  51906. * well as opacity information in the alpha channel.
  51907. */
  51908. baseTexture: BaseTexture;
  51909. /**
  51910. * Specifies the metallic scalar value of the material.
  51911. * Can also be used to scale the metalness values of the metallic texture.
  51912. */
  51913. metallic: number;
  51914. /**
  51915. * Specifies the roughness scalar value of the material.
  51916. * Can also be used to scale the roughness values of the metallic texture.
  51917. */
  51918. roughness: number;
  51919. /**
  51920. * Texture containing both the metallic value in the B channel and the
  51921. * roughness value in the G channel to keep better precision.
  51922. */
  51923. metallicRoughnessTexture: BaseTexture;
  51924. /**
  51925. * Instantiates a new PBRMetalRoughnessMaterial instance.
  51926. *
  51927. * @param name The material name
  51928. * @param scene The scene the material will be use in.
  51929. */
  51930. constructor(name: string, scene: Scene);
  51931. /**
  51932. * Return the currrent class name of the material.
  51933. */
  51934. getClassName(): string;
  51935. /**
  51936. * Makes a duplicate of the current material.
  51937. * @param name - name to use for the new material.
  51938. */
  51939. clone(name: string): PBRMetallicRoughnessMaterial;
  51940. /**
  51941. * Serialize the material to a parsable JSON object.
  51942. */
  51943. serialize(): any;
  51944. /**
  51945. * Parses a JSON object correponding to the serialize function.
  51946. */
  51947. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  51948. }
  51949. }
  51950. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  51951. import { Scene } from "babylonjs/scene";
  51952. import { Color3 } from "babylonjs/Maths/math";
  51953. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51954. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  51955. /**
  51956. * The PBR material of BJS following the specular glossiness convention.
  51957. *
  51958. * This fits to the PBR convention in the GLTF definition:
  51959. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  51960. */
  51961. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  51962. /**
  51963. * Specifies the diffuse color of the material.
  51964. */
  51965. diffuseColor: Color3;
  51966. /**
  51967. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  51968. * channel.
  51969. */
  51970. diffuseTexture: BaseTexture;
  51971. /**
  51972. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  51973. */
  51974. specularColor: Color3;
  51975. /**
  51976. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  51977. */
  51978. glossiness: number;
  51979. /**
  51980. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  51981. */
  51982. specularGlossinessTexture: BaseTexture;
  51983. /**
  51984. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  51985. *
  51986. * @param name The material name
  51987. * @param scene The scene the material will be use in.
  51988. */
  51989. constructor(name: string, scene: Scene);
  51990. /**
  51991. * Return the currrent class name of the material.
  51992. */
  51993. getClassName(): string;
  51994. /**
  51995. * Makes a duplicate of the current material.
  51996. * @param name - name to use for the new material.
  51997. */
  51998. clone(name: string): PBRSpecularGlossinessMaterial;
  51999. /**
  52000. * Serialize the material to a parsable JSON object.
  52001. */
  52002. serialize(): any;
  52003. /**
  52004. * Parses a JSON object correponding to the serialize function.
  52005. */
  52006. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  52007. }
  52008. }
  52009. declare module "babylonjs/Materials/PBR/index" {
  52010. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  52011. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  52012. export * from "babylonjs/Materials/PBR/pbrMaterial";
  52013. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  52014. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  52015. }
  52016. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  52017. import { Nullable } from "babylonjs/types";
  52018. import { Scene } from "babylonjs/scene";
  52019. import { Matrix } from "babylonjs/Maths/math";
  52020. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52021. /**
  52022. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  52023. * It can help converting any input color in a desired output one. This can then be used to create effects
  52024. * from sepia, black and white to sixties or futuristic rendering...
  52025. *
  52026. * The only supported format is currently 3dl.
  52027. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  52028. */
  52029. export class ColorGradingTexture extends BaseTexture {
  52030. /**
  52031. * The current texture matrix. (will always be identity in color grading texture)
  52032. */
  52033. private _textureMatrix;
  52034. /**
  52035. * The texture URL.
  52036. */
  52037. url: string;
  52038. /**
  52039. * Empty line regex stored for GC.
  52040. */
  52041. private static _noneEmptyLineRegex;
  52042. private _engine;
  52043. /**
  52044. * Instantiates a ColorGradingTexture from the following parameters.
  52045. *
  52046. * @param url The location of the color gradind data (currently only supporting 3dl)
  52047. * @param scene The scene the texture will be used in
  52048. */
  52049. constructor(url: string, scene: Scene);
  52050. /**
  52051. * Returns the texture matrix used in most of the material.
  52052. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  52053. */
  52054. getTextureMatrix(): Matrix;
  52055. /**
  52056. * Occurs when the file being loaded is a .3dl LUT file.
  52057. */
  52058. private load3dlTexture;
  52059. /**
  52060. * Starts the loading process of the texture.
  52061. */
  52062. private loadTexture;
  52063. /**
  52064. * Clones the color gradind texture.
  52065. */
  52066. clone(): ColorGradingTexture;
  52067. /**
  52068. * Called during delayed load for textures.
  52069. */
  52070. delayLoad(): void;
  52071. /**
  52072. * Parses a color grading texture serialized by Babylon.
  52073. * @param parsedTexture The texture information being parsedTexture
  52074. * @param scene The scene to load the texture in
  52075. * @param rootUrl The root url of the data assets to load
  52076. * @return A color gradind texture
  52077. */
  52078. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  52079. /**
  52080. * Serializes the LUT texture to json format.
  52081. */
  52082. serialize(): any;
  52083. }
  52084. }
  52085. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  52086. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52087. import { Scene } from "babylonjs/scene";
  52088. import { Nullable } from "babylonjs/types";
  52089. import "babylonjs/Engines/Extensions/engine.rawTexture";
  52090. /**
  52091. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  52092. */
  52093. export class EquiRectangularCubeTexture extends BaseTexture {
  52094. /** The six faces of the cube. */
  52095. private static _FacesMapping;
  52096. private _noMipmap;
  52097. private _onLoad;
  52098. private _onError;
  52099. /** The size of the cubemap. */
  52100. private _size;
  52101. /** The buffer of the image. */
  52102. private _buffer;
  52103. /** The width of the input image. */
  52104. private _width;
  52105. /** The height of the input image. */
  52106. private _height;
  52107. /** The URL to the image. */
  52108. url: string;
  52109. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  52110. coordinatesMode: number;
  52111. /**
  52112. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  52113. * @param url The location of the image
  52114. * @param scene The scene the texture will be used in
  52115. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  52116. * @param noMipmap Forces to not generate the mipmap if true
  52117. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  52118. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  52119. * @param onLoad — defines a callback called when texture is loaded
  52120. * @param onError — defines a callback called if there is an error
  52121. */
  52122. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  52123. /**
  52124. * Load the image data, by putting the image on a canvas and extracting its buffer.
  52125. */
  52126. private loadImage;
  52127. /**
  52128. * Convert the image buffer into a cubemap and create a CubeTexture.
  52129. */
  52130. private loadTexture;
  52131. /**
  52132. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  52133. * @param buffer The ArrayBuffer that should be converted.
  52134. * @returns The buffer as Float32Array.
  52135. */
  52136. private getFloat32ArrayFromArrayBuffer;
  52137. /**
  52138. * Get the current class name of the texture useful for serialization or dynamic coding.
  52139. * @returns "EquiRectangularCubeTexture"
  52140. */
  52141. getClassName(): string;
  52142. /**
  52143. * Create a clone of the current EquiRectangularCubeTexture and return it.
  52144. * @returns A clone of the current EquiRectangularCubeTexture.
  52145. */
  52146. clone(): EquiRectangularCubeTexture;
  52147. }
  52148. }
  52149. declare module "babylonjs/Misc/tga" {
  52150. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52151. /**
  52152. * Based on jsTGALoader - Javascript loader for TGA file
  52153. * By Vincent Thibault
  52154. * @see http://blog.robrowser.com/javascript-tga-loader.html
  52155. */
  52156. export class TGATools {
  52157. private static _TYPE_INDEXED;
  52158. private static _TYPE_RGB;
  52159. private static _TYPE_GREY;
  52160. private static _TYPE_RLE_INDEXED;
  52161. private static _TYPE_RLE_RGB;
  52162. private static _TYPE_RLE_GREY;
  52163. private static _ORIGIN_MASK;
  52164. private static _ORIGIN_SHIFT;
  52165. private static _ORIGIN_BL;
  52166. private static _ORIGIN_BR;
  52167. private static _ORIGIN_UL;
  52168. private static _ORIGIN_UR;
  52169. /**
  52170. * Gets the header of a TGA file
  52171. * @param data defines the TGA data
  52172. * @returns the header
  52173. */
  52174. static GetTGAHeader(data: Uint8Array): any;
  52175. /**
  52176. * Uploads TGA content to a Babylon Texture
  52177. * @hidden
  52178. */
  52179. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  52180. /** @hidden */
  52181. 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;
  52182. /** @hidden */
  52183. 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;
  52184. /** @hidden */
  52185. 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;
  52186. /** @hidden */
  52187. 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;
  52188. /** @hidden */
  52189. 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;
  52190. /** @hidden */
  52191. 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;
  52192. }
  52193. }
  52194. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  52195. import { Nullable } from "babylonjs/types";
  52196. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52197. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  52198. /**
  52199. * Implementation of the TGA Texture Loader.
  52200. * @hidden
  52201. */
  52202. export class _TGATextureLoader implements IInternalTextureLoader {
  52203. /**
  52204. * Defines wether the loader supports cascade loading the different faces.
  52205. */
  52206. readonly supportCascades: boolean;
  52207. /**
  52208. * This returns if the loader support the current file information.
  52209. * @param extension defines the file extension of the file being loaded
  52210. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52211. * @param fallback defines the fallback internal texture if any
  52212. * @param isBase64 defines whether the texture is encoded as a base64
  52213. * @param isBuffer defines whether the texture data are stored as a buffer
  52214. * @returns true if the loader can load the specified file
  52215. */
  52216. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52217. /**
  52218. * Transform the url before loading if required.
  52219. * @param rootUrl the url of the texture
  52220. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52221. * @returns the transformed texture
  52222. */
  52223. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52224. /**
  52225. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52226. * @param rootUrl the url of the texture
  52227. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52228. * @returns the fallback texture
  52229. */
  52230. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52231. /**
  52232. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52233. * @param data contains the texture data
  52234. * @param texture defines the BabylonJS internal texture
  52235. * @param createPolynomials will be true if polynomials have been requested
  52236. * @param onLoad defines the callback to trigger once the texture is ready
  52237. * @param onError defines the callback to trigger in case of error
  52238. */
  52239. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52240. /**
  52241. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52242. * @param data contains the texture data
  52243. * @param texture defines the BabylonJS internal texture
  52244. * @param callback defines the method to call once ready to upload
  52245. */
  52246. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52247. }
  52248. }
  52249. declare module "babylonjs/Misc/basis" {
  52250. import { Nullable } from "babylonjs/types";
  52251. import { Engine } from "babylonjs/Engines/engine";
  52252. /**
  52253. * Info about the .basis files
  52254. */
  52255. class BasisFileInfo {
  52256. /**
  52257. * If the file has alpha
  52258. */
  52259. hasAlpha: boolean;
  52260. /**
  52261. * Width of the image
  52262. */
  52263. width: number;
  52264. /**
  52265. * Height of the image
  52266. */
  52267. height: number;
  52268. /**
  52269. * Aligned width used when falling back to Rgb565 ((width + 3) & ~3)
  52270. */
  52271. alignedWidth: number;
  52272. /**
  52273. * Aligned height used when falling back to Rgb565 ((height + 3) & ~3)
  52274. */
  52275. alignedHeight: number;
  52276. }
  52277. /**
  52278. * Used to load .Basis files
  52279. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  52280. */
  52281. export class BasisTools {
  52282. private static _IgnoreSupportedFormats;
  52283. private static _LoadScriptPromise;
  52284. private static _FallbackURL;
  52285. private static _BASIS_FORMAT;
  52286. /**
  52287. * Basis module can be aquired from https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  52288. * This should be set prior to loading a .basis texture
  52289. */
  52290. static BasisModule: Nullable<any>;
  52291. /**
  52292. * Verifies that the BasisModule has been populated and falls back to loading from the web if not availible
  52293. * @returns promise which will resolve if the basis module was loaded
  52294. */
  52295. static VerifyBasisModuleAsync(): any;
  52296. /**
  52297. * Verifies that the basis module has been populated and creates a bsis file from the image data
  52298. * @param data array buffer of the .basis file
  52299. * @returns the Basis file
  52300. */
  52301. static LoadBasisFile(data: ArrayBuffer): any;
  52302. /**
  52303. * Detects the supported transcode format for the file
  52304. * @param engine Babylon engine
  52305. * @param fileInfo info about the file
  52306. * @returns the chosed format or null if none are supported
  52307. */
  52308. static GetSupportedTranscodeFormat(engine: Engine, fileInfo: BasisFileInfo): Nullable<number>;
  52309. /**
  52310. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  52311. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  52312. * @returns internal format corresponding to the Basis format
  52313. */
  52314. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  52315. /**
  52316. * Retreives information about the basis file eg. dimensions
  52317. * @param basisFile the basis file to get the info from
  52318. * @returns information about the basis file
  52319. */
  52320. static GetFileInfo(basisFile: any): BasisFileInfo;
  52321. /**
  52322. * Transcodes the basis file to the requested format to be transferred to the gpu
  52323. * @param format fromat to be transferred to
  52324. * @param fileInfo information about the loaded file
  52325. * @param loadedFile the loaded basis file
  52326. * @returns the resulting pixels and if the transcode fell back to using Rgb565
  52327. */
  52328. static TranscodeFile(format: Nullable<number>, fileInfo: BasisFileInfo, loadedFile: any): {
  52329. fallbackToRgb565: boolean;
  52330. pixels: Uint8Array;
  52331. };
  52332. /**
  52333. * From https://github.com/BinomialLLC/basis_universal/blob/master/webgl/texture/dxt-to-rgb565.js
  52334. * An unoptimized version of dxtToRgb565. Also, the floating
  52335. * point math used to compute the colors actually results in
  52336. * slightly different colors compared to hardware DXT decoders.
  52337. * @param src dxt src pixels
  52338. * @param srcByteOffset offset for the start of src
  52339. * @param width aligned width of the image
  52340. * @param height aligned height of the image
  52341. * @return the converted pixels
  52342. */
  52343. static ConvertDxtToRgb565(src: Uint16Array, srcByteOffset: number, width: number, height: number): Uint16Array;
  52344. }
  52345. }
  52346. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  52347. import { Nullable } from "babylonjs/types";
  52348. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52349. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  52350. /**
  52351. * Loader for .basis file format
  52352. */
  52353. export class _BasisTextureLoader implements IInternalTextureLoader {
  52354. /**
  52355. * Defines whether the loader supports cascade loading the different faces.
  52356. */
  52357. readonly supportCascades: boolean;
  52358. /**
  52359. * This returns if the loader support the current file information.
  52360. * @param extension defines the file extension of the file being loaded
  52361. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52362. * @param fallback defines the fallback internal texture if any
  52363. * @param isBase64 defines whether the texture is encoded as a base64
  52364. * @param isBuffer defines whether the texture data are stored as a buffer
  52365. * @returns true if the loader can load the specified file
  52366. */
  52367. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52368. /**
  52369. * Transform the url before loading if required.
  52370. * @param rootUrl the url of the texture
  52371. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52372. * @returns the transformed texture
  52373. */
  52374. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52375. /**
  52376. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52377. * @param rootUrl the url of the texture
  52378. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52379. * @returns the fallback texture
  52380. */
  52381. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52382. /**
  52383. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  52384. * @param data contains the texture data
  52385. * @param texture defines the BabylonJS internal texture
  52386. * @param createPolynomials will be true if polynomials have been requested
  52387. * @param onLoad defines the callback to trigger once the texture is ready
  52388. * @param onError defines the callback to trigger in case of error
  52389. */
  52390. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52391. /**
  52392. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52393. * @param data contains the texture data
  52394. * @param texture defines the BabylonJS internal texture
  52395. * @param callback defines the method to call once ready to upload
  52396. */
  52397. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52398. }
  52399. }
  52400. declare module "babylonjs/Materials/Textures/Loaders/index" {
  52401. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  52402. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  52403. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  52404. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  52405. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  52406. }
  52407. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  52408. import { Scene } from "babylonjs/scene";
  52409. import { Texture } from "babylonjs/Materials/Textures/texture";
  52410. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  52411. /**
  52412. * 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.
  52413. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  52414. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  52415. */
  52416. export class CustomProceduralTexture extends ProceduralTexture {
  52417. private _animate;
  52418. private _time;
  52419. private _config;
  52420. private _texturePath;
  52421. /**
  52422. * Instantiates a new Custom Procedural Texture.
  52423. * 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.
  52424. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  52425. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  52426. * @param name Define the name of the texture
  52427. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  52428. * @param size Define the size of the texture to create
  52429. * @param scene Define the scene the texture belongs to
  52430. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  52431. * @param generateMipMaps Define if the texture should creates mip maps or not
  52432. */
  52433. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  52434. private _loadJson;
  52435. /**
  52436. * Is the texture ready to be used ? (rendered at least once)
  52437. * @returns true if ready, otherwise, false.
  52438. */
  52439. isReady(): boolean;
  52440. /**
  52441. * Render the texture to its associated render target.
  52442. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  52443. */
  52444. render(useCameraPostProcess?: boolean): void;
  52445. /**
  52446. * Update the list of dependant textures samplers in the shader.
  52447. */
  52448. updateTextures(): void;
  52449. /**
  52450. * Update the uniform values of the procedural texture in the shader.
  52451. */
  52452. updateShaderUniforms(): void;
  52453. /**
  52454. * Define if the texture animates or not.
  52455. */
  52456. animate: boolean;
  52457. }
  52458. }
  52459. declare module "babylonjs/Shaders/noise.fragment" {
  52460. /** @hidden */
  52461. export var noisePixelShader: {
  52462. name: string;
  52463. shader: string;
  52464. };
  52465. }
  52466. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  52467. import { Nullable } from "babylonjs/types";
  52468. import { Scene } from "babylonjs/scene";
  52469. import { Texture } from "babylonjs/Materials/Textures/texture";
  52470. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  52471. import "babylonjs/Shaders/noise.fragment";
  52472. /**
  52473. * Class used to generate noise procedural textures
  52474. */
  52475. export class NoiseProceduralTexture extends ProceduralTexture {
  52476. private _time;
  52477. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  52478. brightness: number;
  52479. /** Defines the number of octaves to process */
  52480. octaves: number;
  52481. /** Defines the level of persistence (0.8 by default) */
  52482. persistence: number;
  52483. /** Gets or sets animation speed factor (default is 1) */
  52484. animationSpeedFactor: number;
  52485. /**
  52486. * Creates a new NoiseProceduralTexture
  52487. * @param name defines the name fo the texture
  52488. * @param size defines the size of the texture (default is 256)
  52489. * @param scene defines the hosting scene
  52490. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  52491. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  52492. */
  52493. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  52494. private _updateShaderUniforms;
  52495. protected _getDefines(): string;
  52496. /** Generate the current state of the procedural texture */
  52497. render(useCameraPostProcess?: boolean): void;
  52498. /**
  52499. * Serializes this noise procedural texture
  52500. * @returns a serialized noise procedural texture object
  52501. */
  52502. serialize(): any;
  52503. /**
  52504. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  52505. * @param parsedTexture defines parsed texture data
  52506. * @param scene defines the current scene
  52507. * @param rootUrl defines the root URL containing noise procedural texture information
  52508. * @returns a parsed NoiseProceduralTexture
  52509. */
  52510. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  52511. }
  52512. }
  52513. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  52514. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  52515. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  52516. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  52517. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  52518. }
  52519. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  52520. import { Nullable } from "babylonjs/types";
  52521. import { Scene } from "babylonjs/scene";
  52522. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  52523. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52524. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  52525. import "babylonjs/Engines/Extensions/engine.rawTexture";
  52526. /**
  52527. * Raw cube texture where the raw buffers are passed in
  52528. */
  52529. export class RawCubeTexture extends CubeTexture {
  52530. /**
  52531. * Creates a cube texture where the raw buffers are passed in.
  52532. * @param scene defines the scene the texture is attached to
  52533. * @param data defines the array of data to use to create each face
  52534. * @param size defines the size of the textures
  52535. * @param format defines the format of the data
  52536. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  52537. * @param generateMipMaps defines if the engine should generate the mip levels
  52538. * @param invertY defines if data must be stored with Y axis inverted
  52539. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  52540. * @param compression defines the compression used (null by default)
  52541. */
  52542. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  52543. /**
  52544. * Updates the raw cube texture.
  52545. * @param data defines the data to store
  52546. * @param format defines the data format
  52547. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  52548. * @param invertY defines if data must be stored with Y axis inverted
  52549. * @param compression defines the compression used (null by default)
  52550. * @param level defines which level of the texture to update
  52551. */
  52552. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  52553. /**
  52554. * Updates a raw cube texture with RGBD encoded data.
  52555. * @param data defines the array of data [mipmap][face] to use to create each face
  52556. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  52557. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  52558. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  52559. * @returns a promsie that resolves when the operation is complete
  52560. */
  52561. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  52562. /**
  52563. * Clones the raw cube texture.
  52564. * @return a new cube texture
  52565. */
  52566. clone(): CubeTexture;
  52567. /** @hidden */
  52568. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  52569. }
  52570. }
  52571. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  52572. import { Scene } from "babylonjs/scene";
  52573. import { Texture } from "babylonjs/Materials/Textures/texture";
  52574. import "babylonjs/Engines/Extensions/engine.rawTexture";
  52575. /**
  52576. * Class used to store 3D textures containing user data
  52577. */
  52578. export class RawTexture3D extends Texture {
  52579. /** Gets or sets the texture format to use */
  52580. format: number;
  52581. private _engine;
  52582. /**
  52583. * Create a new RawTexture3D
  52584. * @param data defines the data of the texture
  52585. * @param width defines the width of the texture
  52586. * @param height defines the height of the texture
  52587. * @param depth defines the depth of the texture
  52588. * @param format defines the texture format to use
  52589. * @param scene defines the hosting scene
  52590. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  52591. * @param invertY defines if texture must be stored with Y axis inverted
  52592. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  52593. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  52594. */
  52595. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  52596. /** Gets or sets the texture format to use */
  52597. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  52598. /**
  52599. * Update the texture with new data
  52600. * @param data defines the data to store in the texture
  52601. */
  52602. update(data: ArrayBufferView): void;
  52603. }
  52604. }
  52605. declare module "babylonjs/Materials/Textures/refractionTexture" {
  52606. import { Scene } from "babylonjs/scene";
  52607. import { Plane } from "babylonjs/Maths/math";
  52608. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52609. /**
  52610. * Creates a refraction texture used by refraction channel of the standard material.
  52611. * It is like a mirror but to see through a material.
  52612. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52613. */
  52614. export class RefractionTexture extends RenderTargetTexture {
  52615. /**
  52616. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  52617. * 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.
  52618. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52619. */
  52620. refractionPlane: Plane;
  52621. /**
  52622. * Define how deep under the surface we should see.
  52623. */
  52624. depth: number;
  52625. /**
  52626. * Creates a refraction texture used by refraction channel of the standard material.
  52627. * It is like a mirror but to see through a material.
  52628. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52629. * @param name Define the texture name
  52630. * @param size Define the size of the underlying texture
  52631. * @param scene Define the scene the refraction belongs to
  52632. * @param generateMipMaps Define if we need to generate mips level for the refraction
  52633. */
  52634. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  52635. /**
  52636. * Clone the refraction texture.
  52637. * @returns the cloned texture
  52638. */
  52639. clone(): RefractionTexture;
  52640. /**
  52641. * Serialize the texture to a JSON representation you could use in Parse later on
  52642. * @returns the serialized JSON representation
  52643. */
  52644. serialize(): any;
  52645. }
  52646. }
  52647. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  52648. import { Nullable } from "babylonjs/types";
  52649. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52650. import { Matrix } from "babylonjs/Maths/math";
  52651. import { Engine } from "babylonjs/Engines/engine";
  52652. import { Scene } from "babylonjs/scene";
  52653. /**
  52654. * Defines the options related to the creation of an HtmlElementTexture
  52655. */
  52656. export interface IHtmlElementTextureOptions {
  52657. /**
  52658. * Defines wether mip maps should be created or not.
  52659. */
  52660. generateMipMaps?: boolean;
  52661. /**
  52662. * Defines the sampling mode of the texture.
  52663. */
  52664. samplingMode?: number;
  52665. /**
  52666. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  52667. */
  52668. engine: Nullable<Engine>;
  52669. /**
  52670. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  52671. */
  52672. scene: Nullable<Scene>;
  52673. }
  52674. /**
  52675. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  52676. * To be as efficient as possible depending on your constraints nothing aside the first upload
  52677. * is automatically managed.
  52678. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  52679. * in your application.
  52680. *
  52681. * As the update is not automatic, you need to call them manually.
  52682. */
  52683. export class HtmlElementTexture extends BaseTexture {
  52684. /**
  52685. * The texture URL.
  52686. */
  52687. element: HTMLVideoElement | HTMLCanvasElement;
  52688. private static readonly DefaultOptions;
  52689. private _textureMatrix;
  52690. private _engine;
  52691. private _isVideo;
  52692. private _generateMipMaps;
  52693. private _samplingMode;
  52694. /**
  52695. * Instantiates a HtmlElementTexture from the following parameters.
  52696. *
  52697. * @param name Defines the name of the texture
  52698. * @param element Defines the video or canvas the texture is filled with
  52699. * @param options Defines the other none mandatory texture creation options
  52700. */
  52701. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  52702. private _createInternalTexture;
  52703. /**
  52704. * Returns the texture matrix used in most of the material.
  52705. */
  52706. getTextureMatrix(): Matrix;
  52707. /**
  52708. * Updates the content of the texture.
  52709. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  52710. */
  52711. update(invertY?: Nullable<boolean>): void;
  52712. }
  52713. }
  52714. declare module "babylonjs/Materials/Textures/index" {
  52715. export * from "babylonjs/Materials/Textures/baseTexture";
  52716. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  52717. export * from "babylonjs/Materials/Textures/cubeTexture";
  52718. export * from "babylonjs/Materials/Textures/dynamicTexture";
  52719. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  52720. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  52721. export * from "babylonjs/Materials/Textures/internalTexture";
  52722. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  52723. export * from "babylonjs/Materials/Textures/Loaders/index";
  52724. export * from "babylonjs/Materials/Textures/mirrorTexture";
  52725. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  52726. export * from "babylonjs/Materials/Textures/Procedurals/index";
  52727. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  52728. export * from "babylonjs/Materials/Textures/rawTexture";
  52729. export * from "babylonjs/Materials/Textures/rawTexture3D";
  52730. export * from "babylonjs/Materials/Textures/refractionTexture";
  52731. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  52732. export * from "babylonjs/Materials/Textures/texture";
  52733. export * from "babylonjs/Materials/Textures/videoTexture";
  52734. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  52735. }
  52736. declare module "babylonjs/Materials/Node/nodeMaterialBlockTargets" {
  52737. /**
  52738. * Enum used to define the target of a block
  52739. */
  52740. export enum NodeMaterialBlockTargets {
  52741. /** Vertex shader */
  52742. Vertex = 1,
  52743. /** Fragment shader */
  52744. Fragment = 2,
  52745. /** Vertex and Fragment */
  52746. VertexAndFragment = 3
  52747. }
  52748. }
  52749. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes" {
  52750. /**
  52751. * Defines the kind of connection point for node based material
  52752. */
  52753. export enum NodeMaterialBlockConnectionPointTypes {
  52754. /** Float */
  52755. Float = 1,
  52756. /** Int */
  52757. Int = 2,
  52758. /** Vector2 */
  52759. Vector2 = 4,
  52760. /** Vector3 */
  52761. Vector3 = 8,
  52762. /** Vector4 */
  52763. Vector4 = 16,
  52764. /** Color3 */
  52765. Color3 = 32,
  52766. /** Color4 */
  52767. Color4 = 64,
  52768. /** Matrix */
  52769. Matrix = 128,
  52770. /** Texture */
  52771. Texture = 256,
  52772. /** Texture3D */
  52773. Texture3D = 512,
  52774. /** Vector3 or Color3 */
  52775. Vector3OrColor3 = 40,
  52776. /** Vector3 or Vector4 */
  52777. Vector3OrVector4 = 24,
  52778. /** Vector4 or Color4 */
  52779. Vector4OrColor4 = 80,
  52780. /** Color3 or Color4 */
  52781. Color3OrColor4 = 96,
  52782. /** Vector3 or Color3 */
  52783. Vector3OrColor3OrVector4OrColor4 = 120,
  52784. /** Detect type based on connection */
  52785. AutoDetect = 1024,
  52786. /** Output type that will be defined by input type */
  52787. BasedOnInput = 2048
  52788. }
  52789. }
  52790. declare module "babylonjs/Materials/Node/nodeMaterialWellKnownValues" {
  52791. /**
  52792. * Enum used to define well known values e.g. values automatically provided by the system
  52793. */
  52794. export enum NodeMaterialWellKnownValues {
  52795. /** World */
  52796. World = 1,
  52797. /** View */
  52798. View = 2,
  52799. /** Projection */
  52800. Projection = 3,
  52801. /** ViewProjection */
  52802. ViewProjection = 4,
  52803. /** WorldView */
  52804. WorldView = 5,
  52805. /** WorldViewProjection */
  52806. WorldViewProjection = 6,
  52807. /** Will be filled by the block itself */
  52808. Automatic = 7
  52809. }
  52810. }
  52811. declare module "babylonjs/Materials/Node/NodeMaterialBlockConnectionPointMode" {
  52812. /**
  52813. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  52814. */
  52815. export enum NodeMaterialBlockConnectionPointMode {
  52816. /** Value is an uniform */
  52817. Uniform = 0,
  52818. /** Value is a mesh attribute */
  52819. Attribute = 1,
  52820. /** Value is a varying between vertex and fragment shaders */
  52821. Varying = 2,
  52822. /** Mode is undefined */
  52823. Undefined = 3
  52824. }
  52825. }
  52826. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  52827. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  52828. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  52829. /**
  52830. * Class used to store shared data between 2 NodeMaterialBuildState
  52831. */
  52832. export class NodeMaterialBuildStateSharedData {
  52833. /**
  52834. * Gets the list of emitted varyings
  52835. */
  52836. varyings: string[];
  52837. /**
  52838. * Gets the varying declaration string
  52839. */
  52840. varyingDeclaration: string;
  52841. /**
  52842. * Uniform connection points
  52843. */
  52844. uniformConnectionPoints: NodeMaterialConnectionPoint[];
  52845. /**
  52846. * Bindable blocks (Blocks that need to set data to the effect)
  52847. */
  52848. bindableBlocks: NodeMaterialBlock[];
  52849. /**
  52850. * List of blocks that can provide a compilation fallback
  52851. */
  52852. blocksWithFallbacks: NodeMaterialBlock[];
  52853. /**
  52854. * List of blocks that can provide a define update
  52855. */
  52856. blocksWithDefines: NodeMaterialBlock[];
  52857. /**
  52858. * List of blocks that can provide a repeatable content
  52859. */
  52860. repeatableContentBlocks: NodeMaterialBlock[];
  52861. /**
  52862. * List of blocks that can block the isReady function for the material
  52863. */
  52864. blockingBlocks: NodeMaterialBlock[];
  52865. /**
  52866. * Build Id used to avoid multiple recompilations
  52867. */
  52868. buildId: number;
  52869. /** List of emitted variables */
  52870. variableNames: {
  52871. [key: string]: number;
  52872. };
  52873. /** List of emitted defines */
  52874. defineNames: {
  52875. [key: string]: number;
  52876. };
  52877. /** Should emit comments? */
  52878. emitComments: boolean;
  52879. /** Emit build activity */
  52880. verbose: boolean;
  52881. /**
  52882. * Gets the compilation hints emitted at compilation time
  52883. */
  52884. hints: {
  52885. needWorldViewMatrix: boolean;
  52886. needWorldViewProjectionMatrix: boolean;
  52887. needAlphaBlending: boolean;
  52888. needAlphaTesting: boolean;
  52889. };
  52890. /**
  52891. * List of compilation checks
  52892. */
  52893. checks: {
  52894. emitVertex: boolean;
  52895. emitFragment: boolean;
  52896. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  52897. };
  52898. /** Creates a new shared data */
  52899. constructor();
  52900. /**
  52901. * Emits console errors and exceptions if there is a failing check
  52902. */
  52903. emitErrors(): void;
  52904. }
  52905. }
  52906. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  52907. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  52908. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  52909. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  52910. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  52911. /**
  52912. * Class used to store node based material build state
  52913. */
  52914. export class NodeMaterialBuildState {
  52915. /**
  52916. * Gets the list of emitted attributes
  52917. */
  52918. attributes: string[];
  52919. /**
  52920. * Gets the list of emitted uniforms
  52921. */
  52922. uniforms: string[];
  52923. /**
  52924. * Gets the list of emitted samplers
  52925. */
  52926. samplers: string[];
  52927. /**
  52928. * Gets the list of emitted functions
  52929. */
  52930. functions: {
  52931. [key: string]: string;
  52932. };
  52933. /**
  52934. * Gets the target of the compilation state
  52935. */
  52936. target: NodeMaterialBlockTargets;
  52937. /**
  52938. * Shared data between multiple NodeMaterialBuildState instances
  52939. */
  52940. sharedData: NodeMaterialBuildStateSharedData;
  52941. /** @hidden */
  52942. _vertexState: NodeMaterialBuildState;
  52943. private _attributeDeclaration;
  52944. private _uniformDeclaration;
  52945. private _samplerDeclaration;
  52946. private _varyingTransfer;
  52947. private _repeatableContentAnchorIndex;
  52948. /** @hidden */
  52949. _builtCompilationString: string;
  52950. /**
  52951. * Gets the emitted compilation strings
  52952. */
  52953. compilationString: string;
  52954. /**
  52955. * Finalize the compilation strings
  52956. * @param state defines the current compilation state
  52957. */
  52958. finalize(state: NodeMaterialBuildState): void;
  52959. /** @hidden */
  52960. readonly _repeatableContentAnchor: string;
  52961. /** @hidden */
  52962. _getFreeVariableName(prefix: string): string;
  52963. /** @hidden */
  52964. _getFreeDefineName(prefix: string): string;
  52965. /** @hidden */
  52966. _excludeVariableName(name: string): void;
  52967. /** @hidden */
  52968. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  52969. /** @hidden */
  52970. _emitFunction(name: string, code: string, comments: string): void;
  52971. /** @hidden */
  52972. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  52973. replaceStrings?: {
  52974. search: RegExp;
  52975. replace: string;
  52976. }[];
  52977. }): string;
  52978. /** @hidden */
  52979. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  52980. repeatKey?: string;
  52981. removeAttributes?: boolean;
  52982. removeUniforms?: boolean;
  52983. removeVaryings?: boolean;
  52984. removeIfDef?: boolean;
  52985. replaceStrings?: {
  52986. search: RegExp;
  52987. replace: string;
  52988. }[];
  52989. }): void;
  52990. /** @hidden */
  52991. _emitVaryings(point: NodeMaterialConnectionPoint, define?: string, force?: boolean, fromFragment?: boolean, replacementName?: string): void;
  52992. private _emitDefine;
  52993. /** @hidden */
  52994. _emitUniformOrAttributes(point: NodeMaterialConnectionPoint, define?: string): void;
  52995. }
  52996. }
  52997. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  52998. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  52999. /**
  53000. * Root class for all node material optimizers
  53001. */
  53002. export class NodeMaterialOptimizer {
  53003. /**
  53004. * Function used to optimize a NodeMaterial graph
  53005. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  53006. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  53007. */
  53008. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  53009. }
  53010. }
  53011. declare module "babylonjs/Materials/Node/Blocks/vector4TransformBlock" {
  53012. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53013. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53014. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53015. /**
  53016. * Block used to transform a vector4 with a matrix
  53017. */
  53018. export class Vector4TransformBlock extends NodeMaterialBlock {
  53019. /**
  53020. * Defines the value to use to complement Vector3 to transform it to a Vector4
  53021. */
  53022. complementW: number;
  53023. /**
  53024. * Creates a new Vector4TransformBlock
  53025. * @param name defines the block name
  53026. */
  53027. constructor(name: string);
  53028. /**
  53029. * Gets the current class name
  53030. * @returns the class name
  53031. */
  53032. getClassName(): string;
  53033. /**
  53034. * Gets the vector input
  53035. */
  53036. readonly vector: NodeMaterialConnectionPoint;
  53037. /**
  53038. * Gets the matrix transform input
  53039. */
  53040. readonly transform: NodeMaterialConnectionPoint;
  53041. protected _buildBlock(state: NodeMaterialBuildState): this;
  53042. }
  53043. }
  53044. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  53045. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53046. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53047. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53048. /**
  53049. * Block used to output the vertex position
  53050. */
  53051. export class VertexOutputBlock extends NodeMaterialBlock {
  53052. /**
  53053. * Creates a new VertexOutputBlock
  53054. * @param name defines the block name
  53055. */
  53056. constructor(name: string);
  53057. /**
  53058. * Gets the current class name
  53059. * @returns the class name
  53060. */
  53061. getClassName(): string;
  53062. /**
  53063. * Gets the vector input component
  53064. */
  53065. readonly vector: NodeMaterialConnectionPoint;
  53066. protected _buildBlock(state: NodeMaterialBuildState): this;
  53067. }
  53068. }
  53069. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  53070. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53071. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53072. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53073. /**
  53074. * Block used to output the final color
  53075. */
  53076. export class FragmentOutputBlock extends NodeMaterialBlock {
  53077. /**
  53078. * Gets or sets a boolean indicating if this block will output an alpha value
  53079. */
  53080. alphaBlendingEnabled: boolean;
  53081. /**
  53082. * Create a new FragmentOutputBlock
  53083. * @param name defines the block name
  53084. */
  53085. constructor(name: string);
  53086. /**
  53087. * Gets the current class name
  53088. * @returns the class name
  53089. */
  53090. getClassName(): string;
  53091. /**
  53092. * Gets the color input component
  53093. */
  53094. readonly color: NodeMaterialConnectionPoint;
  53095. protected _buildBlock(state: NodeMaterialBuildState): this;
  53096. }
  53097. }
  53098. declare module "babylonjs/Materials/Node/nodeMaterial" {
  53099. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53100. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  53101. import { Scene } from "babylonjs/scene";
  53102. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53103. import { Matrix } from "babylonjs/Maths/math";
  53104. import { Mesh } from "babylonjs/Meshes/mesh";
  53105. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53106. import { Observable } from "babylonjs/Misc/observable";
  53107. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53108. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  53109. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  53110. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  53111. import { Nullable } from "babylonjs/types";
  53112. /**
  53113. * Interface used to configure the node material editor
  53114. */
  53115. export interface INodeMaterialEditorOptions {
  53116. /** Define the URl to load node editor script */
  53117. editorURL?: string;
  53118. }
  53119. /** @hidden */
  53120. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  53121. /** BONES */
  53122. NUM_BONE_INFLUENCERS: number;
  53123. BonesPerMesh: number;
  53124. BONETEXTURE: boolean;
  53125. /** MORPH TARGETS */
  53126. MORPHTARGETS: boolean;
  53127. MORPHTARGETS_NORMAL: boolean;
  53128. MORPHTARGETS_TANGENT: boolean;
  53129. NUM_MORPH_INFLUENCERS: number;
  53130. /** IMAGE PROCESSING */
  53131. IMAGEPROCESSING: boolean;
  53132. VIGNETTE: boolean;
  53133. VIGNETTEBLENDMODEMULTIPLY: boolean;
  53134. VIGNETTEBLENDMODEOPAQUE: boolean;
  53135. TONEMAPPING: boolean;
  53136. TONEMAPPING_ACES: boolean;
  53137. CONTRAST: boolean;
  53138. EXPOSURE: boolean;
  53139. COLORCURVES: boolean;
  53140. COLORGRADING: boolean;
  53141. COLORGRADING3D: boolean;
  53142. SAMPLER3DGREENDEPTH: boolean;
  53143. SAMPLER3DBGRMAP: boolean;
  53144. IMAGEPROCESSINGPOSTPROCESS: boolean;
  53145. constructor();
  53146. setValue(name: string, value: boolean): void;
  53147. }
  53148. /**
  53149. * Class used to configure NodeMaterial
  53150. */
  53151. export interface INodeMaterialOptions {
  53152. /**
  53153. * Defines if blocks should emit comments
  53154. */
  53155. emitComments: boolean;
  53156. }
  53157. /**
  53158. * Class used to create a node based material built by assembling shader blocks
  53159. */
  53160. export class NodeMaterial extends PushMaterial {
  53161. private _options;
  53162. private _vertexCompilationState;
  53163. private _fragmentCompilationState;
  53164. private _sharedData;
  53165. private _buildId;
  53166. private _buildWasSuccessful;
  53167. private _cachedWorldViewMatrix;
  53168. private _cachedWorldViewProjectionMatrix;
  53169. private _textureConnectionPoints;
  53170. private _optimizers;
  53171. /** Define the URl to load node editor script */
  53172. static EditorURL: string;
  53173. private BJSNODEMATERIALEDITOR;
  53174. /** Get the inspector from bundle or global */
  53175. private _getGlobalNodeMaterialEditor;
  53176. /**
  53177. * Defines the maximum number of lights that can be used in the material
  53178. */
  53179. maxSimultaneousLights: number;
  53180. /**
  53181. * Observable raised when the material is built
  53182. */
  53183. onBuildObservable: Observable<NodeMaterial>;
  53184. /**
  53185. * Gets or sets the root nodes of the material vertex shader
  53186. */
  53187. _vertexOutputNodes: NodeMaterialBlock[];
  53188. /**
  53189. * Gets or sets the root nodes of the material fragment (pixel) shader
  53190. */
  53191. _fragmentOutputNodes: NodeMaterialBlock[];
  53192. /** Gets or sets options to control the node material overall behavior */
  53193. options: INodeMaterialOptions;
  53194. /**
  53195. * Default configuration related to image processing available in the standard Material.
  53196. */
  53197. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  53198. /**
  53199. * Gets the image processing configuration used either in this material.
  53200. */
  53201. /**
  53202. * Sets the Default image processing configuration used either in the this material.
  53203. *
  53204. * If sets to null, the scene one is in use.
  53205. */
  53206. imageProcessingConfiguration: ImageProcessingConfiguration;
  53207. /**
  53208. * Create a new node based material
  53209. * @param name defines the material name
  53210. * @param scene defines the hosting scene
  53211. * @param options defines creation option
  53212. */
  53213. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  53214. /**
  53215. * Gets the current class name of the material e.g. "NodeMaterial"
  53216. * @returns the class name
  53217. */
  53218. getClassName(): string;
  53219. /**
  53220. * Keep track of the image processing observer to allow dispose and replace.
  53221. */
  53222. private _imageProcessingObserver;
  53223. /**
  53224. * Attaches a new image processing configuration to the Standard Material.
  53225. * @param configuration
  53226. */
  53227. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  53228. /**
  53229. * Adds a new optimizer to the list of optimizers
  53230. * @param optimizer defines the optimizers to add
  53231. * @returns the current material
  53232. */
  53233. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  53234. /**
  53235. * Remove an optimizer from the list of optimizers
  53236. * @param optimizer defines the optimizers to remove
  53237. * @returns the current material
  53238. */
  53239. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  53240. /**
  53241. * Add a new block to the list of output nodes
  53242. * @param node defines the node to add
  53243. * @returns the current material
  53244. */
  53245. addOutputNode(node: NodeMaterialBlock): this;
  53246. /**
  53247. * Remove a block from the list of root nodes
  53248. * @param node defines the node to remove
  53249. * @returns the current material
  53250. */
  53251. removeOutputNode(node: NodeMaterialBlock): this;
  53252. private _addVertexOutputNode;
  53253. private _removeVertexOutputNode;
  53254. private _addFragmentOutputNode;
  53255. private _removeFragmentOutputNode;
  53256. /**
  53257. * Specifies if the material will require alpha blending
  53258. * @returns a boolean specifying if alpha blending is needed
  53259. */
  53260. needAlphaBlending(): boolean;
  53261. /**
  53262. * Specifies if this material should be rendered in alpha test mode
  53263. * @returns a boolean specifying if an alpha test is needed.
  53264. */
  53265. needAlphaTesting(): boolean;
  53266. private _initializeBlock;
  53267. private _resetDualBlocks;
  53268. /**
  53269. * Build the material and generates the inner effect
  53270. * @param verbose defines if the build should log activity
  53271. */
  53272. build(verbose?: boolean): void;
  53273. /**
  53274. * Runs an otpimization phase to try to improve the shader code
  53275. */
  53276. optimize(): void;
  53277. private _prepareDefinesForAttributes;
  53278. /**
  53279. * Get if the submesh is ready to be used and all its information available.
  53280. * Child classes can use it to update shaders
  53281. * @param mesh defines the mesh to check
  53282. * @param subMesh defines which submesh to check
  53283. * @param useInstances specifies that instances should be used
  53284. * @returns a boolean indicating that the submesh is ready or not
  53285. */
  53286. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  53287. /**
  53288. * Binds the world matrix to the material
  53289. * @param world defines the world transformation matrix
  53290. */
  53291. bindOnlyWorldMatrix(world: Matrix): void;
  53292. /**
  53293. * Binds the submesh to this material by preparing the effect and shader to draw
  53294. * @param world defines the world transformation matrix
  53295. * @param mesh defines the mesh containing the submesh
  53296. * @param subMesh defines the submesh to bind the material to
  53297. */
  53298. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  53299. /**
  53300. * Gets the active textures from the material
  53301. * @returns an array of textures
  53302. */
  53303. getActiveTextures(): BaseTexture[];
  53304. /**
  53305. * Specifies if the material uses a texture
  53306. * @param texture defines the texture to check against the material
  53307. * @returns a boolean specifying if the material uses the texture
  53308. */
  53309. hasTexture(texture: BaseTexture): boolean;
  53310. /**
  53311. * Disposes the material
  53312. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  53313. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  53314. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  53315. */
  53316. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  53317. /** Creates the node editor window. */
  53318. private _createNodeEditor;
  53319. /**
  53320. * Launch the node material editor
  53321. * @param config Define the configuration of the editor
  53322. * @return a promise fulfilled when the node editor is visible
  53323. */
  53324. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  53325. /**
  53326. * Clear the current material
  53327. */
  53328. clear(): void;
  53329. /**
  53330. * Clear the current material and set it to a default state
  53331. */
  53332. setToDefault(): void;
  53333. }
  53334. }
  53335. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  53336. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  53337. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53338. import { Nullable } from "babylonjs/types";
  53339. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53340. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  53341. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  53342. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53343. import { Mesh } from "babylonjs/Meshes/mesh";
  53344. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  53345. /**
  53346. * Defines a block that can be used inside a node based material
  53347. */
  53348. export class NodeMaterialBlock {
  53349. private _buildId;
  53350. private _target;
  53351. private _isFinalMerger;
  53352. /** @hidden */
  53353. _inputs: NodeMaterialConnectionPoint[];
  53354. /** @hidden */
  53355. _outputs: NodeMaterialConnectionPoint[];
  53356. /**
  53357. * Gets or sets the name of the block
  53358. */
  53359. name: string;
  53360. /**
  53361. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  53362. */
  53363. readonly isFinalMerger: boolean;
  53364. /**
  53365. * Gets or sets the build Id
  53366. */
  53367. buildId: number;
  53368. /**
  53369. * Gets or sets the target of the block
  53370. */
  53371. target: NodeMaterialBlockTargets;
  53372. /**
  53373. * Gets the list of input points
  53374. */
  53375. readonly inputs: NodeMaterialConnectionPoint[];
  53376. /** Gets the list of output points */
  53377. readonly outputs: NodeMaterialConnectionPoint[];
  53378. /**
  53379. * Find an input by its name
  53380. * @param name defines the name of the input to look for
  53381. * @returns the input or null if not found
  53382. */
  53383. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  53384. /**
  53385. * Find an output by its name
  53386. * @param name defines the name of the outputto look for
  53387. * @returns the output or null if not found
  53388. */
  53389. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  53390. /**
  53391. * Creates a new NodeMaterialBlock
  53392. * @param name defines the block name
  53393. * @param target defines the target of that block (Vertex by default)
  53394. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  53395. */
  53396. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean);
  53397. /**
  53398. * Initialize the block and prepare the context for build
  53399. * @param state defines the state that will be used for the build
  53400. */
  53401. initialize(state: NodeMaterialBuildState): void;
  53402. /**
  53403. * Bind data to effect. Will only be called for blocks with isBindable === true
  53404. * @param effect defines the effect to bind data to
  53405. * @param nodeMaterial defines the hosting NodeMaterial
  53406. * @param mesh defines the mesh that will be rendered
  53407. */
  53408. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53409. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  53410. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  53411. protected _writeFloat(value: number): string;
  53412. /**
  53413. * Gets the current class name e.g. "NodeMaterialBlock"
  53414. * @returns the class name
  53415. */
  53416. getClassName(): string;
  53417. /**
  53418. * Register a new input. Must be called inside a block constructor
  53419. * @param name defines the connection point name
  53420. * @param type defines the connection point type
  53421. * @param isOptional defines a boolean indicating that this input can be omitted
  53422. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  53423. * @returns the current block
  53424. */
  53425. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  53426. /**
  53427. * Register a new output. Must be called inside a block constructor
  53428. * @param name defines the connection point name
  53429. * @param type defines the connection point type
  53430. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  53431. * @returns the current block
  53432. */
  53433. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  53434. /**
  53435. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  53436. * @param forOutput defines an optional connection point to check compatibility with
  53437. * @returns the first available input or null
  53438. */
  53439. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  53440. /**
  53441. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  53442. * @param forBlock defines an optional block to check compatibility with
  53443. * @returns the first available input or null
  53444. */
  53445. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  53446. /**
  53447. * Connect current block with another block
  53448. * @param other defines the block to connect with
  53449. * @param options define the various options to help pick the right connections
  53450. * @returns the current block
  53451. */
  53452. connectTo(other: NodeMaterialBlock, options?: {
  53453. input?: string;
  53454. output?: string;
  53455. outputSwizzle?: string;
  53456. }): this | undefined;
  53457. protected _buildBlock(state: NodeMaterialBuildState): void;
  53458. /**
  53459. * Add potential fallbacks if shader compilation fails
  53460. * @param mesh defines the mesh to be rendered
  53461. * @param fallbacks defines the current prioritized list of fallbacks
  53462. */
  53463. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  53464. /**
  53465. * Update defines for shader compilation
  53466. * @param mesh defines the mesh to be rendered
  53467. * @param nodeMaterial defines the node material requesting the update
  53468. * @param defines defines the material defines to update
  53469. * @param useInstances specifies that instances should be used
  53470. */
  53471. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53472. /**
  53473. * Lets the block try to connect some inputs automatically
  53474. */
  53475. autoConfigure(): void;
  53476. /**
  53477. * Function called when a block is declared as repeatable content generator
  53478. * @param vertexShaderState defines the current compilation state for the vertex shader
  53479. * @param fragmentShaderState defines the current compilation state for the fragment shader
  53480. * @param mesh defines the mesh to be rendered
  53481. * @param defines defines the material defines to update
  53482. */
  53483. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  53484. /**
  53485. * Checks if the block is ready
  53486. * @param mesh defines the mesh to be rendered
  53487. * @param nodeMaterial defines the node material requesting the update
  53488. * @param defines defines the material defines to update
  53489. * @param useInstances specifies that instances should be used
  53490. * @returns true if the block is ready
  53491. */
  53492. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  53493. /**
  53494. * Compile the current node and generate the shader code
  53495. * @param state defines the current compilation state (uniforms, samplers, current string)
  53496. * @returns the current block
  53497. */
  53498. build(state: NodeMaterialBuildState): this | undefined;
  53499. }
  53500. }
  53501. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  53502. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  53503. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  53504. import { Nullable } from "babylonjs/types";
  53505. import { Effect } from "babylonjs/Materials/effect";
  53506. import { NodeMaterialWellKnownValues } from "babylonjs/Materials/Node/nodeMaterialWellKnownValues";
  53507. import { Scene } from "babylonjs/scene";
  53508. import { Matrix } from "babylonjs/Maths/math";
  53509. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53510. /**
  53511. * Defines a connection point for a block
  53512. */
  53513. export class NodeMaterialConnectionPoint {
  53514. /** @hidden */
  53515. _ownerBlock: NodeMaterialBlock;
  53516. /** @hidden */
  53517. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  53518. private _associatedVariableName;
  53519. private _endpoints;
  53520. private _storedValue;
  53521. private _valueCallback;
  53522. private _mode;
  53523. /** @hidden */
  53524. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  53525. /** @hidden */
  53526. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  53527. /** @hidden */
  53528. _needToEmitVarying: boolean;
  53529. private _type;
  53530. /**
  53531. * Gets or sets the connection point type (default is float)
  53532. */
  53533. type: NodeMaterialBlockConnectionPointTypes;
  53534. /**
  53535. * Gets or sets the connection point name
  53536. */
  53537. name: string;
  53538. /**
  53539. * Gets or sets the swizzle to apply to this connection point when reading or writing
  53540. */
  53541. swizzle: string;
  53542. /**
  53543. * Gets or sets a boolean indicating that this connection point can be omitted
  53544. */
  53545. isOptional: boolean;
  53546. /**
  53547. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  53548. */
  53549. define: string;
  53550. /** Gets or sets the target of that connection point */
  53551. target: NodeMaterialBlockTargets;
  53552. /**
  53553. * Gets or sets the value of that point.
  53554. * Please note that this value will be ignored if valueCallback is defined
  53555. */
  53556. value: any;
  53557. /**
  53558. * Gets or sets a callback used to get the value of that point.
  53559. * Please note that setting this value will force the connection point to ignore the value property
  53560. */
  53561. valueCallback: () => any;
  53562. /**
  53563. * Gets or sets the associated variable name in the shader
  53564. */
  53565. associatedVariableName: string;
  53566. /**
  53567. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  53568. * In this case the connection point name must be the name of the uniform to use.
  53569. * Can only be set on inputs
  53570. */
  53571. isUniform: boolean;
  53572. /**
  53573. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  53574. * In this case the connection point name must be the name of the attribute to use
  53575. * Can only be set on inputs
  53576. */
  53577. isAttribute: boolean;
  53578. /**
  53579. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  53580. * Can only be set on exit points
  53581. */
  53582. isVarying: boolean;
  53583. /** Get the other side of the connection (if any) */
  53584. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  53585. /** Get the block that owns this connection point */
  53586. readonly ownerBlock: NodeMaterialBlock;
  53587. /** Get the block connected on the other side of this connection (if any) */
  53588. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  53589. /** Get the block connected on the endpoints of this connection (if any) */
  53590. readonly connectedBlocks: Array<NodeMaterialBlock>;
  53591. /**
  53592. * Creates a new connection point
  53593. * @param name defines the connection point name
  53594. * @param ownerBlock defines the block hosting this connection point
  53595. */
  53596. constructor(name: string, ownerBlock: NodeMaterialBlock);
  53597. /**
  53598. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  53599. * @returns the class name
  53600. */
  53601. getClassName(): string;
  53602. /**
  53603. * Set the source of this connection point to a vertex attribute
  53604. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  53605. * @returns the current connection point
  53606. */
  53607. setAsAttribute(attributeName?: string): NodeMaterialConnectionPoint;
  53608. /**
  53609. * Set the source of this connection point to a well known value
  53610. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  53611. * @returns the current connection point
  53612. */
  53613. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): NodeMaterialConnectionPoint;
  53614. /**
  53615. * Gets a boolean indicating that the current connection point is a well known value
  53616. */
  53617. readonly isWellKnownValue: boolean;
  53618. /**
  53619. * Gets or sets the current well known value or null if not defined as well know value
  53620. */
  53621. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  53622. private _getTypeLength;
  53623. /**
  53624. * Connect this point to another connection point
  53625. * @param connectionPoint defines the other connection point
  53626. * @returns the current connection point
  53627. */
  53628. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  53629. /**
  53630. * Disconnect this point from one of his endpoint
  53631. * @param endpoint defines the other connection point
  53632. * @returns the current connection point
  53633. */
  53634. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  53635. /**
  53636. * When connection point is an uniform, this function will send its value to the effect
  53637. * @param effect defines the effect to transmit value to
  53638. * @param world defines the world matrix
  53639. * @param worldView defines the worldxview matrix
  53640. * @param worldViewProjection defines the worldxviewxprojection matrix
  53641. */
  53642. transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  53643. /**
  53644. * When connection point is an uniform, this function will send its value to the effect
  53645. * @param effect defines the effect to transmit value to
  53646. * @param scene defines the hosting scene
  53647. */
  53648. transmit(effect: Effect, scene: Scene): void;
  53649. }
  53650. }
  53651. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  53652. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53653. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53654. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53655. import { Mesh } from "babylonjs/Meshes/mesh";
  53656. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  53657. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53658. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  53659. /**
  53660. * Block used to add support for vertex skinning (bones)
  53661. */
  53662. export class BonesBlock extends NodeMaterialBlock {
  53663. /**
  53664. * Creates a new BonesBlock
  53665. * @param name defines the block name
  53666. */
  53667. constructor(name: string);
  53668. /**
  53669. * Initialize the block and prepare the context for build
  53670. * @param state defines the state that will be used for the build
  53671. */
  53672. initialize(state: NodeMaterialBuildState): void;
  53673. /**
  53674. * Gets the current class name
  53675. * @returns the class name
  53676. */
  53677. getClassName(): string;
  53678. /**
  53679. * Gets the matrix indices input component
  53680. */
  53681. readonly matricesIndices: NodeMaterialConnectionPoint;
  53682. /**
  53683. * Gets the matrix weights input component
  53684. */
  53685. readonly matricesWeights: NodeMaterialConnectionPoint;
  53686. /**
  53687. * Gets the extra matrix indices input component
  53688. */
  53689. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  53690. /**
  53691. * Gets the extra matrix weights input component
  53692. */
  53693. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  53694. /**
  53695. * Gets the world input component
  53696. */
  53697. readonly world: NodeMaterialConnectionPoint;
  53698. autoConfigure(): void;
  53699. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  53700. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53701. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53702. protected _buildBlock(state: NodeMaterialBuildState): this;
  53703. }
  53704. }
  53705. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  53706. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53707. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53708. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53709. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53710. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  53711. /**
  53712. * Block used to add support for instances
  53713. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  53714. */
  53715. export class InstancesBlock extends NodeMaterialBlock {
  53716. /**
  53717. * Creates a new InstancesBlock
  53718. * @param name defines the block name
  53719. */
  53720. constructor(name: string);
  53721. /**
  53722. * Gets the current class name
  53723. * @returns the class name
  53724. */
  53725. getClassName(): string;
  53726. /**
  53727. * Gets the first world row input component
  53728. */
  53729. readonly world0: NodeMaterialConnectionPoint;
  53730. /**
  53731. * Gets the second world row input component
  53732. */
  53733. readonly world1: NodeMaterialConnectionPoint;
  53734. /**
  53735. * Gets the third world row input component
  53736. */
  53737. readonly world2: NodeMaterialConnectionPoint;
  53738. /**
  53739. * Gets the forth world row input component
  53740. */
  53741. readonly world3: NodeMaterialConnectionPoint;
  53742. /**
  53743. * Gets the world input component
  53744. */
  53745. readonly world: NodeMaterialConnectionPoint;
  53746. /**
  53747. * Gets the output component
  53748. */
  53749. readonly output: NodeMaterialConnectionPoint;
  53750. autoConfigure(): void;
  53751. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53752. protected _buildBlock(state: NodeMaterialBuildState): this;
  53753. }
  53754. }
  53755. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  53756. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53757. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53758. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53759. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53760. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  53761. import { Effect } from "babylonjs/Materials/effect";
  53762. import { Mesh } from "babylonjs/Meshes/mesh";
  53763. /**
  53764. * Block used to add morph targets support to vertex shader
  53765. */
  53766. export class MorphTargetsBlock extends NodeMaterialBlock {
  53767. private _repeatableContentAnchor;
  53768. private _repeatebleContentGenerated;
  53769. /**
  53770. * Create a new MorphTargetsBlock
  53771. * @param name defines the block name
  53772. */
  53773. constructor(name: string);
  53774. /**
  53775. * Gets the current class name
  53776. * @returns the class name
  53777. */
  53778. getClassName(): string;
  53779. /**
  53780. * Gets the position input component
  53781. */
  53782. readonly position: NodeMaterialConnectionPoint;
  53783. /**
  53784. * Gets the normal input component
  53785. */
  53786. readonly normal: NodeMaterialConnectionPoint;
  53787. /**
  53788. * Gets the tangent input component
  53789. */
  53790. readonly tangent: NodeMaterialConnectionPoint;
  53791. /**
  53792. * Gets the position output component
  53793. */
  53794. readonly positionOutput: NodeMaterialConnectionPoint;
  53795. /**
  53796. * Gets the normal output component
  53797. */
  53798. readonly normalOutput: NodeMaterialConnectionPoint;
  53799. /**
  53800. * Gets the tangent output component
  53801. */
  53802. readonly tangentOutput: NodeMaterialConnectionPoint;
  53803. initialize(state: NodeMaterialBuildState): void;
  53804. autoConfigure(): void;
  53805. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53806. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53807. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  53808. protected _buildBlock(state: NodeMaterialBuildState): this;
  53809. }
  53810. }
  53811. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  53812. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  53813. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  53814. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  53815. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  53816. }
  53817. declare module "babylonjs/Materials/Node/Blocks/Fragment/alphaTestBlock" {
  53818. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53819. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53820. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53821. /**
  53822. * Block used to add an alpha test in the fragment shader
  53823. */
  53824. export class AlphaTestBlock extends NodeMaterialBlock {
  53825. /**
  53826. * Gets or sets the alpha value where alpha testing happens
  53827. */
  53828. alphaCutOff: number;
  53829. /**
  53830. * Create a new AlphaTestBlock
  53831. * @param name defines the block name
  53832. */
  53833. constructor(name: string);
  53834. /**
  53835. * Gets the current class name
  53836. * @returns the class name
  53837. */
  53838. getClassName(): string;
  53839. /**
  53840. * Gets the color input component
  53841. */
  53842. readonly color: NodeMaterialConnectionPoint;
  53843. protected _buildBlock(state: NodeMaterialBuildState): this;
  53844. }
  53845. }
  53846. declare module "babylonjs/Materials/Node/Blocks/Fragment/rgbaMergerBlock" {
  53847. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53848. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53849. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53850. /**
  53851. * Block used to create a Color4 out of 4 inputs (one for each component)
  53852. */
  53853. export class RGBAMergerBlock extends NodeMaterialBlock {
  53854. /**
  53855. * Create a new RGBAMergerBlock
  53856. * @param name defines the block name
  53857. */
  53858. constructor(name: string);
  53859. /**
  53860. * Gets the current class name
  53861. * @returns the class name
  53862. */
  53863. getClassName(): string;
  53864. /**
  53865. * Gets the R input component
  53866. */
  53867. readonly r: NodeMaterialConnectionPoint;
  53868. /**
  53869. * Gets the G input component
  53870. */
  53871. readonly g: NodeMaterialConnectionPoint;
  53872. /**
  53873. * Gets the B input component
  53874. */
  53875. readonly b: NodeMaterialConnectionPoint;
  53876. /**
  53877. * Gets the RGB input component
  53878. */
  53879. readonly rgb: NodeMaterialConnectionPoint;
  53880. /**
  53881. * Gets the R input component
  53882. */
  53883. readonly a: NodeMaterialConnectionPoint;
  53884. protected _buildBlock(state: NodeMaterialBuildState): this;
  53885. }
  53886. }
  53887. declare module "babylonjs/Materials/Node/Blocks/Fragment/rgbMergerBlock" {
  53888. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53889. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53890. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53891. /**
  53892. * Block used to create a Color3 out of 3 inputs (one for each component)
  53893. */
  53894. export class RGBMergerBlock extends NodeMaterialBlock {
  53895. /**
  53896. * Create a new RGBMergerBlock
  53897. * @param name defines the block name
  53898. */
  53899. constructor(name: string);
  53900. /**
  53901. * Gets the current class name
  53902. * @returns the class name
  53903. */
  53904. getClassName(): string;
  53905. /**
  53906. * Gets the R component input
  53907. */
  53908. readonly r: NodeMaterialConnectionPoint;
  53909. /**
  53910. * Gets the G component input
  53911. */
  53912. readonly g: NodeMaterialConnectionPoint;
  53913. /**
  53914. * Gets the B component input
  53915. */
  53916. readonly b: NodeMaterialConnectionPoint;
  53917. protected _buildBlock(state: NodeMaterialBuildState): this;
  53918. }
  53919. }
  53920. declare module "babylonjs/Materials/Node/Blocks/Fragment/rgbaSplitterBlock" {
  53921. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53922. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53923. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53924. /**
  53925. * Block used to expand a Color4 or a Vector4 into 4 outputs (one for each component)
  53926. */
  53927. export class RGBASplitterBlock extends NodeMaterialBlock {
  53928. /**
  53929. * Create a new RGBASplitterBlock
  53930. * @param name defines the block name
  53931. */
  53932. constructor(name: string);
  53933. /**
  53934. * Gets the current class name
  53935. * @returns the class name
  53936. */
  53937. getClassName(): string;
  53938. /**
  53939. * Gets the input component
  53940. */
  53941. readonly input: NodeMaterialConnectionPoint;
  53942. protected _buildBlock(state: NodeMaterialBuildState): this;
  53943. }
  53944. }
  53945. declare module "babylonjs/Materials/Node/Blocks/Fragment/rgbSplitterBlock" {
  53946. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53947. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53948. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53949. /**
  53950. * Block used to expand a Color3 or a Vector3 into 3 outputs (one for each component)
  53951. */
  53952. export class RGBSplitterBlock extends NodeMaterialBlock {
  53953. /**
  53954. * Create a new RGBSplitterBlock
  53955. * @param name defines the block name
  53956. */
  53957. constructor(name: string);
  53958. /**
  53959. * Gets the current class name
  53960. * @returns the class name
  53961. */
  53962. getClassName(): string;
  53963. /**
  53964. * Gets the input component
  53965. */
  53966. readonly input: NodeMaterialConnectionPoint;
  53967. protected _buildBlock(state: NodeMaterialBuildState): this;
  53968. }
  53969. }
  53970. declare module "babylonjs/Materials/Node/Blocks/Fragment/textureBlock" {
  53971. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53972. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53973. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53974. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53975. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  53976. /**
  53977. * Block used to read a texture from a sampler
  53978. */
  53979. export class TextureBlock extends NodeMaterialBlock {
  53980. private _defineName;
  53981. /**
  53982. * Gets or sets a boolean indicating that the block can automatically fetch the texture matrix
  53983. */
  53984. autoConnectTextureMatrix: boolean;
  53985. /**
  53986. * Gets or sets a boolean indicating that the block can automatically select the uv channel based on texture
  53987. */
  53988. autoSelectUV: boolean;
  53989. /**
  53990. * Create a new TextureBlock
  53991. * @param name defines the block name
  53992. */
  53993. constructor(name: string);
  53994. /**
  53995. * Gets the current class name
  53996. * @returns the class name
  53997. */
  53998. getClassName(): string;
  53999. /**
  54000. * Gets the uv input component
  54001. */
  54002. readonly uv: NodeMaterialConnectionPoint;
  54003. /**
  54004. * Gets the texture information input component
  54005. */
  54006. readonly textureInfo: NodeMaterialConnectionPoint;
  54007. /**
  54008. * Gets the transformed uv input component
  54009. */
  54010. readonly transformedUV: NodeMaterialConnectionPoint;
  54011. /**
  54012. * Gets the texture input component
  54013. */
  54014. readonly texture: NodeMaterialConnectionPoint;
  54015. /**
  54016. * Gets the texture transform input component
  54017. */
  54018. readonly textureTransform: NodeMaterialConnectionPoint;
  54019. autoConfigure(): void;
  54020. initialize(state: NodeMaterialBuildState): void;
  54021. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54022. isReady(): boolean;
  54023. private _injectVertexCode;
  54024. protected _buildBlock(state: NodeMaterialBuildState): this;
  54025. }
  54026. }
  54027. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  54028. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54029. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54030. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54031. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54032. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54033. import { Effect } from "babylonjs/Materials/effect";
  54034. import { Mesh } from "babylonjs/Meshes/mesh";
  54035. /**
  54036. * Block used to add image processing support to fragment shader
  54037. */
  54038. export class ImageProcessingBlock extends NodeMaterialBlock {
  54039. /**
  54040. * Create a new ImageProcessingBlock
  54041. * @param name defines the block name
  54042. */
  54043. constructor(name: string);
  54044. /**
  54045. * Gets the current class name
  54046. * @returns the class name
  54047. */
  54048. getClassName(): string;
  54049. /**
  54050. * Gets the color input component
  54051. */
  54052. readonly color: NodeMaterialConnectionPoint;
  54053. /**
  54054. * Initialize the block and prepare the context for build
  54055. * @param state defines the state that will be used for the build
  54056. */
  54057. initialize(state: NodeMaterialBuildState): void;
  54058. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  54059. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54060. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54061. protected _buildBlock(state: NodeMaterialBuildState): this;
  54062. }
  54063. }
  54064. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  54065. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  54066. export * from "babylonjs/Materials/Node/Blocks/Fragment/alphaTestBlock";
  54067. export * from "babylonjs/Materials/Node/Blocks/Fragment/rgbaMergerBlock";
  54068. export * from "babylonjs/Materials/Node/Blocks/Fragment/rgbMergerBlock";
  54069. export * from "babylonjs/Materials/Node/Blocks/Fragment/rgbaSplitterBlock";
  54070. export * from "babylonjs/Materials/Node/Blocks/Fragment/rgbSplitterBlock";
  54071. export * from "babylonjs/Materials/Node/Blocks/Fragment/textureBlock";
  54072. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  54073. }
  54074. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  54075. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54076. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54077. import { Mesh } from "babylonjs/Meshes/mesh";
  54078. import { Effect } from "babylonjs/Materials/effect";
  54079. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54080. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54081. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54082. /**
  54083. * Block used to add support for scene fog
  54084. */
  54085. export class FogBlock extends NodeMaterialBlock {
  54086. /**
  54087. * Create a new FogBlock
  54088. * @param name defines the block name
  54089. */
  54090. constructor(name: string);
  54091. /**
  54092. * Gets the current class name
  54093. * @returns the class name
  54094. */
  54095. getClassName(): string;
  54096. /**
  54097. * Gets the world position input component
  54098. */
  54099. readonly worldPosition: NodeMaterialConnectionPoint;
  54100. /**
  54101. * Gets the view input component
  54102. */
  54103. readonly view: NodeMaterialConnectionPoint;
  54104. /**
  54105. * Gets the color input component
  54106. */
  54107. readonly color: NodeMaterialConnectionPoint;
  54108. /**
  54109. * Gets the fog color input component
  54110. */
  54111. readonly fogColor: NodeMaterialConnectionPoint;
  54112. /**
  54113. * Gets the for parameter input component
  54114. */
  54115. readonly fogParameters: NodeMaterialConnectionPoint;
  54116. autoConfigure(): void;
  54117. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54118. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54119. protected _buildBlock(state: NodeMaterialBuildState): this;
  54120. }
  54121. }
  54122. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  54123. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  54124. }
  54125. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  54126. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54127. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54128. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54129. /**
  54130. * Block used to multiply 2 vector4
  54131. */
  54132. export class MultiplyBlock extends NodeMaterialBlock {
  54133. /**
  54134. * Creates a new MultiplyBlock
  54135. * @param name defines the block name
  54136. */
  54137. constructor(name: string);
  54138. /**
  54139. * Gets the current class name
  54140. * @returns the class name
  54141. */
  54142. getClassName(): string;
  54143. /**
  54144. * Gets the left operand input component
  54145. */
  54146. readonly left: NodeMaterialConnectionPoint;
  54147. /**
  54148. * Gets the right operand input component
  54149. */
  54150. readonly right: NodeMaterialConnectionPoint;
  54151. protected _buildBlock(state: NodeMaterialBuildState): this;
  54152. }
  54153. }
  54154. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  54155. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54156. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54157. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54158. /**
  54159. * Block used to add 2 vector4
  54160. */
  54161. export class AddBlock extends NodeMaterialBlock {
  54162. /**
  54163. * Creates a new AddBlock
  54164. * @param name defines the block name
  54165. */
  54166. constructor(name: string);
  54167. /**
  54168. * Gets the current class name
  54169. * @returns the class name
  54170. */
  54171. getClassName(): string;
  54172. /**
  54173. * Gets the left operand input component
  54174. */
  54175. readonly left: NodeMaterialConnectionPoint;
  54176. /**
  54177. * Gets the right operand input component
  54178. */
  54179. readonly right: NodeMaterialConnectionPoint;
  54180. protected _buildBlock(state: NodeMaterialBuildState): this;
  54181. }
  54182. }
  54183. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  54184. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54185. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54186. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54187. /**
  54188. * Block used to clamp a float
  54189. */
  54190. export class ClampBlock extends NodeMaterialBlock {
  54191. /** Gets or sets the minimum range */
  54192. minimum: number;
  54193. /** Gets or sets the maximum range */
  54194. maximum: number;
  54195. /**
  54196. * Creates a new ClampBlock
  54197. * @param name defines the block name
  54198. */
  54199. constructor(name: string);
  54200. /**
  54201. * Gets the current class name
  54202. * @returns the class name
  54203. */
  54204. getClassName(): string;
  54205. /**
  54206. * Gets the value input component
  54207. */
  54208. readonly value: NodeMaterialConnectionPoint;
  54209. protected _buildBlock(state: NodeMaterialBuildState): this;
  54210. }
  54211. }
  54212. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  54213. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54214. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54215. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54216. /**
  54217. * Block used to scale a value
  54218. */
  54219. export class ScaleBlock extends NodeMaterialBlock {
  54220. /**
  54221. * Creates a new ScaleBlock
  54222. * @param name defines the block name
  54223. */
  54224. constructor(name: string);
  54225. /**
  54226. * Gets the current class name
  54227. * @returns the class name
  54228. */
  54229. getClassName(): string;
  54230. /**
  54231. * Gets the value operand input component
  54232. */
  54233. readonly value: NodeMaterialConnectionPoint;
  54234. /**
  54235. * Gets the scale operand input component
  54236. */
  54237. readonly scale: NodeMaterialConnectionPoint;
  54238. /**
  54239. * Gets the right operand input component
  54240. */
  54241. readonly right: NodeMaterialConnectionPoint;
  54242. protected _buildBlock(state: NodeMaterialBuildState): this;
  54243. }
  54244. }
  54245. declare module "babylonjs/Materials/Node/Blocks/vector2TransformBlock" {
  54246. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54247. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54248. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54249. /**
  54250. * Block used to transform a vector2 with a matrix
  54251. */
  54252. export class Vector2TransformBlock extends NodeMaterialBlock {
  54253. /**
  54254. * Defines the value to use to complement Vector2 to transform it to a Vector4
  54255. */
  54256. complementZ: number;
  54257. /**
  54258. * Defines the value to use to complement Vector2 to transform it to a Vector4
  54259. */
  54260. complementW: number;
  54261. /**
  54262. * Creates a new Vector2TransformBlock
  54263. * @param name defines the block name
  54264. */
  54265. constructor(name: string);
  54266. /**
  54267. * Gets the vector input
  54268. */
  54269. readonly vector: NodeMaterialConnectionPoint;
  54270. /**
  54271. * Gets the matrix transform input
  54272. */
  54273. readonly transform: NodeMaterialConnectionPoint;
  54274. /**
  54275. * Gets the current class name
  54276. * @returns the class name
  54277. */
  54278. getClassName(): string;
  54279. protected _buildBlock(state: NodeMaterialBuildState): this;
  54280. }
  54281. }
  54282. declare module "babylonjs/Materials/Node/Blocks/vector3TransformBlock" {
  54283. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54284. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54285. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54286. /**
  54287. * Block used to transform a vector3 with a matrix
  54288. */
  54289. export class Vector3TransformBlock extends NodeMaterialBlock {
  54290. /**
  54291. * Defines the value to use to complement Vector3 to transform it to a Vector4
  54292. */
  54293. complement: number;
  54294. /**
  54295. * Creates a new Vector3TransformBlock
  54296. * @param name defines the block name
  54297. */
  54298. constructor(name: string);
  54299. /**
  54300. * Gets the vector input
  54301. */
  54302. readonly vector: NodeMaterialConnectionPoint;
  54303. /**
  54304. * Gets the matrix transform input
  54305. */
  54306. readonly transform: NodeMaterialConnectionPoint;
  54307. /**
  54308. * Gets the current class name
  54309. * @returns the class name
  54310. */
  54311. getClassName(): string;
  54312. protected _buildBlock(state: NodeMaterialBuildState): this;
  54313. }
  54314. }
  54315. declare module "babylonjs/Materials/Node/Blocks/matrixMultiplicationBlock" {
  54316. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54317. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54318. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54319. /**
  54320. * Block used to multiply two matrices
  54321. */
  54322. export class MatrixMultiplicationBlock extends NodeMaterialBlock {
  54323. /**
  54324. * Creates a new MatrixMultiplicationBlock
  54325. * @param name defines the block name
  54326. */
  54327. constructor(name: string);
  54328. /**
  54329. * Gets the left operand
  54330. */
  54331. readonly left: NodeMaterialConnectionPoint;
  54332. /**
  54333. * Gets the right operand
  54334. */
  54335. readonly right: NodeMaterialConnectionPoint;
  54336. /**
  54337. * Gets the current class name
  54338. * @returns the class name
  54339. */
  54340. getClassName(): string;
  54341. protected _buildBlock(state: NodeMaterialBuildState): this;
  54342. }
  54343. }
  54344. declare module "babylonjs/Materials/Node/Blocks/index" {
  54345. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  54346. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  54347. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  54348. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  54349. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  54350. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  54351. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  54352. export * from "babylonjs/Materials/Node/Blocks/vector2TransformBlock";
  54353. export * from "babylonjs/Materials/Node/Blocks/vector3TransformBlock";
  54354. export * from "babylonjs/Materials/Node/Blocks/vector4TransformBlock";
  54355. export * from "babylonjs/Materials/Node/Blocks/matrixMultiplicationBlock";
  54356. }
  54357. declare module "babylonjs/Materials/Node/Optimizers/index" {
  54358. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  54359. }
  54360. declare module "babylonjs/Materials/Node/index" {
  54361. export * from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  54362. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  54363. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54364. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  54365. export * from "babylonjs/Materials/Node/nodeMaterial";
  54366. export * from "babylonjs/Materials/Node/nodeMaterialWellKnownValues";
  54367. export * from "babylonjs/Materials/Node/Blocks/index";
  54368. export * from "babylonjs/Materials/Node/Optimizers/index";
  54369. }
  54370. declare module "babylonjs/Materials/index" {
  54371. export * from "babylonjs/Materials/Background/index";
  54372. export * from "babylonjs/Materials/colorCurves";
  54373. export * from "babylonjs/Materials/effect";
  54374. export * from "babylonjs/Materials/fresnelParameters";
  54375. export * from "babylonjs/Materials/imageProcessingConfiguration";
  54376. export * from "babylonjs/Materials/material";
  54377. export * from "babylonjs/Materials/materialDefines";
  54378. export * from "babylonjs/Materials/materialHelper";
  54379. export * from "babylonjs/Materials/multiMaterial";
  54380. export * from "babylonjs/Materials/PBR/index";
  54381. export * from "babylonjs/Materials/pushMaterial";
  54382. export * from "babylonjs/Materials/shaderMaterial";
  54383. export * from "babylonjs/Materials/standardMaterial";
  54384. export * from "babylonjs/Materials/Textures/index";
  54385. export * from "babylonjs/Materials/uniformBuffer";
  54386. export * from "babylonjs/Materials/materialFlags";
  54387. export * from "babylonjs/Materials/Node/index";
  54388. }
  54389. declare module "babylonjs/Maths/index" {
  54390. export * from "babylonjs/Maths/math.scalar";
  54391. export * from "babylonjs/Maths/math";
  54392. export * from "babylonjs/Maths/sphericalPolynomial";
  54393. }
  54394. declare module "babylonjs/Misc/workerPool" {
  54395. import { IDisposable } from "babylonjs/scene";
  54396. /**
  54397. * Helper class to push actions to a pool of workers.
  54398. */
  54399. export class WorkerPool implements IDisposable {
  54400. private _workerInfos;
  54401. private _pendingActions;
  54402. /**
  54403. * Constructor
  54404. * @param workers Array of workers to use for actions
  54405. */
  54406. constructor(workers: Array<Worker>);
  54407. /**
  54408. * Terminates all workers and clears any pending actions.
  54409. */
  54410. dispose(): void;
  54411. /**
  54412. * Pushes an action to the worker pool. If all the workers are active, the action will be
  54413. * pended until a worker has completed its action.
  54414. * @param action The action to perform. Call onComplete when the action is complete.
  54415. */
  54416. push(action: (worker: Worker, onComplete: () => void) => void): void;
  54417. private _execute;
  54418. }
  54419. }
  54420. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  54421. import { IDisposable } from "babylonjs/scene";
  54422. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  54423. /**
  54424. * Configuration for Draco compression
  54425. */
  54426. export interface IDracoCompressionConfiguration {
  54427. /**
  54428. * Configuration for the decoder.
  54429. */
  54430. decoder: {
  54431. /**
  54432. * The url to the WebAssembly module.
  54433. */
  54434. wasmUrl?: string;
  54435. /**
  54436. * The url to the WebAssembly binary.
  54437. */
  54438. wasmBinaryUrl?: string;
  54439. /**
  54440. * The url to the fallback JavaScript module.
  54441. */
  54442. fallbackUrl?: string;
  54443. };
  54444. }
  54445. /**
  54446. * Draco compression (https://google.github.io/draco/)
  54447. *
  54448. * This class wraps the Draco module.
  54449. *
  54450. * **Encoder**
  54451. *
  54452. * The encoder is not currently implemented.
  54453. *
  54454. * **Decoder**
  54455. *
  54456. * 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.
  54457. *
  54458. * To update the configuration, use the following code:
  54459. * ```javascript
  54460. * DracoCompression.Configuration = {
  54461. * decoder: {
  54462. * wasmUrl: "<url to the WebAssembly library>",
  54463. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  54464. * fallbackUrl: "<url to the fallback JavaScript library>",
  54465. * }
  54466. * };
  54467. * ```
  54468. *
  54469. * 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.
  54470. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  54471. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  54472. *
  54473. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  54474. * ```javascript
  54475. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  54476. * ```
  54477. *
  54478. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  54479. */
  54480. export class DracoCompression implements IDisposable {
  54481. private _workerPoolPromise?;
  54482. private _decoderModulePromise?;
  54483. /**
  54484. * The configuration. Defaults to the following urls:
  54485. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  54486. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  54487. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  54488. */
  54489. static Configuration: IDracoCompressionConfiguration;
  54490. /**
  54491. * Returns true if the decoder configuration is available.
  54492. */
  54493. static readonly DecoderAvailable: boolean;
  54494. /**
  54495. * Default number of workers to create when creating the draco compression object.
  54496. */
  54497. static DefaultNumWorkers: number;
  54498. private static GetDefaultNumWorkers;
  54499. private static _Default;
  54500. /**
  54501. * Default instance for the draco compression object.
  54502. */
  54503. static readonly Default: DracoCompression;
  54504. /**
  54505. * Constructor
  54506. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  54507. */
  54508. constructor(numWorkers?: number);
  54509. /**
  54510. * Stop all async operations and release resources.
  54511. */
  54512. dispose(): void;
  54513. /**
  54514. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  54515. * @returns a promise that resolves when ready
  54516. */
  54517. whenReadyAsync(): Promise<void>;
  54518. /**
  54519. * Decode Draco compressed mesh data to vertex data.
  54520. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  54521. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  54522. * @returns A promise that resolves with the decoded vertex data
  54523. */
  54524. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  54525. [kind: string]: number;
  54526. }): Promise<VertexData>;
  54527. }
  54528. }
  54529. declare module "babylonjs/Meshes/Compression/index" {
  54530. export * from "babylonjs/Meshes/Compression/dracoCompression";
  54531. }
  54532. declare module "babylonjs/Meshes/csg" {
  54533. import { Nullable } from "babylonjs/types";
  54534. import { Scene } from "babylonjs/scene";
  54535. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  54536. import { Mesh } from "babylonjs/Meshes/mesh";
  54537. import { Material } from "babylonjs/Materials/material";
  54538. /**
  54539. * Class for building Constructive Solid Geometry
  54540. */
  54541. export class CSG {
  54542. private polygons;
  54543. /**
  54544. * The world matrix
  54545. */
  54546. matrix: Matrix;
  54547. /**
  54548. * Stores the position
  54549. */
  54550. position: Vector3;
  54551. /**
  54552. * Stores the rotation
  54553. */
  54554. rotation: Vector3;
  54555. /**
  54556. * Stores the rotation quaternion
  54557. */
  54558. rotationQuaternion: Nullable<Quaternion>;
  54559. /**
  54560. * Stores the scaling vector
  54561. */
  54562. scaling: Vector3;
  54563. /**
  54564. * Convert the Mesh to CSG
  54565. * @param mesh The Mesh to convert to CSG
  54566. * @returns A new CSG from the Mesh
  54567. */
  54568. static FromMesh(mesh: Mesh): CSG;
  54569. /**
  54570. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  54571. * @param polygons Polygons used to construct a CSG solid
  54572. */
  54573. private static FromPolygons;
  54574. /**
  54575. * Clones, or makes a deep copy, of the CSG
  54576. * @returns A new CSG
  54577. */
  54578. clone(): CSG;
  54579. /**
  54580. * Unions this CSG with another CSG
  54581. * @param csg The CSG to union against this CSG
  54582. * @returns The unioned CSG
  54583. */
  54584. union(csg: CSG): CSG;
  54585. /**
  54586. * Unions this CSG with another CSG in place
  54587. * @param csg The CSG to union against this CSG
  54588. */
  54589. unionInPlace(csg: CSG): void;
  54590. /**
  54591. * Subtracts this CSG with another CSG
  54592. * @param csg The CSG to subtract against this CSG
  54593. * @returns A new CSG
  54594. */
  54595. subtract(csg: CSG): CSG;
  54596. /**
  54597. * Subtracts this CSG with another CSG in place
  54598. * @param csg The CSG to subtact against this CSG
  54599. */
  54600. subtractInPlace(csg: CSG): void;
  54601. /**
  54602. * Intersect this CSG with another CSG
  54603. * @param csg The CSG to intersect against this CSG
  54604. * @returns A new CSG
  54605. */
  54606. intersect(csg: CSG): CSG;
  54607. /**
  54608. * Intersects this CSG with another CSG in place
  54609. * @param csg The CSG to intersect against this CSG
  54610. */
  54611. intersectInPlace(csg: CSG): void;
  54612. /**
  54613. * Return a new CSG solid with solid and empty space switched. This solid is
  54614. * not modified.
  54615. * @returns A new CSG solid with solid and empty space switched
  54616. */
  54617. inverse(): CSG;
  54618. /**
  54619. * Inverses the CSG in place
  54620. */
  54621. inverseInPlace(): void;
  54622. /**
  54623. * This is used to keep meshes transformations so they can be restored
  54624. * when we build back a Babylon Mesh
  54625. * NB : All CSG operations are performed in world coordinates
  54626. * @param csg The CSG to copy the transform attributes from
  54627. * @returns This CSG
  54628. */
  54629. copyTransformAttributes(csg: CSG): CSG;
  54630. /**
  54631. * Build Raw mesh from CSG
  54632. * Coordinates here are in world space
  54633. * @param name The name of the mesh geometry
  54634. * @param scene The Scene
  54635. * @param keepSubMeshes Specifies if the submeshes should be kept
  54636. * @returns A new Mesh
  54637. */
  54638. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  54639. /**
  54640. * Build Mesh from CSG taking material and transforms into account
  54641. * @param name The name of the Mesh
  54642. * @param material The material of the Mesh
  54643. * @param scene The Scene
  54644. * @param keepSubMeshes Specifies if submeshes should be kept
  54645. * @returns The new Mesh
  54646. */
  54647. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  54648. }
  54649. }
  54650. declare module "babylonjs/Meshes/trailMesh" {
  54651. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54652. import { Mesh } from "babylonjs/Meshes/mesh";
  54653. import { Scene } from "babylonjs/scene";
  54654. /**
  54655. * Class used to create a trail following a mesh
  54656. */
  54657. export class TrailMesh extends Mesh {
  54658. private _generator;
  54659. private _autoStart;
  54660. private _running;
  54661. private _diameter;
  54662. private _length;
  54663. private _sectionPolygonPointsCount;
  54664. private _sectionVectors;
  54665. private _sectionNormalVectors;
  54666. private _beforeRenderObserver;
  54667. /**
  54668. * @constructor
  54669. * @param name The value used by scene.getMeshByName() to do a lookup.
  54670. * @param generator The mesh to generate a trail.
  54671. * @param scene The scene to add this mesh to.
  54672. * @param diameter Diameter of trailing mesh. Default is 1.
  54673. * @param length Length of trailing mesh. Default is 60.
  54674. * @param autoStart Automatically start trailing mesh. Default true.
  54675. */
  54676. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  54677. /**
  54678. * "TrailMesh"
  54679. * @returns "TrailMesh"
  54680. */
  54681. getClassName(): string;
  54682. private _createMesh;
  54683. /**
  54684. * Start trailing mesh.
  54685. */
  54686. start(): void;
  54687. /**
  54688. * Stop trailing mesh.
  54689. */
  54690. stop(): void;
  54691. /**
  54692. * Update trailing mesh geometry.
  54693. */
  54694. update(): void;
  54695. /**
  54696. * Returns a new TrailMesh object.
  54697. * @param name is a string, the name given to the new mesh
  54698. * @param newGenerator use new generator object for cloned trail mesh
  54699. * @returns a new mesh
  54700. */
  54701. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  54702. /**
  54703. * Serializes this trail mesh
  54704. * @param serializationObject object to write serialization to
  54705. */
  54706. serialize(serializationObject: any): void;
  54707. /**
  54708. * Parses a serialized trail mesh
  54709. * @param parsedMesh the serialized mesh
  54710. * @param scene the scene to create the trail mesh in
  54711. * @returns the created trail mesh
  54712. */
  54713. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  54714. }
  54715. }
  54716. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  54717. import { Nullable } from "babylonjs/types";
  54718. import { Scene } from "babylonjs/scene";
  54719. import { Vector4, Color4 } from "babylonjs/Maths/math";
  54720. import { Mesh } from "babylonjs/Meshes/mesh";
  54721. /**
  54722. * Class containing static functions to help procedurally build meshes
  54723. */
  54724. export class TiledBoxBuilder {
  54725. /**
  54726. * Creates a box mesh
  54727. * faceTiles sets the pattern, tile size and number of tiles for a face * * 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)
  54728. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  54729. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54730. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54731. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54732. * @param name defines the name of the mesh
  54733. * @param options defines the options used to create the mesh
  54734. * @param scene defines the hosting scene
  54735. * @returns the box mesh
  54736. */
  54737. static CreateTiledBox(name: string, options: {
  54738. pattern?: number;
  54739. width?: number;
  54740. height?: number;
  54741. depth?: number;
  54742. tileSize?: number;
  54743. tileWidth?: number;
  54744. tileHeight?: number;
  54745. alignHorizontal?: number;
  54746. alignVertical?: number;
  54747. faceUV?: Vector4[];
  54748. faceColors?: Color4[];
  54749. sideOrientation?: number;
  54750. updatable?: boolean;
  54751. }, scene?: Nullable<Scene>): Mesh;
  54752. }
  54753. }
  54754. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  54755. import { Vector4 } from "babylonjs/Maths/math";
  54756. import { Mesh } from "babylonjs/Meshes/mesh";
  54757. /**
  54758. * Class containing static functions to help procedurally build meshes
  54759. */
  54760. export class TorusKnotBuilder {
  54761. /**
  54762. * Creates a torus knot mesh
  54763. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  54764. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  54765. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  54766. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  54767. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54768. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54769. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54770. * @param name defines the name of the mesh
  54771. * @param options defines the options used to create the mesh
  54772. * @param scene defines the hosting scene
  54773. * @returns the torus knot mesh
  54774. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  54775. */
  54776. static CreateTorusKnot(name: string, options: {
  54777. radius?: number;
  54778. tube?: number;
  54779. radialSegments?: number;
  54780. tubularSegments?: number;
  54781. p?: number;
  54782. q?: number;
  54783. updatable?: boolean;
  54784. sideOrientation?: number;
  54785. frontUVs?: Vector4;
  54786. backUVs?: Vector4;
  54787. }, scene: any): Mesh;
  54788. }
  54789. }
  54790. declare module "babylonjs/Meshes/polygonMesh" {
  54791. import { Scene } from "babylonjs/scene";
  54792. import { Vector2, Path2 } from "babylonjs/Maths/math";
  54793. import { Mesh } from "babylonjs/Meshes/mesh";
  54794. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  54795. /**
  54796. * Polygon
  54797. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  54798. */
  54799. export class Polygon {
  54800. /**
  54801. * Creates a rectangle
  54802. * @param xmin bottom X coord
  54803. * @param ymin bottom Y coord
  54804. * @param xmax top X coord
  54805. * @param ymax top Y coord
  54806. * @returns points that make the resulting rectation
  54807. */
  54808. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  54809. /**
  54810. * Creates a circle
  54811. * @param radius radius of circle
  54812. * @param cx scale in x
  54813. * @param cy scale in y
  54814. * @param numberOfSides number of sides that make up the circle
  54815. * @returns points that make the resulting circle
  54816. */
  54817. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  54818. /**
  54819. * Creates a polygon from input string
  54820. * @param input Input polygon data
  54821. * @returns the parsed points
  54822. */
  54823. static Parse(input: string): Vector2[];
  54824. /**
  54825. * Starts building a polygon from x and y coordinates
  54826. * @param x x coordinate
  54827. * @param y y coordinate
  54828. * @returns the started path2
  54829. */
  54830. static StartingAt(x: number, y: number): Path2;
  54831. }
  54832. /**
  54833. * Builds a polygon
  54834. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  54835. */
  54836. export class PolygonMeshBuilder {
  54837. private _points;
  54838. private _outlinepoints;
  54839. private _holes;
  54840. private _name;
  54841. private _scene;
  54842. private _epoints;
  54843. private _eholes;
  54844. private _addToepoint;
  54845. /**
  54846. * Babylon reference to the earcut plugin.
  54847. */
  54848. bjsEarcut: any;
  54849. /**
  54850. * Creates a PolygonMeshBuilder
  54851. * @param name name of the builder
  54852. * @param contours Path of the polygon
  54853. * @param scene scene to add to when creating the mesh
  54854. * @param earcutInjection can be used to inject your own earcut reference
  54855. */
  54856. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  54857. /**
  54858. * Adds a whole within the polygon
  54859. * @param hole Array of points defining the hole
  54860. * @returns this
  54861. */
  54862. addHole(hole: Vector2[]): PolygonMeshBuilder;
  54863. /**
  54864. * Creates the polygon
  54865. * @param updatable If the mesh should be updatable
  54866. * @param depth The depth of the mesh created
  54867. * @returns the created mesh
  54868. */
  54869. build(updatable?: boolean, depth?: number): Mesh;
  54870. /**
  54871. * Creates the polygon
  54872. * @param depth The depth of the mesh created
  54873. * @returns the created VertexData
  54874. */
  54875. buildVertexData(depth?: number): VertexData;
  54876. /**
  54877. * Adds a side to the polygon
  54878. * @param positions points that make the polygon
  54879. * @param normals normals of the polygon
  54880. * @param uvs uvs of the polygon
  54881. * @param indices indices of the polygon
  54882. * @param bounds bounds of the polygon
  54883. * @param points points of the polygon
  54884. * @param depth depth of the polygon
  54885. * @param flip flip of the polygon
  54886. */
  54887. private addSide;
  54888. }
  54889. }
  54890. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  54891. import { Scene } from "babylonjs/scene";
  54892. import { Vector3, Color4, Vector4 } from "babylonjs/Maths/math";
  54893. import { Mesh } from "babylonjs/Meshes/mesh";
  54894. import { Nullable } from "babylonjs/types";
  54895. /**
  54896. * Class containing static functions to help procedurally build meshes
  54897. */
  54898. export class PolygonBuilder {
  54899. /**
  54900. * Creates a polygon mesh
  54901. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  54902. * * 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
  54903. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  54904. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54905. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  54906. * * Remember you can only change the shape positions, not their number when updating a polygon
  54907. * @param name defines the name of the mesh
  54908. * @param options defines the options used to create the mesh
  54909. * @param scene defines the hosting scene
  54910. * @param earcutInjection can be used to inject your own earcut reference
  54911. * @returns the polygon mesh
  54912. */
  54913. static CreatePolygon(name: string, options: {
  54914. shape: Vector3[];
  54915. holes?: Vector3[][];
  54916. depth?: number;
  54917. faceUV?: Vector4[];
  54918. faceColors?: Color4[];
  54919. updatable?: boolean;
  54920. sideOrientation?: number;
  54921. frontUVs?: Vector4;
  54922. backUVs?: Vector4;
  54923. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  54924. /**
  54925. * Creates an extruded polygon mesh, with depth in the Y direction.
  54926. * * 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)
  54927. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  54928. * @param name defines the name of the mesh
  54929. * @param options defines the options used to create the mesh
  54930. * @param scene defines the hosting scene
  54931. * @param earcutInjection can be used to inject your own earcut reference
  54932. * @returns the polygon mesh
  54933. */
  54934. static ExtrudePolygon(name: string, options: {
  54935. shape: Vector3[];
  54936. holes?: Vector3[][];
  54937. depth?: number;
  54938. faceUV?: Vector4[];
  54939. faceColors?: Color4[];
  54940. updatable?: boolean;
  54941. sideOrientation?: number;
  54942. frontUVs?: Vector4;
  54943. backUVs?: Vector4;
  54944. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  54945. }
  54946. }
  54947. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  54948. import { Scene } from "babylonjs/scene";
  54949. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  54950. import { Mesh } from "babylonjs/Meshes/mesh";
  54951. import { Nullable } from "babylonjs/types";
  54952. /**
  54953. * Class containing static functions to help procedurally build meshes
  54954. */
  54955. export class LatheBuilder {
  54956. /**
  54957. * Creates lathe mesh.
  54958. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  54959. * * 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
  54960. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  54961. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  54962. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  54963. * * 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
  54964. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  54965. * * 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
  54966. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54967. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54968. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54969. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54970. * @param name defines the name of the mesh
  54971. * @param options defines the options used to create the mesh
  54972. * @param scene defines the hosting scene
  54973. * @returns the lathe mesh
  54974. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  54975. */
  54976. static CreateLathe(name: string, options: {
  54977. shape: Vector3[];
  54978. radius?: number;
  54979. tessellation?: number;
  54980. clip?: number;
  54981. arc?: number;
  54982. closed?: boolean;
  54983. updatable?: boolean;
  54984. sideOrientation?: number;
  54985. frontUVs?: Vector4;
  54986. backUVs?: Vector4;
  54987. cap?: number;
  54988. invertUV?: boolean;
  54989. }, scene?: Nullable<Scene>): Mesh;
  54990. }
  54991. }
  54992. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  54993. import { Nullable } from "babylonjs/types";
  54994. import { Scene } from "babylonjs/scene";
  54995. import { Vector4 } from "babylonjs/Maths/math";
  54996. import { Mesh } from "babylonjs/Meshes/mesh";
  54997. /**
  54998. * Class containing static functions to help procedurally build meshes
  54999. */
  55000. export class TiledPlaneBuilder {
  55001. /**
  55002. * Creates a tiled plane mesh
  55003. * * The parameter `pattern` will, depending on value, do nothing or
  55004. * * * flip (reflect about central vertical) alternate tiles across and up
  55005. * * * flip every tile on alternate rows
  55006. * * * rotate (180 degs) alternate tiles across and up
  55007. * * * rotate every tile on alternate rows
  55008. * * * flip and rotate alternate tiles across and up
  55009. * * * flip and rotate every tile on alternate rows
  55010. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  55011. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  55012. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55013. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  55014. * * 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)
  55015. * * 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)
  55016. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  55017. * @param name defines the name of the mesh
  55018. * @param options defines the options used to create the mesh
  55019. * @param scene defines the hosting scene
  55020. * @returns the box mesh
  55021. */
  55022. static CreateTiledPlane(name: string, options: {
  55023. pattern?: number;
  55024. tileSize?: number;
  55025. tileWidth?: number;
  55026. tileHeight?: number;
  55027. size?: number;
  55028. width?: number;
  55029. height?: number;
  55030. alignHorizontal?: number;
  55031. alignVertical?: number;
  55032. sideOrientation?: number;
  55033. frontUVs?: Vector4;
  55034. backUVs?: Vector4;
  55035. updatable?: boolean;
  55036. }, scene?: Nullable<Scene>): Mesh;
  55037. }
  55038. }
  55039. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  55040. import { Nullable } from "babylonjs/types";
  55041. import { Scene } from "babylonjs/scene";
  55042. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  55043. import { Mesh } from "babylonjs/Meshes/mesh";
  55044. /**
  55045. * Class containing static functions to help procedurally build meshes
  55046. */
  55047. export class TubeBuilder {
  55048. /**
  55049. * Creates a tube mesh.
  55050. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55051. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  55052. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  55053. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  55054. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  55055. * * 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)
  55056. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  55057. * * 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
  55058. * * 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
  55059. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55060. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55061. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55062. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55063. * @param name defines the name of the mesh
  55064. * @param options defines the options used to create the mesh
  55065. * @param scene defines the hosting scene
  55066. * @returns the tube mesh
  55067. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55068. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  55069. */
  55070. static CreateTube(name: string, options: {
  55071. path: Vector3[];
  55072. radius?: number;
  55073. tessellation?: number;
  55074. radiusFunction?: {
  55075. (i: number, distance: number): number;
  55076. };
  55077. cap?: number;
  55078. arc?: number;
  55079. updatable?: boolean;
  55080. sideOrientation?: number;
  55081. frontUVs?: Vector4;
  55082. backUVs?: Vector4;
  55083. instance?: Mesh;
  55084. invertUV?: boolean;
  55085. }, scene?: Nullable<Scene>): Mesh;
  55086. }
  55087. }
  55088. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  55089. import { Scene } from "babylonjs/scene";
  55090. import { Vector4 } from "babylonjs/Maths/math";
  55091. import { Mesh } from "babylonjs/Meshes/mesh";
  55092. import { Nullable } from "babylonjs/types";
  55093. /**
  55094. * Class containing static functions to help procedurally build meshes
  55095. */
  55096. export class IcoSphereBuilder {
  55097. /**
  55098. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  55099. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  55100. * * 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`)
  55101. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  55102. * * 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
  55103. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55104. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55105. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55106. * @param name defines the name of the mesh
  55107. * @param options defines the options used to create the mesh
  55108. * @param scene defines the hosting scene
  55109. * @returns the icosahedron mesh
  55110. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  55111. */
  55112. static CreateIcoSphere(name: string, options: {
  55113. radius?: number;
  55114. radiusX?: number;
  55115. radiusY?: number;
  55116. radiusZ?: number;
  55117. flat?: boolean;
  55118. subdivisions?: number;
  55119. sideOrientation?: number;
  55120. frontUVs?: Vector4;
  55121. backUVs?: Vector4;
  55122. updatable?: boolean;
  55123. }, scene?: Nullable<Scene>): Mesh;
  55124. }
  55125. }
  55126. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  55127. import { Vector3 } from "babylonjs/Maths/math";
  55128. import { Mesh } from "babylonjs/Meshes/mesh";
  55129. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55130. /**
  55131. * Class containing static functions to help procedurally build meshes
  55132. */
  55133. export class DecalBuilder {
  55134. /**
  55135. * Creates a decal mesh.
  55136. * 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
  55137. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  55138. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  55139. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  55140. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  55141. * @param name defines the name of the mesh
  55142. * @param sourceMesh defines the mesh where the decal must be applied
  55143. * @param options defines the options used to create the mesh
  55144. * @param scene defines the hosting scene
  55145. * @returns the decal mesh
  55146. * @see https://doc.babylonjs.com/how_to/decals
  55147. */
  55148. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  55149. position?: Vector3;
  55150. normal?: Vector3;
  55151. size?: Vector3;
  55152. angle?: number;
  55153. }): Mesh;
  55154. }
  55155. }
  55156. declare module "babylonjs/Meshes/meshBuilder" {
  55157. import { Vector4, Color4, Vector3, Vector2, Plane, Color3 } from "babylonjs/Maths/math";
  55158. import { Nullable } from "babylonjs/types";
  55159. import { Scene } from "babylonjs/scene";
  55160. import { Mesh } from "babylonjs/Meshes/mesh";
  55161. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  55162. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  55163. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55164. /**
  55165. * Class containing static functions to help procedurally build meshes
  55166. */
  55167. export class MeshBuilder {
  55168. /**
  55169. * Creates a box mesh
  55170. * * The parameter `size` sets the size (float) of each box side (default 1)
  55171. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  55172. * * 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)
  55173. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55174. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55175. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55176. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55177. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  55178. * @param name defines the name of the mesh
  55179. * @param options defines the options used to create the mesh
  55180. * @param scene defines the hosting scene
  55181. * @returns the box mesh
  55182. */
  55183. static CreateBox(name: string, options: {
  55184. size?: number;
  55185. width?: number;
  55186. height?: number;
  55187. depth?: number;
  55188. faceUV?: Vector4[];
  55189. faceColors?: Color4[];
  55190. sideOrientation?: number;
  55191. frontUVs?: Vector4;
  55192. backUVs?: Vector4;
  55193. updatable?: boolean;
  55194. }, scene?: Nullable<Scene>): Mesh;
  55195. /**
  55196. * Creates a tiled box mesh
  55197. * * faceTiles sets the pattern, tile size and number of tiles for a face
  55198. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55199. * @param name defines the name of the mesh
  55200. * @param options defines the options used to create the mesh
  55201. * @param scene defines the hosting scene
  55202. * @returns the tiled box mesh
  55203. */
  55204. static CreateTiledBox(name: string, options: {
  55205. pattern?: number;
  55206. size?: number;
  55207. width?: number;
  55208. height?: number;
  55209. depth: number;
  55210. tileSize?: number;
  55211. tileWidth?: number;
  55212. tileHeight?: number;
  55213. faceUV?: Vector4[];
  55214. faceColors?: Color4[];
  55215. alignHorizontal?: number;
  55216. alignVertical?: number;
  55217. sideOrientation?: number;
  55218. updatable?: boolean;
  55219. }, scene?: Nullable<Scene>): Mesh;
  55220. /**
  55221. * Creates a sphere mesh
  55222. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  55223. * * 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`)
  55224. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  55225. * * 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
  55226. * * 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)
  55227. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55228. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55229. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55230. * @param name defines the name of the mesh
  55231. * @param options defines the options used to create the mesh
  55232. * @param scene defines the hosting scene
  55233. * @returns the sphere mesh
  55234. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  55235. */
  55236. static CreateSphere(name: string, options: {
  55237. segments?: number;
  55238. diameter?: number;
  55239. diameterX?: number;
  55240. diameterY?: number;
  55241. diameterZ?: number;
  55242. arc?: number;
  55243. slice?: number;
  55244. sideOrientation?: number;
  55245. frontUVs?: Vector4;
  55246. backUVs?: Vector4;
  55247. updatable?: boolean;
  55248. }, scene?: Nullable<Scene>): Mesh;
  55249. /**
  55250. * Creates a plane polygonal mesh. By default, this is a disc
  55251. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  55252. * * 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
  55253. * * 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
  55254. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55255. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55256. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55257. * @param name defines the name of the mesh
  55258. * @param options defines the options used to create the mesh
  55259. * @param scene defines the hosting scene
  55260. * @returns the plane polygonal mesh
  55261. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  55262. */
  55263. static CreateDisc(name: string, options: {
  55264. radius?: number;
  55265. tessellation?: number;
  55266. arc?: number;
  55267. updatable?: boolean;
  55268. sideOrientation?: number;
  55269. frontUVs?: Vector4;
  55270. backUVs?: Vector4;
  55271. }, scene?: Nullable<Scene>): Mesh;
  55272. /**
  55273. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  55274. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  55275. * * 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`)
  55276. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  55277. * * 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
  55278. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55279. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55280. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55281. * @param name defines the name of the mesh
  55282. * @param options defines the options used to create the mesh
  55283. * @param scene defines the hosting scene
  55284. * @returns the icosahedron mesh
  55285. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  55286. */
  55287. static CreateIcoSphere(name: string, options: {
  55288. radius?: number;
  55289. radiusX?: number;
  55290. radiusY?: number;
  55291. radiusZ?: number;
  55292. flat?: boolean;
  55293. subdivisions?: number;
  55294. sideOrientation?: number;
  55295. frontUVs?: Vector4;
  55296. backUVs?: Vector4;
  55297. updatable?: boolean;
  55298. }, scene?: Nullable<Scene>): Mesh;
  55299. /**
  55300. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55301. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  55302. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  55303. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  55304. * * 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
  55305. * * 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
  55306. * * 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
  55307. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55308. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55309. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55310. * * 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
  55311. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  55312. * * 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
  55313. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  55314. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55315. * @param name defines the name of the mesh
  55316. * @param options defines the options used to create the mesh
  55317. * @param scene defines the hosting scene
  55318. * @returns the ribbon mesh
  55319. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  55320. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55321. */
  55322. static CreateRibbon(name: string, options: {
  55323. pathArray: Vector3[][];
  55324. closeArray?: boolean;
  55325. closePath?: boolean;
  55326. offset?: number;
  55327. updatable?: boolean;
  55328. sideOrientation?: number;
  55329. frontUVs?: Vector4;
  55330. backUVs?: Vector4;
  55331. instance?: Mesh;
  55332. invertUV?: boolean;
  55333. uvs?: Vector2[];
  55334. colors?: Color4[];
  55335. }, scene?: Nullable<Scene>): Mesh;
  55336. /**
  55337. * Creates a cylinder or a cone mesh
  55338. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  55339. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  55340. * * 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.
  55341. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  55342. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  55343. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  55344. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  55345. * * The parameter `cap` sets the way the cylinder is capped. Possible values : BABYLON.Mesh.NO_CAP, BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL (default).
  55346. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  55347. * * 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).
  55348. * * 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
  55349. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  55350. * * 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
  55351. * * 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.
  55352. * * If `enclose` is false, a ring surface is one element.
  55353. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  55354. * * 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
  55355. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55356. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55357. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55358. * @param name defines the name of the mesh
  55359. * @param options defines the options used to create the mesh
  55360. * @param scene defines the hosting scene
  55361. * @returns the cylinder mesh
  55362. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  55363. */
  55364. static CreateCylinder(name: string, options: {
  55365. height?: number;
  55366. diameterTop?: number;
  55367. diameterBottom?: number;
  55368. diameter?: number;
  55369. tessellation?: number;
  55370. subdivisions?: number;
  55371. arc?: number;
  55372. faceColors?: Color4[];
  55373. faceUV?: Vector4[];
  55374. updatable?: boolean;
  55375. hasRings?: boolean;
  55376. enclose?: boolean;
  55377. cap?: number;
  55378. sideOrientation?: number;
  55379. frontUVs?: Vector4;
  55380. backUVs?: Vector4;
  55381. }, scene?: Nullable<Scene>): Mesh;
  55382. /**
  55383. * Creates a torus mesh
  55384. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  55385. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  55386. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  55387. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55388. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55389. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55390. * @param name defines the name of the mesh
  55391. * @param options defines the options used to create the mesh
  55392. * @param scene defines the hosting scene
  55393. * @returns the torus mesh
  55394. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  55395. */
  55396. static CreateTorus(name: string, options: {
  55397. diameter?: number;
  55398. thickness?: number;
  55399. tessellation?: number;
  55400. updatable?: boolean;
  55401. sideOrientation?: number;
  55402. frontUVs?: Vector4;
  55403. backUVs?: Vector4;
  55404. }, scene?: Nullable<Scene>): Mesh;
  55405. /**
  55406. * Creates a torus knot mesh
  55407. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  55408. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  55409. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  55410. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  55411. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55412. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55413. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55414. * @param name defines the name of the mesh
  55415. * @param options defines the options used to create the mesh
  55416. * @param scene defines the hosting scene
  55417. * @returns the torus knot mesh
  55418. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  55419. */
  55420. static CreateTorusKnot(name: string, options: {
  55421. radius?: number;
  55422. tube?: number;
  55423. radialSegments?: number;
  55424. tubularSegments?: number;
  55425. p?: number;
  55426. q?: number;
  55427. updatable?: boolean;
  55428. sideOrientation?: number;
  55429. frontUVs?: Vector4;
  55430. backUVs?: Vector4;
  55431. }, scene?: Nullable<Scene>): Mesh;
  55432. /**
  55433. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  55434. * * 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
  55435. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  55436. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  55437. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  55438. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  55439. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  55440. * * 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
  55441. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  55442. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55443. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  55444. * @param name defines the name of the new line system
  55445. * @param options defines the options used to create the line system
  55446. * @param scene defines the hosting scene
  55447. * @returns a new line system mesh
  55448. */
  55449. static CreateLineSystem(name: string, options: {
  55450. lines: Vector3[][];
  55451. updatable?: boolean;
  55452. instance?: Nullable<LinesMesh>;
  55453. colors?: Nullable<Color4[][]>;
  55454. useVertexAlpha?: boolean;
  55455. }, scene: Nullable<Scene>): LinesMesh;
  55456. /**
  55457. * Creates a line mesh
  55458. * 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
  55459. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  55460. * * The parameter `points` is an array successive Vector3
  55461. * * 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
  55462. * * The optional parameter `colors` is an array of successive Color4, one per line point
  55463. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  55464. * * When updating an instance, remember that only point positions can change, not the number of points
  55465. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55466. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  55467. * @param name defines the name of the new line system
  55468. * @param options defines the options used to create the line system
  55469. * @param scene defines the hosting scene
  55470. * @returns a new line mesh
  55471. */
  55472. static CreateLines(name: string, options: {
  55473. points: Vector3[];
  55474. updatable?: boolean;
  55475. instance?: Nullable<LinesMesh>;
  55476. colors?: Color4[];
  55477. useVertexAlpha?: boolean;
  55478. }, scene?: Nullable<Scene>): LinesMesh;
  55479. /**
  55480. * Creates a dashed line mesh
  55481. * * 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
  55482. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  55483. * * The parameter `points` is an array successive Vector3
  55484. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  55485. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  55486. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  55487. * * 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
  55488. * * When updating an instance, remember that only point positions can change, not the number of points
  55489. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55490. * @param name defines the name of the mesh
  55491. * @param options defines the options used to create the mesh
  55492. * @param scene defines the hosting scene
  55493. * @returns the dashed line mesh
  55494. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  55495. */
  55496. static CreateDashedLines(name: string, options: {
  55497. points: Vector3[];
  55498. dashSize?: number;
  55499. gapSize?: number;
  55500. dashNb?: number;
  55501. updatable?: boolean;
  55502. instance?: LinesMesh;
  55503. }, scene?: Nullable<Scene>): LinesMesh;
  55504. /**
  55505. * 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.
  55506. * * 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.
  55507. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55508. * * 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.
  55509. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  55510. * * 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
  55511. * * 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
  55512. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  55513. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55514. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55515. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  55516. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55517. * @param name defines the name of the mesh
  55518. * @param options defines the options used to create the mesh
  55519. * @param scene defines the hosting scene
  55520. * @returns the extruded shape mesh
  55521. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55522. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55523. */
  55524. static ExtrudeShape(name: string, options: {
  55525. shape: Vector3[];
  55526. path: Vector3[];
  55527. scale?: number;
  55528. rotation?: number;
  55529. cap?: number;
  55530. updatable?: boolean;
  55531. sideOrientation?: number;
  55532. frontUVs?: Vector4;
  55533. backUVs?: Vector4;
  55534. instance?: Mesh;
  55535. invertUV?: boolean;
  55536. }, scene?: Nullable<Scene>): Mesh;
  55537. /**
  55538. * Creates an custom extruded shape mesh.
  55539. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55540. * * 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.
  55541. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55542. * * 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
  55543. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55544. * * 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
  55545. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55546. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55547. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55548. * * 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
  55549. * * 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
  55550. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55551. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55552. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55553. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55554. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55555. * @param name defines the name of the mesh
  55556. * @param options defines the options used to create the mesh
  55557. * @param scene defines the hosting scene
  55558. * @returns the custom extruded shape mesh
  55559. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  55560. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55561. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55562. */
  55563. static ExtrudeShapeCustom(name: string, options: {
  55564. shape: Vector3[];
  55565. path: Vector3[];
  55566. scaleFunction?: any;
  55567. rotationFunction?: any;
  55568. ribbonCloseArray?: boolean;
  55569. ribbonClosePath?: boolean;
  55570. cap?: number;
  55571. updatable?: boolean;
  55572. sideOrientation?: number;
  55573. frontUVs?: Vector4;
  55574. backUVs?: Vector4;
  55575. instance?: Mesh;
  55576. invertUV?: boolean;
  55577. }, scene?: Nullable<Scene>): Mesh;
  55578. /**
  55579. * Creates lathe mesh.
  55580. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  55581. * * 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
  55582. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  55583. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  55584. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  55585. * * 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
  55586. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  55587. * * 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
  55588. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55589. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55590. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55591. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55592. * @param name defines the name of the mesh
  55593. * @param options defines the options used to create the mesh
  55594. * @param scene defines the hosting scene
  55595. * @returns the lathe mesh
  55596. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  55597. */
  55598. static CreateLathe(name: string, options: {
  55599. shape: Vector3[];
  55600. radius?: number;
  55601. tessellation?: number;
  55602. clip?: number;
  55603. arc?: number;
  55604. closed?: boolean;
  55605. updatable?: boolean;
  55606. sideOrientation?: number;
  55607. frontUVs?: Vector4;
  55608. backUVs?: Vector4;
  55609. cap?: number;
  55610. invertUV?: boolean;
  55611. }, scene?: Nullable<Scene>): Mesh;
  55612. /**
  55613. * Creates a tiled plane mesh
  55614. * * You can set a limited pattern arrangement with the tiles
  55615. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55616. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55617. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55618. * @param name defines the name of the mesh
  55619. * @param options defines the options used to create the mesh
  55620. * @param scene defines the hosting scene
  55621. * @returns the plane mesh
  55622. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  55623. */
  55624. static CreateTiledPlane(name: string, options: {
  55625. pattern?: number;
  55626. tileSize?: number;
  55627. tileWidth?: number;
  55628. tileHeight?: number;
  55629. size?: number;
  55630. width?: number;
  55631. height?: number;
  55632. alignHorizontal?: number;
  55633. alignVertical?: number;
  55634. sideOrientation?: number;
  55635. frontUVs?: Vector4;
  55636. backUVs?: Vector4;
  55637. updatable?: boolean;
  55638. }, scene?: Nullable<Scene>): Mesh;
  55639. /**
  55640. * Creates a plane mesh
  55641. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  55642. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  55643. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  55644. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55645. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55646. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55647. * @param name defines the name of the mesh
  55648. * @param options defines the options used to create the mesh
  55649. * @param scene defines the hosting scene
  55650. * @returns the plane mesh
  55651. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  55652. */
  55653. static CreatePlane(name: string, options: {
  55654. size?: number;
  55655. width?: number;
  55656. height?: number;
  55657. sideOrientation?: number;
  55658. frontUVs?: Vector4;
  55659. backUVs?: Vector4;
  55660. updatable?: boolean;
  55661. sourcePlane?: Plane;
  55662. }, scene?: Nullable<Scene>): Mesh;
  55663. /**
  55664. * Creates a ground mesh
  55665. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  55666. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  55667. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55668. * @param name defines the name of the mesh
  55669. * @param options defines the options used to create the mesh
  55670. * @param scene defines the hosting scene
  55671. * @returns the ground mesh
  55672. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  55673. */
  55674. static CreateGround(name: string, options: {
  55675. width?: number;
  55676. height?: number;
  55677. subdivisions?: number;
  55678. subdivisionsX?: number;
  55679. subdivisionsY?: number;
  55680. updatable?: boolean;
  55681. }, scene?: Nullable<Scene>): Mesh;
  55682. /**
  55683. * Creates a tiled ground mesh
  55684. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  55685. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  55686. * * 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
  55687. * * 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
  55688. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55689. * @param name defines the name of the mesh
  55690. * @param options defines the options used to create the mesh
  55691. * @param scene defines the hosting scene
  55692. * @returns the tiled ground mesh
  55693. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  55694. */
  55695. static CreateTiledGround(name: string, options: {
  55696. xmin: number;
  55697. zmin: number;
  55698. xmax: number;
  55699. zmax: number;
  55700. subdivisions?: {
  55701. w: number;
  55702. h: number;
  55703. };
  55704. precision?: {
  55705. w: number;
  55706. h: number;
  55707. };
  55708. updatable?: boolean;
  55709. }, scene?: Nullable<Scene>): Mesh;
  55710. /**
  55711. * Creates a ground mesh from a height map
  55712. * * The parameter `url` sets the URL of the height map image resource.
  55713. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  55714. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  55715. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  55716. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  55717. * * 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.
  55718. * * 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).
  55719. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  55720. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55721. * @param name defines the name of the mesh
  55722. * @param url defines the url to the height map
  55723. * @param options defines the options used to create the mesh
  55724. * @param scene defines the hosting scene
  55725. * @returns the ground mesh
  55726. * @see https://doc.babylonjs.com/babylon101/height_map
  55727. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  55728. */
  55729. static CreateGroundFromHeightMap(name: string, url: string, options: {
  55730. width?: number;
  55731. height?: number;
  55732. subdivisions?: number;
  55733. minHeight?: number;
  55734. maxHeight?: number;
  55735. colorFilter?: Color3;
  55736. alphaFilter?: number;
  55737. updatable?: boolean;
  55738. onReady?: (mesh: GroundMesh) => void;
  55739. }, scene?: Nullable<Scene>): GroundMesh;
  55740. /**
  55741. * Creates a polygon mesh
  55742. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  55743. * * 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
  55744. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  55745. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55746. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  55747. * * Remember you can only change the shape positions, not their number when updating a polygon
  55748. * @param name defines the name of the mesh
  55749. * @param options defines the options used to create the mesh
  55750. * @param scene defines the hosting scene
  55751. * @param earcutInjection can be used to inject your own earcut reference
  55752. * @returns the polygon mesh
  55753. */
  55754. static CreatePolygon(name: string, options: {
  55755. shape: Vector3[];
  55756. holes?: Vector3[][];
  55757. depth?: number;
  55758. faceUV?: Vector4[];
  55759. faceColors?: Color4[];
  55760. updatable?: boolean;
  55761. sideOrientation?: number;
  55762. frontUVs?: Vector4;
  55763. backUVs?: Vector4;
  55764. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55765. /**
  55766. * Creates an extruded polygon mesh, with depth in the Y direction.
  55767. * * 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)
  55768. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55769. * @param name defines the name of the mesh
  55770. * @param options defines the options used to create the mesh
  55771. * @param scene defines the hosting scene
  55772. * @param earcutInjection can be used to inject your own earcut reference
  55773. * @returns the polygon mesh
  55774. */
  55775. static ExtrudePolygon(name: string, options: {
  55776. shape: Vector3[];
  55777. holes?: Vector3[][];
  55778. depth?: number;
  55779. faceUV?: Vector4[];
  55780. faceColors?: Color4[];
  55781. updatable?: boolean;
  55782. sideOrientation?: number;
  55783. frontUVs?: Vector4;
  55784. backUVs?: Vector4;
  55785. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55786. /**
  55787. * Creates a tube mesh.
  55788. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55789. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  55790. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  55791. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  55792. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  55793. * * 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)
  55794. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  55795. * * 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
  55796. * * 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
  55797. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55798. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55799. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55800. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55801. * @param name defines the name of the mesh
  55802. * @param options defines the options used to create the mesh
  55803. * @param scene defines the hosting scene
  55804. * @returns the tube mesh
  55805. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55806. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  55807. */
  55808. static CreateTube(name: string, options: {
  55809. path: Vector3[];
  55810. radius?: number;
  55811. tessellation?: number;
  55812. radiusFunction?: {
  55813. (i: number, distance: number): number;
  55814. };
  55815. cap?: number;
  55816. arc?: number;
  55817. updatable?: boolean;
  55818. sideOrientation?: number;
  55819. frontUVs?: Vector4;
  55820. backUVs?: Vector4;
  55821. instance?: Mesh;
  55822. invertUV?: boolean;
  55823. }, scene?: Nullable<Scene>): Mesh;
  55824. /**
  55825. * Creates a polyhedron mesh
  55826. * * 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
  55827. * * The parameter `size` (positive float, default 1) sets the polygon size
  55828. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  55829. * * 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`
  55830. * * 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
  55831. * * 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)`)
  55832. * * 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
  55833. * * 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
  55834. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55835. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55836. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55837. * @param name defines the name of the mesh
  55838. * @param options defines the options used to create the mesh
  55839. * @param scene defines the hosting scene
  55840. * @returns the polyhedron mesh
  55841. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  55842. */
  55843. static CreatePolyhedron(name: string, options: {
  55844. type?: number;
  55845. size?: number;
  55846. sizeX?: number;
  55847. sizeY?: number;
  55848. sizeZ?: number;
  55849. custom?: any;
  55850. faceUV?: Vector4[];
  55851. faceColors?: Color4[];
  55852. flat?: boolean;
  55853. updatable?: boolean;
  55854. sideOrientation?: number;
  55855. frontUVs?: Vector4;
  55856. backUVs?: Vector4;
  55857. }, scene?: Nullable<Scene>): Mesh;
  55858. /**
  55859. * Creates a decal mesh.
  55860. * 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
  55861. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  55862. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  55863. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  55864. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  55865. * @param name defines the name of the mesh
  55866. * @param sourceMesh defines the mesh where the decal must be applied
  55867. * @param options defines the options used to create the mesh
  55868. * @param scene defines the hosting scene
  55869. * @returns the decal mesh
  55870. * @see https://doc.babylonjs.com/how_to/decals
  55871. */
  55872. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  55873. position?: Vector3;
  55874. normal?: Vector3;
  55875. size?: Vector3;
  55876. angle?: number;
  55877. }): Mesh;
  55878. }
  55879. }
  55880. declare module "babylonjs/Meshes/meshSimplification" {
  55881. import { Mesh } from "babylonjs/Meshes/mesh";
  55882. /**
  55883. * A simplifier interface for future simplification implementations
  55884. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55885. */
  55886. export interface ISimplifier {
  55887. /**
  55888. * Simplification of a given mesh according to the given settings.
  55889. * Since this requires computation, it is assumed that the function runs async.
  55890. * @param settings The settings of the simplification, including quality and distance
  55891. * @param successCallback A callback that will be called after the mesh was simplified.
  55892. * @param errorCallback in case of an error, this callback will be called. optional.
  55893. */
  55894. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  55895. }
  55896. /**
  55897. * Expected simplification settings.
  55898. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  55899. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55900. */
  55901. export interface ISimplificationSettings {
  55902. /**
  55903. * Gets or sets the expected quality
  55904. */
  55905. quality: number;
  55906. /**
  55907. * Gets or sets the distance when this optimized version should be used
  55908. */
  55909. distance: number;
  55910. /**
  55911. * Gets an already optimized mesh
  55912. */
  55913. optimizeMesh?: boolean;
  55914. }
  55915. /**
  55916. * Class used to specify simplification options
  55917. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55918. */
  55919. export class SimplificationSettings implements ISimplificationSettings {
  55920. /** expected quality */
  55921. quality: number;
  55922. /** distance when this optimized version should be used */
  55923. distance: number;
  55924. /** already optimized mesh */
  55925. optimizeMesh?: boolean | undefined;
  55926. /**
  55927. * Creates a SimplificationSettings
  55928. * @param quality expected quality
  55929. * @param distance distance when this optimized version should be used
  55930. * @param optimizeMesh already optimized mesh
  55931. */
  55932. constructor(
  55933. /** expected quality */
  55934. quality: number,
  55935. /** distance when this optimized version should be used */
  55936. distance: number,
  55937. /** already optimized mesh */
  55938. optimizeMesh?: boolean | undefined);
  55939. }
  55940. /**
  55941. * Interface used to define a simplification task
  55942. */
  55943. export interface ISimplificationTask {
  55944. /**
  55945. * Array of settings
  55946. */
  55947. settings: Array<ISimplificationSettings>;
  55948. /**
  55949. * Simplification type
  55950. */
  55951. simplificationType: SimplificationType;
  55952. /**
  55953. * Mesh to simplify
  55954. */
  55955. mesh: Mesh;
  55956. /**
  55957. * Callback called on success
  55958. */
  55959. successCallback?: () => void;
  55960. /**
  55961. * Defines if parallel processing can be used
  55962. */
  55963. parallelProcessing: boolean;
  55964. }
  55965. /**
  55966. * Queue used to order the simplification tasks
  55967. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55968. */
  55969. export class SimplificationQueue {
  55970. private _simplificationArray;
  55971. /**
  55972. * Gets a boolean indicating that the process is still running
  55973. */
  55974. running: boolean;
  55975. /**
  55976. * Creates a new queue
  55977. */
  55978. constructor();
  55979. /**
  55980. * Adds a new simplification task
  55981. * @param task defines a task to add
  55982. */
  55983. addTask(task: ISimplificationTask): void;
  55984. /**
  55985. * Execute next task
  55986. */
  55987. executeNext(): void;
  55988. /**
  55989. * Execute a simplification task
  55990. * @param task defines the task to run
  55991. */
  55992. runSimplification(task: ISimplificationTask): void;
  55993. private getSimplifier;
  55994. }
  55995. /**
  55996. * The implemented types of simplification
  55997. * At the moment only Quadratic Error Decimation is implemented
  55998. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55999. */
  56000. export enum SimplificationType {
  56001. /** Quadratic error decimation */
  56002. QUADRATIC = 0
  56003. }
  56004. }
  56005. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  56006. import { Scene } from "babylonjs/scene";
  56007. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  56008. import { ISceneComponent } from "babylonjs/sceneComponent";
  56009. module "babylonjs/scene" {
  56010. interface Scene {
  56011. /** @hidden (Backing field) */
  56012. _simplificationQueue: SimplificationQueue;
  56013. /**
  56014. * Gets or sets the simplification queue attached to the scene
  56015. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56016. */
  56017. simplificationQueue: SimplificationQueue;
  56018. }
  56019. }
  56020. module "babylonjs/Meshes/mesh" {
  56021. interface Mesh {
  56022. /**
  56023. * Simplify the mesh according to the given array of settings.
  56024. * Function will return immediately and will simplify async
  56025. * @param settings a collection of simplification settings
  56026. * @param parallelProcessing should all levels calculate parallel or one after the other
  56027. * @param simplificationType the type of simplification to run
  56028. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  56029. * @returns the current mesh
  56030. */
  56031. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  56032. }
  56033. }
  56034. /**
  56035. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  56036. * created in a scene
  56037. */
  56038. export class SimplicationQueueSceneComponent implements ISceneComponent {
  56039. /**
  56040. * The component name helpfull to identify the component in the list of scene components.
  56041. */
  56042. readonly name: string;
  56043. /**
  56044. * The scene the component belongs to.
  56045. */
  56046. scene: Scene;
  56047. /**
  56048. * Creates a new instance of the component for the given scene
  56049. * @param scene Defines the scene to register the component in
  56050. */
  56051. constructor(scene: Scene);
  56052. /**
  56053. * Registers the component in a given scene
  56054. */
  56055. register(): void;
  56056. /**
  56057. * Rebuilds the elements related to this component in case of
  56058. * context lost for instance.
  56059. */
  56060. rebuild(): void;
  56061. /**
  56062. * Disposes the component and the associated ressources
  56063. */
  56064. dispose(): void;
  56065. private _beforeCameraUpdate;
  56066. }
  56067. }
  56068. declare module "babylonjs/Meshes/Builders/index" {
  56069. export * from "babylonjs/Meshes/Builders/boxBuilder";
  56070. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  56071. export * from "babylonjs/Meshes/Builders/discBuilder";
  56072. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  56073. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  56074. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  56075. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  56076. export * from "babylonjs/Meshes/Builders/torusBuilder";
  56077. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  56078. export * from "babylonjs/Meshes/Builders/linesBuilder";
  56079. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  56080. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  56081. export * from "babylonjs/Meshes/Builders/latheBuilder";
  56082. export * from "babylonjs/Meshes/Builders/planeBuilder";
  56083. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  56084. export * from "babylonjs/Meshes/Builders/groundBuilder";
  56085. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  56086. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  56087. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  56088. export * from "babylonjs/Meshes/Builders/decalBuilder";
  56089. }
  56090. declare module "babylonjs/Meshes/index" {
  56091. export * from "babylonjs/Meshes/abstractMesh";
  56092. export * from "babylonjs/Meshes/buffer";
  56093. export * from "babylonjs/Meshes/Compression/index";
  56094. export * from "babylonjs/Meshes/csg";
  56095. export * from "babylonjs/Meshes/geometry";
  56096. export * from "babylonjs/Meshes/groundMesh";
  56097. export * from "babylonjs/Meshes/trailMesh";
  56098. export * from "babylonjs/Meshes/instancedMesh";
  56099. export * from "babylonjs/Meshes/linesMesh";
  56100. export * from "babylonjs/Meshes/mesh";
  56101. export * from "babylonjs/Meshes/mesh.vertexData";
  56102. export * from "babylonjs/Meshes/meshBuilder";
  56103. export * from "babylonjs/Meshes/meshSimplification";
  56104. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  56105. export * from "babylonjs/Meshes/polygonMesh";
  56106. export * from "babylonjs/Meshes/subMesh";
  56107. export * from "babylonjs/Meshes/meshLODLevel";
  56108. export * from "babylonjs/Meshes/transformNode";
  56109. export * from "babylonjs/Meshes/Builders/index";
  56110. export * from "babylonjs/Meshes/dataBuffer";
  56111. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  56112. }
  56113. declare module "babylonjs/Morph/index" {
  56114. export * from "babylonjs/Morph/morphTarget";
  56115. export * from "babylonjs/Morph/morphTargetManager";
  56116. }
  56117. declare module "babylonjs/Offline/database" {
  56118. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  56119. /**
  56120. * Class used to enable access to IndexedDB
  56121. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  56122. */
  56123. export class Database implements IOfflineProvider {
  56124. private _callbackManifestChecked;
  56125. private _currentSceneUrl;
  56126. private _db;
  56127. private _enableSceneOffline;
  56128. private _enableTexturesOffline;
  56129. private _manifestVersionFound;
  56130. private _mustUpdateRessources;
  56131. private _hasReachedQuota;
  56132. private _isSupported;
  56133. private _idbFactory;
  56134. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  56135. private static IsUASupportingBlobStorage;
  56136. /**
  56137. * Gets a boolean indicating if Database storate is enabled (off by default)
  56138. */
  56139. static IDBStorageEnabled: boolean;
  56140. /**
  56141. * Gets a boolean indicating if scene must be saved in the database
  56142. */
  56143. readonly enableSceneOffline: boolean;
  56144. /**
  56145. * Gets a boolean indicating if textures must be saved in the database
  56146. */
  56147. readonly enableTexturesOffline: boolean;
  56148. /**
  56149. * Creates a new Database
  56150. * @param urlToScene defines the url to load the scene
  56151. * @param callbackManifestChecked defines the callback to use when manifest is checked
  56152. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  56153. */
  56154. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  56155. private static _ParseURL;
  56156. private static _ReturnFullUrlLocation;
  56157. private _checkManifestFile;
  56158. /**
  56159. * Open the database and make it available
  56160. * @param successCallback defines the callback to call on success
  56161. * @param errorCallback defines the callback to call on error
  56162. */
  56163. open(successCallback: () => void, errorCallback: () => void): void;
  56164. /**
  56165. * Loads an image from the database
  56166. * @param url defines the url to load from
  56167. * @param image defines the target DOM image
  56168. */
  56169. loadImage(url: string, image: HTMLImageElement): void;
  56170. private _loadImageFromDBAsync;
  56171. private _saveImageIntoDBAsync;
  56172. private _checkVersionFromDB;
  56173. private _loadVersionFromDBAsync;
  56174. private _saveVersionIntoDBAsync;
  56175. /**
  56176. * Loads a file from database
  56177. * @param url defines the URL to load from
  56178. * @param sceneLoaded defines a callback to call on success
  56179. * @param progressCallBack defines a callback to call when progress changed
  56180. * @param errorCallback defines a callback to call on error
  56181. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  56182. */
  56183. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  56184. private _loadFileAsync;
  56185. private _saveFileAsync;
  56186. /**
  56187. * Validates if xhr data is correct
  56188. * @param xhr defines the request to validate
  56189. * @param dataType defines the expected data type
  56190. * @returns true if data is correct
  56191. */
  56192. private static _ValidateXHRData;
  56193. }
  56194. }
  56195. declare module "babylonjs/Offline/index" {
  56196. export * from "babylonjs/Offline/database";
  56197. export * from "babylonjs/Offline/IOfflineProvider";
  56198. }
  56199. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  56200. /** @hidden */
  56201. export var gpuUpdateParticlesPixelShader: {
  56202. name: string;
  56203. shader: string;
  56204. };
  56205. }
  56206. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  56207. /** @hidden */
  56208. export var gpuUpdateParticlesVertexShader: {
  56209. name: string;
  56210. shader: string;
  56211. };
  56212. }
  56213. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  56214. /** @hidden */
  56215. export var clipPlaneFragmentDeclaration2: {
  56216. name: string;
  56217. shader: string;
  56218. };
  56219. }
  56220. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  56221. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  56222. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  56223. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56224. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  56225. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  56226. /** @hidden */
  56227. export var gpuRenderParticlesPixelShader: {
  56228. name: string;
  56229. shader: string;
  56230. };
  56231. }
  56232. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  56233. /** @hidden */
  56234. export var clipPlaneVertexDeclaration2: {
  56235. name: string;
  56236. shader: string;
  56237. };
  56238. }
  56239. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  56240. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  56241. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  56242. /** @hidden */
  56243. export var gpuRenderParticlesVertexShader: {
  56244. name: string;
  56245. shader: string;
  56246. };
  56247. }
  56248. declare module "babylonjs/Particles/gpuParticleSystem" {
  56249. import { Nullable } from "babylonjs/types";
  56250. import { IAnimatable, IValueGradient, Color3Gradient } from "babylonjs/Misc/tools";
  56251. import { Observable } from "babylonjs/Misc/observable";
  56252. import { Color4, Color3 } from "babylonjs/Maths/math";
  56253. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  56254. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  56255. import { Scene, IDisposable } from "babylonjs/scene";
  56256. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  56257. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  56258. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  56259. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  56260. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  56261. /**
  56262. * This represents a GPU particle system in Babylon
  56263. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  56264. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  56265. */
  56266. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  56267. /**
  56268. * The layer mask we are rendering the particles through.
  56269. */
  56270. layerMask: number;
  56271. private _capacity;
  56272. private _activeCount;
  56273. private _currentActiveCount;
  56274. private _accumulatedCount;
  56275. private _renderEffect;
  56276. private _updateEffect;
  56277. private _buffer0;
  56278. private _buffer1;
  56279. private _spriteBuffer;
  56280. private _updateVAO;
  56281. private _renderVAO;
  56282. private _targetIndex;
  56283. private _sourceBuffer;
  56284. private _targetBuffer;
  56285. private _engine;
  56286. private _currentRenderId;
  56287. private _started;
  56288. private _stopped;
  56289. private _timeDelta;
  56290. private _randomTexture;
  56291. private _randomTexture2;
  56292. private _attributesStrideSize;
  56293. private _updateEffectOptions;
  56294. private _randomTextureSize;
  56295. private _actualFrame;
  56296. private readonly _rawTextureWidth;
  56297. /**
  56298. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  56299. */
  56300. static readonly IsSupported: boolean;
  56301. /**
  56302. * An event triggered when the system is disposed.
  56303. */
  56304. onDisposeObservable: Observable<GPUParticleSystem>;
  56305. /**
  56306. * Gets the maximum number of particles active at the same time.
  56307. * @returns The max number of active particles.
  56308. */
  56309. getCapacity(): number;
  56310. /**
  56311. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  56312. * to override the particles.
  56313. */
  56314. forceDepthWrite: boolean;
  56315. /**
  56316. * Gets or set the number of active particles
  56317. */
  56318. activeParticleCount: number;
  56319. private _preWarmDone;
  56320. /**
  56321. * Is this system ready to be used/rendered
  56322. * @return true if the system is ready
  56323. */
  56324. isReady(): boolean;
  56325. /**
  56326. * Gets if the system has been started. (Note: this will still be true after stop is called)
  56327. * @returns True if it has been started, otherwise false.
  56328. */
  56329. isStarted(): boolean;
  56330. /**
  56331. * Starts the particle system and begins to emit
  56332. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  56333. */
  56334. start(delay?: number): void;
  56335. /**
  56336. * Stops the particle system.
  56337. */
  56338. stop(): void;
  56339. /**
  56340. * Remove all active particles
  56341. */
  56342. reset(): void;
  56343. /**
  56344. * Returns the string "GPUParticleSystem"
  56345. * @returns a string containing the class name
  56346. */
  56347. getClassName(): string;
  56348. private _colorGradientsTexture;
  56349. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  56350. /**
  56351. * Adds a new color gradient
  56352. * @param gradient defines the gradient to use (between 0 and 1)
  56353. * @param color1 defines the color to affect to the specified gradient
  56354. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  56355. * @returns the current particle system
  56356. */
  56357. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  56358. /**
  56359. * Remove a specific color gradient
  56360. * @param gradient defines the gradient to remove
  56361. * @returns the current particle system
  56362. */
  56363. removeColorGradient(gradient: number): GPUParticleSystem;
  56364. private _angularSpeedGradientsTexture;
  56365. private _sizeGradientsTexture;
  56366. private _velocityGradientsTexture;
  56367. private _limitVelocityGradientsTexture;
  56368. private _dragGradientsTexture;
  56369. private _addFactorGradient;
  56370. /**
  56371. * Adds a new size gradient
  56372. * @param gradient defines the gradient to use (between 0 and 1)
  56373. * @param factor defines the size factor to affect to the specified gradient
  56374. * @returns the current particle system
  56375. */
  56376. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  56377. /**
  56378. * Remove a specific size gradient
  56379. * @param gradient defines the gradient to remove
  56380. * @returns the current particle system
  56381. */
  56382. removeSizeGradient(gradient: number): GPUParticleSystem;
  56383. /**
  56384. * Adds a new angular speed gradient
  56385. * @param gradient defines the gradient to use (between 0 and 1)
  56386. * @param factor defines the angular speed to affect to the specified gradient
  56387. * @returns the current particle system
  56388. */
  56389. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  56390. /**
  56391. * Remove a specific angular speed gradient
  56392. * @param gradient defines the gradient to remove
  56393. * @returns the current particle system
  56394. */
  56395. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  56396. /**
  56397. * Adds a new velocity gradient
  56398. * @param gradient defines the gradient to use (between 0 and 1)
  56399. * @param factor defines the velocity to affect to the specified gradient
  56400. * @returns the current particle system
  56401. */
  56402. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  56403. /**
  56404. * Remove a specific velocity gradient
  56405. * @param gradient defines the gradient to remove
  56406. * @returns the current particle system
  56407. */
  56408. removeVelocityGradient(gradient: number): GPUParticleSystem;
  56409. /**
  56410. * Adds a new limit velocity gradient
  56411. * @param gradient defines the gradient to use (between 0 and 1)
  56412. * @param factor defines the limit velocity value to affect to the specified gradient
  56413. * @returns the current particle system
  56414. */
  56415. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  56416. /**
  56417. * Remove a specific limit velocity gradient
  56418. * @param gradient defines the gradient to remove
  56419. * @returns the current particle system
  56420. */
  56421. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  56422. /**
  56423. * Adds a new drag gradient
  56424. * @param gradient defines the gradient to use (between 0 and 1)
  56425. * @param factor defines the drag value to affect to the specified gradient
  56426. * @returns the current particle system
  56427. */
  56428. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  56429. /**
  56430. * Remove a specific drag gradient
  56431. * @param gradient defines the gradient to remove
  56432. * @returns the current particle system
  56433. */
  56434. removeDragGradient(gradient: number): GPUParticleSystem;
  56435. /**
  56436. * Not supported by GPUParticleSystem
  56437. * @param gradient defines the gradient to use (between 0 and 1)
  56438. * @param factor defines the emit rate value to affect to the specified gradient
  56439. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  56440. * @returns the current particle system
  56441. */
  56442. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  56443. /**
  56444. * Not supported by GPUParticleSystem
  56445. * @param gradient defines the gradient to remove
  56446. * @returns the current particle system
  56447. */
  56448. removeEmitRateGradient(gradient: number): IParticleSystem;
  56449. /**
  56450. * Not supported by GPUParticleSystem
  56451. * @param gradient defines the gradient to use (between 0 and 1)
  56452. * @param factor defines the start size value to affect to the specified gradient
  56453. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  56454. * @returns the current particle system
  56455. */
  56456. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  56457. /**
  56458. * Not supported by GPUParticleSystem
  56459. * @param gradient defines the gradient to remove
  56460. * @returns the current particle system
  56461. */
  56462. removeStartSizeGradient(gradient: number): IParticleSystem;
  56463. /**
  56464. * Not supported by GPUParticleSystem
  56465. * @param gradient defines the gradient to use (between 0 and 1)
  56466. * @param min defines the color remap minimal range
  56467. * @param max defines the color remap maximal range
  56468. * @returns the current particle system
  56469. */
  56470. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  56471. /**
  56472. * Not supported by GPUParticleSystem
  56473. * @param gradient defines the gradient to remove
  56474. * @returns the current particle system
  56475. */
  56476. removeColorRemapGradient(): IParticleSystem;
  56477. /**
  56478. * Not supported by GPUParticleSystem
  56479. * @param gradient defines the gradient to use (between 0 and 1)
  56480. * @param min defines the alpha remap minimal range
  56481. * @param max defines the alpha remap maximal range
  56482. * @returns the current particle system
  56483. */
  56484. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  56485. /**
  56486. * Not supported by GPUParticleSystem
  56487. * @param gradient defines the gradient to remove
  56488. * @returns the current particle system
  56489. */
  56490. removeAlphaRemapGradient(): IParticleSystem;
  56491. /**
  56492. * Not supported by GPUParticleSystem
  56493. * @param gradient defines the gradient to use (between 0 and 1)
  56494. * @param color defines the color to affect to the specified gradient
  56495. * @returns the current particle system
  56496. */
  56497. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  56498. /**
  56499. * Not supported by GPUParticleSystem
  56500. * @param gradient defines the gradient to remove
  56501. * @returns the current particle system
  56502. */
  56503. removeRampGradient(): IParticleSystem;
  56504. /**
  56505. * Not supported by GPUParticleSystem
  56506. * @returns the list of ramp gradients
  56507. */
  56508. getRampGradients(): Nullable<Array<Color3Gradient>>;
  56509. /**
  56510. * Not supported by GPUParticleSystem
  56511. * Gets or sets a boolean indicating that ramp gradients must be used
  56512. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  56513. */
  56514. useRampGradients: boolean;
  56515. /**
  56516. * Not supported by GPUParticleSystem
  56517. * @param gradient defines the gradient to use (between 0 and 1)
  56518. * @param factor defines the life time factor to affect to the specified gradient
  56519. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  56520. * @returns the current particle system
  56521. */
  56522. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  56523. /**
  56524. * Not supported by GPUParticleSystem
  56525. * @param gradient defines the gradient to remove
  56526. * @returns the current particle system
  56527. */
  56528. removeLifeTimeGradient(gradient: number): IParticleSystem;
  56529. /**
  56530. * Instantiates a GPU particle system.
  56531. * 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.
  56532. * @param name The name of the particle system
  56533. * @param options The options used to create the system
  56534. * @param scene The scene the particle system belongs to
  56535. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  56536. */
  56537. constructor(name: string, options: Partial<{
  56538. capacity: number;
  56539. randomTextureSize: number;
  56540. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  56541. protected _reset(): void;
  56542. private _createUpdateVAO;
  56543. private _createRenderVAO;
  56544. private _initialize;
  56545. /** @hidden */
  56546. _recreateUpdateEffect(): void;
  56547. /** @hidden */
  56548. _recreateRenderEffect(): void;
  56549. /**
  56550. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  56551. * @param preWarm defines if we are in the pre-warmimg phase
  56552. */
  56553. animate(preWarm?: boolean): void;
  56554. private _createFactorGradientTexture;
  56555. private _createSizeGradientTexture;
  56556. private _createAngularSpeedGradientTexture;
  56557. private _createVelocityGradientTexture;
  56558. private _createLimitVelocityGradientTexture;
  56559. private _createDragGradientTexture;
  56560. private _createColorGradientTexture;
  56561. /**
  56562. * Renders the particle system in its current state
  56563. * @param preWarm defines if the system should only update the particles but not render them
  56564. * @returns the current number of particles
  56565. */
  56566. render(preWarm?: boolean): number;
  56567. /**
  56568. * Rebuilds the particle system
  56569. */
  56570. rebuild(): void;
  56571. private _releaseBuffers;
  56572. private _releaseVAOs;
  56573. /**
  56574. * Disposes the particle system and free the associated resources
  56575. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  56576. */
  56577. dispose(disposeTexture?: boolean): void;
  56578. /**
  56579. * Clones the particle system.
  56580. * @param name The name of the cloned object
  56581. * @param newEmitter The new emitter to use
  56582. * @returns the cloned particle system
  56583. */
  56584. clone(name: string, newEmitter: any): GPUParticleSystem;
  56585. /**
  56586. * Serializes the particle system to a JSON object.
  56587. * @returns the JSON object
  56588. */
  56589. serialize(): any;
  56590. /**
  56591. * Parses a JSON object to create a GPU particle system.
  56592. * @param parsedParticleSystem The JSON object to parse
  56593. * @param scene The scene to create the particle system in
  56594. * @param rootUrl The root url to use to load external dependencies like texture
  56595. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  56596. * @returns the parsed GPU particle system
  56597. */
  56598. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  56599. }
  56600. }
  56601. declare module "babylonjs/Particles/particleSystemSet" {
  56602. import { Nullable } from "babylonjs/types";
  56603. import { Color3 } from "babylonjs/Maths/math";
  56604. import { TransformNode } from "babylonjs/Meshes/transformNode";
  56605. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56606. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  56607. import { Scene, IDisposable } from "babylonjs/scene";
  56608. /**
  56609. * Represents a set of particle systems working together to create a specific effect
  56610. */
  56611. export class ParticleSystemSet implements IDisposable {
  56612. private _emitterCreationOptions;
  56613. private _emitterNode;
  56614. /**
  56615. * Gets the particle system list
  56616. */
  56617. systems: IParticleSystem[];
  56618. /**
  56619. * Gets the emitter node used with this set
  56620. */
  56621. readonly emitterNode: Nullable<TransformNode>;
  56622. /**
  56623. * Creates a new emitter mesh as a sphere
  56624. * @param options defines the options used to create the sphere
  56625. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  56626. * @param scene defines the hosting scene
  56627. */
  56628. setEmitterAsSphere(options: {
  56629. diameter: number;
  56630. segments: number;
  56631. color: Color3;
  56632. }, renderingGroupId: number, scene: Scene): void;
  56633. /**
  56634. * Starts all particle systems of the set
  56635. * @param emitter defines an optional mesh to use as emitter for the particle systems
  56636. */
  56637. start(emitter?: AbstractMesh): void;
  56638. /**
  56639. * Release all associated resources
  56640. */
  56641. dispose(): void;
  56642. /**
  56643. * Serialize the set into a JSON compatible object
  56644. * @returns a JSON compatible representation of the set
  56645. */
  56646. serialize(): any;
  56647. /**
  56648. * Parse a new ParticleSystemSet from a serialized source
  56649. * @param data defines a JSON compatible representation of the set
  56650. * @param scene defines the hosting scene
  56651. * @param gpu defines if we want GPU particles or CPU particles
  56652. * @returns a new ParticleSystemSet
  56653. */
  56654. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  56655. }
  56656. }
  56657. declare module "babylonjs/Particles/particleHelper" {
  56658. import { Nullable } from "babylonjs/types";
  56659. import { Scene } from "babylonjs/scene";
  56660. import { Vector3 } from "babylonjs/Maths/math";
  56661. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56662. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  56663. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  56664. /**
  56665. * This class is made for on one-liner static method to help creating particle system set.
  56666. */
  56667. export class ParticleHelper {
  56668. /**
  56669. * Gets or sets base Assets URL
  56670. */
  56671. static BaseAssetsUrl: string;
  56672. /**
  56673. * Create a default particle system that you can tweak
  56674. * @param emitter defines the emitter to use
  56675. * @param capacity defines the system capacity (default is 500 particles)
  56676. * @param scene defines the hosting scene
  56677. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  56678. * @returns the new Particle system
  56679. */
  56680. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  56681. /**
  56682. * This is the main static method (one-liner) of this helper to create different particle systems
  56683. * @param type This string represents the type to the particle system to create
  56684. * @param scene The scene where the particle system should live
  56685. * @param gpu If the system will use gpu
  56686. * @returns the ParticleSystemSet created
  56687. */
  56688. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  56689. /**
  56690. * Static function used to export a particle system to a ParticleSystemSet variable.
  56691. * Please note that the emitter shape is not exported
  56692. * @param systems defines the particle systems to export
  56693. * @returns the created particle system set
  56694. */
  56695. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  56696. }
  56697. }
  56698. declare module "babylonjs/Particles/particleSystemComponent" {
  56699. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  56700. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  56701. import "babylonjs/Shaders/particles.vertex";
  56702. module "babylonjs/Engines/engine" {
  56703. interface Engine {
  56704. /**
  56705. * Create an effect to use with particle systems.
  56706. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  56707. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  56708. * @param uniformsNames defines a list of attribute names
  56709. * @param samplers defines an array of string used to represent textures
  56710. * @param defines defines the string containing the defines to use to compile the shaders
  56711. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  56712. * @param onCompiled defines a function to call when the effect creation is successful
  56713. * @param onError defines a function to call when the effect creation has failed
  56714. * @returns the new Effect
  56715. */
  56716. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  56717. }
  56718. }
  56719. module "babylonjs/Meshes/mesh" {
  56720. interface Mesh {
  56721. /**
  56722. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  56723. * @returns an array of IParticleSystem
  56724. */
  56725. getEmittedParticleSystems(): IParticleSystem[];
  56726. /**
  56727. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  56728. * @returns an array of IParticleSystem
  56729. */
  56730. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  56731. }
  56732. }
  56733. /**
  56734. * @hidden
  56735. */
  56736. export var _IDoNeedToBeInTheBuild: number;
  56737. }
  56738. declare module "babylonjs/Particles/index" {
  56739. export * from "babylonjs/Particles/baseParticleSystem";
  56740. export * from "babylonjs/Particles/EmitterTypes/index";
  56741. export * from "babylonjs/Particles/gpuParticleSystem";
  56742. export * from "babylonjs/Particles/IParticleSystem";
  56743. export * from "babylonjs/Particles/particle";
  56744. export * from "babylonjs/Particles/particleHelper";
  56745. export * from "babylonjs/Particles/particleSystem";
  56746. export * from "babylonjs/Particles/particleSystemComponent";
  56747. export * from "babylonjs/Particles/particleSystemSet";
  56748. export * from "babylonjs/Particles/solidParticle";
  56749. export * from "babylonjs/Particles/solidParticleSystem";
  56750. export * from "babylonjs/Particles/subEmitter";
  56751. }
  56752. declare module "babylonjs/Physics/physicsEngineComponent" {
  56753. import { Nullable } from "babylonjs/types";
  56754. import { Observable, Observer } from "babylonjs/Misc/observable";
  56755. import { Vector3 } from "babylonjs/Maths/math";
  56756. import { Mesh } from "babylonjs/Meshes/mesh";
  56757. import { ISceneComponent } from "babylonjs/sceneComponent";
  56758. import { Scene } from "babylonjs/scene";
  56759. import { Node } from "babylonjs/node";
  56760. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  56761. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  56762. module "babylonjs/scene" {
  56763. interface Scene {
  56764. /** @hidden (Backing field) */
  56765. _physicsEngine: Nullable<IPhysicsEngine>;
  56766. /**
  56767. * Gets the current physics engine
  56768. * @returns a IPhysicsEngine or null if none attached
  56769. */
  56770. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  56771. /**
  56772. * Enables physics to the current scene
  56773. * @param gravity defines the scene's gravity for the physics engine
  56774. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  56775. * @return a boolean indicating if the physics engine was initialized
  56776. */
  56777. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  56778. /**
  56779. * Disables and disposes the physics engine associated with the scene
  56780. */
  56781. disablePhysicsEngine(): void;
  56782. /**
  56783. * Gets a boolean indicating if there is an active physics engine
  56784. * @returns a boolean indicating if there is an active physics engine
  56785. */
  56786. isPhysicsEnabled(): boolean;
  56787. /**
  56788. * Deletes a physics compound impostor
  56789. * @param compound defines the compound to delete
  56790. */
  56791. deleteCompoundImpostor(compound: any): void;
  56792. /**
  56793. * An event triggered when physic simulation is about to be run
  56794. */
  56795. onBeforePhysicsObservable: Observable<Scene>;
  56796. /**
  56797. * An event triggered when physic simulation has been done
  56798. */
  56799. onAfterPhysicsObservable: Observable<Scene>;
  56800. }
  56801. }
  56802. module "babylonjs/Meshes/abstractMesh" {
  56803. interface AbstractMesh {
  56804. /** @hidden */
  56805. _physicsImpostor: Nullable<PhysicsImpostor>;
  56806. /**
  56807. * Gets or sets impostor used for physic simulation
  56808. * @see http://doc.babylonjs.com/features/physics_engine
  56809. */
  56810. physicsImpostor: Nullable<PhysicsImpostor>;
  56811. /**
  56812. * Gets the current physics impostor
  56813. * @see http://doc.babylonjs.com/features/physics_engine
  56814. * @returns a physics impostor or null
  56815. */
  56816. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  56817. /** Apply a physic impulse to the mesh
  56818. * @param force defines the force to apply
  56819. * @param contactPoint defines where to apply the force
  56820. * @returns the current mesh
  56821. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  56822. */
  56823. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  56824. /**
  56825. * Creates a physic joint between two meshes
  56826. * @param otherMesh defines the other mesh to use
  56827. * @param pivot1 defines the pivot to use on this mesh
  56828. * @param pivot2 defines the pivot to use on the other mesh
  56829. * @param options defines additional options (can be plugin dependent)
  56830. * @returns the current mesh
  56831. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  56832. */
  56833. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  56834. /** @hidden */
  56835. _disposePhysicsObserver: Nullable<Observer<Node>>;
  56836. }
  56837. }
  56838. /**
  56839. * Defines the physics engine scene component responsible to manage a physics engine
  56840. */
  56841. export class PhysicsEngineSceneComponent implements ISceneComponent {
  56842. /**
  56843. * The component name helpful to identify the component in the list of scene components.
  56844. */
  56845. readonly name: string;
  56846. /**
  56847. * The scene the component belongs to.
  56848. */
  56849. scene: Scene;
  56850. /**
  56851. * Creates a new instance of the component for the given scene
  56852. * @param scene Defines the scene to register the component in
  56853. */
  56854. constructor(scene: Scene);
  56855. /**
  56856. * Registers the component in a given scene
  56857. */
  56858. register(): void;
  56859. /**
  56860. * Rebuilds the elements related to this component in case of
  56861. * context lost for instance.
  56862. */
  56863. rebuild(): void;
  56864. /**
  56865. * Disposes the component and the associated ressources
  56866. */
  56867. dispose(): void;
  56868. }
  56869. }
  56870. declare module "babylonjs/Physics/physicsHelper" {
  56871. import { Nullable } from "babylonjs/types";
  56872. import { Vector3 } from "babylonjs/Maths/math";
  56873. import { Mesh } from "babylonjs/Meshes/mesh";
  56874. import { Scene } from "babylonjs/scene";
  56875. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  56876. /**
  56877. * A helper for physics simulations
  56878. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56879. */
  56880. export class PhysicsHelper {
  56881. private _scene;
  56882. private _physicsEngine;
  56883. /**
  56884. * Initializes the Physics helper
  56885. * @param scene Babylon.js scene
  56886. */
  56887. constructor(scene: Scene);
  56888. /**
  56889. * Applies a radial explosion impulse
  56890. * @param origin the origin of the explosion
  56891. * @param radiusOrEventOptions the radius or the options of radial explosion
  56892. * @param strength the explosion strength
  56893. * @param falloff possible options: Constant & Linear. Defaults to Constant
  56894. * @returns A physics radial explosion event, or null
  56895. */
  56896. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  56897. /**
  56898. * Applies a radial explosion force
  56899. * @param origin the origin of the explosion
  56900. * @param radiusOrEventOptions the radius or the options of radial explosion
  56901. * @param strength the explosion strength
  56902. * @param falloff possible options: Constant & Linear. Defaults to Constant
  56903. * @returns A physics radial explosion event, or null
  56904. */
  56905. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  56906. /**
  56907. * Creates a gravitational field
  56908. * @param origin the origin of the explosion
  56909. * @param radiusOrEventOptions the radius or the options of radial explosion
  56910. * @param strength the explosion strength
  56911. * @param falloff possible options: Constant & Linear. Defaults to Constant
  56912. * @returns A physics gravitational field event, or null
  56913. */
  56914. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  56915. /**
  56916. * Creates a physics updraft event
  56917. * @param origin the origin of the updraft
  56918. * @param radiusOrEventOptions the radius or the options of the updraft
  56919. * @param strength the strength of the updraft
  56920. * @param height the height of the updraft
  56921. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  56922. * @returns A physics updraft event, or null
  56923. */
  56924. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  56925. /**
  56926. * Creates a physics vortex event
  56927. * @param origin the of the vortex
  56928. * @param radiusOrEventOptions the radius or the options of the vortex
  56929. * @param strength the strength of the vortex
  56930. * @param height the height of the vortex
  56931. * @returns a Physics vortex event, or null
  56932. * A physics vortex event or null
  56933. */
  56934. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  56935. }
  56936. /**
  56937. * Represents a physics radial explosion event
  56938. */
  56939. class PhysicsRadialExplosionEvent {
  56940. private _scene;
  56941. private _options;
  56942. private _sphere;
  56943. private _dataFetched;
  56944. /**
  56945. * Initializes a radial explosioin event
  56946. * @param _scene BabylonJS scene
  56947. * @param _options The options for the vortex event
  56948. */
  56949. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  56950. /**
  56951. * Returns the data related to the radial explosion event (sphere).
  56952. * @returns The radial explosion event data
  56953. */
  56954. getData(): PhysicsRadialExplosionEventData;
  56955. /**
  56956. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  56957. * @param impostor A physics imposter
  56958. * @param origin the origin of the explosion
  56959. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  56960. */
  56961. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  56962. /**
  56963. * Triggers affecterd impostors callbacks
  56964. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  56965. */
  56966. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  56967. /**
  56968. * Disposes the sphere.
  56969. * @param force Specifies if the sphere should be disposed by force
  56970. */
  56971. dispose(force?: boolean): void;
  56972. /*** Helpers ***/
  56973. private _prepareSphere;
  56974. private _intersectsWithSphere;
  56975. }
  56976. /**
  56977. * Represents a gravitational field event
  56978. */
  56979. class PhysicsGravitationalFieldEvent {
  56980. private _physicsHelper;
  56981. private _scene;
  56982. private _origin;
  56983. private _options;
  56984. private _tickCallback;
  56985. private _sphere;
  56986. private _dataFetched;
  56987. /**
  56988. * Initializes the physics gravitational field event
  56989. * @param _physicsHelper A physics helper
  56990. * @param _scene BabylonJS scene
  56991. * @param _origin The origin position of the gravitational field event
  56992. * @param _options The options for the vortex event
  56993. */
  56994. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  56995. /**
  56996. * Returns the data related to the gravitational field event (sphere).
  56997. * @returns A gravitational field event
  56998. */
  56999. getData(): PhysicsGravitationalFieldEventData;
  57000. /**
  57001. * Enables the gravitational field.
  57002. */
  57003. enable(): void;
  57004. /**
  57005. * Disables the gravitational field.
  57006. */
  57007. disable(): void;
  57008. /**
  57009. * Disposes the sphere.
  57010. * @param force The force to dispose from the gravitational field event
  57011. */
  57012. dispose(force?: boolean): void;
  57013. private _tick;
  57014. }
  57015. /**
  57016. * Represents a physics updraft event
  57017. */
  57018. class PhysicsUpdraftEvent {
  57019. private _scene;
  57020. private _origin;
  57021. private _options;
  57022. private _physicsEngine;
  57023. private _originTop;
  57024. private _originDirection;
  57025. private _tickCallback;
  57026. private _cylinder;
  57027. private _cylinderPosition;
  57028. private _dataFetched;
  57029. /**
  57030. * Initializes the physics updraft event
  57031. * @param _scene BabylonJS scene
  57032. * @param _origin The origin position of the updraft
  57033. * @param _options The options for the updraft event
  57034. */
  57035. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  57036. /**
  57037. * Returns the data related to the updraft event (cylinder).
  57038. * @returns A physics updraft event
  57039. */
  57040. getData(): PhysicsUpdraftEventData;
  57041. /**
  57042. * Enables the updraft.
  57043. */
  57044. enable(): void;
  57045. /**
  57046. * Disables the updraft.
  57047. */
  57048. disable(): void;
  57049. /**
  57050. * Disposes the cylinder.
  57051. * @param force Specifies if the updraft should be disposed by force
  57052. */
  57053. dispose(force?: boolean): void;
  57054. private getImpostorHitData;
  57055. private _tick;
  57056. /*** Helpers ***/
  57057. private _prepareCylinder;
  57058. private _intersectsWithCylinder;
  57059. }
  57060. /**
  57061. * Represents a physics vortex event
  57062. */
  57063. class PhysicsVortexEvent {
  57064. private _scene;
  57065. private _origin;
  57066. private _options;
  57067. private _physicsEngine;
  57068. private _originTop;
  57069. private _tickCallback;
  57070. private _cylinder;
  57071. private _cylinderPosition;
  57072. private _dataFetched;
  57073. /**
  57074. * Initializes the physics vortex event
  57075. * @param _scene The BabylonJS scene
  57076. * @param _origin The origin position of the vortex
  57077. * @param _options The options for the vortex event
  57078. */
  57079. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  57080. /**
  57081. * Returns the data related to the vortex event (cylinder).
  57082. * @returns The physics vortex event data
  57083. */
  57084. getData(): PhysicsVortexEventData;
  57085. /**
  57086. * Enables the vortex.
  57087. */
  57088. enable(): void;
  57089. /**
  57090. * Disables the cortex.
  57091. */
  57092. disable(): void;
  57093. /**
  57094. * Disposes the sphere.
  57095. * @param force
  57096. */
  57097. dispose(force?: boolean): void;
  57098. private getImpostorHitData;
  57099. private _tick;
  57100. /*** Helpers ***/
  57101. private _prepareCylinder;
  57102. private _intersectsWithCylinder;
  57103. }
  57104. /**
  57105. * Options fot the radial explosion event
  57106. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57107. */
  57108. export class PhysicsRadialExplosionEventOptions {
  57109. /**
  57110. * The radius of the sphere for the radial explosion.
  57111. */
  57112. radius: number;
  57113. /**
  57114. * The strenth of the explosion.
  57115. */
  57116. strength: number;
  57117. /**
  57118. * The strenght of the force in correspondence to the distance of the affected object
  57119. */
  57120. falloff: PhysicsRadialImpulseFalloff;
  57121. /**
  57122. * Sphere options for the radial explosion.
  57123. */
  57124. sphere: {
  57125. segments: number;
  57126. diameter: number;
  57127. };
  57128. /**
  57129. * Sphere options for the radial explosion.
  57130. */
  57131. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  57132. }
  57133. /**
  57134. * Options fot the updraft event
  57135. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57136. */
  57137. export class PhysicsUpdraftEventOptions {
  57138. /**
  57139. * The radius of the cylinder for the vortex
  57140. */
  57141. radius: number;
  57142. /**
  57143. * The strenth of the updraft.
  57144. */
  57145. strength: number;
  57146. /**
  57147. * The height of the cylinder for the updraft.
  57148. */
  57149. height: number;
  57150. /**
  57151. * The mode for the the updraft.
  57152. */
  57153. updraftMode: PhysicsUpdraftMode;
  57154. }
  57155. /**
  57156. * Options fot the vortex event
  57157. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57158. */
  57159. export class PhysicsVortexEventOptions {
  57160. /**
  57161. * The radius of the cylinder for the vortex
  57162. */
  57163. radius: number;
  57164. /**
  57165. * The strenth of the vortex.
  57166. */
  57167. strength: number;
  57168. /**
  57169. * The height of the cylinder for the vortex.
  57170. */
  57171. height: number;
  57172. /**
  57173. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  57174. */
  57175. centripetalForceThreshold: number;
  57176. /**
  57177. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  57178. */
  57179. centripetalForceMultiplier: number;
  57180. /**
  57181. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  57182. */
  57183. centrifugalForceMultiplier: number;
  57184. /**
  57185. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  57186. */
  57187. updraftForceMultiplier: number;
  57188. }
  57189. /**
  57190. * The strenght of the force in correspondence to the distance of the affected object
  57191. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57192. */
  57193. export enum PhysicsRadialImpulseFalloff {
  57194. /** Defines that impulse is constant in strength across it's whole radius */
  57195. Constant = 0,
  57196. /** Defines that impulse gets weaker if it's further from the origin */
  57197. Linear = 1
  57198. }
  57199. /**
  57200. * The strength of the force in correspondence to the distance of the affected object
  57201. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57202. */
  57203. export enum PhysicsUpdraftMode {
  57204. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  57205. Center = 0,
  57206. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  57207. Perpendicular = 1
  57208. }
  57209. /**
  57210. * Interface for a physics hit data
  57211. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57212. */
  57213. export interface PhysicsHitData {
  57214. /**
  57215. * The force applied at the contact point
  57216. */
  57217. force: Vector3;
  57218. /**
  57219. * The contact point
  57220. */
  57221. contactPoint: Vector3;
  57222. /**
  57223. * The distance from the origin to the contact point
  57224. */
  57225. distanceFromOrigin: number;
  57226. }
  57227. /**
  57228. * Interface for radial explosion event data
  57229. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57230. */
  57231. export interface PhysicsRadialExplosionEventData {
  57232. /**
  57233. * A sphere used for the radial explosion event
  57234. */
  57235. sphere: Mesh;
  57236. }
  57237. /**
  57238. * Interface for gravitational field event data
  57239. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57240. */
  57241. export interface PhysicsGravitationalFieldEventData {
  57242. /**
  57243. * A sphere mesh used for the gravitational field event
  57244. */
  57245. sphere: Mesh;
  57246. }
  57247. /**
  57248. * Interface for updraft event data
  57249. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57250. */
  57251. export interface PhysicsUpdraftEventData {
  57252. /**
  57253. * A cylinder used for the updraft event
  57254. */
  57255. cylinder: Mesh;
  57256. }
  57257. /**
  57258. * Interface for vortex event data
  57259. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57260. */
  57261. export interface PhysicsVortexEventData {
  57262. /**
  57263. * A cylinder used for the vortex event
  57264. */
  57265. cylinder: Mesh;
  57266. }
  57267. /**
  57268. * Interface for an affected physics impostor
  57269. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57270. */
  57271. export interface PhysicsAffectedImpostorWithData {
  57272. /**
  57273. * The impostor affected by the effect
  57274. */
  57275. impostor: PhysicsImpostor;
  57276. /**
  57277. * The data about the hit/horce from the explosion
  57278. */
  57279. hitData: PhysicsHitData;
  57280. }
  57281. }
  57282. declare module "babylonjs/Physics/Plugins/index" {
  57283. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  57284. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  57285. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  57286. }
  57287. declare module "babylonjs/Physics/index" {
  57288. export * from "babylonjs/Physics/IPhysicsEngine";
  57289. export * from "babylonjs/Physics/physicsEngine";
  57290. export * from "babylonjs/Physics/physicsEngineComponent";
  57291. export * from "babylonjs/Physics/physicsHelper";
  57292. export * from "babylonjs/Physics/physicsImpostor";
  57293. export * from "babylonjs/Physics/physicsJoint";
  57294. export * from "babylonjs/Physics/Plugins/index";
  57295. }
  57296. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  57297. /** @hidden */
  57298. export var blackAndWhitePixelShader: {
  57299. name: string;
  57300. shader: string;
  57301. };
  57302. }
  57303. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  57304. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57305. import { Camera } from "babylonjs/Cameras/camera";
  57306. import { Engine } from "babylonjs/Engines/engine";
  57307. import "babylonjs/Shaders/blackAndWhite.fragment";
  57308. /**
  57309. * Post process used to render in black and white
  57310. */
  57311. export class BlackAndWhitePostProcess extends PostProcess {
  57312. /**
  57313. * Linear about to convert he result to black and white (default: 1)
  57314. */
  57315. degree: number;
  57316. /**
  57317. * Creates a black and white post process
  57318. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  57319. * @param name The name of the effect.
  57320. * @param options The required width/height ratio to downsize to before computing the render pass.
  57321. * @param camera The camera to apply the render pass to.
  57322. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57323. * @param engine The engine which the post process will be applied. (default: current engine)
  57324. * @param reusable If the post process can be reused on the same frame. (default: false)
  57325. */
  57326. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57327. }
  57328. }
  57329. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  57330. import { Nullable } from "babylonjs/types";
  57331. import { Camera } from "babylonjs/Cameras/camera";
  57332. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  57333. import { Engine } from "babylonjs/Engines/engine";
  57334. /**
  57335. * This represents a set of one or more post processes in Babylon.
  57336. * A post process can be used to apply a shader to a texture after it is rendered.
  57337. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  57338. */
  57339. export class PostProcessRenderEffect {
  57340. private _postProcesses;
  57341. private _getPostProcesses;
  57342. private _singleInstance;
  57343. private _cameras;
  57344. private _indicesForCamera;
  57345. /**
  57346. * Name of the effect
  57347. * @hidden
  57348. */
  57349. _name: string;
  57350. /**
  57351. * Instantiates a post process render effect.
  57352. * A post process can be used to apply a shader to a texture after it is rendered.
  57353. * @param engine The engine the effect is tied to
  57354. * @param name The name of the effect
  57355. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  57356. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  57357. */
  57358. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  57359. /**
  57360. * Checks if all the post processes in the effect are supported.
  57361. */
  57362. readonly isSupported: boolean;
  57363. /**
  57364. * Updates the current state of the effect
  57365. * @hidden
  57366. */
  57367. _update(): void;
  57368. /**
  57369. * Attaches the effect on cameras
  57370. * @param cameras The camera to attach to.
  57371. * @hidden
  57372. */
  57373. _attachCameras(cameras: Camera): void;
  57374. /**
  57375. * Attaches the effect on cameras
  57376. * @param cameras The camera to attach to.
  57377. * @hidden
  57378. */
  57379. _attachCameras(cameras: Camera[]): void;
  57380. /**
  57381. * Detaches the effect on cameras
  57382. * @param cameras The camera to detatch from.
  57383. * @hidden
  57384. */
  57385. _detachCameras(cameras: Camera): void;
  57386. /**
  57387. * Detatches the effect on cameras
  57388. * @param cameras The camera to detatch from.
  57389. * @hidden
  57390. */
  57391. _detachCameras(cameras: Camera[]): void;
  57392. /**
  57393. * Enables the effect on given cameras
  57394. * @param cameras The camera to enable.
  57395. * @hidden
  57396. */
  57397. _enable(cameras: Camera): void;
  57398. /**
  57399. * Enables the effect on given cameras
  57400. * @param cameras The camera to enable.
  57401. * @hidden
  57402. */
  57403. _enable(cameras: Nullable<Camera[]>): void;
  57404. /**
  57405. * Disables the effect on the given cameras
  57406. * @param cameras The camera to disable.
  57407. * @hidden
  57408. */
  57409. _disable(cameras: Camera): void;
  57410. /**
  57411. * Disables the effect on the given cameras
  57412. * @param cameras The camera to disable.
  57413. * @hidden
  57414. */
  57415. _disable(cameras: Nullable<Camera[]>): void;
  57416. /**
  57417. * Gets a list of the post processes contained in the effect.
  57418. * @param camera The camera to get the post processes on.
  57419. * @returns The list of the post processes in the effect.
  57420. */
  57421. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  57422. }
  57423. }
  57424. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  57425. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57426. /** @hidden */
  57427. export var extractHighlightsPixelShader: {
  57428. name: string;
  57429. shader: string;
  57430. };
  57431. }
  57432. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  57433. import { Nullable } from "babylonjs/types";
  57434. import { Camera } from "babylonjs/Cameras/camera";
  57435. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57436. import { Engine } from "babylonjs/Engines/engine";
  57437. import "babylonjs/Shaders/extractHighlights.fragment";
  57438. /**
  57439. * 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.
  57440. */
  57441. export class ExtractHighlightsPostProcess extends PostProcess {
  57442. /**
  57443. * The luminance threshold, pixels below this value will be set to black.
  57444. */
  57445. threshold: number;
  57446. /** @hidden */
  57447. _exposure: number;
  57448. /**
  57449. * Post process which has the input texture to be used when performing highlight extraction
  57450. * @hidden
  57451. */
  57452. _inputPostProcess: Nullable<PostProcess>;
  57453. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57454. }
  57455. }
  57456. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  57457. /** @hidden */
  57458. export var bloomMergePixelShader: {
  57459. name: string;
  57460. shader: string;
  57461. };
  57462. }
  57463. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  57464. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57465. import { Nullable } from "babylonjs/types";
  57466. import { Engine } from "babylonjs/Engines/engine";
  57467. import { Camera } from "babylonjs/Cameras/camera";
  57468. import "babylonjs/Shaders/bloomMerge.fragment";
  57469. /**
  57470. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  57471. */
  57472. export class BloomMergePostProcess extends PostProcess {
  57473. /** Weight of the bloom to be added to the original input. */
  57474. weight: number;
  57475. /**
  57476. * Creates a new instance of @see BloomMergePostProcess
  57477. * @param name The name of the effect.
  57478. * @param originalFromInput Post process which's input will be used for the merge.
  57479. * @param blurred Blurred highlights post process which's output will be used.
  57480. * @param weight Weight of the bloom to be added to the original input.
  57481. * @param options The required width/height ratio to downsize to before computing the render pass.
  57482. * @param camera The camera to apply the render pass to.
  57483. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57484. * @param engine The engine which the post process will be applied. (default: current engine)
  57485. * @param reusable If the post process can be reused on the same frame. (default: false)
  57486. * @param textureType Type of textures used when performing the post process. (default: 0)
  57487. * @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)
  57488. */
  57489. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  57490. /** Weight of the bloom to be added to the original input. */
  57491. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57492. }
  57493. }
  57494. declare module "babylonjs/PostProcesses/bloomEffect" {
  57495. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  57496. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  57497. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  57498. import { Camera } from "babylonjs/Cameras/camera";
  57499. import { Scene } from "babylonjs/scene";
  57500. /**
  57501. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  57502. */
  57503. export class BloomEffect extends PostProcessRenderEffect {
  57504. private bloomScale;
  57505. /**
  57506. * @hidden Internal
  57507. */
  57508. _effects: Array<PostProcess>;
  57509. /**
  57510. * @hidden Internal
  57511. */
  57512. _downscale: ExtractHighlightsPostProcess;
  57513. private _blurX;
  57514. private _blurY;
  57515. private _merge;
  57516. /**
  57517. * The luminance threshold to find bright areas of the image to bloom.
  57518. */
  57519. threshold: number;
  57520. /**
  57521. * The strength of the bloom.
  57522. */
  57523. weight: number;
  57524. /**
  57525. * Specifies the size of the bloom blur kernel, relative to the final output size
  57526. */
  57527. kernel: number;
  57528. /**
  57529. * Creates a new instance of @see BloomEffect
  57530. * @param scene The scene the effect belongs to.
  57531. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  57532. * @param bloomKernel The size of the kernel to be used when applying the blur.
  57533. * @param bloomWeight The the strength of bloom.
  57534. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  57535. * @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)
  57536. */
  57537. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  57538. /**
  57539. * Disposes each of the internal effects for a given camera.
  57540. * @param camera The camera to dispose the effect on.
  57541. */
  57542. disposeEffects(camera: Camera): void;
  57543. /**
  57544. * @hidden Internal
  57545. */
  57546. _updateEffects(): void;
  57547. /**
  57548. * Internal
  57549. * @returns if all the contained post processes are ready.
  57550. * @hidden
  57551. */
  57552. _isReady(): boolean;
  57553. }
  57554. }
  57555. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  57556. /** @hidden */
  57557. export var chromaticAberrationPixelShader: {
  57558. name: string;
  57559. shader: string;
  57560. };
  57561. }
  57562. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  57563. import { Vector2 } from "babylonjs/Maths/math";
  57564. import { Nullable } from "babylonjs/types";
  57565. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57566. import { Camera } from "babylonjs/Cameras/camera";
  57567. import { Engine } from "babylonjs/Engines/engine";
  57568. import "babylonjs/Shaders/chromaticAberration.fragment";
  57569. /**
  57570. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  57571. */
  57572. export class ChromaticAberrationPostProcess extends PostProcess {
  57573. /**
  57574. * The amount of seperation of rgb channels (default: 30)
  57575. */
  57576. aberrationAmount: number;
  57577. /**
  57578. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  57579. */
  57580. radialIntensity: number;
  57581. /**
  57582. * 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))
  57583. */
  57584. direction: Vector2;
  57585. /**
  57586. * 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))
  57587. */
  57588. centerPosition: Vector2;
  57589. /**
  57590. * Creates a new instance ChromaticAberrationPostProcess
  57591. * @param name The name of the effect.
  57592. * @param screenWidth The width of the screen to apply the effect on.
  57593. * @param screenHeight The height of the screen to apply the effect on.
  57594. * @param options The required width/height ratio to downsize to before computing the render pass.
  57595. * @param camera The camera to apply the render pass to.
  57596. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57597. * @param engine The engine which the post process will be applied. (default: current engine)
  57598. * @param reusable If the post process can be reused on the same frame. (default: false)
  57599. * @param textureType Type of textures used when performing the post process. (default: 0)
  57600. * @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)
  57601. */
  57602. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57603. }
  57604. }
  57605. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  57606. /** @hidden */
  57607. export var circleOfConfusionPixelShader: {
  57608. name: string;
  57609. shader: string;
  57610. };
  57611. }
  57612. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  57613. import { Nullable } from "babylonjs/types";
  57614. import { Engine } from "babylonjs/Engines/engine";
  57615. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57616. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57617. import { Camera } from "babylonjs/Cameras/camera";
  57618. import "babylonjs/Shaders/circleOfConfusion.fragment";
  57619. /**
  57620. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  57621. */
  57622. export class CircleOfConfusionPostProcess extends PostProcess {
  57623. /**
  57624. * 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.
  57625. */
  57626. lensSize: number;
  57627. /**
  57628. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  57629. */
  57630. fStop: number;
  57631. /**
  57632. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  57633. */
  57634. focusDistance: number;
  57635. /**
  57636. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  57637. */
  57638. focalLength: number;
  57639. private _depthTexture;
  57640. /**
  57641. * Creates a new instance CircleOfConfusionPostProcess
  57642. * @param name The name of the effect.
  57643. * @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.
  57644. * @param options The required width/height ratio to downsize to before computing the render pass.
  57645. * @param camera The camera to apply the render pass to.
  57646. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57647. * @param engine The engine which the post process will be applied. (default: current engine)
  57648. * @param reusable If the post process can be reused on the same frame. (default: false)
  57649. * @param textureType Type of textures used when performing the post process. (default: 0)
  57650. * @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)
  57651. */
  57652. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57653. /**
  57654. * 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.
  57655. */
  57656. depthTexture: RenderTargetTexture;
  57657. }
  57658. }
  57659. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  57660. /** @hidden */
  57661. export var colorCorrectionPixelShader: {
  57662. name: string;
  57663. shader: string;
  57664. };
  57665. }
  57666. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  57667. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57668. import { Engine } from "babylonjs/Engines/engine";
  57669. import { Camera } from "babylonjs/Cameras/camera";
  57670. import "babylonjs/Shaders/colorCorrection.fragment";
  57671. /**
  57672. *
  57673. * This post-process allows the modification of rendered colors by using
  57674. * a 'look-up table' (LUT). This effect is also called Color Grading.
  57675. *
  57676. * The object needs to be provided an url to a texture containing the color
  57677. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  57678. * Use an image editing software to tweak the LUT to match your needs.
  57679. *
  57680. * For an example of a color LUT, see here:
  57681. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  57682. * For explanations on color grading, see here:
  57683. * @see http://udn.epicgames.com/Three/ColorGrading.html
  57684. *
  57685. */
  57686. export class ColorCorrectionPostProcess extends PostProcess {
  57687. private _colorTableTexture;
  57688. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57689. }
  57690. }
  57691. declare module "babylonjs/Shaders/convolution.fragment" {
  57692. /** @hidden */
  57693. export var convolutionPixelShader: {
  57694. name: string;
  57695. shader: string;
  57696. };
  57697. }
  57698. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  57699. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57700. import { Nullable } from "babylonjs/types";
  57701. import { Camera } from "babylonjs/Cameras/camera";
  57702. import { Engine } from "babylonjs/Engines/engine";
  57703. import "babylonjs/Shaders/convolution.fragment";
  57704. /**
  57705. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  57706. * input texture to perform effects such as edge detection or sharpening
  57707. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  57708. */
  57709. export class ConvolutionPostProcess extends PostProcess {
  57710. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  57711. kernel: number[];
  57712. /**
  57713. * Creates a new instance ConvolutionPostProcess
  57714. * @param name The name of the effect.
  57715. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  57716. * @param options The required width/height ratio to downsize to before computing the render pass.
  57717. * @param camera The camera to apply the render pass to.
  57718. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57719. * @param engine The engine which the post process will be applied. (default: current engine)
  57720. * @param reusable If the post process can be reused on the same frame. (default: false)
  57721. * @param textureType Type of textures used when performing the post process. (default: 0)
  57722. */
  57723. constructor(name: string,
  57724. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  57725. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  57726. /**
  57727. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57728. */
  57729. static EdgeDetect0Kernel: number[];
  57730. /**
  57731. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57732. */
  57733. static EdgeDetect1Kernel: number[];
  57734. /**
  57735. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57736. */
  57737. static EdgeDetect2Kernel: number[];
  57738. /**
  57739. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57740. */
  57741. static SharpenKernel: number[];
  57742. /**
  57743. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57744. */
  57745. static EmbossKernel: number[];
  57746. /**
  57747. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57748. */
  57749. static GaussianKernel: number[];
  57750. }
  57751. }
  57752. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  57753. import { Nullable } from "babylonjs/types";
  57754. import { Vector2 } from "babylonjs/Maths/math";
  57755. import { Camera } from "babylonjs/Cameras/camera";
  57756. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57757. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  57758. import { Engine } from "babylonjs/Engines/engine";
  57759. import { Scene } from "babylonjs/scene";
  57760. /**
  57761. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  57762. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  57763. * based on samples that have a large difference in distance than the center pixel.
  57764. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  57765. */
  57766. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  57767. direction: Vector2;
  57768. /**
  57769. * Creates a new instance CircleOfConfusionPostProcess
  57770. * @param name The name of the effect.
  57771. * @param scene The scene the effect belongs to.
  57772. * @param direction The direction the blur should be applied.
  57773. * @param kernel The size of the kernel used to blur.
  57774. * @param options The required width/height ratio to downsize to before computing the render pass.
  57775. * @param camera The camera to apply the render pass to.
  57776. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  57777. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  57778. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57779. * @param engine The engine which the post process will be applied. (default: current engine)
  57780. * @param reusable If the post process can be reused on the same frame. (default: false)
  57781. * @param textureType Type of textures used when performing the post process. (default: 0)
  57782. * @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)
  57783. */
  57784. 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);
  57785. }
  57786. }
  57787. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  57788. /** @hidden */
  57789. export var depthOfFieldMergePixelShader: {
  57790. name: string;
  57791. shader: string;
  57792. };
  57793. }
  57794. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  57795. import { Nullable } from "babylonjs/types";
  57796. import { Camera } from "babylonjs/Cameras/camera";
  57797. import { Effect } from "babylonjs/Materials/effect";
  57798. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57799. import { Engine } from "babylonjs/Engines/engine";
  57800. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  57801. /**
  57802. * Options to be set when merging outputs from the default pipeline.
  57803. */
  57804. export class DepthOfFieldMergePostProcessOptions {
  57805. /**
  57806. * The original image to merge on top of
  57807. */
  57808. originalFromInput: PostProcess;
  57809. /**
  57810. * Parameters to perform the merge of the depth of field effect
  57811. */
  57812. depthOfField?: {
  57813. circleOfConfusion: PostProcess;
  57814. blurSteps: Array<PostProcess>;
  57815. };
  57816. /**
  57817. * Parameters to perform the merge of bloom effect
  57818. */
  57819. bloom?: {
  57820. blurred: PostProcess;
  57821. weight: number;
  57822. };
  57823. }
  57824. /**
  57825. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  57826. */
  57827. export class DepthOfFieldMergePostProcess extends PostProcess {
  57828. private blurSteps;
  57829. /**
  57830. * Creates a new instance of DepthOfFieldMergePostProcess
  57831. * @param name The name of the effect.
  57832. * @param originalFromInput Post process which's input will be used for the merge.
  57833. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  57834. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  57835. * @param options The required width/height ratio to downsize to before computing the render pass.
  57836. * @param camera The camera to apply the render pass to.
  57837. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57838. * @param engine The engine which the post process will be applied. (default: current engine)
  57839. * @param reusable If the post process can be reused on the same frame. (default: false)
  57840. * @param textureType Type of textures used when performing the post process. (default: 0)
  57841. * @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)
  57842. */
  57843. 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);
  57844. /**
  57845. * Updates the effect with the current post process compile time values and recompiles the shader.
  57846. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  57847. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  57848. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  57849. * @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
  57850. * @param onCompiled Called when the shader has been compiled.
  57851. * @param onError Called if there is an error when compiling a shader.
  57852. */
  57853. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  57854. }
  57855. }
  57856. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  57857. import { Nullable } from "babylonjs/types";
  57858. import { Camera } from "babylonjs/Cameras/camera";
  57859. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57860. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  57861. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  57862. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  57863. import { Scene } from "babylonjs/scene";
  57864. /**
  57865. * Specifies the level of max blur that should be applied when using the depth of field effect
  57866. */
  57867. export enum DepthOfFieldEffectBlurLevel {
  57868. /**
  57869. * Subtle blur
  57870. */
  57871. Low = 0,
  57872. /**
  57873. * Medium blur
  57874. */
  57875. Medium = 1,
  57876. /**
  57877. * Large blur
  57878. */
  57879. High = 2
  57880. }
  57881. /**
  57882. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  57883. */
  57884. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  57885. private _circleOfConfusion;
  57886. /**
  57887. * @hidden Internal, blurs from high to low
  57888. */
  57889. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  57890. private _depthOfFieldBlurY;
  57891. private _dofMerge;
  57892. /**
  57893. * @hidden Internal post processes in depth of field effect
  57894. */
  57895. _effects: Array<PostProcess>;
  57896. /**
  57897. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  57898. */
  57899. focalLength: number;
  57900. /**
  57901. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  57902. */
  57903. fStop: number;
  57904. /**
  57905. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  57906. */
  57907. focusDistance: number;
  57908. /**
  57909. * 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.
  57910. */
  57911. lensSize: number;
  57912. /**
  57913. * Creates a new instance DepthOfFieldEffect
  57914. * @param scene The scene the effect belongs to.
  57915. * @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.
  57916. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  57917. * @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)
  57918. */
  57919. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  57920. /**
  57921. * Get the current class name of the current effet
  57922. * @returns "DepthOfFieldEffect"
  57923. */
  57924. getClassName(): string;
  57925. /**
  57926. * 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.
  57927. */
  57928. depthTexture: RenderTargetTexture;
  57929. /**
  57930. * Disposes each of the internal effects for a given camera.
  57931. * @param camera The camera to dispose the effect on.
  57932. */
  57933. disposeEffects(camera: Camera): void;
  57934. /**
  57935. * @hidden Internal
  57936. */
  57937. _updateEffects(): void;
  57938. /**
  57939. * Internal
  57940. * @returns if all the contained post processes are ready.
  57941. * @hidden
  57942. */
  57943. _isReady(): boolean;
  57944. }
  57945. }
  57946. declare module "babylonjs/Shaders/displayPass.fragment" {
  57947. /** @hidden */
  57948. export var displayPassPixelShader: {
  57949. name: string;
  57950. shader: string;
  57951. };
  57952. }
  57953. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  57954. import { Nullable } from "babylonjs/types";
  57955. import { Camera } from "babylonjs/Cameras/camera";
  57956. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57957. import { Engine } from "babylonjs/Engines/engine";
  57958. import "babylonjs/Shaders/displayPass.fragment";
  57959. /**
  57960. * DisplayPassPostProcess which produces an output the same as it's input
  57961. */
  57962. export class DisplayPassPostProcess extends PostProcess {
  57963. /**
  57964. * Creates the DisplayPassPostProcess
  57965. * @param name The name of the effect.
  57966. * @param options The required width/height ratio to downsize to before computing the render pass.
  57967. * @param camera The camera to apply the render pass to.
  57968. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57969. * @param engine The engine which the post process will be applied. (default: current engine)
  57970. * @param reusable If the post process can be reused on the same frame. (default: false)
  57971. */
  57972. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57973. }
  57974. }
  57975. declare module "babylonjs/Shaders/filter.fragment" {
  57976. /** @hidden */
  57977. export var filterPixelShader: {
  57978. name: string;
  57979. shader: string;
  57980. };
  57981. }
  57982. declare module "babylonjs/PostProcesses/filterPostProcess" {
  57983. import { Nullable } from "babylonjs/types";
  57984. import { Matrix } from "babylonjs/Maths/math";
  57985. import { Camera } from "babylonjs/Cameras/camera";
  57986. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57987. import { Engine } from "babylonjs/Engines/engine";
  57988. import "babylonjs/Shaders/filter.fragment";
  57989. /**
  57990. * Applies a kernel filter to the image
  57991. */
  57992. export class FilterPostProcess extends PostProcess {
  57993. /** The matrix to be applied to the image */
  57994. kernelMatrix: Matrix;
  57995. /**
  57996. *
  57997. * @param name The name of the effect.
  57998. * @param kernelMatrix The matrix to be applied to the image
  57999. * @param options The required width/height ratio to downsize to before computing the render pass.
  58000. * @param camera The camera to apply the render pass to.
  58001. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58002. * @param engine The engine which the post process will be applied. (default: current engine)
  58003. * @param reusable If the post process can be reused on the same frame. (default: false)
  58004. */
  58005. constructor(name: string,
  58006. /** The matrix to be applied to the image */
  58007. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58008. }
  58009. }
  58010. declare module "babylonjs/Shaders/fxaa.fragment" {
  58011. /** @hidden */
  58012. export var fxaaPixelShader: {
  58013. name: string;
  58014. shader: string;
  58015. };
  58016. }
  58017. declare module "babylonjs/Shaders/fxaa.vertex" {
  58018. /** @hidden */
  58019. export var fxaaVertexShader: {
  58020. name: string;
  58021. shader: string;
  58022. };
  58023. }
  58024. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  58025. import { Nullable } from "babylonjs/types";
  58026. import { Camera } from "babylonjs/Cameras/camera";
  58027. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58028. import { Engine } from "babylonjs/Engines/engine";
  58029. import "babylonjs/Shaders/fxaa.fragment";
  58030. import "babylonjs/Shaders/fxaa.vertex";
  58031. /**
  58032. * Fxaa post process
  58033. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  58034. */
  58035. export class FxaaPostProcess extends PostProcess {
  58036. /** @hidden */
  58037. texelWidth: number;
  58038. /** @hidden */
  58039. texelHeight: number;
  58040. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  58041. private _getDefines;
  58042. }
  58043. }
  58044. declare module "babylonjs/Shaders/grain.fragment" {
  58045. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58046. /** @hidden */
  58047. export var grainPixelShader: {
  58048. name: string;
  58049. shader: string;
  58050. };
  58051. }
  58052. declare module "babylonjs/PostProcesses/grainPostProcess" {
  58053. import { Nullable } from "babylonjs/types";
  58054. import { Camera } from "babylonjs/Cameras/camera";
  58055. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58056. import { Engine } from "babylonjs/Engines/engine";
  58057. import "babylonjs/Shaders/grain.fragment";
  58058. /**
  58059. * The GrainPostProcess adds noise to the image at mid luminance levels
  58060. */
  58061. export class GrainPostProcess extends PostProcess {
  58062. /**
  58063. * The intensity of the grain added (default: 30)
  58064. */
  58065. intensity: number;
  58066. /**
  58067. * If the grain should be randomized on every frame
  58068. */
  58069. animated: boolean;
  58070. /**
  58071. * Creates a new instance of @see GrainPostProcess
  58072. * @param name The name of the effect.
  58073. * @param options The required width/height ratio to downsize to before computing the render pass.
  58074. * @param camera The camera to apply the render pass to.
  58075. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58076. * @param engine The engine which the post process will be applied. (default: current engine)
  58077. * @param reusable If the post process can be reused on the same frame. (default: false)
  58078. * @param textureType Type of textures used when performing the post process. (default: 0)
  58079. * @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)
  58080. */
  58081. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58082. }
  58083. }
  58084. declare module "babylonjs/Shaders/highlights.fragment" {
  58085. /** @hidden */
  58086. export var highlightsPixelShader: {
  58087. name: string;
  58088. shader: string;
  58089. };
  58090. }
  58091. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  58092. import { Nullable } from "babylonjs/types";
  58093. import { Camera } from "babylonjs/Cameras/camera";
  58094. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58095. import { Engine } from "babylonjs/Engines/engine";
  58096. import "babylonjs/Shaders/highlights.fragment";
  58097. /**
  58098. * Extracts highlights from the image
  58099. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  58100. */
  58101. export class HighlightsPostProcess extends PostProcess {
  58102. /**
  58103. * Extracts highlights from the image
  58104. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  58105. * @param name The name of the effect.
  58106. * @param options The required width/height ratio to downsize to before computing the render pass.
  58107. * @param camera The camera to apply the render pass to.
  58108. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58109. * @param engine The engine which the post process will be applied. (default: current engine)
  58110. * @param reusable If the post process can be reused on the same frame. (default: false)
  58111. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  58112. */
  58113. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  58114. }
  58115. }
  58116. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  58117. /** @hidden */
  58118. export var mrtFragmentDeclaration: {
  58119. name: string;
  58120. shader: string;
  58121. };
  58122. }
  58123. declare module "babylonjs/Shaders/geometry.fragment" {
  58124. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  58125. /** @hidden */
  58126. export var geometryPixelShader: {
  58127. name: string;
  58128. shader: string;
  58129. };
  58130. }
  58131. declare module "babylonjs/Shaders/geometry.vertex" {
  58132. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  58133. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  58134. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  58135. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  58136. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  58137. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  58138. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  58139. /** @hidden */
  58140. export var geometryVertexShader: {
  58141. name: string;
  58142. shader: string;
  58143. };
  58144. }
  58145. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  58146. import { Matrix } from "babylonjs/Maths/math";
  58147. import { SubMesh } from "babylonjs/Meshes/subMesh";
  58148. import { Mesh } from "babylonjs/Meshes/mesh";
  58149. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  58150. import { Effect } from "babylonjs/Materials/effect";
  58151. import { Scene } from "babylonjs/scene";
  58152. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58153. import "babylonjs/Shaders/geometry.fragment";
  58154. import "babylonjs/Shaders/geometry.vertex";
  58155. /** @hidden */
  58156. interface ISavedTransformationMatrix {
  58157. world: Matrix;
  58158. viewProjection: Matrix;
  58159. }
  58160. /**
  58161. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  58162. */
  58163. export class GeometryBufferRenderer {
  58164. /**
  58165. * Constant used to retrieve the position texture index in the G-Buffer textures array
  58166. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  58167. */
  58168. static readonly POSITION_TEXTURE_TYPE: number;
  58169. /**
  58170. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  58171. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  58172. */
  58173. static readonly VELOCITY_TEXTURE_TYPE: number;
  58174. /**
  58175. * Dictionary used to store the previous transformation matrices of each rendered mesh
  58176. * in order to compute objects velocities when enableVelocity is set to "true"
  58177. * @hidden
  58178. */
  58179. _previousTransformationMatrices: {
  58180. [index: number]: ISavedTransformationMatrix;
  58181. };
  58182. /**
  58183. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  58184. * in order to compute objects velocities when enableVelocity is set to "true"
  58185. * @hidden
  58186. */
  58187. _previousBonesTransformationMatrices: {
  58188. [index: number]: Float32Array;
  58189. };
  58190. /**
  58191. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  58192. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  58193. */
  58194. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  58195. private _scene;
  58196. private _multiRenderTarget;
  58197. private _ratio;
  58198. private _enablePosition;
  58199. private _enableVelocity;
  58200. private _positionIndex;
  58201. private _velocityIndex;
  58202. protected _effect: Effect;
  58203. protected _cachedDefines: string;
  58204. /**
  58205. * Set the render list (meshes to be rendered) used in the G buffer.
  58206. */
  58207. renderList: Mesh[];
  58208. /**
  58209. * Gets wether or not G buffer are supported by the running hardware.
  58210. * This requires draw buffer supports
  58211. */
  58212. readonly isSupported: boolean;
  58213. /**
  58214. * Returns the index of the given texture type in the G-Buffer textures array
  58215. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  58216. * @returns the index of the given texture type in the G-Buffer textures array
  58217. */
  58218. getTextureIndex(textureType: number): number;
  58219. /**
  58220. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  58221. */
  58222. /**
  58223. * Sets whether or not objects positions are enabled for the G buffer.
  58224. */
  58225. enablePosition: boolean;
  58226. /**
  58227. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  58228. */
  58229. /**
  58230. * Sets wether or not objects velocities are enabled for the G buffer.
  58231. */
  58232. enableVelocity: boolean;
  58233. /**
  58234. * Gets the scene associated with the buffer.
  58235. */
  58236. readonly scene: Scene;
  58237. /**
  58238. * Gets the ratio used by the buffer during its creation.
  58239. * How big is the buffer related to the main canvas.
  58240. */
  58241. readonly ratio: number;
  58242. /** @hidden */
  58243. static _SceneComponentInitialization: (scene: Scene) => void;
  58244. /**
  58245. * Creates a new G Buffer for the scene
  58246. * @param scene The scene the buffer belongs to
  58247. * @param ratio How big is the buffer related to the main canvas.
  58248. */
  58249. constructor(scene: Scene, ratio?: number);
  58250. /**
  58251. * Checks wether everything is ready to render a submesh to the G buffer.
  58252. * @param subMesh the submesh to check readiness for
  58253. * @param useInstances is the mesh drawn using instance or not
  58254. * @returns true if ready otherwise false
  58255. */
  58256. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58257. /**
  58258. * Gets the current underlying G Buffer.
  58259. * @returns the buffer
  58260. */
  58261. getGBuffer(): MultiRenderTarget;
  58262. /**
  58263. * Gets the number of samples used to render the buffer (anti aliasing).
  58264. */
  58265. /**
  58266. * Sets the number of samples used to render the buffer (anti aliasing).
  58267. */
  58268. samples: number;
  58269. /**
  58270. * Disposes the renderer and frees up associated resources.
  58271. */
  58272. dispose(): void;
  58273. protected _createRenderTargets(): void;
  58274. private _copyBonesTransformationMatrices;
  58275. }
  58276. }
  58277. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  58278. import { Nullable } from "babylonjs/types";
  58279. import { Scene } from "babylonjs/scene";
  58280. import { ISceneComponent } from "babylonjs/sceneComponent";
  58281. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  58282. module "babylonjs/scene" {
  58283. interface Scene {
  58284. /** @hidden (Backing field) */
  58285. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  58286. /**
  58287. * Gets or Sets the current geometry buffer associated to the scene.
  58288. */
  58289. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  58290. /**
  58291. * Enables a GeometryBufferRender and associates it with the scene
  58292. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  58293. * @returns the GeometryBufferRenderer
  58294. */
  58295. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  58296. /**
  58297. * Disables the GeometryBufferRender associated with the scene
  58298. */
  58299. disableGeometryBufferRenderer(): void;
  58300. }
  58301. }
  58302. /**
  58303. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  58304. * in several rendering techniques.
  58305. */
  58306. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  58307. /**
  58308. * The component name helpful to identify the component in the list of scene components.
  58309. */
  58310. readonly name: string;
  58311. /**
  58312. * The scene the component belongs to.
  58313. */
  58314. scene: Scene;
  58315. /**
  58316. * Creates a new instance of the component for the given scene
  58317. * @param scene Defines the scene to register the component in
  58318. */
  58319. constructor(scene: Scene);
  58320. /**
  58321. * Registers the component in a given scene
  58322. */
  58323. register(): void;
  58324. /**
  58325. * Rebuilds the elements related to this component in case of
  58326. * context lost for instance.
  58327. */
  58328. rebuild(): void;
  58329. /**
  58330. * Disposes the component and the associated ressources
  58331. */
  58332. dispose(): void;
  58333. private _gatherRenderTargets;
  58334. }
  58335. }
  58336. declare module "babylonjs/Shaders/motionBlur.fragment" {
  58337. /** @hidden */
  58338. export var motionBlurPixelShader: {
  58339. name: string;
  58340. shader: string;
  58341. };
  58342. }
  58343. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  58344. import { Nullable } from "babylonjs/types";
  58345. import { Camera } from "babylonjs/Cameras/camera";
  58346. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58347. import { Scene } from "babylonjs/scene";
  58348. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58349. import "babylonjs/Animations/animatable";
  58350. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  58351. import "babylonjs/Shaders/motionBlur.fragment";
  58352. import { Engine } from "babylonjs/Engines/engine";
  58353. /**
  58354. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  58355. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  58356. * As an example, all you have to do is to create the post-process:
  58357. * var mb = new BABYLON.MotionBlurPostProcess(
  58358. * 'mb', // The name of the effect.
  58359. * scene, // The scene containing the objects to blur according to their velocity.
  58360. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  58361. * camera // The camera to apply the render pass to.
  58362. * );
  58363. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  58364. */
  58365. export class MotionBlurPostProcess extends PostProcess {
  58366. /**
  58367. * Defines how much the image is blurred by the movement. Default value is equal to 1
  58368. */
  58369. motionStrength: number;
  58370. /**
  58371. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  58372. */
  58373. /**
  58374. * Sets the number of iterations to be used for motion blur quality
  58375. */
  58376. motionBlurSamples: number;
  58377. private _motionBlurSamples;
  58378. private _geometryBufferRenderer;
  58379. /**
  58380. * Creates a new instance MotionBlurPostProcess
  58381. * @param name The name of the effect.
  58382. * @param scene The scene containing the objects to blur according to their velocity.
  58383. * @param options The required width/height ratio to downsize to before computing the render pass.
  58384. * @param camera The camera to apply the render pass to.
  58385. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58386. * @param engine The engine which the post process will be applied. (default: current engine)
  58387. * @param reusable If the post process can be reused on the same frame. (default: false)
  58388. * @param textureType Type of textures used when performing the post process. (default: 0)
  58389. * @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)
  58390. */
  58391. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58392. /**
  58393. * Excludes the given skinned mesh from computing bones velocities.
  58394. * Computing bones velocities can have a cost and that cost. The cost can be saved by calling this function and by passing the skinned mesh reference to ignore.
  58395. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  58396. */
  58397. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  58398. /**
  58399. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  58400. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  58401. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  58402. */
  58403. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  58404. /**
  58405. * Disposes the post process.
  58406. * @param camera The camera to dispose the post process on.
  58407. */
  58408. dispose(camera?: Camera): void;
  58409. }
  58410. }
  58411. declare module "babylonjs/Shaders/refraction.fragment" {
  58412. /** @hidden */
  58413. export var refractionPixelShader: {
  58414. name: string;
  58415. shader: string;
  58416. };
  58417. }
  58418. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  58419. import { Color3 } from "babylonjs/Maths/math";
  58420. import { Camera } from "babylonjs/Cameras/camera";
  58421. import { Texture } from "babylonjs/Materials/Textures/texture";
  58422. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58423. import { Engine } from "babylonjs/Engines/engine";
  58424. import "babylonjs/Shaders/refraction.fragment";
  58425. /**
  58426. * Post process which applies a refractin texture
  58427. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  58428. */
  58429. export class RefractionPostProcess extends PostProcess {
  58430. /** the base color of the refraction (used to taint the rendering) */
  58431. color: Color3;
  58432. /** simulated refraction depth */
  58433. depth: number;
  58434. /** the coefficient of the base color (0 to remove base color tainting) */
  58435. colorLevel: number;
  58436. private _refTexture;
  58437. private _ownRefractionTexture;
  58438. /**
  58439. * Gets or sets the refraction texture
  58440. * Please note that you are responsible for disposing the texture if you set it manually
  58441. */
  58442. refractionTexture: Texture;
  58443. /**
  58444. * Initializes the RefractionPostProcess
  58445. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  58446. * @param name The name of the effect.
  58447. * @param refractionTextureUrl Url of the refraction texture to use
  58448. * @param color the base color of the refraction (used to taint the rendering)
  58449. * @param depth simulated refraction depth
  58450. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  58451. * @param camera The camera to apply the render pass to.
  58452. * @param options The required width/height ratio to downsize to before computing the render pass.
  58453. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58454. * @param engine The engine which the post process will be applied. (default: current engine)
  58455. * @param reusable If the post process can be reused on the same frame. (default: false)
  58456. */
  58457. constructor(name: string, refractionTextureUrl: string,
  58458. /** the base color of the refraction (used to taint the rendering) */
  58459. color: Color3,
  58460. /** simulated refraction depth */
  58461. depth: number,
  58462. /** the coefficient of the base color (0 to remove base color tainting) */
  58463. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58464. /**
  58465. * Disposes of the post process
  58466. * @param camera Camera to dispose post process on
  58467. */
  58468. dispose(camera: Camera): void;
  58469. }
  58470. }
  58471. declare module "babylonjs/Shaders/sharpen.fragment" {
  58472. /** @hidden */
  58473. export var sharpenPixelShader: {
  58474. name: string;
  58475. shader: string;
  58476. };
  58477. }
  58478. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  58479. import { Nullable } from "babylonjs/types";
  58480. import { Camera } from "babylonjs/Cameras/camera";
  58481. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58482. import "babylonjs/Shaders/sharpen.fragment";
  58483. import { Engine } from "babylonjs/Engines/engine";
  58484. /**
  58485. * The SharpenPostProcess applies a sharpen kernel to every pixel
  58486. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  58487. */
  58488. export class SharpenPostProcess extends PostProcess {
  58489. /**
  58490. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  58491. */
  58492. colorAmount: number;
  58493. /**
  58494. * How much sharpness should be applied (default: 0.3)
  58495. */
  58496. edgeAmount: number;
  58497. /**
  58498. * Creates a new instance ConvolutionPostProcess
  58499. * @param name The name of the effect.
  58500. * @param options The required width/height ratio to downsize to before computing the render pass.
  58501. * @param camera The camera to apply the render pass to.
  58502. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58503. * @param engine The engine which the post process will be applied. (default: current engine)
  58504. * @param reusable If the post process can be reused on the same frame. (default: false)
  58505. * @param textureType Type of textures used when performing the post process. (default: 0)
  58506. * @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)
  58507. */
  58508. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58509. }
  58510. }
  58511. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  58512. import { Nullable } from "babylonjs/types";
  58513. import { Camera } from "babylonjs/Cameras/camera";
  58514. import { Engine } from "babylonjs/Engines/engine";
  58515. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  58516. import { IInspectable } from "babylonjs/Misc/iInspectable";
  58517. /**
  58518. * PostProcessRenderPipeline
  58519. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58520. */
  58521. export class PostProcessRenderPipeline {
  58522. private engine;
  58523. private _renderEffects;
  58524. private _renderEffectsForIsolatedPass;
  58525. /**
  58526. * List of inspectable custom properties (used by the Inspector)
  58527. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  58528. */
  58529. inspectableCustomProperties: IInspectable[];
  58530. /**
  58531. * @hidden
  58532. */
  58533. protected _cameras: Camera[];
  58534. /** @hidden */
  58535. _name: string;
  58536. /**
  58537. * Gets pipeline name
  58538. */
  58539. readonly name: string;
  58540. /**
  58541. * Initializes a PostProcessRenderPipeline
  58542. * @param engine engine to add the pipeline to
  58543. * @param name name of the pipeline
  58544. */
  58545. constructor(engine: Engine, name: string);
  58546. /**
  58547. * Gets the class name
  58548. * @returns "PostProcessRenderPipeline"
  58549. */
  58550. getClassName(): string;
  58551. /**
  58552. * If all the render effects in the pipeline are supported
  58553. */
  58554. readonly isSupported: boolean;
  58555. /**
  58556. * Adds an effect to the pipeline
  58557. * @param renderEffect the effect to add
  58558. */
  58559. addEffect(renderEffect: PostProcessRenderEffect): void;
  58560. /** @hidden */
  58561. _rebuild(): void;
  58562. /** @hidden */
  58563. _enableEffect(renderEffectName: string, cameras: Camera): void;
  58564. /** @hidden */
  58565. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  58566. /** @hidden */
  58567. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  58568. /** @hidden */
  58569. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  58570. /** @hidden */
  58571. _attachCameras(cameras: Camera, unique: boolean): void;
  58572. /** @hidden */
  58573. _attachCameras(cameras: Camera[], unique: boolean): void;
  58574. /** @hidden */
  58575. _detachCameras(cameras: Camera): void;
  58576. /** @hidden */
  58577. _detachCameras(cameras: Nullable<Camera[]>): void;
  58578. /** @hidden */
  58579. _update(): void;
  58580. /** @hidden */
  58581. _reset(): void;
  58582. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  58583. /**
  58584. * Disposes of the pipeline
  58585. */
  58586. dispose(): void;
  58587. }
  58588. }
  58589. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  58590. import { Camera } from "babylonjs/Cameras/camera";
  58591. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  58592. /**
  58593. * PostProcessRenderPipelineManager class
  58594. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58595. */
  58596. export class PostProcessRenderPipelineManager {
  58597. private _renderPipelines;
  58598. /**
  58599. * Initializes a PostProcessRenderPipelineManager
  58600. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58601. */
  58602. constructor();
  58603. /**
  58604. * Gets the list of supported render pipelines
  58605. */
  58606. readonly supportedPipelines: PostProcessRenderPipeline[];
  58607. /**
  58608. * Adds a pipeline to the manager
  58609. * @param renderPipeline The pipeline to add
  58610. */
  58611. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  58612. /**
  58613. * Attaches a camera to the pipeline
  58614. * @param renderPipelineName The name of the pipeline to attach to
  58615. * @param cameras the camera to attach
  58616. * @param unique if the camera can be attached multiple times to the pipeline
  58617. */
  58618. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  58619. /**
  58620. * Detaches a camera from the pipeline
  58621. * @param renderPipelineName The name of the pipeline to detach from
  58622. * @param cameras the camera to detach
  58623. */
  58624. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  58625. /**
  58626. * Enables an effect by name on a pipeline
  58627. * @param renderPipelineName the name of the pipeline to enable the effect in
  58628. * @param renderEffectName the name of the effect to enable
  58629. * @param cameras the cameras that the effect should be enabled on
  58630. */
  58631. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  58632. /**
  58633. * Disables an effect by name on a pipeline
  58634. * @param renderPipelineName the name of the pipeline to disable the effect in
  58635. * @param renderEffectName the name of the effect to disable
  58636. * @param cameras the cameras that the effect should be disabled on
  58637. */
  58638. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  58639. /**
  58640. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  58641. */
  58642. update(): void;
  58643. /** @hidden */
  58644. _rebuild(): void;
  58645. /**
  58646. * Disposes of the manager and pipelines
  58647. */
  58648. dispose(): void;
  58649. }
  58650. }
  58651. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  58652. import { ISceneComponent } from "babylonjs/sceneComponent";
  58653. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  58654. import { Scene } from "babylonjs/scene";
  58655. module "babylonjs/scene" {
  58656. interface Scene {
  58657. /** @hidden (Backing field) */
  58658. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  58659. /**
  58660. * Gets the postprocess render pipeline manager
  58661. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58662. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  58663. */
  58664. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  58665. }
  58666. }
  58667. /**
  58668. * Defines the Render Pipeline scene component responsible to rendering pipelines
  58669. */
  58670. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  58671. /**
  58672. * The component name helpfull to identify the component in the list of scene components.
  58673. */
  58674. readonly name: string;
  58675. /**
  58676. * The scene the component belongs to.
  58677. */
  58678. scene: Scene;
  58679. /**
  58680. * Creates a new instance of the component for the given scene
  58681. * @param scene Defines the scene to register the component in
  58682. */
  58683. constructor(scene: Scene);
  58684. /**
  58685. * Registers the component in a given scene
  58686. */
  58687. register(): void;
  58688. /**
  58689. * Rebuilds the elements related to this component in case of
  58690. * context lost for instance.
  58691. */
  58692. rebuild(): void;
  58693. /**
  58694. * Disposes the component and the associated ressources
  58695. */
  58696. dispose(): void;
  58697. private _gatherRenderTargets;
  58698. }
  58699. }
  58700. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  58701. import { Nullable } from "babylonjs/types";
  58702. import { IAnimatable } from "babylonjs/Misc/tools";
  58703. import { Camera } from "babylonjs/Cameras/camera";
  58704. import { IDisposable } from "babylonjs/scene";
  58705. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  58706. import { Scene } from "babylonjs/scene";
  58707. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  58708. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  58709. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  58710. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  58711. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  58712. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  58713. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  58714. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  58715. import { Animation } from "babylonjs/Animations/animation";
  58716. /**
  58717. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  58718. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  58719. */
  58720. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  58721. private _scene;
  58722. private _camerasToBeAttached;
  58723. /**
  58724. * ID of the sharpen post process,
  58725. */
  58726. private readonly SharpenPostProcessId;
  58727. /**
  58728. * @ignore
  58729. * ID of the image processing post process;
  58730. */
  58731. readonly ImageProcessingPostProcessId: string;
  58732. /**
  58733. * @ignore
  58734. * ID of the Fast Approximate Anti-Aliasing post process;
  58735. */
  58736. readonly FxaaPostProcessId: string;
  58737. /**
  58738. * ID of the chromatic aberration post process,
  58739. */
  58740. private readonly ChromaticAberrationPostProcessId;
  58741. /**
  58742. * ID of the grain post process
  58743. */
  58744. private readonly GrainPostProcessId;
  58745. /**
  58746. * Sharpen post process which will apply a sharpen convolution to enhance edges
  58747. */
  58748. sharpen: SharpenPostProcess;
  58749. private _sharpenEffect;
  58750. private bloom;
  58751. /**
  58752. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  58753. */
  58754. depthOfField: DepthOfFieldEffect;
  58755. /**
  58756. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  58757. */
  58758. fxaa: FxaaPostProcess;
  58759. /**
  58760. * Image post processing pass used to perform operations such as tone mapping or color grading.
  58761. */
  58762. imageProcessing: ImageProcessingPostProcess;
  58763. /**
  58764. * Chromatic aberration post process which will shift rgb colors in the image
  58765. */
  58766. chromaticAberration: ChromaticAberrationPostProcess;
  58767. private _chromaticAberrationEffect;
  58768. /**
  58769. * Grain post process which add noise to the image
  58770. */
  58771. grain: GrainPostProcess;
  58772. private _grainEffect;
  58773. /**
  58774. * Glow post process which adds a glow to emissive areas of the image
  58775. */
  58776. private _glowLayer;
  58777. /**
  58778. * Animations which can be used to tweak settings over a period of time
  58779. */
  58780. animations: Animation[];
  58781. private _imageProcessingConfigurationObserver;
  58782. private _sharpenEnabled;
  58783. private _bloomEnabled;
  58784. private _depthOfFieldEnabled;
  58785. private _depthOfFieldBlurLevel;
  58786. private _fxaaEnabled;
  58787. private _imageProcessingEnabled;
  58788. private _defaultPipelineTextureType;
  58789. private _bloomScale;
  58790. private _chromaticAberrationEnabled;
  58791. private _grainEnabled;
  58792. private _buildAllowed;
  58793. /**
  58794. * Gets active scene
  58795. */
  58796. readonly scene: Scene;
  58797. /**
  58798. * Enable or disable the sharpen process from the pipeline
  58799. */
  58800. sharpenEnabled: boolean;
  58801. private _resizeObserver;
  58802. private _hardwareScaleLevel;
  58803. private _bloomKernel;
  58804. /**
  58805. * Specifies the size of the bloom blur kernel, relative to the final output size
  58806. */
  58807. bloomKernel: number;
  58808. /**
  58809. * Specifies the weight of the bloom in the final rendering
  58810. */
  58811. private _bloomWeight;
  58812. /**
  58813. * Specifies the luma threshold for the area that will be blurred by the bloom
  58814. */
  58815. private _bloomThreshold;
  58816. private _hdr;
  58817. /**
  58818. * The strength of the bloom.
  58819. */
  58820. bloomWeight: number;
  58821. /**
  58822. * The strength of the bloom.
  58823. */
  58824. bloomThreshold: number;
  58825. /**
  58826. * The scale of the bloom, lower value will provide better performance.
  58827. */
  58828. bloomScale: number;
  58829. /**
  58830. * Enable or disable the bloom from the pipeline
  58831. */
  58832. bloomEnabled: boolean;
  58833. private _rebuildBloom;
  58834. /**
  58835. * If the depth of field is enabled.
  58836. */
  58837. depthOfFieldEnabled: boolean;
  58838. /**
  58839. * Blur level of the depth of field effect. (Higher blur will effect performance)
  58840. */
  58841. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  58842. /**
  58843. * If the anti aliasing is enabled.
  58844. */
  58845. fxaaEnabled: boolean;
  58846. private _samples;
  58847. /**
  58848. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  58849. */
  58850. samples: number;
  58851. /**
  58852. * If image processing is enabled.
  58853. */
  58854. imageProcessingEnabled: boolean;
  58855. /**
  58856. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  58857. */
  58858. glowLayerEnabled: boolean;
  58859. /**
  58860. * Gets the glow layer (or null if not defined)
  58861. */
  58862. readonly glowLayer: Nullable<GlowLayer>;
  58863. /**
  58864. * Enable or disable the chromaticAberration process from the pipeline
  58865. */
  58866. chromaticAberrationEnabled: boolean;
  58867. /**
  58868. * Enable or disable the grain process from the pipeline
  58869. */
  58870. grainEnabled: boolean;
  58871. /**
  58872. * @constructor
  58873. * @param name - The rendering pipeline name (default: "")
  58874. * @param hdr - If high dynamic range textures should be used (default: true)
  58875. * @param scene - The scene linked to this pipeline (default: the last created scene)
  58876. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  58877. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  58878. */
  58879. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  58880. /**
  58881. * Get the class name
  58882. * @returns "DefaultRenderingPipeline"
  58883. */
  58884. getClassName(): string;
  58885. /**
  58886. * Force the compilation of the entire pipeline.
  58887. */
  58888. prepare(): void;
  58889. private _hasCleared;
  58890. private _prevPostProcess;
  58891. private _prevPrevPostProcess;
  58892. private _setAutoClearAndTextureSharing;
  58893. private _depthOfFieldSceneObserver;
  58894. private _buildPipeline;
  58895. private _disposePostProcesses;
  58896. /**
  58897. * Adds a camera to the pipeline
  58898. * @param camera the camera to be added
  58899. */
  58900. addCamera(camera: Camera): void;
  58901. /**
  58902. * Removes a camera from the pipeline
  58903. * @param camera the camera to remove
  58904. */
  58905. removeCamera(camera: Camera): void;
  58906. /**
  58907. * Dispose of the pipeline and stop all post processes
  58908. */
  58909. dispose(): void;
  58910. /**
  58911. * Serialize the rendering pipeline (Used when exporting)
  58912. * @returns the serialized object
  58913. */
  58914. serialize(): any;
  58915. /**
  58916. * Parse the serialized pipeline
  58917. * @param source Source pipeline.
  58918. * @param scene The scene to load the pipeline to.
  58919. * @param rootUrl The URL of the serialized pipeline.
  58920. * @returns An instantiated pipeline from the serialized object.
  58921. */
  58922. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  58923. }
  58924. }
  58925. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  58926. /** @hidden */
  58927. export var lensHighlightsPixelShader: {
  58928. name: string;
  58929. shader: string;
  58930. };
  58931. }
  58932. declare module "babylonjs/Shaders/depthOfField.fragment" {
  58933. /** @hidden */
  58934. export var depthOfFieldPixelShader: {
  58935. name: string;
  58936. shader: string;
  58937. };
  58938. }
  58939. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  58940. import { Camera } from "babylonjs/Cameras/camera";
  58941. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  58942. import { Scene } from "babylonjs/scene";
  58943. import "babylonjs/Shaders/chromaticAberration.fragment";
  58944. import "babylonjs/Shaders/lensHighlights.fragment";
  58945. import "babylonjs/Shaders/depthOfField.fragment";
  58946. /**
  58947. * BABYLON.JS Chromatic Aberration GLSL Shader
  58948. * Author: Olivier Guyot
  58949. * Separates very slightly R, G and B colors on the edges of the screen
  58950. * Inspired by Francois Tarlier & Martins Upitis
  58951. */
  58952. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  58953. /**
  58954. * @ignore
  58955. * The chromatic aberration PostProcess id in the pipeline
  58956. */
  58957. LensChromaticAberrationEffect: string;
  58958. /**
  58959. * @ignore
  58960. * The highlights enhancing PostProcess id in the pipeline
  58961. */
  58962. HighlightsEnhancingEffect: string;
  58963. /**
  58964. * @ignore
  58965. * The depth-of-field PostProcess id in the pipeline
  58966. */
  58967. LensDepthOfFieldEffect: string;
  58968. private _scene;
  58969. private _depthTexture;
  58970. private _grainTexture;
  58971. private _chromaticAberrationPostProcess;
  58972. private _highlightsPostProcess;
  58973. private _depthOfFieldPostProcess;
  58974. private _edgeBlur;
  58975. private _grainAmount;
  58976. private _chromaticAberration;
  58977. private _distortion;
  58978. private _highlightsGain;
  58979. private _highlightsThreshold;
  58980. private _dofDistance;
  58981. private _dofAperture;
  58982. private _dofDarken;
  58983. private _dofPentagon;
  58984. private _blurNoise;
  58985. /**
  58986. * @constructor
  58987. *
  58988. * Effect parameters are as follow:
  58989. * {
  58990. * chromatic_aberration: number; // from 0 to x (1 for realism)
  58991. * edge_blur: number; // from 0 to x (1 for realism)
  58992. * distortion: number; // from 0 to x (1 for realism)
  58993. * grain_amount: number; // from 0 to 1
  58994. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  58995. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  58996. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  58997. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  58998. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  58999. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  59000. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  59001. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  59002. * }
  59003. * Note: if an effect parameter is unset, effect is disabled
  59004. *
  59005. * @param name The rendering pipeline name
  59006. * @param parameters - An object containing all parameters (see above)
  59007. * @param scene The scene linked to this pipeline
  59008. * @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)
  59009. * @param cameras The array of cameras that the rendering pipeline will be attached to
  59010. */
  59011. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  59012. /**
  59013. * Get the class name
  59014. * @returns "LensRenderingPipeline"
  59015. */
  59016. getClassName(): string;
  59017. /**
  59018. * Gets associated scene
  59019. */
  59020. readonly scene: Scene;
  59021. /**
  59022. * Gets or sets the edge blur
  59023. */
  59024. edgeBlur: number;
  59025. /**
  59026. * Gets or sets the grain amount
  59027. */
  59028. grainAmount: number;
  59029. /**
  59030. * Gets or sets the chromatic aberration amount
  59031. */
  59032. chromaticAberration: number;
  59033. /**
  59034. * Gets or sets the depth of field aperture
  59035. */
  59036. dofAperture: number;
  59037. /**
  59038. * Gets or sets the edge distortion
  59039. */
  59040. edgeDistortion: number;
  59041. /**
  59042. * Gets or sets the depth of field distortion
  59043. */
  59044. dofDistortion: number;
  59045. /**
  59046. * Gets or sets the darken out of focus amount
  59047. */
  59048. darkenOutOfFocus: number;
  59049. /**
  59050. * Gets or sets a boolean indicating if blur noise is enabled
  59051. */
  59052. blurNoise: boolean;
  59053. /**
  59054. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  59055. */
  59056. pentagonBokeh: boolean;
  59057. /**
  59058. * Gets or sets the highlight grain amount
  59059. */
  59060. highlightsGain: number;
  59061. /**
  59062. * Gets or sets the highlight threshold
  59063. */
  59064. highlightsThreshold: number;
  59065. /**
  59066. * Sets the amount of blur at the edges
  59067. * @param amount blur amount
  59068. */
  59069. setEdgeBlur(amount: number): void;
  59070. /**
  59071. * Sets edge blur to 0
  59072. */
  59073. disableEdgeBlur(): void;
  59074. /**
  59075. * Sets the amout of grain
  59076. * @param amount Amount of grain
  59077. */
  59078. setGrainAmount(amount: number): void;
  59079. /**
  59080. * Set grain amount to 0
  59081. */
  59082. disableGrain(): void;
  59083. /**
  59084. * Sets the chromatic aberration amount
  59085. * @param amount amount of chromatic aberration
  59086. */
  59087. setChromaticAberration(amount: number): void;
  59088. /**
  59089. * Sets chromatic aberration amount to 0
  59090. */
  59091. disableChromaticAberration(): void;
  59092. /**
  59093. * Sets the EdgeDistortion amount
  59094. * @param amount amount of EdgeDistortion
  59095. */
  59096. setEdgeDistortion(amount: number): void;
  59097. /**
  59098. * Sets edge distortion to 0
  59099. */
  59100. disableEdgeDistortion(): void;
  59101. /**
  59102. * Sets the FocusDistance amount
  59103. * @param amount amount of FocusDistance
  59104. */
  59105. setFocusDistance(amount: number): void;
  59106. /**
  59107. * Disables depth of field
  59108. */
  59109. disableDepthOfField(): void;
  59110. /**
  59111. * Sets the Aperture amount
  59112. * @param amount amount of Aperture
  59113. */
  59114. setAperture(amount: number): void;
  59115. /**
  59116. * Sets the DarkenOutOfFocus amount
  59117. * @param amount amount of DarkenOutOfFocus
  59118. */
  59119. setDarkenOutOfFocus(amount: number): void;
  59120. private _pentagonBokehIsEnabled;
  59121. /**
  59122. * Creates a pentagon bokeh effect
  59123. */
  59124. enablePentagonBokeh(): void;
  59125. /**
  59126. * Disables the pentagon bokeh effect
  59127. */
  59128. disablePentagonBokeh(): void;
  59129. /**
  59130. * Enables noise blur
  59131. */
  59132. enableNoiseBlur(): void;
  59133. /**
  59134. * Disables noise blur
  59135. */
  59136. disableNoiseBlur(): void;
  59137. /**
  59138. * Sets the HighlightsGain amount
  59139. * @param amount amount of HighlightsGain
  59140. */
  59141. setHighlightsGain(amount: number): void;
  59142. /**
  59143. * Sets the HighlightsThreshold amount
  59144. * @param amount amount of HighlightsThreshold
  59145. */
  59146. setHighlightsThreshold(amount: number): void;
  59147. /**
  59148. * Disables highlights
  59149. */
  59150. disableHighlights(): void;
  59151. /**
  59152. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  59153. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  59154. */
  59155. dispose(disableDepthRender?: boolean): void;
  59156. private _createChromaticAberrationPostProcess;
  59157. private _createHighlightsPostProcess;
  59158. private _createDepthOfFieldPostProcess;
  59159. private _createGrainTexture;
  59160. }
  59161. }
  59162. declare module "babylonjs/Shaders/ssao2.fragment" {
  59163. /** @hidden */
  59164. export var ssao2PixelShader: {
  59165. name: string;
  59166. shader: string;
  59167. };
  59168. }
  59169. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  59170. /** @hidden */
  59171. export var ssaoCombinePixelShader: {
  59172. name: string;
  59173. shader: string;
  59174. };
  59175. }
  59176. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  59177. import { Camera } from "babylonjs/Cameras/camera";
  59178. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  59179. import { Scene } from "babylonjs/scene";
  59180. import "babylonjs/Shaders/ssao2.fragment";
  59181. import "babylonjs/Shaders/ssaoCombine.fragment";
  59182. /**
  59183. * Render pipeline to produce ssao effect
  59184. */
  59185. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  59186. /**
  59187. * @ignore
  59188. * The PassPostProcess id in the pipeline that contains the original scene color
  59189. */
  59190. SSAOOriginalSceneColorEffect: string;
  59191. /**
  59192. * @ignore
  59193. * The SSAO PostProcess id in the pipeline
  59194. */
  59195. SSAORenderEffect: string;
  59196. /**
  59197. * @ignore
  59198. * The horizontal blur PostProcess id in the pipeline
  59199. */
  59200. SSAOBlurHRenderEffect: string;
  59201. /**
  59202. * @ignore
  59203. * The vertical blur PostProcess id in the pipeline
  59204. */
  59205. SSAOBlurVRenderEffect: string;
  59206. /**
  59207. * @ignore
  59208. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  59209. */
  59210. SSAOCombineRenderEffect: string;
  59211. /**
  59212. * The output strength of the SSAO post-process. Default value is 1.0.
  59213. */
  59214. totalStrength: number;
  59215. /**
  59216. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  59217. */
  59218. maxZ: number;
  59219. /**
  59220. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  59221. */
  59222. minZAspect: number;
  59223. private _samples;
  59224. /**
  59225. * Number of samples used for the SSAO calculations. Default value is 8
  59226. */
  59227. samples: number;
  59228. private _textureSamples;
  59229. /**
  59230. * Number of samples to use for antialiasing
  59231. */
  59232. textureSamples: number;
  59233. /**
  59234. * Ratio object used for SSAO ratio and blur ratio
  59235. */
  59236. private _ratio;
  59237. /**
  59238. * Dynamically generated sphere sampler.
  59239. */
  59240. private _sampleSphere;
  59241. /**
  59242. * Blur filter offsets
  59243. */
  59244. private _samplerOffsets;
  59245. private _expensiveBlur;
  59246. /**
  59247. * If bilateral blur should be used
  59248. */
  59249. expensiveBlur: boolean;
  59250. /**
  59251. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  59252. */
  59253. radius: number;
  59254. /**
  59255. * The base color of the SSAO post-process
  59256. * The final result is "base + ssao" between [0, 1]
  59257. */
  59258. base: number;
  59259. /**
  59260. * Support test.
  59261. */
  59262. static readonly IsSupported: boolean;
  59263. private _scene;
  59264. private _depthTexture;
  59265. private _normalTexture;
  59266. private _randomTexture;
  59267. private _originalColorPostProcess;
  59268. private _ssaoPostProcess;
  59269. private _blurHPostProcess;
  59270. private _blurVPostProcess;
  59271. private _ssaoCombinePostProcess;
  59272. private _firstUpdate;
  59273. /**
  59274. * Gets active scene
  59275. */
  59276. readonly scene: Scene;
  59277. /**
  59278. * @constructor
  59279. * @param name The rendering pipeline name
  59280. * @param scene The scene linked to this pipeline
  59281. * @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 }
  59282. * @param cameras The array of cameras that the rendering pipeline will be attached to
  59283. */
  59284. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  59285. /**
  59286. * Get the class name
  59287. * @returns "SSAO2RenderingPipeline"
  59288. */
  59289. getClassName(): string;
  59290. /**
  59291. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  59292. */
  59293. dispose(disableGeometryBufferRenderer?: boolean): void;
  59294. private _createBlurPostProcess;
  59295. /** @hidden */
  59296. _rebuild(): void;
  59297. private _bits;
  59298. private _radicalInverse_VdC;
  59299. private _hammersley;
  59300. private _hemisphereSample_uniform;
  59301. private _generateHemisphere;
  59302. private _createSSAOPostProcess;
  59303. private _createSSAOCombinePostProcess;
  59304. private _createRandomTexture;
  59305. /**
  59306. * Serialize the rendering pipeline (Used when exporting)
  59307. * @returns the serialized object
  59308. */
  59309. serialize(): any;
  59310. /**
  59311. * Parse the serialized pipeline
  59312. * @param source Source pipeline.
  59313. * @param scene The scene to load the pipeline to.
  59314. * @param rootUrl The URL of the serialized pipeline.
  59315. * @returns An instantiated pipeline from the serialized object.
  59316. */
  59317. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  59318. }
  59319. }
  59320. declare module "babylonjs/Shaders/ssao.fragment" {
  59321. /** @hidden */
  59322. export var ssaoPixelShader: {
  59323. name: string;
  59324. shader: string;
  59325. };
  59326. }
  59327. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  59328. import { Camera } from "babylonjs/Cameras/camera";
  59329. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  59330. import { Scene } from "babylonjs/scene";
  59331. import "babylonjs/Shaders/ssao.fragment";
  59332. import "babylonjs/Shaders/ssaoCombine.fragment";
  59333. /**
  59334. * Render pipeline to produce ssao effect
  59335. */
  59336. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  59337. /**
  59338. * @ignore
  59339. * The PassPostProcess id in the pipeline that contains the original scene color
  59340. */
  59341. SSAOOriginalSceneColorEffect: string;
  59342. /**
  59343. * @ignore
  59344. * The SSAO PostProcess id in the pipeline
  59345. */
  59346. SSAORenderEffect: string;
  59347. /**
  59348. * @ignore
  59349. * The horizontal blur PostProcess id in the pipeline
  59350. */
  59351. SSAOBlurHRenderEffect: string;
  59352. /**
  59353. * @ignore
  59354. * The vertical blur PostProcess id in the pipeline
  59355. */
  59356. SSAOBlurVRenderEffect: string;
  59357. /**
  59358. * @ignore
  59359. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  59360. */
  59361. SSAOCombineRenderEffect: string;
  59362. /**
  59363. * The output strength of the SSAO post-process. Default value is 1.0.
  59364. */
  59365. totalStrength: number;
  59366. /**
  59367. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  59368. */
  59369. radius: number;
  59370. /**
  59371. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  59372. * Must not be equal to fallOff and superior to fallOff.
  59373. * Default value is 0.0075
  59374. */
  59375. area: number;
  59376. /**
  59377. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  59378. * Must not be equal to area and inferior to area.
  59379. * Default value is 0.000001
  59380. */
  59381. fallOff: number;
  59382. /**
  59383. * The base color of the SSAO post-process
  59384. * The final result is "base + ssao" between [0, 1]
  59385. */
  59386. base: number;
  59387. private _scene;
  59388. private _depthTexture;
  59389. private _randomTexture;
  59390. private _originalColorPostProcess;
  59391. private _ssaoPostProcess;
  59392. private _blurHPostProcess;
  59393. private _blurVPostProcess;
  59394. private _ssaoCombinePostProcess;
  59395. private _firstUpdate;
  59396. /**
  59397. * Gets active scene
  59398. */
  59399. readonly scene: Scene;
  59400. /**
  59401. * @constructor
  59402. * @param name - The rendering pipeline name
  59403. * @param scene - The scene linked to this pipeline
  59404. * @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 }
  59405. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  59406. */
  59407. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  59408. /**
  59409. * Get the class name
  59410. * @returns "SSAORenderingPipeline"
  59411. */
  59412. getClassName(): string;
  59413. /**
  59414. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  59415. */
  59416. dispose(disableDepthRender?: boolean): void;
  59417. private _createBlurPostProcess;
  59418. /** @hidden */
  59419. _rebuild(): void;
  59420. private _createSSAOPostProcess;
  59421. private _createSSAOCombinePostProcess;
  59422. private _createRandomTexture;
  59423. }
  59424. }
  59425. declare module "babylonjs/Shaders/standard.fragment" {
  59426. /** @hidden */
  59427. export var standardPixelShader: {
  59428. name: string;
  59429. shader: string;
  59430. };
  59431. }
  59432. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  59433. import { Nullable } from "babylonjs/types";
  59434. import { IAnimatable } from "babylonjs/Misc/tools";
  59435. import { Camera } from "babylonjs/Cameras/camera";
  59436. import { Texture } from "babylonjs/Materials/Textures/texture";
  59437. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  59438. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  59439. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  59440. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  59441. import { IDisposable } from "babylonjs/scene";
  59442. import { SpotLight } from "babylonjs/Lights/spotLight";
  59443. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  59444. import { Scene } from "babylonjs/scene";
  59445. import { Animation } from "babylonjs/Animations/animation";
  59446. import "babylonjs/Shaders/standard.fragment";
  59447. /**
  59448. * Standard rendering pipeline
  59449. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  59450. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  59451. */
  59452. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  59453. /**
  59454. * Public members
  59455. */
  59456. /**
  59457. * Post-process which contains the original scene color before the pipeline applies all the effects
  59458. */
  59459. originalPostProcess: Nullable<PostProcess>;
  59460. /**
  59461. * Post-process used to down scale an image x4
  59462. */
  59463. downSampleX4PostProcess: Nullable<PostProcess>;
  59464. /**
  59465. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  59466. */
  59467. brightPassPostProcess: Nullable<PostProcess>;
  59468. /**
  59469. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  59470. */
  59471. blurHPostProcesses: PostProcess[];
  59472. /**
  59473. * Post-process array storing all the vertical blur post-processes used by the pipeline
  59474. */
  59475. blurVPostProcesses: PostProcess[];
  59476. /**
  59477. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  59478. */
  59479. textureAdderPostProcess: Nullable<PostProcess>;
  59480. /**
  59481. * Post-process used to create volumetric lighting effect
  59482. */
  59483. volumetricLightPostProcess: Nullable<PostProcess>;
  59484. /**
  59485. * Post-process used to smooth the previous volumetric light post-process on the X axis
  59486. */
  59487. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  59488. /**
  59489. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  59490. */
  59491. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  59492. /**
  59493. * Post-process used to merge the volumetric light effect and the real scene color
  59494. */
  59495. volumetricLightMergePostProces: Nullable<PostProcess>;
  59496. /**
  59497. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  59498. */
  59499. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  59500. /**
  59501. * Base post-process used to calculate the average luminance of the final image for HDR
  59502. */
  59503. luminancePostProcess: Nullable<PostProcess>;
  59504. /**
  59505. * Post-processes used to create down sample post-processes in order to get
  59506. * the average luminance of the final image for HDR
  59507. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  59508. */
  59509. luminanceDownSamplePostProcesses: PostProcess[];
  59510. /**
  59511. * Post-process used to create a HDR effect (light adaptation)
  59512. */
  59513. hdrPostProcess: Nullable<PostProcess>;
  59514. /**
  59515. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  59516. */
  59517. textureAdderFinalPostProcess: Nullable<PostProcess>;
  59518. /**
  59519. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  59520. */
  59521. lensFlareFinalPostProcess: Nullable<PostProcess>;
  59522. /**
  59523. * Post-process used to merge the final HDR post-process and the real scene color
  59524. */
  59525. hdrFinalPostProcess: Nullable<PostProcess>;
  59526. /**
  59527. * Post-process used to create a lens flare effect
  59528. */
  59529. lensFlarePostProcess: Nullable<PostProcess>;
  59530. /**
  59531. * Post-process that merges the result of the lens flare post-process and the real scene color
  59532. */
  59533. lensFlareComposePostProcess: Nullable<PostProcess>;
  59534. /**
  59535. * Post-process used to create a motion blur effect
  59536. */
  59537. motionBlurPostProcess: Nullable<PostProcess>;
  59538. /**
  59539. * Post-process used to create a depth of field effect
  59540. */
  59541. depthOfFieldPostProcess: Nullable<PostProcess>;
  59542. /**
  59543. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  59544. */
  59545. fxaaPostProcess: Nullable<FxaaPostProcess>;
  59546. /**
  59547. * Represents the brightness threshold in order to configure the illuminated surfaces
  59548. */
  59549. brightThreshold: number;
  59550. /**
  59551. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  59552. */
  59553. blurWidth: number;
  59554. /**
  59555. * Sets if the blur for highlighted surfaces must be only horizontal
  59556. */
  59557. horizontalBlur: boolean;
  59558. /**
  59559. * Gets the overall exposure used by the pipeline
  59560. */
  59561. /**
  59562. * Sets the overall exposure used by the pipeline
  59563. */
  59564. exposure: number;
  59565. /**
  59566. * Texture used typically to simulate "dirty" on camera lens
  59567. */
  59568. lensTexture: Nullable<Texture>;
  59569. /**
  59570. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  59571. */
  59572. volumetricLightCoefficient: number;
  59573. /**
  59574. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  59575. */
  59576. volumetricLightPower: number;
  59577. /**
  59578. * Used the set the blur intensity to smooth the volumetric lights
  59579. */
  59580. volumetricLightBlurScale: number;
  59581. /**
  59582. * Light (spot or directional) used to generate the volumetric lights rays
  59583. * The source light must have a shadow generate so the pipeline can get its
  59584. * depth map
  59585. */
  59586. sourceLight: Nullable<SpotLight | DirectionalLight>;
  59587. /**
  59588. * For eye adaptation, represents the minimum luminance the eye can see
  59589. */
  59590. hdrMinimumLuminance: number;
  59591. /**
  59592. * For eye adaptation, represents the decrease luminance speed
  59593. */
  59594. hdrDecreaseRate: number;
  59595. /**
  59596. * For eye adaptation, represents the increase luminance speed
  59597. */
  59598. hdrIncreaseRate: number;
  59599. /**
  59600. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  59601. */
  59602. /**
  59603. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  59604. */
  59605. hdrAutoExposure: boolean;
  59606. /**
  59607. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  59608. */
  59609. lensColorTexture: Nullable<Texture>;
  59610. /**
  59611. * The overall strengh for the lens flare effect
  59612. */
  59613. lensFlareStrength: number;
  59614. /**
  59615. * Dispersion coefficient for lens flare ghosts
  59616. */
  59617. lensFlareGhostDispersal: number;
  59618. /**
  59619. * Main lens flare halo width
  59620. */
  59621. lensFlareHaloWidth: number;
  59622. /**
  59623. * Based on the lens distortion effect, defines how much the lens flare result
  59624. * is distorted
  59625. */
  59626. lensFlareDistortionStrength: number;
  59627. /**
  59628. * Lens star texture must be used to simulate rays on the flares and is available
  59629. * in the documentation
  59630. */
  59631. lensStarTexture: Nullable<Texture>;
  59632. /**
  59633. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  59634. * flare effect by taking account of the dirt texture
  59635. */
  59636. lensFlareDirtTexture: Nullable<Texture>;
  59637. /**
  59638. * Represents the focal length for the depth of field effect
  59639. */
  59640. depthOfFieldDistance: number;
  59641. /**
  59642. * Represents the blur intensity for the blurred part of the depth of field effect
  59643. */
  59644. depthOfFieldBlurWidth: number;
  59645. /**
  59646. * Gets how much the image is blurred by the movement while using the motion blur post-process
  59647. */
  59648. /**
  59649. * Sets how much the image is blurred by the movement while using the motion blur post-process
  59650. */
  59651. motionStrength: number;
  59652. /**
  59653. * Gets wether or not the motion blur post-process is object based or screen based.
  59654. */
  59655. /**
  59656. * Sets wether or not the motion blur post-process should be object based or screen based
  59657. */
  59658. objectBasedMotionBlur: boolean;
  59659. /**
  59660. * List of animations for the pipeline (IAnimatable implementation)
  59661. */
  59662. animations: Animation[];
  59663. /**
  59664. * Private members
  59665. */
  59666. private _scene;
  59667. private _currentDepthOfFieldSource;
  59668. private _basePostProcess;
  59669. private _fixedExposure;
  59670. private _currentExposure;
  59671. private _hdrAutoExposure;
  59672. private _hdrCurrentLuminance;
  59673. private _motionStrength;
  59674. private _isObjectBasedMotionBlur;
  59675. private _floatTextureType;
  59676. private _ratio;
  59677. private _bloomEnabled;
  59678. private _depthOfFieldEnabled;
  59679. private _vlsEnabled;
  59680. private _lensFlareEnabled;
  59681. private _hdrEnabled;
  59682. private _motionBlurEnabled;
  59683. private _fxaaEnabled;
  59684. private _motionBlurSamples;
  59685. private _volumetricLightStepsCount;
  59686. private _samples;
  59687. /**
  59688. * @ignore
  59689. * Specifies if the bloom pipeline is enabled
  59690. */
  59691. BloomEnabled: boolean;
  59692. /**
  59693. * @ignore
  59694. * Specifies if the depth of field pipeline is enabed
  59695. */
  59696. DepthOfFieldEnabled: boolean;
  59697. /**
  59698. * @ignore
  59699. * Specifies if the lens flare pipeline is enabed
  59700. */
  59701. LensFlareEnabled: boolean;
  59702. /**
  59703. * @ignore
  59704. * Specifies if the HDR pipeline is enabled
  59705. */
  59706. HDREnabled: boolean;
  59707. /**
  59708. * @ignore
  59709. * Specifies if the volumetric lights scattering effect is enabled
  59710. */
  59711. VLSEnabled: boolean;
  59712. /**
  59713. * @ignore
  59714. * Specifies if the motion blur effect is enabled
  59715. */
  59716. MotionBlurEnabled: boolean;
  59717. /**
  59718. * Specifies if anti-aliasing is enabled
  59719. */
  59720. fxaaEnabled: boolean;
  59721. /**
  59722. * Specifies the number of steps used to calculate the volumetric lights
  59723. * Typically in interval [50, 200]
  59724. */
  59725. volumetricLightStepsCount: number;
  59726. /**
  59727. * Specifies the number of samples used for the motion blur effect
  59728. * Typically in interval [16, 64]
  59729. */
  59730. motionBlurSamples: number;
  59731. /**
  59732. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  59733. */
  59734. samples: number;
  59735. /**
  59736. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  59737. * @constructor
  59738. * @param name The rendering pipeline name
  59739. * @param scene The scene linked to this pipeline
  59740. * @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)
  59741. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  59742. * @param cameras The array of cameras that the rendering pipeline will be attached to
  59743. */
  59744. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  59745. private _buildPipeline;
  59746. private _createDownSampleX4PostProcess;
  59747. private _createBrightPassPostProcess;
  59748. private _createBlurPostProcesses;
  59749. private _createTextureAdderPostProcess;
  59750. private _createVolumetricLightPostProcess;
  59751. private _createLuminancePostProcesses;
  59752. private _createHdrPostProcess;
  59753. private _createLensFlarePostProcess;
  59754. private _createDepthOfFieldPostProcess;
  59755. private _createMotionBlurPostProcess;
  59756. private _getDepthTexture;
  59757. private _disposePostProcesses;
  59758. /**
  59759. * Dispose of the pipeline and stop all post processes
  59760. */
  59761. dispose(): void;
  59762. /**
  59763. * Serialize the rendering pipeline (Used when exporting)
  59764. * @returns the serialized object
  59765. */
  59766. serialize(): any;
  59767. /**
  59768. * Parse the serialized pipeline
  59769. * @param source Source pipeline.
  59770. * @param scene The scene to load the pipeline to.
  59771. * @param rootUrl The URL of the serialized pipeline.
  59772. * @returns An instantiated pipeline from the serialized object.
  59773. */
  59774. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  59775. /**
  59776. * Luminance steps
  59777. */
  59778. static LuminanceSteps: number;
  59779. }
  59780. }
  59781. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  59782. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  59783. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  59784. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  59785. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  59786. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  59787. }
  59788. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  59789. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  59790. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  59791. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  59792. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  59793. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  59794. }
  59795. declare module "babylonjs/Shaders/tonemap.fragment" {
  59796. /** @hidden */
  59797. export var tonemapPixelShader: {
  59798. name: string;
  59799. shader: string;
  59800. };
  59801. }
  59802. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  59803. import { Camera } from "babylonjs/Cameras/camera";
  59804. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  59805. import "babylonjs/Shaders/tonemap.fragment";
  59806. import { Engine } from "babylonjs/Engines/engine";
  59807. /** Defines operator used for tonemapping */
  59808. export enum TonemappingOperator {
  59809. /** Hable */
  59810. Hable = 0,
  59811. /** Reinhard */
  59812. Reinhard = 1,
  59813. /** HejiDawson */
  59814. HejiDawson = 2,
  59815. /** Photographic */
  59816. Photographic = 3
  59817. }
  59818. /**
  59819. * Defines a post process to apply tone mapping
  59820. */
  59821. export class TonemapPostProcess extends PostProcess {
  59822. private _operator;
  59823. /** Defines the required exposure adjustement */
  59824. exposureAdjustment: number;
  59825. /**
  59826. * Creates a new TonemapPostProcess
  59827. * @param name defines the name of the postprocess
  59828. * @param _operator defines the operator to use
  59829. * @param exposureAdjustment defines the required exposure adjustement
  59830. * @param camera defines the camera to use (can be null)
  59831. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  59832. * @param engine defines the hosting engine (can be ignore if camera is set)
  59833. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  59834. */
  59835. constructor(name: string, _operator: TonemappingOperator,
  59836. /** Defines the required exposure adjustement */
  59837. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  59838. }
  59839. }
  59840. declare module "babylonjs/Shaders/depth.vertex" {
  59841. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  59842. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  59843. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  59844. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  59845. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  59846. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  59847. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  59848. /** @hidden */
  59849. export var depthVertexShader: {
  59850. name: string;
  59851. shader: string;
  59852. };
  59853. }
  59854. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  59855. /** @hidden */
  59856. export var volumetricLightScatteringPixelShader: {
  59857. name: string;
  59858. shader: string;
  59859. };
  59860. }
  59861. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  59862. /** @hidden */
  59863. export var volumetricLightScatteringPassPixelShader: {
  59864. name: string;
  59865. shader: string;
  59866. };
  59867. }
  59868. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  59869. import { Vector3 } from "babylonjs/Maths/math";
  59870. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59871. import { Mesh } from "babylonjs/Meshes/mesh";
  59872. import { Camera } from "babylonjs/Cameras/camera";
  59873. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  59874. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  59875. import { Scene } from "babylonjs/scene";
  59876. import "babylonjs/Meshes/Builders/planeBuilder";
  59877. import "babylonjs/Shaders/depth.vertex";
  59878. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  59879. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  59880. import { Engine } from "babylonjs/Engines/engine";
  59881. /**
  59882. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  59883. */
  59884. export class VolumetricLightScatteringPostProcess extends PostProcess {
  59885. private _volumetricLightScatteringPass;
  59886. private _volumetricLightScatteringRTT;
  59887. private _viewPort;
  59888. private _screenCoordinates;
  59889. private _cachedDefines;
  59890. /**
  59891. * If not undefined, the mesh position is computed from the attached node position
  59892. */
  59893. attachedNode: {
  59894. position: Vector3;
  59895. };
  59896. /**
  59897. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  59898. */
  59899. customMeshPosition: Vector3;
  59900. /**
  59901. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  59902. */
  59903. useCustomMeshPosition: boolean;
  59904. /**
  59905. * If the post-process should inverse the light scattering direction
  59906. */
  59907. invert: boolean;
  59908. /**
  59909. * The internal mesh used by the post-process
  59910. */
  59911. mesh: Mesh;
  59912. /**
  59913. * @hidden
  59914. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  59915. */
  59916. useDiffuseColor: boolean;
  59917. /**
  59918. * Array containing the excluded meshes not rendered in the internal pass
  59919. */
  59920. excludedMeshes: AbstractMesh[];
  59921. /**
  59922. * Controls the overall intensity of the post-process
  59923. */
  59924. exposure: number;
  59925. /**
  59926. * Dissipates each sample's contribution in range [0, 1]
  59927. */
  59928. decay: number;
  59929. /**
  59930. * Controls the overall intensity of each sample
  59931. */
  59932. weight: number;
  59933. /**
  59934. * Controls the density of each sample
  59935. */
  59936. density: number;
  59937. /**
  59938. * @constructor
  59939. * @param name The post-process name
  59940. * @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)
  59941. * @param camera The camera that the post-process will be attached to
  59942. * @param mesh The mesh used to create the light scattering
  59943. * @param samples The post-process quality, default 100
  59944. * @param samplingModeThe post-process filtering mode
  59945. * @param engine The babylon engine
  59946. * @param reusable If the post-process is reusable
  59947. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  59948. */
  59949. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  59950. /**
  59951. * Returns the string "VolumetricLightScatteringPostProcess"
  59952. * @returns "VolumetricLightScatteringPostProcess"
  59953. */
  59954. getClassName(): string;
  59955. private _isReady;
  59956. /**
  59957. * Sets the new light position for light scattering effect
  59958. * @param position The new custom light position
  59959. */
  59960. setCustomMeshPosition(position: Vector3): void;
  59961. /**
  59962. * Returns the light position for light scattering effect
  59963. * @return Vector3 The custom light position
  59964. */
  59965. getCustomMeshPosition(): Vector3;
  59966. /**
  59967. * Disposes the internal assets and detaches the post-process from the camera
  59968. */
  59969. dispose(camera: Camera): void;
  59970. /**
  59971. * Returns the render target texture used by the post-process
  59972. * @return the render target texture used by the post-process
  59973. */
  59974. getPass(): RenderTargetTexture;
  59975. private _meshExcluded;
  59976. private _createPass;
  59977. private _updateMeshScreenCoordinates;
  59978. /**
  59979. * Creates a default mesh for the Volumeric Light Scattering post-process
  59980. * @param name The mesh name
  59981. * @param scene The scene where to create the mesh
  59982. * @return the default mesh
  59983. */
  59984. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  59985. }
  59986. }
  59987. declare module "babylonjs/PostProcesses/index" {
  59988. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  59989. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  59990. export * from "babylonjs/PostProcesses/bloomEffect";
  59991. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  59992. export * from "babylonjs/PostProcesses/blurPostProcess";
  59993. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  59994. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  59995. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  59996. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  59997. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  59998. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  59999. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  60000. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  60001. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  60002. export * from "babylonjs/PostProcesses/filterPostProcess";
  60003. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  60004. export * from "babylonjs/PostProcesses/grainPostProcess";
  60005. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  60006. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  60007. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  60008. export * from "babylonjs/PostProcesses/passPostProcess";
  60009. export * from "babylonjs/PostProcesses/postProcess";
  60010. export * from "babylonjs/PostProcesses/postProcessManager";
  60011. export * from "babylonjs/PostProcesses/refractionPostProcess";
  60012. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  60013. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  60014. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  60015. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  60016. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  60017. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  60018. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  60019. }
  60020. declare module "babylonjs/Probes/index" {
  60021. export * from "babylonjs/Probes/reflectionProbe";
  60022. }
  60023. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  60024. import { Scene } from "babylonjs/scene";
  60025. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60026. import { Color3 } from "babylonjs/Maths/math";
  60027. import { SmartArray } from "babylonjs/Misc/smartArray";
  60028. import { ISceneComponent } from "babylonjs/sceneComponent";
  60029. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  60030. import "babylonjs/Meshes/Builders/boxBuilder";
  60031. import "babylonjs/Shaders/color.fragment";
  60032. import "babylonjs/Shaders/color.vertex";
  60033. module "babylonjs/scene" {
  60034. interface Scene {
  60035. /** @hidden (Backing field) */
  60036. _boundingBoxRenderer: BoundingBoxRenderer;
  60037. /** @hidden (Backing field) */
  60038. _forceShowBoundingBoxes: boolean;
  60039. /**
  60040. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  60041. */
  60042. forceShowBoundingBoxes: boolean;
  60043. /**
  60044. * Gets the bounding box renderer associated with the scene
  60045. * @returns a BoundingBoxRenderer
  60046. */
  60047. getBoundingBoxRenderer(): BoundingBoxRenderer;
  60048. }
  60049. }
  60050. module "babylonjs/Meshes/abstractMesh" {
  60051. interface AbstractMesh {
  60052. /** @hidden (Backing field) */
  60053. _showBoundingBox: boolean;
  60054. /**
  60055. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  60056. */
  60057. showBoundingBox: boolean;
  60058. }
  60059. }
  60060. /**
  60061. * Component responsible of rendering the bounding box of the meshes in a scene.
  60062. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  60063. */
  60064. export class BoundingBoxRenderer implements ISceneComponent {
  60065. /**
  60066. * The component name helpfull to identify the component in the list of scene components.
  60067. */
  60068. readonly name: string;
  60069. /**
  60070. * The scene the component belongs to.
  60071. */
  60072. scene: Scene;
  60073. /**
  60074. * Color of the bounding box lines placed in front of an object
  60075. */
  60076. frontColor: Color3;
  60077. /**
  60078. * Color of the bounding box lines placed behind an object
  60079. */
  60080. backColor: Color3;
  60081. /**
  60082. * Defines if the renderer should show the back lines or not
  60083. */
  60084. showBackLines: boolean;
  60085. /**
  60086. * @hidden
  60087. */
  60088. renderList: SmartArray<BoundingBox>;
  60089. private _colorShader;
  60090. private _vertexBuffers;
  60091. private _indexBuffer;
  60092. private _fillIndexBuffer;
  60093. private _fillIndexData;
  60094. /**
  60095. * Instantiates a new bounding box renderer in a scene.
  60096. * @param scene the scene the renderer renders in
  60097. */
  60098. constructor(scene: Scene);
  60099. /**
  60100. * Registers the component in a given scene
  60101. */
  60102. register(): void;
  60103. private _evaluateSubMesh;
  60104. private _activeMesh;
  60105. private _prepareRessources;
  60106. private _createIndexBuffer;
  60107. /**
  60108. * Rebuilds the elements related to this component in case of
  60109. * context lost for instance.
  60110. */
  60111. rebuild(): void;
  60112. /**
  60113. * @hidden
  60114. */
  60115. reset(): void;
  60116. /**
  60117. * Render the bounding boxes of a specific rendering group
  60118. * @param renderingGroupId defines the rendering group to render
  60119. */
  60120. render(renderingGroupId: number): void;
  60121. /**
  60122. * In case of occlusion queries, we can render the occlusion bounding box through this method
  60123. * @param mesh Define the mesh to render the occlusion bounding box for
  60124. */
  60125. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  60126. /**
  60127. * Dispose and release the resources attached to this renderer.
  60128. */
  60129. dispose(): void;
  60130. }
  60131. }
  60132. declare module "babylonjs/Shaders/depth.fragment" {
  60133. /** @hidden */
  60134. export var depthPixelShader: {
  60135. name: string;
  60136. shader: string;
  60137. };
  60138. }
  60139. declare module "babylonjs/Rendering/depthRenderer" {
  60140. import { Nullable } from "babylonjs/types";
  60141. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60142. import { Scene } from "babylonjs/scene";
  60143. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60144. import { Camera } from "babylonjs/Cameras/camera";
  60145. import "babylonjs/Shaders/depth.fragment";
  60146. import "babylonjs/Shaders/depth.vertex";
  60147. /**
  60148. * This represents a depth renderer in Babylon.
  60149. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  60150. */
  60151. export class DepthRenderer {
  60152. private _scene;
  60153. private _depthMap;
  60154. private _effect;
  60155. private _cachedDefines;
  60156. private _camera;
  60157. /**
  60158. * Specifiess that the depth renderer will only be used within
  60159. * the camera it is created for.
  60160. * This can help forcing its rendering during the camera processing.
  60161. */
  60162. useOnlyInActiveCamera: boolean;
  60163. /** @hidden */
  60164. static _SceneComponentInitialization: (scene: Scene) => void;
  60165. /**
  60166. * Instantiates a depth renderer
  60167. * @param scene The scene the renderer belongs to
  60168. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  60169. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  60170. */
  60171. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  60172. /**
  60173. * Creates the depth rendering effect and checks if the effect is ready.
  60174. * @param subMesh The submesh to be used to render the depth map of
  60175. * @param useInstances If multiple world instances should be used
  60176. * @returns if the depth renderer is ready to render the depth map
  60177. */
  60178. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60179. /**
  60180. * Gets the texture which the depth map will be written to.
  60181. * @returns The depth map texture
  60182. */
  60183. getDepthMap(): RenderTargetTexture;
  60184. /**
  60185. * Disposes of the depth renderer.
  60186. */
  60187. dispose(): void;
  60188. }
  60189. }
  60190. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  60191. import { Nullable } from "babylonjs/types";
  60192. import { Scene } from "babylonjs/scene";
  60193. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  60194. import { Camera } from "babylonjs/Cameras/camera";
  60195. import { ISceneComponent } from "babylonjs/sceneComponent";
  60196. module "babylonjs/scene" {
  60197. interface Scene {
  60198. /** @hidden (Backing field) */
  60199. _depthRenderer: {
  60200. [id: string]: DepthRenderer;
  60201. };
  60202. /**
  60203. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  60204. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  60205. * @returns the created depth renderer
  60206. */
  60207. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  60208. /**
  60209. * Disables a depth renderer for a given camera
  60210. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  60211. */
  60212. disableDepthRenderer(camera?: Nullable<Camera>): void;
  60213. }
  60214. }
  60215. /**
  60216. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  60217. * in several rendering techniques.
  60218. */
  60219. export class DepthRendererSceneComponent implements ISceneComponent {
  60220. /**
  60221. * The component name helpfull to identify the component in the list of scene components.
  60222. */
  60223. readonly name: string;
  60224. /**
  60225. * The scene the component belongs to.
  60226. */
  60227. scene: Scene;
  60228. /**
  60229. * Creates a new instance of the component for the given scene
  60230. * @param scene Defines the scene to register the component in
  60231. */
  60232. constructor(scene: Scene);
  60233. /**
  60234. * Registers the component in a given scene
  60235. */
  60236. register(): void;
  60237. /**
  60238. * Rebuilds the elements related to this component in case of
  60239. * context lost for instance.
  60240. */
  60241. rebuild(): void;
  60242. /**
  60243. * Disposes the component and the associated ressources
  60244. */
  60245. dispose(): void;
  60246. private _gatherRenderTargets;
  60247. private _gatherActiveCameraRenderTargets;
  60248. }
  60249. }
  60250. declare module "babylonjs/Shaders/outline.fragment" {
  60251. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  60252. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  60253. /** @hidden */
  60254. export var outlinePixelShader: {
  60255. name: string;
  60256. shader: string;
  60257. };
  60258. }
  60259. declare module "babylonjs/Shaders/outline.vertex" {
  60260. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60261. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  60262. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60263. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  60264. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  60265. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  60266. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  60267. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60268. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  60269. /** @hidden */
  60270. export var outlineVertexShader: {
  60271. name: string;
  60272. shader: string;
  60273. };
  60274. }
  60275. declare module "babylonjs/Rendering/outlineRenderer" {
  60276. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60277. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  60278. import { Scene } from "babylonjs/scene";
  60279. import { ISceneComponent } from "babylonjs/sceneComponent";
  60280. import "babylonjs/Shaders/outline.fragment";
  60281. import "babylonjs/Shaders/outline.vertex";
  60282. module "babylonjs/scene" {
  60283. interface Scene {
  60284. /** @hidden */
  60285. _outlineRenderer: OutlineRenderer;
  60286. /**
  60287. * Gets the outline renderer associated with the scene
  60288. * @returns a OutlineRenderer
  60289. */
  60290. getOutlineRenderer(): OutlineRenderer;
  60291. }
  60292. }
  60293. module "babylonjs/Meshes/abstractMesh" {
  60294. interface AbstractMesh {
  60295. /** @hidden (Backing field) */
  60296. _renderOutline: boolean;
  60297. /**
  60298. * Gets or sets a boolean indicating if the outline must be rendered as well
  60299. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  60300. */
  60301. renderOutline: boolean;
  60302. /** @hidden (Backing field) */
  60303. _renderOverlay: boolean;
  60304. /**
  60305. * Gets or sets a boolean indicating if the overlay must be rendered as well
  60306. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  60307. */
  60308. renderOverlay: boolean;
  60309. }
  60310. }
  60311. /**
  60312. * This class is responsible to draw bothe outline/overlay of meshes.
  60313. * It should not be used directly but through the available method on mesh.
  60314. */
  60315. export class OutlineRenderer implements ISceneComponent {
  60316. /**
  60317. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  60318. */
  60319. private static _StencilReference;
  60320. /**
  60321. * The name of the component. Each component must have a unique name.
  60322. */
  60323. name: string;
  60324. /**
  60325. * The scene the component belongs to.
  60326. */
  60327. scene: Scene;
  60328. /**
  60329. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  60330. */
  60331. zOffset: number;
  60332. private _engine;
  60333. private _effect;
  60334. private _cachedDefines;
  60335. private _savedDepthWrite;
  60336. /**
  60337. * Instantiates a new outline renderer. (There could be only one per scene).
  60338. * @param scene Defines the scene it belongs to
  60339. */
  60340. constructor(scene: Scene);
  60341. /**
  60342. * Register the component to one instance of a scene.
  60343. */
  60344. register(): void;
  60345. /**
  60346. * Rebuilds the elements related to this component in case of
  60347. * context lost for instance.
  60348. */
  60349. rebuild(): void;
  60350. /**
  60351. * Disposes the component and the associated ressources.
  60352. */
  60353. dispose(): void;
  60354. /**
  60355. * Renders the outline in the canvas.
  60356. * @param subMesh Defines the sumesh to render
  60357. * @param batch Defines the batch of meshes in case of instances
  60358. * @param useOverlay Defines if the rendering is for the overlay or the outline
  60359. */
  60360. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  60361. /**
  60362. * Returns whether or not the outline renderer is ready for a given submesh.
  60363. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  60364. * @param subMesh Defines the submesh to check readyness for
  60365. * @param useInstances Defines wheter wee are trying to render instances or not
  60366. * @returns true if ready otherwise false
  60367. */
  60368. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60369. private _beforeRenderingMesh;
  60370. private _afterRenderingMesh;
  60371. }
  60372. }
  60373. declare module "babylonjs/Rendering/index" {
  60374. export * from "babylonjs/Rendering/boundingBoxRenderer";
  60375. export * from "babylonjs/Rendering/depthRenderer";
  60376. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  60377. export * from "babylonjs/Rendering/edgesRenderer";
  60378. export * from "babylonjs/Rendering/geometryBufferRenderer";
  60379. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  60380. export * from "babylonjs/Rendering/outlineRenderer";
  60381. export * from "babylonjs/Rendering/renderingGroup";
  60382. export * from "babylonjs/Rendering/renderingManager";
  60383. export * from "babylonjs/Rendering/utilityLayerRenderer";
  60384. }
  60385. declare module "babylonjs/Sprites/index" {
  60386. export * from "babylonjs/Sprites/sprite";
  60387. export * from "babylonjs/Sprites/spriteManager";
  60388. export * from "babylonjs/Sprites/spriteSceneComponent";
  60389. }
  60390. declare module "babylonjs/Misc/assetsManager" {
  60391. import { Scene } from "babylonjs/scene";
  60392. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60393. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  60394. import { Skeleton } from "babylonjs/Bones/skeleton";
  60395. import { Observable } from "babylonjs/Misc/observable";
  60396. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60397. import { Texture } from "babylonjs/Materials/Textures/texture";
  60398. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  60399. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  60400. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  60401. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  60402. /**
  60403. * Defines the list of states available for a task inside a AssetsManager
  60404. */
  60405. export enum AssetTaskState {
  60406. /**
  60407. * Initialization
  60408. */
  60409. INIT = 0,
  60410. /**
  60411. * Running
  60412. */
  60413. RUNNING = 1,
  60414. /**
  60415. * Done
  60416. */
  60417. DONE = 2,
  60418. /**
  60419. * Error
  60420. */
  60421. ERROR = 3
  60422. }
  60423. /**
  60424. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  60425. */
  60426. export abstract class AbstractAssetTask {
  60427. /**
  60428. * Task name
  60429. */ name: string;
  60430. /**
  60431. * Callback called when the task is successful
  60432. */
  60433. onSuccess: (task: any) => void;
  60434. /**
  60435. * Callback called when the task is not successful
  60436. */
  60437. onError: (task: any, message?: string, exception?: any) => void;
  60438. /**
  60439. * Creates a new AssetsManager
  60440. * @param name defines the name of the task
  60441. */
  60442. constructor(
  60443. /**
  60444. * Task name
  60445. */ name: string);
  60446. private _isCompleted;
  60447. private _taskState;
  60448. private _errorObject;
  60449. /**
  60450. * Get if the task is completed
  60451. */
  60452. readonly isCompleted: boolean;
  60453. /**
  60454. * Gets the current state of the task
  60455. */
  60456. readonly taskState: AssetTaskState;
  60457. /**
  60458. * Gets the current error object (if task is in error)
  60459. */
  60460. readonly errorObject: {
  60461. message?: string;
  60462. exception?: any;
  60463. };
  60464. /**
  60465. * Internal only
  60466. * @hidden
  60467. */
  60468. _setErrorObject(message?: string, exception?: any): void;
  60469. /**
  60470. * Execute the current task
  60471. * @param scene defines the scene where you want your assets to be loaded
  60472. * @param onSuccess is a callback called when the task is successfully executed
  60473. * @param onError is a callback called if an error occurs
  60474. */
  60475. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60476. /**
  60477. * Execute the current task
  60478. * @param scene defines the scene where you want your assets to be loaded
  60479. * @param onSuccess is a callback called when the task is successfully executed
  60480. * @param onError is a callback called if an error occurs
  60481. */
  60482. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60483. /**
  60484. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  60485. * This can be used with failed tasks that have the reason for failure fixed.
  60486. */
  60487. reset(): void;
  60488. private onErrorCallback;
  60489. private onDoneCallback;
  60490. }
  60491. /**
  60492. * Define the interface used by progress events raised during assets loading
  60493. */
  60494. export interface IAssetsProgressEvent {
  60495. /**
  60496. * Defines the number of remaining tasks to process
  60497. */
  60498. remainingCount: number;
  60499. /**
  60500. * Defines the total number of tasks
  60501. */
  60502. totalCount: number;
  60503. /**
  60504. * Defines the task that was just processed
  60505. */
  60506. task: AbstractAssetTask;
  60507. }
  60508. /**
  60509. * Class used to share progress information about assets loading
  60510. */
  60511. export class AssetsProgressEvent implements IAssetsProgressEvent {
  60512. /**
  60513. * Defines the number of remaining tasks to process
  60514. */
  60515. remainingCount: number;
  60516. /**
  60517. * Defines the total number of tasks
  60518. */
  60519. totalCount: number;
  60520. /**
  60521. * Defines the task that was just processed
  60522. */
  60523. task: AbstractAssetTask;
  60524. /**
  60525. * Creates a AssetsProgressEvent
  60526. * @param remainingCount defines the number of remaining tasks to process
  60527. * @param totalCount defines the total number of tasks
  60528. * @param task defines the task that was just processed
  60529. */
  60530. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  60531. }
  60532. /**
  60533. * Define a task used by AssetsManager to load meshes
  60534. */
  60535. export class MeshAssetTask extends AbstractAssetTask {
  60536. /**
  60537. * Defines the name of the task
  60538. */
  60539. name: string;
  60540. /**
  60541. * Defines the list of mesh's names you want to load
  60542. */
  60543. meshesNames: any;
  60544. /**
  60545. * Defines the root url to use as a base to load your meshes and associated resources
  60546. */
  60547. rootUrl: string;
  60548. /**
  60549. * Defines the filename of the scene to load from
  60550. */
  60551. sceneFilename: string;
  60552. /**
  60553. * Gets the list of loaded meshes
  60554. */
  60555. loadedMeshes: Array<AbstractMesh>;
  60556. /**
  60557. * Gets the list of loaded particle systems
  60558. */
  60559. loadedParticleSystems: Array<IParticleSystem>;
  60560. /**
  60561. * Gets the list of loaded skeletons
  60562. */
  60563. loadedSkeletons: Array<Skeleton>;
  60564. /**
  60565. * Gets the list of loaded animation groups
  60566. */
  60567. loadedAnimationGroups: Array<AnimationGroup>;
  60568. /**
  60569. * Callback called when the task is successful
  60570. */
  60571. onSuccess: (task: MeshAssetTask) => void;
  60572. /**
  60573. * Callback called when the task is successful
  60574. */
  60575. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  60576. /**
  60577. * Creates a new MeshAssetTask
  60578. * @param name defines the name of the task
  60579. * @param meshesNames defines the list of mesh's names you want to load
  60580. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  60581. * @param sceneFilename defines the filename of the scene to load from
  60582. */
  60583. constructor(
  60584. /**
  60585. * Defines the name of the task
  60586. */
  60587. name: string,
  60588. /**
  60589. * Defines the list of mesh's names you want to load
  60590. */
  60591. meshesNames: any,
  60592. /**
  60593. * Defines the root url to use as a base to load your meshes and associated resources
  60594. */
  60595. rootUrl: string,
  60596. /**
  60597. * Defines the filename of the scene to load from
  60598. */
  60599. sceneFilename: string);
  60600. /**
  60601. * Execute the current task
  60602. * @param scene defines the scene where you want your assets to be loaded
  60603. * @param onSuccess is a callback called when the task is successfully executed
  60604. * @param onError is a callback called if an error occurs
  60605. */
  60606. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60607. }
  60608. /**
  60609. * Define a task used by AssetsManager to load text content
  60610. */
  60611. export class TextFileAssetTask extends AbstractAssetTask {
  60612. /**
  60613. * Defines the name of the task
  60614. */
  60615. name: string;
  60616. /**
  60617. * Defines the location of the file to load
  60618. */
  60619. url: string;
  60620. /**
  60621. * Gets the loaded text string
  60622. */
  60623. text: string;
  60624. /**
  60625. * Callback called when the task is successful
  60626. */
  60627. onSuccess: (task: TextFileAssetTask) => void;
  60628. /**
  60629. * Callback called when the task is successful
  60630. */
  60631. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  60632. /**
  60633. * Creates a new TextFileAssetTask object
  60634. * @param name defines the name of the task
  60635. * @param url defines the location of the file to load
  60636. */
  60637. constructor(
  60638. /**
  60639. * Defines the name of the task
  60640. */
  60641. name: string,
  60642. /**
  60643. * Defines the location of the file to load
  60644. */
  60645. url: string);
  60646. /**
  60647. * Execute the current task
  60648. * @param scene defines the scene where you want your assets to be loaded
  60649. * @param onSuccess is a callback called when the task is successfully executed
  60650. * @param onError is a callback called if an error occurs
  60651. */
  60652. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60653. }
  60654. /**
  60655. * Define a task used by AssetsManager to load binary data
  60656. */
  60657. export class BinaryFileAssetTask extends AbstractAssetTask {
  60658. /**
  60659. * Defines the name of the task
  60660. */
  60661. name: string;
  60662. /**
  60663. * Defines the location of the file to load
  60664. */
  60665. url: string;
  60666. /**
  60667. * Gets the lodaded data (as an array buffer)
  60668. */
  60669. data: ArrayBuffer;
  60670. /**
  60671. * Callback called when the task is successful
  60672. */
  60673. onSuccess: (task: BinaryFileAssetTask) => void;
  60674. /**
  60675. * Callback called when the task is successful
  60676. */
  60677. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  60678. /**
  60679. * Creates a new BinaryFileAssetTask object
  60680. * @param name defines the name of the new task
  60681. * @param url defines the location of the file to load
  60682. */
  60683. constructor(
  60684. /**
  60685. * Defines the name of the task
  60686. */
  60687. name: string,
  60688. /**
  60689. * Defines the location of the file to load
  60690. */
  60691. url: string);
  60692. /**
  60693. * Execute the current task
  60694. * @param scene defines the scene where you want your assets to be loaded
  60695. * @param onSuccess is a callback called when the task is successfully executed
  60696. * @param onError is a callback called if an error occurs
  60697. */
  60698. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60699. }
  60700. /**
  60701. * Define a task used by AssetsManager to load images
  60702. */
  60703. export class ImageAssetTask extends AbstractAssetTask {
  60704. /**
  60705. * Defines the name of the task
  60706. */
  60707. name: string;
  60708. /**
  60709. * Defines the location of the image to load
  60710. */
  60711. url: string;
  60712. /**
  60713. * Gets the loaded images
  60714. */
  60715. image: HTMLImageElement;
  60716. /**
  60717. * Callback called when the task is successful
  60718. */
  60719. onSuccess: (task: ImageAssetTask) => void;
  60720. /**
  60721. * Callback called when the task is successful
  60722. */
  60723. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  60724. /**
  60725. * Creates a new ImageAssetTask
  60726. * @param name defines the name of the task
  60727. * @param url defines the location of the image to load
  60728. */
  60729. constructor(
  60730. /**
  60731. * Defines the name of the task
  60732. */
  60733. name: string,
  60734. /**
  60735. * Defines the location of the image to load
  60736. */
  60737. url: string);
  60738. /**
  60739. * Execute the current task
  60740. * @param scene defines the scene where you want your assets to be loaded
  60741. * @param onSuccess is a callback called when the task is successfully executed
  60742. * @param onError is a callback called if an error occurs
  60743. */
  60744. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60745. }
  60746. /**
  60747. * Defines the interface used by texture loading tasks
  60748. */
  60749. export interface ITextureAssetTask<TEX extends BaseTexture> {
  60750. /**
  60751. * Gets the loaded texture
  60752. */
  60753. texture: TEX;
  60754. }
  60755. /**
  60756. * Define a task used by AssetsManager to load 2D textures
  60757. */
  60758. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  60759. /**
  60760. * Defines the name of the task
  60761. */
  60762. name: string;
  60763. /**
  60764. * Defines the location of the file to load
  60765. */
  60766. url: string;
  60767. /**
  60768. * Defines if mipmap should not be generated (default is false)
  60769. */
  60770. noMipmap?: boolean | undefined;
  60771. /**
  60772. * Defines if texture must be inverted on Y axis (default is false)
  60773. */
  60774. invertY?: boolean | undefined;
  60775. /**
  60776. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  60777. */
  60778. samplingMode: number;
  60779. /**
  60780. * Gets the loaded texture
  60781. */
  60782. texture: Texture;
  60783. /**
  60784. * Callback called when the task is successful
  60785. */
  60786. onSuccess: (task: TextureAssetTask) => void;
  60787. /**
  60788. * Callback called when the task is successful
  60789. */
  60790. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  60791. /**
  60792. * Creates a new TextureAssetTask object
  60793. * @param name defines the name of the task
  60794. * @param url defines the location of the file to load
  60795. * @param noMipmap defines if mipmap should not be generated (default is false)
  60796. * @param invertY defines if texture must be inverted on Y axis (default is false)
  60797. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  60798. */
  60799. constructor(
  60800. /**
  60801. * Defines the name of the task
  60802. */
  60803. name: string,
  60804. /**
  60805. * Defines the location of the file to load
  60806. */
  60807. url: string,
  60808. /**
  60809. * Defines if mipmap should not be generated (default is false)
  60810. */
  60811. noMipmap?: boolean | undefined,
  60812. /**
  60813. * Defines if texture must be inverted on Y axis (default is false)
  60814. */
  60815. invertY?: boolean | undefined,
  60816. /**
  60817. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  60818. */
  60819. samplingMode?: number);
  60820. /**
  60821. * Execute the current task
  60822. * @param scene defines the scene where you want your assets to be loaded
  60823. * @param onSuccess is a callback called when the task is successfully executed
  60824. * @param onError is a callback called if an error occurs
  60825. */
  60826. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60827. }
  60828. /**
  60829. * Define a task used by AssetsManager to load cube textures
  60830. */
  60831. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  60832. /**
  60833. * Defines the name of the task
  60834. */
  60835. name: string;
  60836. /**
  60837. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  60838. */
  60839. url: string;
  60840. /**
  60841. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  60842. */
  60843. extensions?: string[] | undefined;
  60844. /**
  60845. * Defines if mipmaps should not be generated (default is false)
  60846. */
  60847. noMipmap?: boolean | undefined;
  60848. /**
  60849. * Defines the explicit list of files (undefined by default)
  60850. */
  60851. files?: string[] | undefined;
  60852. /**
  60853. * Gets the loaded texture
  60854. */
  60855. texture: CubeTexture;
  60856. /**
  60857. * Callback called when the task is successful
  60858. */
  60859. onSuccess: (task: CubeTextureAssetTask) => void;
  60860. /**
  60861. * Callback called when the task is successful
  60862. */
  60863. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  60864. /**
  60865. * Creates a new CubeTextureAssetTask
  60866. * @param name defines the name of the task
  60867. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  60868. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  60869. * @param noMipmap defines if mipmaps should not be generated (default is false)
  60870. * @param files defines the explicit list of files (undefined by default)
  60871. */
  60872. constructor(
  60873. /**
  60874. * Defines the name of the task
  60875. */
  60876. name: string,
  60877. /**
  60878. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  60879. */
  60880. url: string,
  60881. /**
  60882. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  60883. */
  60884. extensions?: string[] | undefined,
  60885. /**
  60886. * Defines if mipmaps should not be generated (default is false)
  60887. */
  60888. noMipmap?: boolean | undefined,
  60889. /**
  60890. * Defines the explicit list of files (undefined by default)
  60891. */
  60892. files?: string[] | undefined);
  60893. /**
  60894. * Execute the current task
  60895. * @param scene defines the scene where you want your assets to be loaded
  60896. * @param onSuccess is a callback called when the task is successfully executed
  60897. * @param onError is a callback called if an error occurs
  60898. */
  60899. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60900. }
  60901. /**
  60902. * Define a task used by AssetsManager to load HDR cube textures
  60903. */
  60904. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  60905. /**
  60906. * Defines the name of the task
  60907. */
  60908. name: string;
  60909. /**
  60910. * Defines the location of the file to load
  60911. */
  60912. url: string;
  60913. /**
  60914. * Defines the desired size (the more it increases the longer the generation will be)
  60915. */
  60916. size: number;
  60917. /**
  60918. * Defines if mipmaps should not be generated (default is false)
  60919. */
  60920. noMipmap: boolean;
  60921. /**
  60922. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  60923. */
  60924. generateHarmonics: boolean;
  60925. /**
  60926. * 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)
  60927. */
  60928. gammaSpace: boolean;
  60929. /**
  60930. * Internal Use Only
  60931. */
  60932. reserved: boolean;
  60933. /**
  60934. * Gets the loaded texture
  60935. */
  60936. texture: HDRCubeTexture;
  60937. /**
  60938. * Callback called when the task is successful
  60939. */
  60940. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  60941. /**
  60942. * Callback called when the task is successful
  60943. */
  60944. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  60945. /**
  60946. * Creates a new HDRCubeTextureAssetTask object
  60947. * @param name defines the name of the task
  60948. * @param url defines the location of the file to load
  60949. * @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.
  60950. * @param noMipmap defines if mipmaps should not be generated (default is false)
  60951. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  60952. * @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)
  60953. * @param reserved Internal use only
  60954. */
  60955. constructor(
  60956. /**
  60957. * Defines the name of the task
  60958. */
  60959. name: string,
  60960. /**
  60961. * Defines the location of the file to load
  60962. */
  60963. url: string,
  60964. /**
  60965. * Defines the desired size (the more it increases the longer the generation will be)
  60966. */
  60967. size: number,
  60968. /**
  60969. * Defines if mipmaps should not be generated (default is false)
  60970. */
  60971. noMipmap?: boolean,
  60972. /**
  60973. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  60974. */
  60975. generateHarmonics?: boolean,
  60976. /**
  60977. * 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)
  60978. */
  60979. gammaSpace?: boolean,
  60980. /**
  60981. * Internal Use Only
  60982. */
  60983. reserved?: boolean);
  60984. /**
  60985. * Execute the current task
  60986. * @param scene defines the scene where you want your assets to be loaded
  60987. * @param onSuccess is a callback called when the task is successfully executed
  60988. * @param onError is a callback called if an error occurs
  60989. */
  60990. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60991. }
  60992. /**
  60993. * Define a task used by AssetsManager to load Equirectangular cube textures
  60994. */
  60995. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  60996. /**
  60997. * Defines the name of the task
  60998. */
  60999. name: string;
  61000. /**
  61001. * Defines the location of the file to load
  61002. */
  61003. url: string;
  61004. /**
  61005. * Defines the desired size (the more it increases the longer the generation will be)
  61006. */
  61007. size: number;
  61008. /**
  61009. * Defines if mipmaps should not be generated (default is false)
  61010. */
  61011. noMipmap: boolean;
  61012. /**
  61013. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  61014. * but the standard material would require them in Gamma space) (default is true)
  61015. */
  61016. gammaSpace: boolean;
  61017. /**
  61018. * Gets the loaded texture
  61019. */
  61020. texture: EquiRectangularCubeTexture;
  61021. /**
  61022. * Callback called when the task is successful
  61023. */
  61024. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  61025. /**
  61026. * Callback called when the task is successful
  61027. */
  61028. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  61029. /**
  61030. * Creates a new EquiRectangularCubeTextureAssetTask object
  61031. * @param name defines the name of the task
  61032. * @param url defines the location of the file to load
  61033. * @param size defines the desired size (the more it increases the longer the generation will be)
  61034. * If the size is omitted this implies you are using a preprocessed cubemap.
  61035. * @param noMipmap defines if mipmaps should not be generated (default is false)
  61036. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  61037. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  61038. * (default is true)
  61039. */
  61040. constructor(
  61041. /**
  61042. * Defines the name of the task
  61043. */
  61044. name: string,
  61045. /**
  61046. * Defines the location of the file to load
  61047. */
  61048. url: string,
  61049. /**
  61050. * Defines the desired size (the more it increases the longer the generation will be)
  61051. */
  61052. size: number,
  61053. /**
  61054. * Defines if mipmaps should not be generated (default is false)
  61055. */
  61056. noMipmap?: boolean,
  61057. /**
  61058. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  61059. * but the standard material would require them in Gamma space) (default is true)
  61060. */
  61061. gammaSpace?: boolean);
  61062. /**
  61063. * Execute the current task
  61064. * @param scene defines the scene where you want your assets to be loaded
  61065. * @param onSuccess is a callback called when the task is successfully executed
  61066. * @param onError is a callback called if an error occurs
  61067. */
  61068. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61069. }
  61070. /**
  61071. * This class can be used to easily import assets into a scene
  61072. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  61073. */
  61074. export class AssetsManager {
  61075. private _scene;
  61076. private _isLoading;
  61077. protected _tasks: AbstractAssetTask[];
  61078. protected _waitingTasksCount: number;
  61079. protected _totalTasksCount: number;
  61080. /**
  61081. * Callback called when all tasks are processed
  61082. */
  61083. onFinish: (tasks: AbstractAssetTask[]) => void;
  61084. /**
  61085. * Callback called when a task is successful
  61086. */
  61087. onTaskSuccess: (task: AbstractAssetTask) => void;
  61088. /**
  61089. * Callback called when a task had an error
  61090. */
  61091. onTaskError: (task: AbstractAssetTask) => void;
  61092. /**
  61093. * Callback called when a task is done (whatever the result is)
  61094. */
  61095. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  61096. /**
  61097. * Observable called when all tasks are processed
  61098. */
  61099. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  61100. /**
  61101. * Observable called when a task had an error
  61102. */
  61103. onTaskErrorObservable: Observable<AbstractAssetTask>;
  61104. /**
  61105. * Observable called when all tasks were executed
  61106. */
  61107. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  61108. /**
  61109. * Observable called when a task is done (whatever the result is)
  61110. */
  61111. onProgressObservable: Observable<IAssetsProgressEvent>;
  61112. /**
  61113. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  61114. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  61115. */
  61116. useDefaultLoadingScreen: boolean;
  61117. /**
  61118. * Creates a new AssetsManager
  61119. * @param scene defines the scene to work on
  61120. */
  61121. constructor(scene: Scene);
  61122. /**
  61123. * Add a MeshAssetTask to the list of active tasks
  61124. * @param taskName defines the name of the new task
  61125. * @param meshesNames defines the name of meshes to load
  61126. * @param rootUrl defines the root url to use to locate files
  61127. * @param sceneFilename defines the filename of the scene file
  61128. * @returns a new MeshAssetTask object
  61129. */
  61130. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  61131. /**
  61132. * Add a TextFileAssetTask to the list of active tasks
  61133. * @param taskName defines the name of the new task
  61134. * @param url defines the url of the file to load
  61135. * @returns a new TextFileAssetTask object
  61136. */
  61137. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  61138. /**
  61139. * Add a BinaryFileAssetTask to the list of active tasks
  61140. * @param taskName defines the name of the new task
  61141. * @param url defines the url of the file to load
  61142. * @returns a new BinaryFileAssetTask object
  61143. */
  61144. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  61145. /**
  61146. * Add a ImageAssetTask to the list of active tasks
  61147. * @param taskName defines the name of the new task
  61148. * @param url defines the url of the file to load
  61149. * @returns a new ImageAssetTask object
  61150. */
  61151. addImageTask(taskName: string, url: string): ImageAssetTask;
  61152. /**
  61153. * Add a TextureAssetTask to the list of active tasks
  61154. * @param taskName defines the name of the new task
  61155. * @param url defines the url of the file to load
  61156. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61157. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  61158. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  61159. * @returns a new TextureAssetTask object
  61160. */
  61161. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  61162. /**
  61163. * Add a CubeTextureAssetTask to the list of active tasks
  61164. * @param taskName defines the name of the new task
  61165. * @param url defines the url of the file to load
  61166. * @param extensions defines the extension to use to load the cube map (can be null)
  61167. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61168. * @param files defines the list of files to load (can be null)
  61169. * @returns a new CubeTextureAssetTask object
  61170. */
  61171. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  61172. /**
  61173. *
  61174. * Add a HDRCubeTextureAssetTask to the list of active tasks
  61175. * @param taskName defines the name of the new task
  61176. * @param url defines the url of the file to load
  61177. * @param size defines the size you want for the cubemap (can be null)
  61178. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61179. * @param generateHarmonics defines if you want to automatically generate (true by default)
  61180. * @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)
  61181. * @param reserved Internal use only
  61182. * @returns a new HDRCubeTextureAssetTask object
  61183. */
  61184. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  61185. /**
  61186. *
  61187. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  61188. * @param taskName defines the name of the new task
  61189. * @param url defines the url of the file to load
  61190. * @param size defines the size you want for the cubemap (can be null)
  61191. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61192. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  61193. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  61194. * @returns a new EquiRectangularCubeTextureAssetTask object
  61195. */
  61196. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  61197. /**
  61198. * Remove a task from the assets manager.
  61199. * @param task the task to remove
  61200. */
  61201. removeTask(task: AbstractAssetTask): void;
  61202. private _decreaseWaitingTasksCount;
  61203. private _runTask;
  61204. /**
  61205. * Reset the AssetsManager and remove all tasks
  61206. * @return the current instance of the AssetsManager
  61207. */
  61208. reset(): AssetsManager;
  61209. /**
  61210. * Start the loading process
  61211. * @return the current instance of the AssetsManager
  61212. */
  61213. load(): AssetsManager;
  61214. /**
  61215. * Start the loading process as an async operation
  61216. * @return a promise returning the list of failed tasks
  61217. */
  61218. loadAsync(): Promise<void>;
  61219. }
  61220. }
  61221. declare module "babylonjs/Misc/deferred" {
  61222. /**
  61223. * Wrapper class for promise with external resolve and reject.
  61224. */
  61225. export class Deferred<T> {
  61226. /**
  61227. * The promise associated with this deferred object.
  61228. */
  61229. readonly promise: Promise<T>;
  61230. private _resolve;
  61231. private _reject;
  61232. /**
  61233. * The resolve method of the promise associated with this deferred object.
  61234. */
  61235. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  61236. /**
  61237. * The reject method of the promise associated with this deferred object.
  61238. */
  61239. readonly reject: (reason?: any) => void;
  61240. /**
  61241. * Constructor for this deferred object.
  61242. */
  61243. constructor();
  61244. }
  61245. }
  61246. declare module "babylonjs/Misc/meshExploder" {
  61247. import { Mesh } from "babylonjs/Meshes/mesh";
  61248. /**
  61249. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  61250. */
  61251. export class MeshExploder {
  61252. private _centerMesh;
  61253. private _meshes;
  61254. private _meshesOrigins;
  61255. private _toCenterVectors;
  61256. private _scaledDirection;
  61257. private _newPosition;
  61258. private _centerPosition;
  61259. /**
  61260. * Explodes meshes from a center mesh.
  61261. * @param meshes The meshes to explode.
  61262. * @param centerMesh The mesh to be center of explosion.
  61263. */
  61264. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  61265. private _setCenterMesh;
  61266. /**
  61267. * Get class name
  61268. * @returns "MeshExploder"
  61269. */
  61270. getClassName(): string;
  61271. /**
  61272. * "Exploded meshes"
  61273. * @returns Array of meshes with the centerMesh at index 0.
  61274. */
  61275. getMeshes(): Array<Mesh>;
  61276. /**
  61277. * Explodes meshes giving a specific direction
  61278. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  61279. */
  61280. explode(direction?: number): void;
  61281. }
  61282. }
  61283. declare module "babylonjs/Misc/filesInput" {
  61284. import { Engine } from "babylonjs/Engines/engine";
  61285. import { Scene } from "babylonjs/scene";
  61286. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  61287. /**
  61288. * Class used to help managing file picking and drag'n'drop
  61289. */
  61290. export class FilesInput {
  61291. /**
  61292. * List of files ready to be loaded
  61293. */
  61294. static readonly FilesToLoad: {
  61295. [key: string]: File;
  61296. };
  61297. /**
  61298. * Callback called when a file is processed
  61299. */
  61300. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  61301. private _engine;
  61302. private _currentScene;
  61303. private _sceneLoadedCallback;
  61304. private _progressCallback;
  61305. private _additionalRenderLoopLogicCallback;
  61306. private _textureLoadingCallback;
  61307. private _startingProcessingFilesCallback;
  61308. private _onReloadCallback;
  61309. private _errorCallback;
  61310. private _elementToMonitor;
  61311. private _sceneFileToLoad;
  61312. private _filesToLoad;
  61313. /**
  61314. * Creates a new FilesInput
  61315. * @param engine defines the rendering engine
  61316. * @param scene defines the hosting scene
  61317. * @param sceneLoadedCallback callback called when scene is loaded
  61318. * @param progressCallback callback called to track progress
  61319. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  61320. * @param textureLoadingCallback callback called when a texture is loading
  61321. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  61322. * @param onReloadCallback callback called when a reload is requested
  61323. * @param errorCallback callback call if an error occurs
  61324. */
  61325. 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);
  61326. private _dragEnterHandler;
  61327. private _dragOverHandler;
  61328. private _dropHandler;
  61329. /**
  61330. * Calls this function to listen to drag'n'drop events on a specific DOM element
  61331. * @param elementToMonitor defines the DOM element to track
  61332. */
  61333. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  61334. /**
  61335. * Release all associated resources
  61336. */
  61337. dispose(): void;
  61338. private renderFunction;
  61339. private drag;
  61340. private drop;
  61341. private _traverseFolder;
  61342. private _processFiles;
  61343. /**
  61344. * Load files from a drop event
  61345. * @param event defines the drop event to use as source
  61346. */
  61347. loadFiles(event: any): void;
  61348. private _processReload;
  61349. /**
  61350. * Reload the current scene from the loaded files
  61351. */
  61352. reload(): void;
  61353. }
  61354. }
  61355. declare module "babylonjs/Misc/HighDynamicRange/index" {
  61356. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  61357. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  61358. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  61359. }
  61360. declare module "babylonjs/Misc/sceneOptimizer" {
  61361. import { Scene, IDisposable } from "babylonjs/scene";
  61362. import { Observable } from "babylonjs/Misc/observable";
  61363. /**
  61364. * Defines the root class used to create scene optimization to use with SceneOptimizer
  61365. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61366. */
  61367. export class SceneOptimization {
  61368. /**
  61369. * Defines the priority of this optimization (0 by default which means first in the list)
  61370. */
  61371. priority: number;
  61372. /**
  61373. * Gets a string describing the action executed by the current optimization
  61374. * @returns description string
  61375. */
  61376. getDescription(): string;
  61377. /**
  61378. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61379. * @param scene defines the current scene where to apply this optimization
  61380. * @param optimizer defines the current optimizer
  61381. * @returns true if everything that can be done was applied
  61382. */
  61383. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61384. /**
  61385. * Creates the SceneOptimization object
  61386. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61387. * @param desc defines the description associated with the optimization
  61388. */
  61389. constructor(
  61390. /**
  61391. * Defines the priority of this optimization (0 by default which means first in the list)
  61392. */
  61393. priority?: number);
  61394. }
  61395. /**
  61396. * Defines an optimization used to reduce the size of render target textures
  61397. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61398. */
  61399. export class TextureOptimization extends SceneOptimization {
  61400. /**
  61401. * Defines the priority of this optimization (0 by default which means first in the list)
  61402. */
  61403. priority: number;
  61404. /**
  61405. * 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
  61406. */
  61407. maximumSize: number;
  61408. /**
  61409. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61410. */
  61411. step: number;
  61412. /**
  61413. * Gets a string describing the action executed by the current optimization
  61414. * @returns description string
  61415. */
  61416. getDescription(): string;
  61417. /**
  61418. * Creates the TextureOptimization object
  61419. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61420. * @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
  61421. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61422. */
  61423. constructor(
  61424. /**
  61425. * Defines the priority of this optimization (0 by default which means first in the list)
  61426. */
  61427. priority?: number,
  61428. /**
  61429. * 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
  61430. */
  61431. maximumSize?: number,
  61432. /**
  61433. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61434. */
  61435. step?: number);
  61436. /**
  61437. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61438. * @param scene defines the current scene where to apply this optimization
  61439. * @param optimizer defines the current optimizer
  61440. * @returns true if everything that can be done was applied
  61441. */
  61442. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61443. }
  61444. /**
  61445. * Defines an optimization used to increase or decrease the rendering resolution
  61446. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61447. */
  61448. export class HardwareScalingOptimization extends SceneOptimization {
  61449. /**
  61450. * Defines the priority of this optimization (0 by default which means first in the list)
  61451. */
  61452. priority: number;
  61453. /**
  61454. * Defines the maximum scale to use (2 by default)
  61455. */
  61456. maximumScale: number;
  61457. /**
  61458. * Defines the step to use between two passes (0.5 by default)
  61459. */
  61460. step: number;
  61461. private _currentScale;
  61462. private _directionOffset;
  61463. /**
  61464. * Gets a string describing the action executed by the current optimization
  61465. * @return description string
  61466. */
  61467. getDescription(): string;
  61468. /**
  61469. * Creates the HardwareScalingOptimization object
  61470. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61471. * @param maximumScale defines the maximum scale to use (2 by default)
  61472. * @param step defines the step to use between two passes (0.5 by default)
  61473. */
  61474. constructor(
  61475. /**
  61476. * Defines the priority of this optimization (0 by default which means first in the list)
  61477. */
  61478. priority?: number,
  61479. /**
  61480. * Defines the maximum scale to use (2 by default)
  61481. */
  61482. maximumScale?: number,
  61483. /**
  61484. * Defines the step to use between two passes (0.5 by default)
  61485. */
  61486. step?: number);
  61487. /**
  61488. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61489. * @param scene defines the current scene where to apply this optimization
  61490. * @param optimizer defines the current optimizer
  61491. * @returns true if everything that can be done was applied
  61492. */
  61493. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61494. }
  61495. /**
  61496. * Defines an optimization used to remove shadows
  61497. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61498. */
  61499. export class ShadowsOptimization extends SceneOptimization {
  61500. /**
  61501. * Gets a string describing the action executed by the current optimization
  61502. * @return description string
  61503. */
  61504. getDescription(): string;
  61505. /**
  61506. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61507. * @param scene defines the current scene where to apply this optimization
  61508. * @param optimizer defines the current optimizer
  61509. * @returns true if everything that can be done was applied
  61510. */
  61511. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61512. }
  61513. /**
  61514. * Defines an optimization used to turn post-processes off
  61515. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61516. */
  61517. export class PostProcessesOptimization extends SceneOptimization {
  61518. /**
  61519. * Gets a string describing the action executed by the current optimization
  61520. * @return description string
  61521. */
  61522. getDescription(): string;
  61523. /**
  61524. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61525. * @param scene defines the current scene where to apply this optimization
  61526. * @param optimizer defines the current optimizer
  61527. * @returns true if everything that can be done was applied
  61528. */
  61529. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61530. }
  61531. /**
  61532. * Defines an optimization used to turn lens flares off
  61533. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61534. */
  61535. export class LensFlaresOptimization extends SceneOptimization {
  61536. /**
  61537. * Gets a string describing the action executed by the current optimization
  61538. * @return description string
  61539. */
  61540. getDescription(): string;
  61541. /**
  61542. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61543. * @param scene defines the current scene where to apply this optimization
  61544. * @param optimizer defines the current optimizer
  61545. * @returns true if everything that can be done was applied
  61546. */
  61547. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61548. }
  61549. /**
  61550. * Defines an optimization based on user defined callback.
  61551. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61552. */
  61553. export class CustomOptimization extends SceneOptimization {
  61554. /**
  61555. * Callback called to apply the custom optimization.
  61556. */
  61557. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  61558. /**
  61559. * Callback called to get custom description
  61560. */
  61561. onGetDescription: () => string;
  61562. /**
  61563. * Gets a string describing the action executed by the current optimization
  61564. * @returns description string
  61565. */
  61566. getDescription(): string;
  61567. /**
  61568. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61569. * @param scene defines the current scene where to apply this optimization
  61570. * @param optimizer defines the current optimizer
  61571. * @returns true if everything that can be done was applied
  61572. */
  61573. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61574. }
  61575. /**
  61576. * Defines an optimization used to turn particles off
  61577. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61578. */
  61579. export class ParticlesOptimization extends SceneOptimization {
  61580. /**
  61581. * Gets a string describing the action executed by the current optimization
  61582. * @return description string
  61583. */
  61584. getDescription(): string;
  61585. /**
  61586. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61587. * @param scene defines the current scene where to apply this optimization
  61588. * @param optimizer defines the current optimizer
  61589. * @returns true if everything that can be done was applied
  61590. */
  61591. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61592. }
  61593. /**
  61594. * Defines an optimization used to turn render targets off
  61595. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61596. */
  61597. export class RenderTargetsOptimization extends SceneOptimization {
  61598. /**
  61599. * Gets a string describing the action executed by the current optimization
  61600. * @return description string
  61601. */
  61602. getDescription(): string;
  61603. /**
  61604. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61605. * @param scene defines the current scene where to apply this optimization
  61606. * @param optimizer defines the current optimizer
  61607. * @returns true if everything that can be done was applied
  61608. */
  61609. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61610. }
  61611. /**
  61612. * Defines an optimization used to merge meshes with compatible materials
  61613. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61614. */
  61615. export class MergeMeshesOptimization extends SceneOptimization {
  61616. private static _UpdateSelectionTree;
  61617. /**
  61618. * Gets or sets a boolean which defines if optimization octree has to be updated
  61619. */
  61620. /**
  61621. * Gets or sets a boolean which defines if optimization octree has to be updated
  61622. */
  61623. static UpdateSelectionTree: boolean;
  61624. /**
  61625. * Gets a string describing the action executed by the current optimization
  61626. * @return description string
  61627. */
  61628. getDescription(): string;
  61629. private _canBeMerged;
  61630. /**
  61631. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61632. * @param scene defines the current scene where to apply this optimization
  61633. * @param optimizer defines the current optimizer
  61634. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  61635. * @returns true if everything that can be done was applied
  61636. */
  61637. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  61638. }
  61639. /**
  61640. * Defines a list of options used by SceneOptimizer
  61641. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61642. */
  61643. export class SceneOptimizerOptions {
  61644. /**
  61645. * Defines the target frame rate to reach (60 by default)
  61646. */
  61647. targetFrameRate: number;
  61648. /**
  61649. * Defines the interval between two checkes (2000ms by default)
  61650. */
  61651. trackerDuration: number;
  61652. /**
  61653. * Gets the list of optimizations to apply
  61654. */
  61655. optimizations: SceneOptimization[];
  61656. /**
  61657. * Creates a new list of options used by SceneOptimizer
  61658. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  61659. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  61660. */
  61661. constructor(
  61662. /**
  61663. * Defines the target frame rate to reach (60 by default)
  61664. */
  61665. targetFrameRate?: number,
  61666. /**
  61667. * Defines the interval between two checkes (2000ms by default)
  61668. */
  61669. trackerDuration?: number);
  61670. /**
  61671. * Add a new optimization
  61672. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  61673. * @returns the current SceneOptimizerOptions
  61674. */
  61675. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  61676. /**
  61677. * Add a new custom optimization
  61678. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  61679. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  61680. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61681. * @returns the current SceneOptimizerOptions
  61682. */
  61683. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  61684. /**
  61685. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  61686. * @param targetFrameRate defines the target frame rate (60 by default)
  61687. * @returns a SceneOptimizerOptions object
  61688. */
  61689. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  61690. /**
  61691. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  61692. * @param targetFrameRate defines the target frame rate (60 by default)
  61693. * @returns a SceneOptimizerOptions object
  61694. */
  61695. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  61696. /**
  61697. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  61698. * @param targetFrameRate defines the target frame rate (60 by default)
  61699. * @returns a SceneOptimizerOptions object
  61700. */
  61701. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  61702. }
  61703. /**
  61704. * Class used to run optimizations in order to reach a target frame rate
  61705. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61706. */
  61707. export class SceneOptimizer implements IDisposable {
  61708. private _isRunning;
  61709. private _options;
  61710. private _scene;
  61711. private _currentPriorityLevel;
  61712. private _targetFrameRate;
  61713. private _trackerDuration;
  61714. private _currentFrameRate;
  61715. private _sceneDisposeObserver;
  61716. private _improvementMode;
  61717. /**
  61718. * Defines an observable called when the optimizer reaches the target frame rate
  61719. */
  61720. onSuccessObservable: Observable<SceneOptimizer>;
  61721. /**
  61722. * Defines an observable called when the optimizer enables an optimization
  61723. */
  61724. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  61725. /**
  61726. * Defines an observable called when the optimizer is not able to reach the target frame rate
  61727. */
  61728. onFailureObservable: Observable<SceneOptimizer>;
  61729. /**
  61730. * Gets a boolean indicating if the optimizer is in improvement mode
  61731. */
  61732. readonly isInImprovementMode: boolean;
  61733. /**
  61734. * Gets the current priority level (0 at start)
  61735. */
  61736. readonly currentPriorityLevel: number;
  61737. /**
  61738. * Gets the current frame rate checked by the SceneOptimizer
  61739. */
  61740. readonly currentFrameRate: number;
  61741. /**
  61742. * Gets or sets the current target frame rate (60 by default)
  61743. */
  61744. /**
  61745. * Gets or sets the current target frame rate (60 by default)
  61746. */
  61747. targetFrameRate: number;
  61748. /**
  61749. * Gets or sets the current interval between two checks (every 2000ms by default)
  61750. */
  61751. /**
  61752. * Gets or sets the current interval between two checks (every 2000ms by default)
  61753. */
  61754. trackerDuration: number;
  61755. /**
  61756. * Gets the list of active optimizations
  61757. */
  61758. readonly optimizations: SceneOptimization[];
  61759. /**
  61760. * Creates a new SceneOptimizer
  61761. * @param scene defines the scene to work on
  61762. * @param options defines the options to use with the SceneOptimizer
  61763. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  61764. * @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)
  61765. */
  61766. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  61767. /**
  61768. * Stops the current optimizer
  61769. */
  61770. stop(): void;
  61771. /**
  61772. * Reset the optimizer to initial step (current priority level = 0)
  61773. */
  61774. reset(): void;
  61775. /**
  61776. * Start the optimizer. By default it will try to reach a specific framerate
  61777. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  61778. */
  61779. start(): void;
  61780. private _checkCurrentState;
  61781. /**
  61782. * Release all resources
  61783. */
  61784. dispose(): void;
  61785. /**
  61786. * Helper function to create a SceneOptimizer with one single line of code
  61787. * @param scene defines the scene to work on
  61788. * @param options defines the options to use with the SceneOptimizer
  61789. * @param onSuccess defines a callback to call on success
  61790. * @param onFailure defines a callback to call on failure
  61791. * @returns the new SceneOptimizer object
  61792. */
  61793. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  61794. }
  61795. }
  61796. declare module "babylonjs/Misc/sceneSerializer" {
  61797. import { Scene } from "babylonjs/scene";
  61798. /**
  61799. * Class used to serialize a scene into a string
  61800. */
  61801. export class SceneSerializer {
  61802. /**
  61803. * Clear cache used by a previous serialization
  61804. */
  61805. static ClearCache(): void;
  61806. /**
  61807. * Serialize a scene into a JSON compatible object
  61808. * @param scene defines the scene to serialize
  61809. * @returns a JSON compatible object
  61810. */
  61811. static Serialize(scene: Scene): any;
  61812. /**
  61813. * Serialize a mesh into a JSON compatible object
  61814. * @param toSerialize defines the mesh to serialize
  61815. * @param withParents defines if parents must be serialized as well
  61816. * @param withChildren defines if children must be serialized as well
  61817. * @returns a JSON compatible object
  61818. */
  61819. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  61820. }
  61821. }
  61822. declare module "babylonjs/Misc/textureTools" {
  61823. import { Texture } from "babylonjs/Materials/Textures/texture";
  61824. /**
  61825. * Class used to host texture specific utilities
  61826. */
  61827. export class TextureTools {
  61828. /**
  61829. * Uses the GPU to create a copy texture rescaled at a given size
  61830. * @param texture Texture to copy from
  61831. * @param width defines the desired width
  61832. * @param height defines the desired height
  61833. * @param useBilinearMode defines if bilinear mode has to be used
  61834. * @return the generated texture
  61835. */
  61836. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  61837. }
  61838. }
  61839. declare module "babylonjs/Misc/videoRecorder" {
  61840. import { Nullable } from "babylonjs/types";
  61841. import { Engine } from "babylonjs/Engines/engine";
  61842. /**
  61843. * This represents the different options available for the video capture.
  61844. */
  61845. export interface VideoRecorderOptions {
  61846. /** Defines the mime type of the video. */
  61847. mimeType: string;
  61848. /** Defines the FPS the video should be recorded at. */
  61849. fps: number;
  61850. /** Defines the chunk size for the recording data. */
  61851. recordChunckSize: number;
  61852. /** The audio tracks to attach to the recording. */
  61853. audioTracks?: MediaStreamTrack[];
  61854. }
  61855. /**
  61856. * This can help with recording videos from BabylonJS.
  61857. * This is based on the available WebRTC functionalities of the browser.
  61858. *
  61859. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  61860. */
  61861. export class VideoRecorder {
  61862. private static readonly _defaultOptions;
  61863. /**
  61864. * Returns whether or not the VideoRecorder is available in your browser.
  61865. * @param engine Defines the Babylon Engine.
  61866. * @returns true if supported otherwise false.
  61867. */
  61868. static IsSupported(engine: Engine): boolean;
  61869. private readonly _options;
  61870. private _canvas;
  61871. private _mediaRecorder;
  61872. private _recordedChunks;
  61873. private _fileName;
  61874. private _resolve;
  61875. private _reject;
  61876. /**
  61877. * True when a recording is already in progress.
  61878. */
  61879. readonly isRecording: boolean;
  61880. /**
  61881. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  61882. * @param engine Defines the BabylonJS Engine you wish to record.
  61883. * @param options Defines options that can be used to customize the capture.
  61884. */
  61885. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  61886. /**
  61887. * Stops the current recording before the default capture timeout passed in the startRecording function.
  61888. */
  61889. stopRecording(): void;
  61890. /**
  61891. * Starts recording the canvas for a max duration specified in parameters.
  61892. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  61893. * If null no automatic download will start and you can rely on the promise to get the data back.
  61894. * @param maxDuration Defines the maximum recording time in seconds.
  61895. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  61896. * @return A promise callback at the end of the recording with the video data in Blob.
  61897. */
  61898. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  61899. /**
  61900. * Releases internal resources used during the recording.
  61901. */
  61902. dispose(): void;
  61903. private _handleDataAvailable;
  61904. private _handleError;
  61905. private _handleStop;
  61906. }
  61907. }
  61908. declare module "babylonjs/Misc/screenshotTools" {
  61909. import { Camera } from "babylonjs/Cameras/camera";
  61910. import { Engine } from "babylonjs/Engines/engine";
  61911. /**
  61912. * Class containing a set of static utilities functions for screenshots
  61913. */
  61914. export class ScreenshotTools {
  61915. /**
  61916. * Captures a screenshot of the current rendering
  61917. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  61918. * @param engine defines the rendering engine
  61919. * @param camera defines the source camera
  61920. * @param size This parameter can be set to a single number or to an object with the
  61921. * following (optional) properties: precision, width, height. If a single number is passed,
  61922. * it will be used for both width and height. If an object is passed, the screenshot size
  61923. * will be derived from the parameters. The precision property is a multiplier allowing
  61924. * rendering at a higher or lower resolution
  61925. * @param successCallback defines the callback receives a single parameter which contains the
  61926. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  61927. * src parameter of an <img> to display it
  61928. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  61929. * Check your browser for supported MIME types
  61930. */
  61931. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  61932. /**
  61933. * Generates an image screenshot from the specified camera.
  61934. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  61935. * @param engine The engine to use for rendering
  61936. * @param camera The camera to use for rendering
  61937. * @param size This parameter can be set to a single number or to an object with the
  61938. * following (optional) properties: precision, width, height. If a single number is passed,
  61939. * it will be used for both width and height. If an object is passed, the screenshot size
  61940. * will be derived from the parameters. The precision property is a multiplier allowing
  61941. * rendering at a higher or lower resolution
  61942. * @param successCallback The callback receives a single parameter which contains the
  61943. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  61944. * src parameter of an <img> to display it
  61945. * @param mimeType The MIME type of the screenshot image (default: image/png).
  61946. * Check your browser for supported MIME types
  61947. * @param samples Texture samples (default: 1)
  61948. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  61949. * @param fileName A name for for the downloaded file.
  61950. */
  61951. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  61952. }
  61953. }
  61954. declare module "babylonjs/Misc/index" {
  61955. export * from "babylonjs/Misc/andOrNotEvaluator";
  61956. export * from "babylonjs/Misc/assetsManager";
  61957. export * from "babylonjs/Misc/dds";
  61958. export * from "babylonjs/Misc/decorators";
  61959. export * from "babylonjs/Misc/deferred";
  61960. export * from "babylonjs/Misc/environmentTextureTools";
  61961. export * from "babylonjs/Misc/meshExploder";
  61962. export * from "babylonjs/Misc/filesInput";
  61963. export * from "babylonjs/Misc/HighDynamicRange/index";
  61964. export * from "babylonjs/Misc/khronosTextureContainer";
  61965. export * from "babylonjs/Misc/observable";
  61966. export * from "babylonjs/Misc/performanceMonitor";
  61967. export * from "babylonjs/Misc/promise";
  61968. export * from "babylonjs/Misc/sceneOptimizer";
  61969. export * from "babylonjs/Misc/sceneSerializer";
  61970. export * from "babylonjs/Misc/smartArray";
  61971. export * from "babylonjs/Misc/stringDictionary";
  61972. export * from "babylonjs/Misc/tags";
  61973. export * from "babylonjs/Misc/textureTools";
  61974. export * from "babylonjs/Misc/tga";
  61975. export * from "babylonjs/Misc/tools";
  61976. export * from "babylonjs/Misc/videoRecorder";
  61977. export * from "babylonjs/Misc/virtualJoystick";
  61978. export * from "babylonjs/Misc/workerPool";
  61979. export * from "babylonjs/Misc/logger";
  61980. export * from "babylonjs/Misc/typeStore";
  61981. export * from "babylonjs/Misc/filesInputStore";
  61982. export * from "babylonjs/Misc/deepCopier";
  61983. export * from "babylonjs/Misc/pivotTools";
  61984. export * from "babylonjs/Misc/precisionDate";
  61985. export * from "babylonjs/Misc/screenshotTools";
  61986. export * from "babylonjs/Misc/typeStore";
  61987. export * from "babylonjs/Misc/webRequest";
  61988. export * from "babylonjs/Misc/iInspectable";
  61989. export * from "babylonjs/Misc/brdfTextureTools";
  61990. }
  61991. declare module "babylonjs/index" {
  61992. export * from "babylonjs/abstractScene";
  61993. export * from "babylonjs/Actions/index";
  61994. export * from "babylonjs/Animations/index";
  61995. export * from "babylonjs/assetContainer";
  61996. export * from "babylonjs/Audio/index";
  61997. export * from "babylonjs/Behaviors/index";
  61998. export * from "babylonjs/Bones/index";
  61999. export * from "babylonjs/Cameras/index";
  62000. export * from "babylonjs/Collisions/index";
  62001. export * from "babylonjs/Culling/index";
  62002. export * from "babylonjs/Debug/index";
  62003. export * from "babylonjs/Engines/index";
  62004. export * from "babylonjs/Events/index";
  62005. export * from "babylonjs/Gamepads/index";
  62006. export * from "babylonjs/Gizmos/index";
  62007. export * from "babylonjs/Helpers/index";
  62008. export * from "babylonjs/Instrumentation/index";
  62009. export * from "babylonjs/Layers/index";
  62010. export * from "babylonjs/LensFlares/index";
  62011. export * from "babylonjs/Lights/index";
  62012. export * from "babylonjs/Loading/index";
  62013. export * from "babylonjs/Materials/index";
  62014. export * from "babylonjs/Maths/index";
  62015. export * from "babylonjs/Meshes/index";
  62016. export * from "babylonjs/Morph/index";
  62017. export * from "babylonjs/node";
  62018. export * from "babylonjs/Offline/index";
  62019. export * from "babylonjs/Particles/index";
  62020. export * from "babylonjs/Physics/index";
  62021. export * from "babylonjs/PostProcesses/index";
  62022. export * from "babylonjs/Probes/index";
  62023. export * from "babylonjs/Rendering/index";
  62024. export * from "babylonjs/scene";
  62025. export * from "babylonjs/sceneComponent";
  62026. export * from "babylonjs/Sprites/index";
  62027. export * from "babylonjs/States/index";
  62028. export * from "babylonjs/Misc/index";
  62029. export * from "babylonjs/types";
  62030. }
  62031. declare module "babylonjs/Animations/pathCursor" {
  62032. import { Path2, Vector3 } from "babylonjs/Maths/math";
  62033. /**
  62034. * A cursor which tracks a point on a path
  62035. */
  62036. export class PathCursor {
  62037. private path;
  62038. /**
  62039. * Stores path cursor callbacks for when an onchange event is triggered
  62040. */
  62041. private _onchange;
  62042. /**
  62043. * The value of the path cursor
  62044. */
  62045. value: number;
  62046. /**
  62047. * The animation array of the path cursor
  62048. */
  62049. animations: Animation[];
  62050. /**
  62051. * Initializes the path cursor
  62052. * @param path The path to track
  62053. */
  62054. constructor(path: Path2);
  62055. /**
  62056. * Gets the cursor point on the path
  62057. * @returns A point on the path cursor at the cursor location
  62058. */
  62059. getPoint(): Vector3;
  62060. /**
  62061. * Moves the cursor ahead by the step amount
  62062. * @param step The amount to move the cursor forward
  62063. * @returns This path cursor
  62064. */
  62065. moveAhead(step?: number): PathCursor;
  62066. /**
  62067. * Moves the cursor behind by the step amount
  62068. * @param step The amount to move the cursor back
  62069. * @returns This path cursor
  62070. */
  62071. moveBack(step?: number): PathCursor;
  62072. /**
  62073. * Moves the cursor by the step amount
  62074. * If the step amount is greater than one, an exception is thrown
  62075. * @param step The amount to move the cursor
  62076. * @returns This path cursor
  62077. */
  62078. move(step: number): PathCursor;
  62079. /**
  62080. * Ensures that the value is limited between zero and one
  62081. * @returns This path cursor
  62082. */
  62083. private ensureLimits;
  62084. /**
  62085. * Runs onchange callbacks on change (used by the animation engine)
  62086. * @returns This path cursor
  62087. */
  62088. private raiseOnChange;
  62089. /**
  62090. * Executes a function on change
  62091. * @param f A path cursor onchange callback
  62092. * @returns This path cursor
  62093. */
  62094. onchange(f: (cursor: PathCursor) => void): PathCursor;
  62095. }
  62096. }
  62097. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  62098. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  62099. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  62100. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  62101. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  62102. }
  62103. declare module "babylonjs/Engines/Processors/Expressions/index" {
  62104. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  62105. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  62106. }
  62107. declare module "babylonjs/Engines/Processors/index" {
  62108. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  62109. export * from "babylonjs/Engines/Processors/Expressions/index";
  62110. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  62111. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  62112. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  62113. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  62114. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  62115. export * from "babylonjs/Engines/Processors/shaderProcessor";
  62116. }
  62117. declare module "babylonjs/Legacy/legacy" {
  62118. import * as Babylon from "babylonjs/index";
  62119. export * from "babylonjs/index";
  62120. }
  62121. declare module "babylonjs/Shaders/blur.fragment" {
  62122. /** @hidden */
  62123. export var blurPixelShader: {
  62124. name: string;
  62125. shader: string;
  62126. };
  62127. }
  62128. declare module "babylonjs/Shaders/ShadersInclude/bones300Declaration" {
  62129. /** @hidden */
  62130. export var bones300Declaration: {
  62131. name: string;
  62132. shader: string;
  62133. };
  62134. }
  62135. declare module "babylonjs/Shaders/ShadersInclude/instances300Declaration" {
  62136. /** @hidden */
  62137. export var instances300Declaration: {
  62138. name: string;
  62139. shader: string;
  62140. };
  62141. }
  62142. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  62143. /** @hidden */
  62144. export var pointCloudVertexDeclaration: {
  62145. name: string;
  62146. shader: string;
  62147. };
  62148. }
  62149. // Mixins
  62150. interface Window {
  62151. mozIndexedDB: IDBFactory;
  62152. webkitIndexedDB: IDBFactory;
  62153. msIndexedDB: IDBFactory;
  62154. webkitURL: typeof URL;
  62155. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  62156. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  62157. WebGLRenderingContext: WebGLRenderingContext;
  62158. MSGesture: MSGesture;
  62159. CANNON: any;
  62160. AudioContext: AudioContext;
  62161. webkitAudioContext: AudioContext;
  62162. PointerEvent: any;
  62163. Math: Math;
  62164. Uint8Array: Uint8ArrayConstructor;
  62165. Float32Array: Float32ArrayConstructor;
  62166. mozURL: typeof URL;
  62167. msURL: typeof URL;
  62168. VRFrameData: any; // WebVR, from specs 1.1
  62169. DracoDecoderModule: any;
  62170. setImmediate(handler: (...args: any[]) => void): number;
  62171. }
  62172. interface HTMLCanvasElement {
  62173. requestPointerLock(): void;
  62174. msRequestPointerLock?(): void;
  62175. mozRequestPointerLock?(): void;
  62176. webkitRequestPointerLock?(): void;
  62177. /** Track wether a record is in progress */
  62178. isRecording: boolean;
  62179. /** Capture Stream method defined by some browsers */
  62180. captureStream(fps?: number): MediaStream;
  62181. }
  62182. interface CanvasRenderingContext2D {
  62183. msImageSmoothingEnabled: boolean;
  62184. }
  62185. interface MouseEvent {
  62186. mozMovementX: number;
  62187. mozMovementY: number;
  62188. webkitMovementX: number;
  62189. webkitMovementY: number;
  62190. msMovementX: number;
  62191. msMovementY: number;
  62192. }
  62193. interface Navigator {
  62194. mozGetVRDevices: (any: any) => any;
  62195. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  62196. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  62197. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  62198. webkitGetGamepads(): Gamepad[];
  62199. msGetGamepads(): Gamepad[];
  62200. webkitGamepads(): Gamepad[];
  62201. }
  62202. interface HTMLVideoElement {
  62203. mozSrcObject: any;
  62204. }
  62205. interface Math {
  62206. fround(x: number): number;
  62207. imul(a: number, b: number): number;
  62208. }
  62209. interface WebGLRenderingContext {
  62210. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  62211. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  62212. vertexAttribDivisor(index: number, divisor: number): void;
  62213. createVertexArray(): any;
  62214. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  62215. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  62216. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  62217. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  62218. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  62219. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  62220. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  62221. // Queries
  62222. createQuery(): WebGLQuery;
  62223. deleteQuery(query: WebGLQuery): void;
  62224. beginQuery(target: number, query: WebGLQuery): void;
  62225. endQuery(target: number): void;
  62226. getQueryParameter(query: WebGLQuery, pname: number): any;
  62227. getQuery(target: number, pname: number): any;
  62228. MAX_SAMPLES: number;
  62229. RGBA8: number;
  62230. READ_FRAMEBUFFER: number;
  62231. DRAW_FRAMEBUFFER: number;
  62232. UNIFORM_BUFFER: number;
  62233. HALF_FLOAT_OES: number;
  62234. RGBA16F: number;
  62235. RGBA32F: number;
  62236. R32F: number;
  62237. RG32F: number;
  62238. RGB32F: number;
  62239. R16F: number;
  62240. RG16F: number;
  62241. RGB16F: number;
  62242. RED: number;
  62243. RG: number;
  62244. R8: number;
  62245. RG8: number;
  62246. UNSIGNED_INT_24_8: number;
  62247. DEPTH24_STENCIL8: number;
  62248. /* Multiple Render Targets */
  62249. drawBuffers(buffers: number[]): void;
  62250. readBuffer(src: number): void;
  62251. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  62252. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  62253. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  62254. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  62255. // Occlusion Query
  62256. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  62257. ANY_SAMPLES_PASSED: number;
  62258. QUERY_RESULT_AVAILABLE: number;
  62259. QUERY_RESULT: number;
  62260. }
  62261. interface WebGLProgram {
  62262. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  62263. }
  62264. interface EXT_disjoint_timer_query {
  62265. QUERY_COUNTER_BITS_EXT: number;
  62266. TIME_ELAPSED_EXT: number;
  62267. TIMESTAMP_EXT: number;
  62268. GPU_DISJOINT_EXT: number;
  62269. QUERY_RESULT_EXT: number;
  62270. QUERY_RESULT_AVAILABLE_EXT: number;
  62271. queryCounterEXT(query: WebGLQuery, target: number): void;
  62272. createQueryEXT(): WebGLQuery;
  62273. beginQueryEXT(target: number, query: WebGLQuery): void;
  62274. endQueryEXT(target: number): void;
  62275. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  62276. deleteQueryEXT(query: WebGLQuery): void;
  62277. }
  62278. interface WebGLUniformLocation {
  62279. _currentState: any;
  62280. }
  62281. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  62282. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  62283. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  62284. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  62285. interface WebGLRenderingContext {
  62286. readonly RASTERIZER_DISCARD: number;
  62287. readonly DEPTH_COMPONENT24: number;
  62288. readonly TEXTURE_3D: number;
  62289. readonly TEXTURE_2D_ARRAY: number;
  62290. readonly TEXTURE_COMPARE_FUNC: number;
  62291. readonly TEXTURE_COMPARE_MODE: number;
  62292. readonly COMPARE_REF_TO_TEXTURE: number;
  62293. readonly TEXTURE_WRAP_R: number;
  62294. readonly HALF_FLOAT: number;
  62295. readonly RGB8: number;
  62296. readonly RED_INTEGER: number;
  62297. readonly RG_INTEGER: number;
  62298. readonly RGB_INTEGER: number;
  62299. readonly RGBA_INTEGER: number;
  62300. readonly R8_SNORM: number;
  62301. readonly RG8_SNORM: number;
  62302. readonly RGB8_SNORM: number;
  62303. readonly RGBA8_SNORM: number;
  62304. readonly R8I: number;
  62305. readonly RG8I: number;
  62306. readonly RGB8I: number;
  62307. readonly RGBA8I: number;
  62308. readonly R8UI: number;
  62309. readonly RG8UI: number;
  62310. readonly RGB8UI: number;
  62311. readonly RGBA8UI: number;
  62312. readonly R16I: number;
  62313. readonly RG16I: number;
  62314. readonly RGB16I: number;
  62315. readonly RGBA16I: number;
  62316. readonly R16UI: number;
  62317. readonly RG16UI: number;
  62318. readonly RGB16UI: number;
  62319. readonly RGBA16UI: number;
  62320. readonly R32I: number;
  62321. readonly RG32I: number;
  62322. readonly RGB32I: number;
  62323. readonly RGBA32I: number;
  62324. readonly R32UI: number;
  62325. readonly RG32UI: number;
  62326. readonly RGB32UI: number;
  62327. readonly RGBA32UI: number;
  62328. readonly RGB10_A2UI: number;
  62329. readonly R11F_G11F_B10F: number;
  62330. readonly RGB9_E5: number;
  62331. readonly RGB10_A2: number;
  62332. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  62333. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  62334. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  62335. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  62336. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  62337. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  62338. 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;
  62339. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  62340. readonly TRANSFORM_FEEDBACK: number;
  62341. readonly INTERLEAVED_ATTRIBS: number;
  62342. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  62343. createTransformFeedback(): WebGLTransformFeedback;
  62344. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  62345. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  62346. beginTransformFeedback(primitiveMode: number): void;
  62347. endTransformFeedback(): void;
  62348. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  62349. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  62350. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  62351. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  62352. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  62353. }
  62354. interface ImageBitmap {
  62355. readonly width: number;
  62356. readonly height: number;
  62357. close(): void;
  62358. }
  62359. interface WebGLQuery extends WebGLObject {
  62360. }
  62361. declare var WebGLQuery: {
  62362. prototype: WebGLQuery;
  62363. new(): WebGLQuery;
  62364. };
  62365. interface WebGLSampler extends WebGLObject {
  62366. }
  62367. declare var WebGLSampler: {
  62368. prototype: WebGLSampler;
  62369. new(): WebGLSampler;
  62370. };
  62371. interface WebGLSync extends WebGLObject {
  62372. }
  62373. declare var WebGLSync: {
  62374. prototype: WebGLSync;
  62375. new(): WebGLSync;
  62376. };
  62377. interface WebGLTransformFeedback extends WebGLObject {
  62378. }
  62379. declare var WebGLTransformFeedback: {
  62380. prototype: WebGLTransformFeedback;
  62381. new(): WebGLTransformFeedback;
  62382. };
  62383. interface WebGLVertexArrayObject extends WebGLObject {
  62384. }
  62385. declare var WebGLVertexArrayObject: {
  62386. prototype: WebGLVertexArrayObject;
  62387. new(): WebGLVertexArrayObject;
  62388. };
  62389. // Type definitions for WebVR API
  62390. // Project: https://w3c.github.io/webvr/
  62391. // Definitions by: six a <https://github.com/lostfictions>
  62392. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  62393. interface VRDisplay extends EventTarget {
  62394. /**
  62395. * Dictionary of capabilities describing the VRDisplay.
  62396. */
  62397. readonly capabilities: VRDisplayCapabilities;
  62398. /**
  62399. * z-depth defining the far plane of the eye view frustum
  62400. * enables mapping of values in the render target depth
  62401. * attachment to scene coordinates. Initially set to 10000.0.
  62402. */
  62403. depthFar: number;
  62404. /**
  62405. * z-depth defining the near plane of the eye view frustum
  62406. * enables mapping of values in the render target depth
  62407. * attachment to scene coordinates. Initially set to 0.01.
  62408. */
  62409. depthNear: number;
  62410. /**
  62411. * An identifier for this distinct VRDisplay. Used as an
  62412. * association point in the Gamepad API.
  62413. */
  62414. readonly displayId: number;
  62415. /**
  62416. * A display name, a user-readable name identifying it.
  62417. */
  62418. readonly displayName: string;
  62419. readonly isConnected: boolean;
  62420. readonly isPresenting: boolean;
  62421. /**
  62422. * If this VRDisplay supports room-scale experiences, the optional
  62423. * stage attribute contains details on the room-scale parameters.
  62424. */
  62425. readonly stageParameters: VRStageParameters | null;
  62426. /**
  62427. * Passing the value returned by `requestAnimationFrame` to
  62428. * `cancelAnimationFrame` will unregister the callback.
  62429. * @param handle Define the hanle of the request to cancel
  62430. */
  62431. cancelAnimationFrame(handle: number): void;
  62432. /**
  62433. * Stops presenting to the VRDisplay.
  62434. * @returns a promise to know when it stopped
  62435. */
  62436. exitPresent(): Promise<void>;
  62437. /**
  62438. * Return the current VREyeParameters for the given eye.
  62439. * @param whichEye Define the eye we want the parameter for
  62440. * @returns the eye parameters
  62441. */
  62442. getEyeParameters(whichEye: string): VREyeParameters;
  62443. /**
  62444. * Populates the passed VRFrameData with the information required to render
  62445. * the current frame.
  62446. * @param frameData Define the data structure to populate
  62447. * @returns true if ok otherwise false
  62448. */
  62449. getFrameData(frameData: VRFrameData): boolean;
  62450. /**
  62451. * Get the layers currently being presented.
  62452. * @returns the list of VR layers
  62453. */
  62454. getLayers(): VRLayer[];
  62455. /**
  62456. * Return a VRPose containing the future predicted pose of the VRDisplay
  62457. * when the current frame will be presented. The value returned will not
  62458. * change until JavaScript has returned control to the browser.
  62459. *
  62460. * The VRPose will contain the position, orientation, velocity,
  62461. * and acceleration of each of these properties.
  62462. * @returns the pose object
  62463. */
  62464. getPose(): VRPose;
  62465. /**
  62466. * Return the current instantaneous pose of the VRDisplay, with no
  62467. * prediction applied.
  62468. * @returns the current instantaneous pose
  62469. */
  62470. getImmediatePose(): VRPose;
  62471. /**
  62472. * The callback passed to `requestAnimationFrame` will be called
  62473. * any time a new frame should be rendered. When the VRDisplay is
  62474. * presenting the callback will be called at the native refresh
  62475. * rate of the HMD. When not presenting this function acts
  62476. * identically to how window.requestAnimationFrame acts. Content should
  62477. * make no assumptions of frame rate or vsync behavior as the HMD runs
  62478. * asynchronously from other displays and at differing refresh rates.
  62479. * @param callback Define the eaction to run next frame
  62480. * @returns the request handle it
  62481. */
  62482. requestAnimationFrame(callback: FrameRequestCallback): number;
  62483. /**
  62484. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  62485. * Repeat calls while already presenting will update the VRLayers being displayed.
  62486. * @param layers Define the list of layer to present
  62487. * @returns a promise to know when the request has been fulfilled
  62488. */
  62489. requestPresent(layers: VRLayer[]): Promise<void>;
  62490. /**
  62491. * Reset the pose for this display, treating its current position and
  62492. * orientation as the "origin/zero" values. VRPose.position,
  62493. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  62494. * updated when calling resetPose(). This should be called in only
  62495. * sitting-space experiences.
  62496. */
  62497. resetPose(): void;
  62498. /**
  62499. * The VRLayer provided to the VRDisplay will be captured and presented
  62500. * in the HMD. Calling this function has the same effect on the source
  62501. * canvas as any other operation that uses its source image, and canvases
  62502. * created without preserveDrawingBuffer set to true will be cleared.
  62503. * @param pose Define the pose to submit
  62504. */
  62505. submitFrame(pose?: VRPose): void;
  62506. }
  62507. declare var VRDisplay: {
  62508. prototype: VRDisplay;
  62509. new(): VRDisplay;
  62510. };
  62511. interface VRLayer {
  62512. leftBounds?: number[] | Float32Array | null;
  62513. rightBounds?: number[] | Float32Array | null;
  62514. source?: HTMLCanvasElement | null;
  62515. }
  62516. interface VRDisplayCapabilities {
  62517. readonly canPresent: boolean;
  62518. readonly hasExternalDisplay: boolean;
  62519. readonly hasOrientation: boolean;
  62520. readonly hasPosition: boolean;
  62521. readonly maxLayers: number;
  62522. }
  62523. interface VREyeParameters {
  62524. /** @deprecated */
  62525. readonly fieldOfView: VRFieldOfView;
  62526. readonly offset: Float32Array;
  62527. readonly renderHeight: number;
  62528. readonly renderWidth: number;
  62529. }
  62530. interface VRFieldOfView {
  62531. readonly downDegrees: number;
  62532. readonly leftDegrees: number;
  62533. readonly rightDegrees: number;
  62534. readonly upDegrees: number;
  62535. }
  62536. interface VRFrameData {
  62537. readonly leftProjectionMatrix: Float32Array;
  62538. readonly leftViewMatrix: Float32Array;
  62539. readonly pose: VRPose;
  62540. readonly rightProjectionMatrix: Float32Array;
  62541. readonly rightViewMatrix: Float32Array;
  62542. readonly timestamp: number;
  62543. }
  62544. interface VRPose {
  62545. readonly angularAcceleration: Float32Array | null;
  62546. readonly angularVelocity: Float32Array | null;
  62547. readonly linearAcceleration: Float32Array | null;
  62548. readonly linearVelocity: Float32Array | null;
  62549. readonly orientation: Float32Array | null;
  62550. readonly position: Float32Array | null;
  62551. readonly timestamp: number;
  62552. }
  62553. interface VRStageParameters {
  62554. sittingToStandingTransform?: Float32Array;
  62555. sizeX?: number;
  62556. sizeY?: number;
  62557. }
  62558. interface Navigator {
  62559. getVRDisplays(): Promise<VRDisplay[]>;
  62560. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  62561. }
  62562. interface Window {
  62563. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  62564. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  62565. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  62566. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  62567. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  62568. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  62569. }
  62570. interface Gamepad {
  62571. readonly displayId: number;
  62572. }
  62573. interface XRDevice {
  62574. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  62575. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  62576. }
  62577. interface XRSession {
  62578. getInputSources(): Array<any>;
  62579. baseLayer: XRWebGLLayer;
  62580. requestFrameOfReference(type: string): Promise<void>;
  62581. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  62582. end(): Promise<void>;
  62583. requestAnimationFrame: Function;
  62584. addEventListener: Function;
  62585. }
  62586. interface XRSessionCreationOptions {
  62587. outputContext?: WebGLRenderingContext | null;
  62588. immersive?: boolean;
  62589. environmentIntegration?: boolean;
  62590. }
  62591. interface XRLayer {
  62592. getViewport: Function;
  62593. framebufferWidth: number;
  62594. framebufferHeight: number;
  62595. }
  62596. interface XRView {
  62597. projectionMatrix: Float32Array;
  62598. }
  62599. interface XRFrame {
  62600. getDevicePose: Function;
  62601. getInputPose: Function;
  62602. views: Array<XRView>;
  62603. baseLayer: XRLayer;
  62604. }
  62605. interface XRFrameOfReference {
  62606. }
  62607. interface XRWebGLLayer extends XRLayer {
  62608. framebuffer: WebGLFramebuffer;
  62609. }
  62610. declare var XRWebGLLayer: {
  62611. prototype: XRWebGLLayer;
  62612. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  62613. };
  62614. declare module "babylonjs" {
  62615. export * from "babylonjs/Legacy/legacy";
  62616. }
  62617. declare module BABYLON {
  62618. /** Alias type for value that can be null */
  62619. export type Nullable<T> = T | null;
  62620. /**
  62621. * Alias type for number that are floats
  62622. * @ignorenaming
  62623. */
  62624. export type float = number;
  62625. /**
  62626. * Alias type for number that are doubles.
  62627. * @ignorenaming
  62628. */
  62629. export type double = number;
  62630. /**
  62631. * Alias type for number that are integer
  62632. * @ignorenaming
  62633. */
  62634. export type int = number;
  62635. /** Alias type for number array or Float32Array */
  62636. export type FloatArray = number[] | Float32Array;
  62637. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  62638. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  62639. /**
  62640. * Alias for types that can be used by a Buffer or VertexBuffer.
  62641. */
  62642. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  62643. /**
  62644. * Alias type for primitive types
  62645. * @ignorenaming
  62646. */
  62647. type Primitive = undefined | null | boolean | string | number | Function;
  62648. /**
  62649. * Type modifier to make all the properties of an object Readonly
  62650. */
  62651. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  62652. /**
  62653. * Type modifier to make all the properties of an object Readonly recursively
  62654. */
  62655. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  62656. /** @hidden */
  62657. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  62658. }
  62659. /** @hidden */
  62660. /** @hidden */
  62661. type DeepImmutableObject<T> = {
  62662. readonly [K in keyof T]: DeepImmutable<T[K]>;
  62663. };
  62664. }
  62665. declare module BABYLON {
  62666. /**
  62667. * Class containing a set of static utilities functions for arrays.
  62668. */
  62669. export class ArrayTools {
  62670. /**
  62671. * Returns an array of the given size filled with element built from the given constructor and the paramters
  62672. * @param size the number of element to construct and put in the array
  62673. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  62674. * @returns a new array filled with new objects
  62675. */
  62676. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  62677. }
  62678. }
  62679. declare module BABYLON {
  62680. /**
  62681. * Scalar computation library
  62682. */
  62683. export class Scalar {
  62684. /**
  62685. * Two pi constants convenient for computation.
  62686. */
  62687. static TwoPi: number;
  62688. /**
  62689. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  62690. * @param a number
  62691. * @param b number
  62692. * @param epsilon (default = 1.401298E-45)
  62693. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  62694. */
  62695. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  62696. /**
  62697. * Returns a string : the upper case translation of the number i to hexadecimal.
  62698. * @param i number
  62699. * @returns the upper case translation of the number i to hexadecimal.
  62700. */
  62701. static ToHex(i: number): string;
  62702. /**
  62703. * Returns -1 if value is negative and +1 is value is positive.
  62704. * @param value the value
  62705. * @returns the value itself if it's equal to zero.
  62706. */
  62707. static Sign(value: number): number;
  62708. /**
  62709. * Returns the value itself if it's between min and max.
  62710. * Returns min if the value is lower than min.
  62711. * Returns max if the value is greater than max.
  62712. * @param value the value to clmap
  62713. * @param min the min value to clamp to (default: 0)
  62714. * @param max the max value to clamp to (default: 1)
  62715. * @returns the clamped value
  62716. */
  62717. static Clamp(value: number, min?: number, max?: number): number;
  62718. /**
  62719. * the log2 of value.
  62720. * @param value the value to compute log2 of
  62721. * @returns the log2 of value.
  62722. */
  62723. static Log2(value: number): number;
  62724. /**
  62725. * Loops the value, so that it is never larger than length and never smaller than 0.
  62726. *
  62727. * This is similar to the modulo operator but it works with floating point numbers.
  62728. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  62729. * With t = 5 and length = 2.5, the result would be 0.0.
  62730. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  62731. * @param value the value
  62732. * @param length the length
  62733. * @returns the looped value
  62734. */
  62735. static Repeat(value: number, length: number): number;
  62736. /**
  62737. * Normalize the value between 0.0 and 1.0 using min and max values
  62738. * @param value value to normalize
  62739. * @param min max to normalize between
  62740. * @param max min to normalize between
  62741. * @returns the normalized value
  62742. */
  62743. static Normalize(value: number, min: number, max: number): number;
  62744. /**
  62745. * Denormalize the value from 0.0 and 1.0 using min and max values
  62746. * @param normalized value to denormalize
  62747. * @param min max to denormalize between
  62748. * @param max min to denormalize between
  62749. * @returns the denormalized value
  62750. */
  62751. static Denormalize(normalized: number, min: number, max: number): number;
  62752. /**
  62753. * Calculates the shortest difference between two given angles given in degrees.
  62754. * @param current current angle in degrees
  62755. * @param target target angle in degrees
  62756. * @returns the delta
  62757. */
  62758. static DeltaAngle(current: number, target: number): number;
  62759. /**
  62760. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  62761. * @param tx value
  62762. * @param length length
  62763. * @returns The returned value will move back and forth between 0 and length
  62764. */
  62765. static PingPong(tx: number, length: number): number;
  62766. /**
  62767. * Interpolates between min and max with smoothing at the limits.
  62768. *
  62769. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  62770. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  62771. * @param from from
  62772. * @param to to
  62773. * @param tx value
  62774. * @returns the smooth stepped value
  62775. */
  62776. static SmoothStep(from: number, to: number, tx: number): number;
  62777. /**
  62778. * Moves a value current towards target.
  62779. *
  62780. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  62781. * Negative values of maxDelta pushes the value away from target.
  62782. * @param current current value
  62783. * @param target target value
  62784. * @param maxDelta max distance to move
  62785. * @returns resulting value
  62786. */
  62787. static MoveTowards(current: number, target: number, maxDelta: number): number;
  62788. /**
  62789. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  62790. *
  62791. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  62792. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  62793. * @param current current value
  62794. * @param target target value
  62795. * @param maxDelta max distance to move
  62796. * @returns resulting angle
  62797. */
  62798. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  62799. /**
  62800. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  62801. * @param start start value
  62802. * @param end target value
  62803. * @param amount amount to lerp between
  62804. * @returns the lerped value
  62805. */
  62806. static Lerp(start: number, end: number, amount: number): number;
  62807. /**
  62808. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  62809. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  62810. * @param start start value
  62811. * @param end target value
  62812. * @param amount amount to lerp between
  62813. * @returns the lerped value
  62814. */
  62815. static LerpAngle(start: number, end: number, amount: number): number;
  62816. /**
  62817. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  62818. * @param a start value
  62819. * @param b target value
  62820. * @param value value between a and b
  62821. * @returns the inverseLerp value
  62822. */
  62823. static InverseLerp(a: number, b: number, value: number): number;
  62824. /**
  62825. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  62826. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  62827. * @param value1 spline value
  62828. * @param tangent1 spline value
  62829. * @param value2 spline value
  62830. * @param tangent2 spline value
  62831. * @param amount input value
  62832. * @returns hermite result
  62833. */
  62834. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  62835. /**
  62836. * Returns a random float number between and min and max values
  62837. * @param min min value of random
  62838. * @param max max value of random
  62839. * @returns random value
  62840. */
  62841. static RandomRange(min: number, max: number): number;
  62842. /**
  62843. * This function returns percentage of a number in a given range.
  62844. *
  62845. * RangeToPercent(40,20,60) will return 0.5 (50%)
  62846. * RangeToPercent(34,0,100) will return 0.34 (34%)
  62847. * @param number to convert to percentage
  62848. * @param min min range
  62849. * @param max max range
  62850. * @returns the percentage
  62851. */
  62852. static RangeToPercent(number: number, min: number, max: number): number;
  62853. /**
  62854. * This function returns number that corresponds to the percentage in a given range.
  62855. *
  62856. * PercentToRange(0.34,0,100) will return 34.
  62857. * @param percent to convert to number
  62858. * @param min min range
  62859. * @param max max range
  62860. * @returns the number
  62861. */
  62862. static PercentToRange(percent: number, min: number, max: number): number;
  62863. /**
  62864. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  62865. * @param angle The angle to normalize in radian.
  62866. * @return The converted angle.
  62867. */
  62868. static NormalizeRadians(angle: number): number;
  62869. }
  62870. }
  62871. declare module BABYLON {
  62872. /**
  62873. * Constant used to convert a value to gamma space
  62874. * @ignorenaming
  62875. */
  62876. export const ToGammaSpace: number;
  62877. /**
  62878. * Constant used to convert a value to linear space
  62879. * @ignorenaming
  62880. */
  62881. export const ToLinearSpace = 2.2;
  62882. /**
  62883. * Constant used to define the minimal number value in Babylon.js
  62884. * @ignorenaming
  62885. */
  62886. let Epsilon: number;
  62887. /**
  62888. * Class used to hold a RBG color
  62889. */
  62890. export class Color3 {
  62891. /**
  62892. * Defines the red component (between 0 and 1, default is 0)
  62893. */
  62894. r: number;
  62895. /**
  62896. * Defines the green component (between 0 and 1, default is 0)
  62897. */
  62898. g: number;
  62899. /**
  62900. * Defines the blue component (between 0 and 1, default is 0)
  62901. */
  62902. b: number;
  62903. /**
  62904. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  62905. * @param r defines the red component (between 0 and 1, default is 0)
  62906. * @param g defines the green component (between 0 and 1, default is 0)
  62907. * @param b defines the blue component (between 0 and 1, default is 0)
  62908. */
  62909. constructor(
  62910. /**
  62911. * Defines the red component (between 0 and 1, default is 0)
  62912. */
  62913. r?: number,
  62914. /**
  62915. * Defines the green component (between 0 and 1, default is 0)
  62916. */
  62917. g?: number,
  62918. /**
  62919. * Defines the blue component (between 0 and 1, default is 0)
  62920. */
  62921. b?: number);
  62922. /**
  62923. * Creates a string with the Color3 current values
  62924. * @returns the string representation of the Color3 object
  62925. */
  62926. toString(): string;
  62927. /**
  62928. * Returns the string "Color3"
  62929. * @returns "Color3"
  62930. */
  62931. getClassName(): string;
  62932. /**
  62933. * Compute the Color3 hash code
  62934. * @returns an unique number that can be used to hash Color3 objects
  62935. */
  62936. getHashCode(): number;
  62937. /**
  62938. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  62939. * @param array defines the array where to store the r,g,b components
  62940. * @param index defines an optional index in the target array to define where to start storing values
  62941. * @returns the current Color3 object
  62942. */
  62943. toArray(array: FloatArray, index?: number): Color3;
  62944. /**
  62945. * Returns a new Color4 object from the current Color3 and the given alpha
  62946. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  62947. * @returns a new Color4 object
  62948. */
  62949. toColor4(alpha?: number): Color4;
  62950. /**
  62951. * Returns a new array populated with 3 numeric elements : red, green and blue values
  62952. * @returns the new array
  62953. */
  62954. asArray(): number[];
  62955. /**
  62956. * Returns the luminance value
  62957. * @returns a float value
  62958. */
  62959. toLuminance(): number;
  62960. /**
  62961. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  62962. * @param otherColor defines the second operand
  62963. * @returns the new Color3 object
  62964. */
  62965. multiply(otherColor: DeepImmutable<Color3>): Color3;
  62966. /**
  62967. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  62968. * @param otherColor defines the second operand
  62969. * @param result defines the Color3 object where to store the result
  62970. * @returns the current Color3
  62971. */
  62972. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  62973. /**
  62974. * Determines equality between Color3 objects
  62975. * @param otherColor defines the second operand
  62976. * @returns true if the rgb values are equal to the given ones
  62977. */
  62978. equals(otherColor: DeepImmutable<Color3>): boolean;
  62979. /**
  62980. * Determines equality between the current Color3 object and a set of r,b,g values
  62981. * @param r defines the red component to check
  62982. * @param g defines the green component to check
  62983. * @param b defines the blue component to check
  62984. * @returns true if the rgb values are equal to the given ones
  62985. */
  62986. equalsFloats(r: number, g: number, b: number): boolean;
  62987. /**
  62988. * Multiplies in place each rgb value by scale
  62989. * @param scale defines the scaling factor
  62990. * @returns the updated Color3
  62991. */
  62992. scale(scale: number): Color3;
  62993. /**
  62994. * Multiplies the rgb values by scale and stores the result into "result"
  62995. * @param scale defines the scaling factor
  62996. * @param result defines the Color3 object where to store the result
  62997. * @returns the unmodified current Color3
  62998. */
  62999. scaleToRef(scale: number, result: Color3): Color3;
  63000. /**
  63001. * Scale the current Color3 values by a factor and add the result to a given Color3
  63002. * @param scale defines the scale factor
  63003. * @param result defines color to store the result into
  63004. * @returns the unmodified current Color3
  63005. */
  63006. scaleAndAddToRef(scale: number, result: Color3): Color3;
  63007. /**
  63008. * Clamps the rgb values by the min and max values and stores the result into "result"
  63009. * @param min defines minimum clamping value (default is 0)
  63010. * @param max defines maximum clamping value (default is 1)
  63011. * @param result defines color to store the result into
  63012. * @returns the original Color3
  63013. */
  63014. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  63015. /**
  63016. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  63017. * @param otherColor defines the second operand
  63018. * @returns the new Color3
  63019. */
  63020. add(otherColor: DeepImmutable<Color3>): Color3;
  63021. /**
  63022. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  63023. * @param otherColor defines the second operand
  63024. * @param result defines Color3 object to store the result into
  63025. * @returns the unmodified current Color3
  63026. */
  63027. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  63028. /**
  63029. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  63030. * @param otherColor defines the second operand
  63031. * @returns the new Color3
  63032. */
  63033. subtract(otherColor: DeepImmutable<Color3>): Color3;
  63034. /**
  63035. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  63036. * @param otherColor defines the second operand
  63037. * @param result defines Color3 object to store the result into
  63038. * @returns the unmodified current Color3
  63039. */
  63040. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  63041. /**
  63042. * Copy the current object
  63043. * @returns a new Color3 copied the current one
  63044. */
  63045. clone(): Color3;
  63046. /**
  63047. * Copies the rgb values from the source in the current Color3
  63048. * @param source defines the source Color3 object
  63049. * @returns the updated Color3 object
  63050. */
  63051. copyFrom(source: DeepImmutable<Color3>): Color3;
  63052. /**
  63053. * Updates the Color3 rgb values from the given floats
  63054. * @param r defines the red component to read from
  63055. * @param g defines the green component to read from
  63056. * @param b defines the blue component to read from
  63057. * @returns the current Color3 object
  63058. */
  63059. copyFromFloats(r: number, g: number, b: number): Color3;
  63060. /**
  63061. * Updates the Color3 rgb values from the given floats
  63062. * @param r defines the red component to read from
  63063. * @param g defines the green component to read from
  63064. * @param b defines the blue component to read from
  63065. * @returns the current Color3 object
  63066. */
  63067. set(r: number, g: number, b: number): Color3;
  63068. /**
  63069. * Compute the Color3 hexadecimal code as a string
  63070. * @returns a string containing the hexadecimal representation of the Color3 object
  63071. */
  63072. toHexString(): string;
  63073. /**
  63074. * Computes a new Color3 converted from the current one to linear space
  63075. * @returns a new Color3 object
  63076. */
  63077. toLinearSpace(): Color3;
  63078. /**
  63079. * Converts current color in rgb space to HSV values
  63080. * @returns a new color3 representing the HSV values
  63081. */
  63082. toHSV(): Color3;
  63083. /**
  63084. * Converts current color in rgb space to HSV values
  63085. * @param result defines the Color3 where to store the HSV values
  63086. */
  63087. toHSVToRef(result: Color3): void;
  63088. /**
  63089. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  63090. * @param convertedColor defines the Color3 object where to store the linear space version
  63091. * @returns the unmodified Color3
  63092. */
  63093. toLinearSpaceToRef(convertedColor: Color3): Color3;
  63094. /**
  63095. * Computes a new Color3 converted from the current one to gamma space
  63096. * @returns a new Color3 object
  63097. */
  63098. toGammaSpace(): Color3;
  63099. /**
  63100. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  63101. * @param convertedColor defines the Color3 object where to store the gamma space version
  63102. * @returns the unmodified Color3
  63103. */
  63104. toGammaSpaceToRef(convertedColor: Color3): Color3;
  63105. private static _BlackReadOnly;
  63106. /**
  63107. * Convert Hue, saturation and value to a Color3 (RGB)
  63108. * @param hue defines the hue
  63109. * @param saturation defines the saturation
  63110. * @param value defines the value
  63111. * @param result defines the Color3 where to store the RGB values
  63112. */
  63113. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  63114. /**
  63115. * Creates a new Color3 from the string containing valid hexadecimal values
  63116. * @param hex defines a string containing valid hexadecimal values
  63117. * @returns a new Color3 object
  63118. */
  63119. static FromHexString(hex: string): Color3;
  63120. /**
  63121. * Creates a new Color3 from the starting index of the given array
  63122. * @param array defines the source array
  63123. * @param offset defines an offset in the source array
  63124. * @returns a new Color3 object
  63125. */
  63126. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  63127. /**
  63128. * Creates a new Color3 from integer values (< 256)
  63129. * @param r defines the red component to read from (value between 0 and 255)
  63130. * @param g defines the green component to read from (value between 0 and 255)
  63131. * @param b defines the blue component to read from (value between 0 and 255)
  63132. * @returns a new Color3 object
  63133. */
  63134. static FromInts(r: number, g: number, b: number): Color3;
  63135. /**
  63136. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  63137. * @param start defines the start Color3 value
  63138. * @param end defines the end Color3 value
  63139. * @param amount defines the gradient value between start and end
  63140. * @returns a new Color3 object
  63141. */
  63142. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  63143. /**
  63144. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  63145. * @param left defines the start value
  63146. * @param right defines the end value
  63147. * @param amount defines the gradient factor
  63148. * @param result defines the Color3 object where to store the result
  63149. */
  63150. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  63151. /**
  63152. * Returns a Color3 value containing a red color
  63153. * @returns a new Color3 object
  63154. */
  63155. static Red(): Color3;
  63156. /**
  63157. * Returns a Color3 value containing a green color
  63158. * @returns a new Color3 object
  63159. */
  63160. static Green(): Color3;
  63161. /**
  63162. * Returns a Color3 value containing a blue color
  63163. * @returns a new Color3 object
  63164. */
  63165. static Blue(): Color3;
  63166. /**
  63167. * Returns a Color3 value containing a black color
  63168. * @returns a new Color3 object
  63169. */
  63170. static Black(): Color3;
  63171. /**
  63172. * Gets a Color3 value containing a black color that must not be updated
  63173. */
  63174. static readonly BlackReadOnly: DeepImmutable<Color3>;
  63175. /**
  63176. * Returns a Color3 value containing a white color
  63177. * @returns a new Color3 object
  63178. */
  63179. static White(): Color3;
  63180. /**
  63181. * Returns a Color3 value containing a purple color
  63182. * @returns a new Color3 object
  63183. */
  63184. static Purple(): Color3;
  63185. /**
  63186. * Returns a Color3 value containing a magenta color
  63187. * @returns a new Color3 object
  63188. */
  63189. static Magenta(): Color3;
  63190. /**
  63191. * Returns a Color3 value containing a yellow color
  63192. * @returns a new Color3 object
  63193. */
  63194. static Yellow(): Color3;
  63195. /**
  63196. * Returns a Color3 value containing a gray color
  63197. * @returns a new Color3 object
  63198. */
  63199. static Gray(): Color3;
  63200. /**
  63201. * Returns a Color3 value containing a teal color
  63202. * @returns a new Color3 object
  63203. */
  63204. static Teal(): Color3;
  63205. /**
  63206. * Returns a Color3 value containing a random color
  63207. * @returns a new Color3 object
  63208. */
  63209. static Random(): Color3;
  63210. }
  63211. /**
  63212. * Class used to hold a RBGA color
  63213. */
  63214. export class Color4 {
  63215. /**
  63216. * Defines the red component (between 0 and 1, default is 0)
  63217. */
  63218. r: number;
  63219. /**
  63220. * Defines the green component (between 0 and 1, default is 0)
  63221. */
  63222. g: number;
  63223. /**
  63224. * Defines the blue component (between 0 and 1, default is 0)
  63225. */
  63226. b: number;
  63227. /**
  63228. * Defines the alpha component (between 0 and 1, default is 1)
  63229. */
  63230. a: number;
  63231. /**
  63232. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  63233. * @param r defines the red component (between 0 and 1, default is 0)
  63234. * @param g defines the green component (between 0 and 1, default is 0)
  63235. * @param b defines the blue component (between 0 and 1, default is 0)
  63236. * @param a defines the alpha component (between 0 and 1, default is 1)
  63237. */
  63238. constructor(
  63239. /**
  63240. * Defines the red component (between 0 and 1, default is 0)
  63241. */
  63242. r?: number,
  63243. /**
  63244. * Defines the green component (between 0 and 1, default is 0)
  63245. */
  63246. g?: number,
  63247. /**
  63248. * Defines the blue component (between 0 and 1, default is 0)
  63249. */
  63250. b?: number,
  63251. /**
  63252. * Defines the alpha component (between 0 and 1, default is 1)
  63253. */
  63254. a?: number);
  63255. /**
  63256. * Adds in place the given Color4 values to the current Color4 object
  63257. * @param right defines the second operand
  63258. * @returns the current updated Color4 object
  63259. */
  63260. addInPlace(right: DeepImmutable<Color4>): Color4;
  63261. /**
  63262. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  63263. * @returns the new array
  63264. */
  63265. asArray(): number[];
  63266. /**
  63267. * Stores from the starting index in the given array the Color4 successive values
  63268. * @param array defines the array where to store the r,g,b components
  63269. * @param index defines an optional index in the target array to define where to start storing values
  63270. * @returns the current Color4 object
  63271. */
  63272. toArray(array: number[], index?: number): Color4;
  63273. /**
  63274. * Determines equality between Color4 objects
  63275. * @param otherColor defines the second operand
  63276. * @returns true if the rgba values are equal to the given ones
  63277. */
  63278. equals(otherColor: DeepImmutable<Color4>): boolean;
  63279. /**
  63280. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  63281. * @param right defines the second operand
  63282. * @returns a new Color4 object
  63283. */
  63284. add(right: DeepImmutable<Color4>): Color4;
  63285. /**
  63286. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  63287. * @param right defines the second operand
  63288. * @returns a new Color4 object
  63289. */
  63290. subtract(right: DeepImmutable<Color4>): Color4;
  63291. /**
  63292. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  63293. * @param right defines the second operand
  63294. * @param result defines the Color4 object where to store the result
  63295. * @returns the current Color4 object
  63296. */
  63297. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  63298. /**
  63299. * Creates a new Color4 with the current Color4 values multiplied by scale
  63300. * @param scale defines the scaling factor to apply
  63301. * @returns a new Color4 object
  63302. */
  63303. scale(scale: number): Color4;
  63304. /**
  63305. * Multiplies the current Color4 values by scale and stores the result in "result"
  63306. * @param scale defines the scaling factor to apply
  63307. * @param result defines the Color4 object where to store the result
  63308. * @returns the current unmodified Color4
  63309. */
  63310. scaleToRef(scale: number, result: Color4): Color4;
  63311. /**
  63312. * Scale the current Color4 values by a factor and add the result to a given Color4
  63313. * @param scale defines the scale factor
  63314. * @param result defines the Color4 object where to store the result
  63315. * @returns the unmodified current Color4
  63316. */
  63317. scaleAndAddToRef(scale: number, result: Color4): Color4;
  63318. /**
  63319. * Clamps the rgb values by the min and max values and stores the result into "result"
  63320. * @param min defines minimum clamping value (default is 0)
  63321. * @param max defines maximum clamping value (default is 1)
  63322. * @param result defines color to store the result into.
  63323. * @returns the cuurent Color4
  63324. */
  63325. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  63326. /**
  63327. * Multipy an Color4 value by another and return a new Color4 object
  63328. * @param color defines the Color4 value to multiply by
  63329. * @returns a new Color4 object
  63330. */
  63331. multiply(color: Color4): Color4;
  63332. /**
  63333. * Multipy a Color4 value by another and push the result in a reference value
  63334. * @param color defines the Color4 value to multiply by
  63335. * @param result defines the Color4 to fill the result in
  63336. * @returns the result Color4
  63337. */
  63338. multiplyToRef(color: Color4, result: Color4): Color4;
  63339. /**
  63340. * Creates a string with the Color4 current values
  63341. * @returns the string representation of the Color4 object
  63342. */
  63343. toString(): string;
  63344. /**
  63345. * Returns the string "Color4"
  63346. * @returns "Color4"
  63347. */
  63348. getClassName(): string;
  63349. /**
  63350. * Compute the Color4 hash code
  63351. * @returns an unique number that can be used to hash Color4 objects
  63352. */
  63353. getHashCode(): number;
  63354. /**
  63355. * Creates a new Color4 copied from the current one
  63356. * @returns a new Color4 object
  63357. */
  63358. clone(): Color4;
  63359. /**
  63360. * Copies the given Color4 values into the current one
  63361. * @param source defines the source Color4 object
  63362. * @returns the current updated Color4 object
  63363. */
  63364. copyFrom(source: Color4): Color4;
  63365. /**
  63366. * Copies the given float values into the current one
  63367. * @param r defines the red component to read from
  63368. * @param g defines the green component to read from
  63369. * @param b defines the blue component to read from
  63370. * @param a defines the alpha component to read from
  63371. * @returns the current updated Color4 object
  63372. */
  63373. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  63374. /**
  63375. * Copies the given float values into the current one
  63376. * @param r defines the red component to read from
  63377. * @param g defines the green component to read from
  63378. * @param b defines the blue component to read from
  63379. * @param a defines the alpha component to read from
  63380. * @returns the current updated Color4 object
  63381. */
  63382. set(r: number, g: number, b: number, a: number): Color4;
  63383. /**
  63384. * Compute the Color4 hexadecimal code as a string
  63385. * @returns a string containing the hexadecimal representation of the Color4 object
  63386. */
  63387. toHexString(): string;
  63388. /**
  63389. * Computes a new Color4 converted from the current one to linear space
  63390. * @returns a new Color4 object
  63391. */
  63392. toLinearSpace(): Color4;
  63393. /**
  63394. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  63395. * @param convertedColor defines the Color4 object where to store the linear space version
  63396. * @returns the unmodified Color4
  63397. */
  63398. toLinearSpaceToRef(convertedColor: Color4): Color4;
  63399. /**
  63400. * Computes a new Color4 converted from the current one to gamma space
  63401. * @returns a new Color4 object
  63402. */
  63403. toGammaSpace(): Color4;
  63404. /**
  63405. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  63406. * @param convertedColor defines the Color4 object where to store the gamma space version
  63407. * @returns the unmodified Color4
  63408. */
  63409. toGammaSpaceToRef(convertedColor: Color4): Color4;
  63410. /**
  63411. * Creates a new Color4 from the string containing valid hexadecimal values
  63412. * @param hex defines a string containing valid hexadecimal values
  63413. * @returns a new Color4 object
  63414. */
  63415. static FromHexString(hex: string): Color4;
  63416. /**
  63417. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  63418. * @param left defines the start value
  63419. * @param right defines the end value
  63420. * @param amount defines the gradient factor
  63421. * @returns a new Color4 object
  63422. */
  63423. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  63424. /**
  63425. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  63426. * @param left defines the start value
  63427. * @param right defines the end value
  63428. * @param amount defines the gradient factor
  63429. * @param result defines the Color4 object where to store data
  63430. */
  63431. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  63432. /**
  63433. * Creates a new Color4 from a Color3 and an alpha value
  63434. * @param color3 defines the source Color3 to read from
  63435. * @param alpha defines the alpha component (1.0 by default)
  63436. * @returns a new Color4 object
  63437. */
  63438. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  63439. /**
  63440. * Creates a new Color4 from the starting index element of the given array
  63441. * @param array defines the source array to read from
  63442. * @param offset defines the offset in the source array
  63443. * @returns a new Color4 object
  63444. */
  63445. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  63446. /**
  63447. * Creates a new Color3 from integer values (< 256)
  63448. * @param r defines the red component to read from (value between 0 and 255)
  63449. * @param g defines the green component to read from (value between 0 and 255)
  63450. * @param b defines the blue component to read from (value between 0 and 255)
  63451. * @param a defines the alpha component to read from (value between 0 and 255)
  63452. * @returns a new Color3 object
  63453. */
  63454. static FromInts(r: number, g: number, b: number, a: number): Color4;
  63455. /**
  63456. * Check the content of a given array and convert it to an array containing RGBA data
  63457. * If the original array was already containing count * 4 values then it is returned directly
  63458. * @param colors defines the array to check
  63459. * @param count defines the number of RGBA data to expect
  63460. * @returns an array containing count * 4 values (RGBA)
  63461. */
  63462. static CheckColors4(colors: number[], count: number): number[];
  63463. }
  63464. /**
  63465. * Class representing a vector containing 2 coordinates
  63466. */
  63467. export class Vector2 {
  63468. /** defines the first coordinate */
  63469. x: number;
  63470. /** defines the second coordinate */
  63471. y: number;
  63472. /**
  63473. * Creates a new Vector2 from the given x and y coordinates
  63474. * @param x defines the first coordinate
  63475. * @param y defines the second coordinate
  63476. */
  63477. constructor(
  63478. /** defines the first coordinate */
  63479. x?: number,
  63480. /** defines the second coordinate */
  63481. y?: number);
  63482. /**
  63483. * Gets a string with the Vector2 coordinates
  63484. * @returns a string with the Vector2 coordinates
  63485. */
  63486. toString(): string;
  63487. /**
  63488. * Gets class name
  63489. * @returns the string "Vector2"
  63490. */
  63491. getClassName(): string;
  63492. /**
  63493. * Gets current vector hash code
  63494. * @returns the Vector2 hash code as a number
  63495. */
  63496. getHashCode(): number;
  63497. /**
  63498. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  63499. * @param array defines the source array
  63500. * @param index defines the offset in source array
  63501. * @returns the current Vector2
  63502. */
  63503. toArray(array: FloatArray, index?: number): Vector2;
  63504. /**
  63505. * Copy the current vector to an array
  63506. * @returns a new array with 2 elements: the Vector2 coordinates.
  63507. */
  63508. asArray(): number[];
  63509. /**
  63510. * Sets the Vector2 coordinates with the given Vector2 coordinates
  63511. * @param source defines the source Vector2
  63512. * @returns the current updated Vector2
  63513. */
  63514. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  63515. /**
  63516. * Sets the Vector2 coordinates with the given floats
  63517. * @param x defines the first coordinate
  63518. * @param y defines the second coordinate
  63519. * @returns the current updated Vector2
  63520. */
  63521. copyFromFloats(x: number, y: number): Vector2;
  63522. /**
  63523. * Sets the Vector2 coordinates with the given floats
  63524. * @param x defines the first coordinate
  63525. * @param y defines the second coordinate
  63526. * @returns the current updated Vector2
  63527. */
  63528. set(x: number, y: number): Vector2;
  63529. /**
  63530. * Add another vector with the current one
  63531. * @param otherVector defines the other vector
  63532. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  63533. */
  63534. add(otherVector: DeepImmutable<Vector2>): Vector2;
  63535. /**
  63536. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  63537. * @param otherVector defines the other vector
  63538. * @param result defines the target vector
  63539. * @returns the unmodified current Vector2
  63540. */
  63541. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  63542. /**
  63543. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  63544. * @param otherVector defines the other vector
  63545. * @returns the current updated Vector2
  63546. */
  63547. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  63548. /**
  63549. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  63550. * @param otherVector defines the other vector
  63551. * @returns a new Vector2
  63552. */
  63553. addVector3(otherVector: Vector3): Vector2;
  63554. /**
  63555. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  63556. * @param otherVector defines the other vector
  63557. * @returns a new Vector2
  63558. */
  63559. subtract(otherVector: Vector2): Vector2;
  63560. /**
  63561. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  63562. * @param otherVector defines the other vector
  63563. * @param result defines the target vector
  63564. * @returns the unmodified current Vector2
  63565. */
  63566. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  63567. /**
  63568. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  63569. * @param otherVector defines the other vector
  63570. * @returns the current updated Vector2
  63571. */
  63572. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  63573. /**
  63574. * Multiplies in place the current Vector2 coordinates by the given ones
  63575. * @param otherVector defines the other vector
  63576. * @returns the current updated Vector2
  63577. */
  63578. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  63579. /**
  63580. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  63581. * @param otherVector defines the other vector
  63582. * @returns a new Vector2
  63583. */
  63584. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  63585. /**
  63586. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  63587. * @param otherVector defines the other vector
  63588. * @param result defines the target vector
  63589. * @returns the unmodified current Vector2
  63590. */
  63591. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  63592. /**
  63593. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  63594. * @param x defines the first coordinate
  63595. * @param y defines the second coordinate
  63596. * @returns a new Vector2
  63597. */
  63598. multiplyByFloats(x: number, y: number): Vector2;
  63599. /**
  63600. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  63601. * @param otherVector defines the other vector
  63602. * @returns a new Vector2
  63603. */
  63604. divide(otherVector: Vector2): Vector2;
  63605. /**
  63606. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  63607. * @param otherVector defines the other vector
  63608. * @param result defines the target vector
  63609. * @returns the unmodified current Vector2
  63610. */
  63611. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  63612. /**
  63613. * Divides the current Vector2 coordinates by the given ones
  63614. * @param otherVector defines the other vector
  63615. * @returns the current updated Vector2
  63616. */
  63617. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  63618. /**
  63619. * Gets a new Vector2 with current Vector2 negated coordinates
  63620. * @returns a new Vector2
  63621. */
  63622. negate(): Vector2;
  63623. /**
  63624. * Multiply the Vector2 coordinates by scale
  63625. * @param scale defines the scaling factor
  63626. * @returns the current updated Vector2
  63627. */
  63628. scaleInPlace(scale: number): Vector2;
  63629. /**
  63630. * Returns a new Vector2 scaled by "scale" from the current Vector2
  63631. * @param scale defines the scaling factor
  63632. * @returns a new Vector2
  63633. */
  63634. scale(scale: number): Vector2;
  63635. /**
  63636. * Scale the current Vector2 values by a factor to a given Vector2
  63637. * @param scale defines the scale factor
  63638. * @param result defines the Vector2 object where to store the result
  63639. * @returns the unmodified current Vector2
  63640. */
  63641. scaleToRef(scale: number, result: Vector2): Vector2;
  63642. /**
  63643. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  63644. * @param scale defines the scale factor
  63645. * @param result defines the Vector2 object where to store the result
  63646. * @returns the unmodified current Vector2
  63647. */
  63648. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  63649. /**
  63650. * Gets a boolean if two vectors are equals
  63651. * @param otherVector defines the other vector
  63652. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  63653. */
  63654. equals(otherVector: DeepImmutable<Vector2>): boolean;
  63655. /**
  63656. * Gets a boolean if two vectors are equals (using an epsilon value)
  63657. * @param otherVector defines the other vector
  63658. * @param epsilon defines the minimal distance to consider equality
  63659. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  63660. */
  63661. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  63662. /**
  63663. * Gets a new Vector2 from current Vector2 floored values
  63664. * @returns a new Vector2
  63665. */
  63666. floor(): Vector2;
  63667. /**
  63668. * Gets a new Vector2 from current Vector2 floored values
  63669. * @returns a new Vector2
  63670. */
  63671. fract(): Vector2;
  63672. /**
  63673. * Gets the length of the vector
  63674. * @returns the vector length (float)
  63675. */
  63676. length(): number;
  63677. /**
  63678. * Gets the vector squared length
  63679. * @returns the vector squared length (float)
  63680. */
  63681. lengthSquared(): number;
  63682. /**
  63683. * Normalize the vector
  63684. * @returns the current updated Vector2
  63685. */
  63686. normalize(): Vector2;
  63687. /**
  63688. * Gets a new Vector2 copied from the Vector2
  63689. * @returns a new Vector2
  63690. */
  63691. clone(): Vector2;
  63692. /**
  63693. * Gets a new Vector2(0, 0)
  63694. * @returns a new Vector2
  63695. */
  63696. static Zero(): Vector2;
  63697. /**
  63698. * Gets a new Vector2(1, 1)
  63699. * @returns a new Vector2
  63700. */
  63701. static One(): Vector2;
  63702. /**
  63703. * Gets a new Vector2 set from the given index element of the given array
  63704. * @param array defines the data source
  63705. * @param offset defines the offset in the data source
  63706. * @returns a new Vector2
  63707. */
  63708. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  63709. /**
  63710. * Sets "result" from the given index element of the given array
  63711. * @param array defines the data source
  63712. * @param offset defines the offset in the data source
  63713. * @param result defines the target vector
  63714. */
  63715. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  63716. /**
  63717. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  63718. * @param value1 defines 1st point of control
  63719. * @param value2 defines 2nd point of control
  63720. * @param value3 defines 3rd point of control
  63721. * @param value4 defines 4th point of control
  63722. * @param amount defines the interpolation factor
  63723. * @returns a new Vector2
  63724. */
  63725. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  63726. /**
  63727. * 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".
  63728. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  63729. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  63730. * @param value defines the value to clamp
  63731. * @param min defines the lower limit
  63732. * @param max defines the upper limit
  63733. * @returns a new Vector2
  63734. */
  63735. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  63736. /**
  63737. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  63738. * @param value1 defines the 1st control point
  63739. * @param tangent1 defines the outgoing tangent
  63740. * @param value2 defines the 2nd control point
  63741. * @param tangent2 defines the incoming tangent
  63742. * @param amount defines the interpolation factor
  63743. * @returns a new Vector2
  63744. */
  63745. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  63746. /**
  63747. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  63748. * @param start defines the start vector
  63749. * @param end defines the end vector
  63750. * @param amount defines the interpolation factor
  63751. * @returns a new Vector2
  63752. */
  63753. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  63754. /**
  63755. * Gets the dot product of the vector "left" and the vector "right"
  63756. * @param left defines first vector
  63757. * @param right defines second vector
  63758. * @returns the dot product (float)
  63759. */
  63760. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  63761. /**
  63762. * Returns a new Vector2 equal to the normalized given vector
  63763. * @param vector defines the vector to normalize
  63764. * @returns a new Vector2
  63765. */
  63766. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  63767. /**
  63768. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  63769. * @param left defines 1st vector
  63770. * @param right defines 2nd vector
  63771. * @returns a new Vector2
  63772. */
  63773. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  63774. /**
  63775. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  63776. * @param left defines 1st vector
  63777. * @param right defines 2nd vector
  63778. * @returns a new Vector2
  63779. */
  63780. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  63781. /**
  63782. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  63783. * @param vector defines the vector to transform
  63784. * @param transformation defines the matrix to apply
  63785. * @returns a new Vector2
  63786. */
  63787. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  63788. /**
  63789. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  63790. * @param vector defines the vector to transform
  63791. * @param transformation defines the matrix to apply
  63792. * @param result defines the target vector
  63793. */
  63794. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  63795. /**
  63796. * Determines if a given vector is included in a triangle
  63797. * @param p defines the vector to test
  63798. * @param p0 defines 1st triangle point
  63799. * @param p1 defines 2nd triangle point
  63800. * @param p2 defines 3rd triangle point
  63801. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  63802. */
  63803. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  63804. /**
  63805. * Gets the distance between the vectors "value1" and "value2"
  63806. * @param value1 defines first vector
  63807. * @param value2 defines second vector
  63808. * @returns the distance between vectors
  63809. */
  63810. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  63811. /**
  63812. * Returns the squared distance between the vectors "value1" and "value2"
  63813. * @param value1 defines first vector
  63814. * @param value2 defines second vector
  63815. * @returns the squared distance between vectors
  63816. */
  63817. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  63818. /**
  63819. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  63820. * @param value1 defines first vector
  63821. * @param value2 defines second vector
  63822. * @returns a new Vector2
  63823. */
  63824. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  63825. /**
  63826. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  63827. * @param p defines the middle point
  63828. * @param segA defines one point of the segment
  63829. * @param segB defines the other point of the segment
  63830. * @returns the shortest distance
  63831. */
  63832. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  63833. }
  63834. /**
  63835. * Classed used to store (x,y,z) vector representation
  63836. * A Vector3 is the main object used in 3D geometry
  63837. * It can represent etiher the coordinates of a point the space, either a direction
  63838. * Reminder: js uses a left handed forward facing system
  63839. */
  63840. export class Vector3 {
  63841. /**
  63842. * Defines the first coordinates (on X axis)
  63843. */
  63844. x: number;
  63845. /**
  63846. * Defines the second coordinates (on Y axis)
  63847. */
  63848. y: number;
  63849. /**
  63850. * Defines the third coordinates (on Z axis)
  63851. */
  63852. z: number;
  63853. private static _UpReadOnly;
  63854. private static _ZeroReadOnly;
  63855. /**
  63856. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  63857. * @param x defines the first coordinates (on X axis)
  63858. * @param y defines the second coordinates (on Y axis)
  63859. * @param z defines the third coordinates (on Z axis)
  63860. */
  63861. constructor(
  63862. /**
  63863. * Defines the first coordinates (on X axis)
  63864. */
  63865. x?: number,
  63866. /**
  63867. * Defines the second coordinates (on Y axis)
  63868. */
  63869. y?: number,
  63870. /**
  63871. * Defines the third coordinates (on Z axis)
  63872. */
  63873. z?: number);
  63874. /**
  63875. * Creates a string representation of the Vector3
  63876. * @returns a string with the Vector3 coordinates.
  63877. */
  63878. toString(): string;
  63879. /**
  63880. * Gets the class name
  63881. * @returns the string "Vector3"
  63882. */
  63883. getClassName(): string;
  63884. /**
  63885. * Creates the Vector3 hash code
  63886. * @returns a number which tends to be unique between Vector3 instances
  63887. */
  63888. getHashCode(): number;
  63889. /**
  63890. * Creates an array containing three elements : the coordinates of the Vector3
  63891. * @returns a new array of numbers
  63892. */
  63893. asArray(): number[];
  63894. /**
  63895. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  63896. * @param array defines the destination array
  63897. * @param index defines the offset in the destination array
  63898. * @returns the current Vector3
  63899. */
  63900. toArray(array: FloatArray, index?: number): Vector3;
  63901. /**
  63902. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  63903. * @returns a new Quaternion object, computed from the Vector3 coordinates
  63904. */
  63905. toQuaternion(): Quaternion;
  63906. /**
  63907. * Adds the given vector to the current Vector3
  63908. * @param otherVector defines the second operand
  63909. * @returns the current updated Vector3
  63910. */
  63911. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  63912. /**
  63913. * Adds the given coordinates to the current Vector3
  63914. * @param x defines the x coordinate of the operand
  63915. * @param y defines the y coordinate of the operand
  63916. * @param z defines the z coordinate of the operand
  63917. * @returns the current updated Vector3
  63918. */
  63919. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  63920. /**
  63921. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  63922. * @param otherVector defines the second operand
  63923. * @returns the resulting Vector3
  63924. */
  63925. add(otherVector: DeepImmutable<Vector3>): Vector3;
  63926. /**
  63927. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  63928. * @param otherVector defines the second operand
  63929. * @param result defines the Vector3 object where to store the result
  63930. * @returns the current Vector3
  63931. */
  63932. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  63933. /**
  63934. * Subtract the given vector from the current Vector3
  63935. * @param otherVector defines the second operand
  63936. * @returns the current updated Vector3
  63937. */
  63938. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  63939. /**
  63940. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  63941. * @param otherVector defines the second operand
  63942. * @returns the resulting Vector3
  63943. */
  63944. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  63945. /**
  63946. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  63947. * @param otherVector defines the second operand
  63948. * @param result defines the Vector3 object where to store the result
  63949. * @returns the current Vector3
  63950. */
  63951. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  63952. /**
  63953. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  63954. * @param x defines the x coordinate of the operand
  63955. * @param y defines the y coordinate of the operand
  63956. * @param z defines the z coordinate of the operand
  63957. * @returns the resulting Vector3
  63958. */
  63959. subtractFromFloats(x: number, y: number, z: number): Vector3;
  63960. /**
  63961. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  63962. * @param x defines the x coordinate of the operand
  63963. * @param y defines the y coordinate of the operand
  63964. * @param z defines the z coordinate of the operand
  63965. * @param result defines the Vector3 object where to store the result
  63966. * @returns the current Vector3
  63967. */
  63968. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  63969. /**
  63970. * Gets a new Vector3 set with the current Vector3 negated coordinates
  63971. * @returns a new Vector3
  63972. */
  63973. negate(): Vector3;
  63974. /**
  63975. * Multiplies the Vector3 coordinates by the float "scale"
  63976. * @param scale defines the multiplier factor
  63977. * @returns the current updated Vector3
  63978. */
  63979. scaleInPlace(scale: number): Vector3;
  63980. /**
  63981. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  63982. * @param scale defines the multiplier factor
  63983. * @returns a new Vector3
  63984. */
  63985. scale(scale: number): Vector3;
  63986. /**
  63987. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  63988. * @param scale defines the multiplier factor
  63989. * @param result defines the Vector3 object where to store the result
  63990. * @returns the current Vector3
  63991. */
  63992. scaleToRef(scale: number, result: Vector3): Vector3;
  63993. /**
  63994. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  63995. * @param scale defines the scale factor
  63996. * @param result defines the Vector3 object where to store the result
  63997. * @returns the unmodified current Vector3
  63998. */
  63999. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  64000. /**
  64001. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  64002. * @param otherVector defines the second operand
  64003. * @returns true if both vectors are equals
  64004. */
  64005. equals(otherVector: DeepImmutable<Vector3>): boolean;
  64006. /**
  64007. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  64008. * @param otherVector defines the second operand
  64009. * @param epsilon defines the minimal distance to define values as equals
  64010. * @returns true if both vectors are distant less than epsilon
  64011. */
  64012. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  64013. /**
  64014. * Returns true if the current Vector3 coordinates equals the given floats
  64015. * @param x defines the x coordinate of the operand
  64016. * @param y defines the y coordinate of the operand
  64017. * @param z defines the z coordinate of the operand
  64018. * @returns true if both vectors are equals
  64019. */
  64020. equalsToFloats(x: number, y: number, z: number): boolean;
  64021. /**
  64022. * Multiplies the current Vector3 coordinates by the given ones
  64023. * @param otherVector defines the second operand
  64024. * @returns the current updated Vector3
  64025. */
  64026. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  64027. /**
  64028. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  64029. * @param otherVector defines the second operand
  64030. * @returns the new Vector3
  64031. */
  64032. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  64033. /**
  64034. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  64035. * @param otherVector defines the second operand
  64036. * @param result defines the Vector3 object where to store the result
  64037. * @returns the current Vector3
  64038. */
  64039. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  64040. /**
  64041. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  64042. * @param x defines the x coordinate of the operand
  64043. * @param y defines the y coordinate of the operand
  64044. * @param z defines the z coordinate of the operand
  64045. * @returns the new Vector3
  64046. */
  64047. multiplyByFloats(x: number, y: number, z: number): Vector3;
  64048. /**
  64049. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  64050. * @param otherVector defines the second operand
  64051. * @returns the new Vector3
  64052. */
  64053. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  64054. /**
  64055. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  64056. * @param otherVector defines the second operand
  64057. * @param result defines the Vector3 object where to store the result
  64058. * @returns the current Vector3
  64059. */
  64060. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  64061. /**
  64062. * Divides the current Vector3 coordinates by the given ones.
  64063. * @param otherVector defines the second operand
  64064. * @returns the current updated Vector3
  64065. */
  64066. divideInPlace(otherVector: Vector3): Vector3;
  64067. /**
  64068. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  64069. * @param other defines the second operand
  64070. * @returns the current updated Vector3
  64071. */
  64072. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  64073. /**
  64074. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  64075. * @param other defines the second operand
  64076. * @returns the current updated Vector3
  64077. */
  64078. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  64079. /**
  64080. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  64081. * @param x defines the x coordinate of the operand
  64082. * @param y defines the y coordinate of the operand
  64083. * @param z defines the z coordinate of the operand
  64084. * @returns the current updated Vector3
  64085. */
  64086. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  64087. /**
  64088. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  64089. * @param x defines the x coordinate of the operand
  64090. * @param y defines the y coordinate of the operand
  64091. * @param z defines the z coordinate of the operand
  64092. * @returns the current updated Vector3
  64093. */
  64094. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  64095. /**
  64096. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  64097. * Check if is non uniform within a certain amount of decimal places to account for this
  64098. * @param epsilon the amount the values can differ
  64099. * @returns if the the vector is non uniform to a certain number of decimal places
  64100. */
  64101. isNonUniformWithinEpsilon(epsilon: number): boolean;
  64102. /**
  64103. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  64104. */
  64105. readonly isNonUniform: boolean;
  64106. /**
  64107. * Gets a new Vector3 from current Vector3 floored values
  64108. * @returns a new Vector3
  64109. */
  64110. floor(): Vector3;
  64111. /**
  64112. * Gets a new Vector3 from current Vector3 floored values
  64113. * @returns a new Vector3
  64114. */
  64115. fract(): Vector3;
  64116. /**
  64117. * Gets the length of the Vector3
  64118. * @returns the length of the Vector3
  64119. */
  64120. length(): number;
  64121. /**
  64122. * Gets the squared length of the Vector3
  64123. * @returns squared length of the Vector3
  64124. */
  64125. lengthSquared(): number;
  64126. /**
  64127. * Normalize the current Vector3.
  64128. * Please note that this is an in place operation.
  64129. * @returns the current updated Vector3
  64130. */
  64131. normalize(): Vector3;
  64132. /**
  64133. * Reorders the x y z properties of the vector in place
  64134. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  64135. * @returns the current updated vector
  64136. */
  64137. reorderInPlace(order: string): this;
  64138. /**
  64139. * Rotates the vector around 0,0,0 by a quaternion
  64140. * @param quaternion the rotation quaternion
  64141. * @param result vector to store the result
  64142. * @returns the resulting vector
  64143. */
  64144. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  64145. /**
  64146. * Rotates a vector around a given point
  64147. * @param quaternion the rotation quaternion
  64148. * @param point the point to rotate around
  64149. * @param result vector to store the result
  64150. * @returns the resulting vector
  64151. */
  64152. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  64153. /**
  64154. * Normalize the current Vector3 with the given input length.
  64155. * Please note that this is an in place operation.
  64156. * @param len the length of the vector
  64157. * @returns the current updated Vector3
  64158. */
  64159. normalizeFromLength(len: number): Vector3;
  64160. /**
  64161. * Normalize the current Vector3 to a new vector
  64162. * @returns the new Vector3
  64163. */
  64164. normalizeToNew(): Vector3;
  64165. /**
  64166. * Normalize the current Vector3 to the reference
  64167. * @param reference define the Vector3 to update
  64168. * @returns the updated Vector3
  64169. */
  64170. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  64171. /**
  64172. * Creates a new Vector3 copied from the current Vector3
  64173. * @returns the new Vector3
  64174. */
  64175. clone(): Vector3;
  64176. /**
  64177. * Copies the given vector coordinates to the current Vector3 ones
  64178. * @param source defines the source Vector3
  64179. * @returns the current updated Vector3
  64180. */
  64181. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  64182. /**
  64183. * Copies the given floats to the current Vector3 coordinates
  64184. * @param x defines the x coordinate of the operand
  64185. * @param y defines the y coordinate of the operand
  64186. * @param z defines the z coordinate of the operand
  64187. * @returns the current updated Vector3
  64188. */
  64189. copyFromFloats(x: number, y: number, z: number): Vector3;
  64190. /**
  64191. * Copies the given floats to the current Vector3 coordinates
  64192. * @param x defines the x coordinate of the operand
  64193. * @param y defines the y coordinate of the operand
  64194. * @param z defines the z coordinate of the operand
  64195. * @returns the current updated Vector3
  64196. */
  64197. set(x: number, y: number, z: number): Vector3;
  64198. /**
  64199. * Copies the given float to the current Vector3 coordinates
  64200. * @param v defines the x, y and z coordinates of the operand
  64201. * @returns the current updated Vector3
  64202. */
  64203. setAll(v: number): Vector3;
  64204. /**
  64205. * Get the clip factor between two vectors
  64206. * @param vector0 defines the first operand
  64207. * @param vector1 defines the second operand
  64208. * @param axis defines the axis to use
  64209. * @param size defines the size along the axis
  64210. * @returns the clip factor
  64211. */
  64212. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  64213. /**
  64214. * Get angle between two vectors
  64215. * @param vector0 angle between vector0 and vector1
  64216. * @param vector1 angle between vector0 and vector1
  64217. * @param normal direction of the normal
  64218. * @return the angle between vector0 and vector1
  64219. */
  64220. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  64221. /**
  64222. * Returns a new Vector3 set from the index "offset" of the given array
  64223. * @param array defines the source array
  64224. * @param offset defines the offset in the source array
  64225. * @returns the new Vector3
  64226. */
  64227. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  64228. /**
  64229. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  64230. * This function is deprecated. Use FromArray instead
  64231. * @param array defines the source array
  64232. * @param offset defines the offset in the source array
  64233. * @returns the new Vector3
  64234. */
  64235. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  64236. /**
  64237. * Sets the given vector "result" with the element values from the index "offset" of the given array
  64238. * @param array defines the source array
  64239. * @param offset defines the offset in the source array
  64240. * @param result defines the Vector3 where to store the result
  64241. */
  64242. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  64243. /**
  64244. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  64245. * This function is deprecated. Use FromArrayToRef instead.
  64246. * @param array defines the source array
  64247. * @param offset defines the offset in the source array
  64248. * @param result defines the Vector3 where to store the result
  64249. */
  64250. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  64251. /**
  64252. * Sets the given vector "result" with the given floats.
  64253. * @param x defines the x coordinate of the source
  64254. * @param y defines the y coordinate of the source
  64255. * @param z defines the z coordinate of the source
  64256. * @param result defines the Vector3 where to store the result
  64257. */
  64258. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  64259. /**
  64260. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  64261. * @returns a new empty Vector3
  64262. */
  64263. static Zero(): Vector3;
  64264. /**
  64265. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  64266. * @returns a new unit Vector3
  64267. */
  64268. static One(): Vector3;
  64269. /**
  64270. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  64271. * @returns a new up Vector3
  64272. */
  64273. static Up(): Vector3;
  64274. /**
  64275. * Gets a up Vector3 that must not be updated
  64276. */
  64277. static readonly UpReadOnly: DeepImmutable<Vector3>;
  64278. /**
  64279. * Gets a zero Vector3 that must not be updated
  64280. */
  64281. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  64282. /**
  64283. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  64284. * @returns a new down Vector3
  64285. */
  64286. static Down(): Vector3;
  64287. /**
  64288. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  64289. * @returns a new forward Vector3
  64290. */
  64291. static Forward(): Vector3;
  64292. /**
  64293. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  64294. * @returns a new forward Vector3
  64295. */
  64296. static Backward(): Vector3;
  64297. /**
  64298. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  64299. * @returns a new right Vector3
  64300. */
  64301. static Right(): Vector3;
  64302. /**
  64303. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  64304. * @returns a new left Vector3
  64305. */
  64306. static Left(): Vector3;
  64307. /**
  64308. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  64309. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  64310. * @param vector defines the Vector3 to transform
  64311. * @param transformation defines the transformation matrix
  64312. * @returns the transformed Vector3
  64313. */
  64314. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  64315. /**
  64316. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  64317. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  64318. * @param vector defines the Vector3 to transform
  64319. * @param transformation defines the transformation matrix
  64320. * @param result defines the Vector3 where to store the result
  64321. */
  64322. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  64323. /**
  64324. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  64325. * This method computes tranformed coordinates only, not transformed direction vectors
  64326. * @param x define the x coordinate of the source vector
  64327. * @param y define the y coordinate of the source vector
  64328. * @param z define the z coordinate of the source vector
  64329. * @param transformation defines the transformation matrix
  64330. * @param result defines the Vector3 where to store the result
  64331. */
  64332. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  64333. /**
  64334. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  64335. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  64336. * @param vector defines the Vector3 to transform
  64337. * @param transformation defines the transformation matrix
  64338. * @returns the new Vector3
  64339. */
  64340. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  64341. /**
  64342. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  64343. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  64344. * @param vector defines the Vector3 to transform
  64345. * @param transformation defines the transformation matrix
  64346. * @param result defines the Vector3 where to store the result
  64347. */
  64348. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  64349. /**
  64350. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  64351. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  64352. * @param x define the x coordinate of the source vector
  64353. * @param y define the y coordinate of the source vector
  64354. * @param z define the z coordinate of the source vector
  64355. * @param transformation defines the transformation matrix
  64356. * @param result defines the Vector3 where to store the result
  64357. */
  64358. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  64359. /**
  64360. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  64361. * @param value1 defines the first control point
  64362. * @param value2 defines the second control point
  64363. * @param value3 defines the third control point
  64364. * @param value4 defines the fourth control point
  64365. * @param amount defines the amount on the spline to use
  64366. * @returns the new Vector3
  64367. */
  64368. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  64369. /**
  64370. * 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"
  64371. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  64372. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  64373. * @param value defines the current value
  64374. * @param min defines the lower range value
  64375. * @param max defines the upper range value
  64376. * @returns the new Vector3
  64377. */
  64378. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  64379. /**
  64380. * 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"
  64381. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  64382. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  64383. * @param value defines the current value
  64384. * @param min defines the lower range value
  64385. * @param max defines the upper range value
  64386. * @param result defines the Vector3 where to store the result
  64387. */
  64388. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  64389. /**
  64390. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  64391. * @param value1 defines the first control point
  64392. * @param tangent1 defines the first tangent vector
  64393. * @param value2 defines the second control point
  64394. * @param tangent2 defines the second tangent vector
  64395. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  64396. * @returns the new Vector3
  64397. */
  64398. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  64399. /**
  64400. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  64401. * @param start defines the start value
  64402. * @param end defines the end value
  64403. * @param amount max defines amount between both (between 0 and 1)
  64404. * @returns the new Vector3
  64405. */
  64406. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  64407. /**
  64408. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  64409. * @param start defines the start value
  64410. * @param end defines the end value
  64411. * @param amount max defines amount between both (between 0 and 1)
  64412. * @param result defines the Vector3 where to store the result
  64413. */
  64414. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  64415. /**
  64416. * Returns the dot product (float) between the vectors "left" and "right"
  64417. * @param left defines the left operand
  64418. * @param right defines the right operand
  64419. * @returns the dot product
  64420. */
  64421. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  64422. /**
  64423. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  64424. * The cross product is then orthogonal to both "left" and "right"
  64425. * @param left defines the left operand
  64426. * @param right defines the right operand
  64427. * @returns the cross product
  64428. */
  64429. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  64430. /**
  64431. * Sets the given vector "result" with the cross product of "left" and "right"
  64432. * The cross product is then orthogonal to both "left" and "right"
  64433. * @param left defines the left operand
  64434. * @param right defines the right operand
  64435. * @param result defines the Vector3 where to store the result
  64436. */
  64437. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  64438. /**
  64439. * Returns a new Vector3 as the normalization of the given vector
  64440. * @param vector defines the Vector3 to normalize
  64441. * @returns the new Vector3
  64442. */
  64443. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  64444. /**
  64445. * Sets the given vector "result" with the normalization of the given first vector
  64446. * @param vector defines the Vector3 to normalize
  64447. * @param result defines the Vector3 where to store the result
  64448. */
  64449. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  64450. /**
  64451. * Project a Vector3 onto screen space
  64452. * @param vector defines the Vector3 to project
  64453. * @param world defines the world matrix to use
  64454. * @param transform defines the transform (view x projection) matrix to use
  64455. * @param viewport defines the screen viewport to use
  64456. * @returns the new Vector3
  64457. */
  64458. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  64459. /** @hidden */
  64460. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  64461. /**
  64462. * Unproject from screen space to object space
  64463. * @param source defines the screen space Vector3 to use
  64464. * @param viewportWidth defines the current width of the viewport
  64465. * @param viewportHeight defines the current height of the viewport
  64466. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  64467. * @param transform defines the transform (view x projection) matrix to use
  64468. * @returns the new Vector3
  64469. */
  64470. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  64471. /**
  64472. * Unproject from screen space to object space
  64473. * @param source defines the screen space Vector3 to use
  64474. * @param viewportWidth defines the current width of the viewport
  64475. * @param viewportHeight defines the current height of the viewport
  64476. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  64477. * @param view defines the view matrix to use
  64478. * @param projection defines the projection matrix to use
  64479. * @returns the new Vector3
  64480. */
  64481. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  64482. /**
  64483. * Unproject from screen space to object space
  64484. * @param source defines the screen space Vector3 to use
  64485. * @param viewportWidth defines the current width of the viewport
  64486. * @param viewportHeight defines the current height of the viewport
  64487. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  64488. * @param view defines the view matrix to use
  64489. * @param projection defines the projection matrix to use
  64490. * @param result defines the Vector3 where to store the result
  64491. */
  64492. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  64493. /**
  64494. * Unproject from screen space to object space
  64495. * @param sourceX defines the screen space x coordinate to use
  64496. * @param sourceY defines the screen space y coordinate to use
  64497. * @param sourceZ defines the screen space z coordinate to use
  64498. * @param viewportWidth defines the current width of the viewport
  64499. * @param viewportHeight defines the current height of the viewport
  64500. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  64501. * @param view defines the view matrix to use
  64502. * @param projection defines the projection matrix to use
  64503. * @param result defines the Vector3 where to store the result
  64504. */
  64505. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  64506. /**
  64507. * Gets the minimal coordinate values between two Vector3
  64508. * @param left defines the first operand
  64509. * @param right defines the second operand
  64510. * @returns the new Vector3
  64511. */
  64512. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  64513. /**
  64514. * Gets the maximal coordinate values between two Vector3
  64515. * @param left defines the first operand
  64516. * @param right defines the second operand
  64517. * @returns the new Vector3
  64518. */
  64519. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  64520. /**
  64521. * Returns the distance between the vectors "value1" and "value2"
  64522. * @param value1 defines the first operand
  64523. * @param value2 defines the second operand
  64524. * @returns the distance
  64525. */
  64526. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  64527. /**
  64528. * Returns the squared distance between the vectors "value1" and "value2"
  64529. * @param value1 defines the first operand
  64530. * @param value2 defines the second operand
  64531. * @returns the squared distance
  64532. */
  64533. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  64534. /**
  64535. * Returns a new Vector3 located at the center between "value1" and "value2"
  64536. * @param value1 defines the first operand
  64537. * @param value2 defines the second operand
  64538. * @returns the new Vector3
  64539. */
  64540. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  64541. /**
  64542. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  64543. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  64544. * to something in order to rotate it from its local system to the given target system
  64545. * Note: axis1, axis2 and axis3 are normalized during this operation
  64546. * @param axis1 defines the first axis
  64547. * @param axis2 defines the second axis
  64548. * @param axis3 defines the third axis
  64549. * @returns a new Vector3
  64550. */
  64551. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  64552. /**
  64553. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  64554. * @param axis1 defines the first axis
  64555. * @param axis2 defines the second axis
  64556. * @param axis3 defines the third axis
  64557. * @param ref defines the Vector3 where to store the result
  64558. */
  64559. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  64560. }
  64561. /**
  64562. * Vector4 class created for EulerAngle class conversion to Quaternion
  64563. */
  64564. export class Vector4 {
  64565. /** x value of the vector */
  64566. x: number;
  64567. /** y value of the vector */
  64568. y: number;
  64569. /** z value of the vector */
  64570. z: number;
  64571. /** w value of the vector */
  64572. w: number;
  64573. /**
  64574. * Creates a Vector4 object from the given floats.
  64575. * @param x x value of the vector
  64576. * @param y y value of the vector
  64577. * @param z z value of the vector
  64578. * @param w w value of the vector
  64579. */
  64580. constructor(
  64581. /** x value of the vector */
  64582. x: number,
  64583. /** y value of the vector */
  64584. y: number,
  64585. /** z value of the vector */
  64586. z: number,
  64587. /** w value of the vector */
  64588. w: number);
  64589. /**
  64590. * Returns the string with the Vector4 coordinates.
  64591. * @returns a string containing all the vector values
  64592. */
  64593. toString(): string;
  64594. /**
  64595. * Returns the string "Vector4".
  64596. * @returns "Vector4"
  64597. */
  64598. getClassName(): string;
  64599. /**
  64600. * Returns the Vector4 hash code.
  64601. * @returns a unique hash code
  64602. */
  64603. getHashCode(): number;
  64604. /**
  64605. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  64606. * @returns the resulting array
  64607. */
  64608. asArray(): number[];
  64609. /**
  64610. * Populates the given array from the given index with the Vector4 coordinates.
  64611. * @param array array to populate
  64612. * @param index index of the array to start at (default: 0)
  64613. * @returns the Vector4.
  64614. */
  64615. toArray(array: FloatArray, index?: number): Vector4;
  64616. /**
  64617. * Adds the given vector to the current Vector4.
  64618. * @param otherVector the vector to add
  64619. * @returns the updated Vector4.
  64620. */
  64621. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  64622. /**
  64623. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  64624. * @param otherVector the vector to add
  64625. * @returns the resulting vector
  64626. */
  64627. add(otherVector: DeepImmutable<Vector4>): Vector4;
  64628. /**
  64629. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  64630. * @param otherVector the vector to add
  64631. * @param result the vector to store the result
  64632. * @returns the current Vector4.
  64633. */
  64634. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  64635. /**
  64636. * Subtract in place the given vector from the current Vector4.
  64637. * @param otherVector the vector to subtract
  64638. * @returns the updated Vector4.
  64639. */
  64640. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  64641. /**
  64642. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  64643. * @param otherVector the vector to add
  64644. * @returns the new vector with the result
  64645. */
  64646. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  64647. /**
  64648. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  64649. * @param otherVector the vector to subtract
  64650. * @param result the vector to store the result
  64651. * @returns the current Vector4.
  64652. */
  64653. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  64654. /**
  64655. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  64656. */
  64657. /**
  64658. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  64659. * @param x value to subtract
  64660. * @param y value to subtract
  64661. * @param z value to subtract
  64662. * @param w value to subtract
  64663. * @returns new vector containing the result
  64664. */
  64665. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  64666. /**
  64667. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  64668. * @param x value to subtract
  64669. * @param y value to subtract
  64670. * @param z value to subtract
  64671. * @param w value to subtract
  64672. * @param result the vector to store the result in
  64673. * @returns the current Vector4.
  64674. */
  64675. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  64676. /**
  64677. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  64678. * @returns a new vector with the negated values
  64679. */
  64680. negate(): Vector4;
  64681. /**
  64682. * Multiplies the current Vector4 coordinates by scale (float).
  64683. * @param scale the number to scale with
  64684. * @returns the updated Vector4.
  64685. */
  64686. scaleInPlace(scale: number): Vector4;
  64687. /**
  64688. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  64689. * @param scale the number to scale with
  64690. * @returns a new vector with the result
  64691. */
  64692. scale(scale: number): Vector4;
  64693. /**
  64694. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  64695. * @param scale the number to scale with
  64696. * @param result a vector to store the result in
  64697. * @returns the current Vector4.
  64698. */
  64699. scaleToRef(scale: number, result: Vector4): Vector4;
  64700. /**
  64701. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  64702. * @param scale defines the scale factor
  64703. * @param result defines the Vector4 object where to store the result
  64704. * @returns the unmodified current Vector4
  64705. */
  64706. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  64707. /**
  64708. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  64709. * @param otherVector the vector to compare against
  64710. * @returns true if they are equal
  64711. */
  64712. equals(otherVector: DeepImmutable<Vector4>): boolean;
  64713. /**
  64714. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  64715. * @param otherVector vector to compare against
  64716. * @param epsilon (Default: very small number)
  64717. * @returns true if they are equal
  64718. */
  64719. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  64720. /**
  64721. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  64722. * @param x x value to compare against
  64723. * @param y y value to compare against
  64724. * @param z z value to compare against
  64725. * @param w w value to compare against
  64726. * @returns true if equal
  64727. */
  64728. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  64729. /**
  64730. * Multiplies in place the current Vector4 by the given one.
  64731. * @param otherVector vector to multiple with
  64732. * @returns the updated Vector4.
  64733. */
  64734. multiplyInPlace(otherVector: Vector4): Vector4;
  64735. /**
  64736. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  64737. * @param otherVector vector to multiple with
  64738. * @returns resulting new vector
  64739. */
  64740. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  64741. /**
  64742. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  64743. * @param otherVector vector to multiple with
  64744. * @param result vector to store the result
  64745. * @returns the current Vector4.
  64746. */
  64747. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  64748. /**
  64749. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  64750. * @param x x value multiply with
  64751. * @param y y value multiply with
  64752. * @param z z value multiply with
  64753. * @param w w value multiply with
  64754. * @returns resulting new vector
  64755. */
  64756. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  64757. /**
  64758. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  64759. * @param otherVector vector to devide with
  64760. * @returns resulting new vector
  64761. */
  64762. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  64763. /**
  64764. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  64765. * @param otherVector vector to devide with
  64766. * @param result vector to store the result
  64767. * @returns the current Vector4.
  64768. */
  64769. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  64770. /**
  64771. * Divides the current Vector3 coordinates by the given ones.
  64772. * @param otherVector vector to devide with
  64773. * @returns the updated Vector3.
  64774. */
  64775. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  64776. /**
  64777. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  64778. * @param other defines the second operand
  64779. * @returns the current updated Vector4
  64780. */
  64781. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  64782. /**
  64783. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  64784. * @param other defines the second operand
  64785. * @returns the current updated Vector4
  64786. */
  64787. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  64788. /**
  64789. * Gets a new Vector4 from current Vector4 floored values
  64790. * @returns a new Vector4
  64791. */
  64792. floor(): Vector4;
  64793. /**
  64794. * Gets a new Vector4 from current Vector3 floored values
  64795. * @returns a new Vector4
  64796. */
  64797. fract(): Vector4;
  64798. /**
  64799. * Returns the Vector4 length (float).
  64800. * @returns the length
  64801. */
  64802. length(): number;
  64803. /**
  64804. * Returns the Vector4 squared length (float).
  64805. * @returns the length squared
  64806. */
  64807. lengthSquared(): number;
  64808. /**
  64809. * Normalizes in place the Vector4.
  64810. * @returns the updated Vector4.
  64811. */
  64812. normalize(): Vector4;
  64813. /**
  64814. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  64815. * @returns this converted to a new vector3
  64816. */
  64817. toVector3(): Vector3;
  64818. /**
  64819. * Returns a new Vector4 copied from the current one.
  64820. * @returns the new cloned vector
  64821. */
  64822. clone(): Vector4;
  64823. /**
  64824. * Updates the current Vector4 with the given one coordinates.
  64825. * @param source the source vector to copy from
  64826. * @returns the updated Vector4.
  64827. */
  64828. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  64829. /**
  64830. * Updates the current Vector4 coordinates with the given floats.
  64831. * @param x float to copy from
  64832. * @param y float to copy from
  64833. * @param z float to copy from
  64834. * @param w float to copy from
  64835. * @returns the updated Vector4.
  64836. */
  64837. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  64838. /**
  64839. * Updates the current Vector4 coordinates with the given floats.
  64840. * @param x float to set from
  64841. * @param y float to set from
  64842. * @param z float to set from
  64843. * @param w float to set from
  64844. * @returns the updated Vector4.
  64845. */
  64846. set(x: number, y: number, z: number, w: number): Vector4;
  64847. /**
  64848. * Copies the given float to the current Vector3 coordinates
  64849. * @param v defines the x, y, z and w coordinates of the operand
  64850. * @returns the current updated Vector3
  64851. */
  64852. setAll(v: number): Vector4;
  64853. /**
  64854. * Returns a new Vector4 set from the starting index of the given array.
  64855. * @param array the array to pull values from
  64856. * @param offset the offset into the array to start at
  64857. * @returns the new vector
  64858. */
  64859. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  64860. /**
  64861. * Updates the given vector "result" from the starting index of the given array.
  64862. * @param array the array to pull values from
  64863. * @param offset the offset into the array to start at
  64864. * @param result the vector to store the result in
  64865. */
  64866. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  64867. /**
  64868. * Updates the given vector "result" from the starting index of the given Float32Array.
  64869. * @param array the array to pull values from
  64870. * @param offset the offset into the array to start at
  64871. * @param result the vector to store the result in
  64872. */
  64873. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  64874. /**
  64875. * Updates the given vector "result" coordinates from the given floats.
  64876. * @param x float to set from
  64877. * @param y float to set from
  64878. * @param z float to set from
  64879. * @param w float to set from
  64880. * @param result the vector to the floats in
  64881. */
  64882. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  64883. /**
  64884. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  64885. * @returns the new vector
  64886. */
  64887. static Zero(): Vector4;
  64888. /**
  64889. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  64890. * @returns the new vector
  64891. */
  64892. static One(): Vector4;
  64893. /**
  64894. * Returns a new normalized Vector4 from the given one.
  64895. * @param vector the vector to normalize
  64896. * @returns the vector
  64897. */
  64898. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  64899. /**
  64900. * Updates the given vector "result" from the normalization of the given one.
  64901. * @param vector the vector to normalize
  64902. * @param result the vector to store the result in
  64903. */
  64904. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  64905. /**
  64906. * Returns a vector with the minimum values from the left and right vectors
  64907. * @param left left vector to minimize
  64908. * @param right right vector to minimize
  64909. * @returns a new vector with the minimum of the left and right vector values
  64910. */
  64911. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  64912. /**
  64913. * Returns a vector with the maximum values from the left and right vectors
  64914. * @param left left vector to maximize
  64915. * @param right right vector to maximize
  64916. * @returns a new vector with the maximum of the left and right vector values
  64917. */
  64918. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  64919. /**
  64920. * Returns the distance (float) between the vectors "value1" and "value2".
  64921. * @param value1 value to calulate the distance between
  64922. * @param value2 value to calulate the distance between
  64923. * @return the distance between the two vectors
  64924. */
  64925. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  64926. /**
  64927. * Returns the squared distance (float) between the vectors "value1" and "value2".
  64928. * @param value1 value to calulate the distance between
  64929. * @param value2 value to calulate the distance between
  64930. * @return the distance between the two vectors squared
  64931. */
  64932. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  64933. /**
  64934. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  64935. * @param value1 value to calulate the center between
  64936. * @param value2 value to calulate the center between
  64937. * @return the center between the two vectors
  64938. */
  64939. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  64940. /**
  64941. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  64942. * This methods computes transformed normalized direction vectors only.
  64943. * @param vector the vector to transform
  64944. * @param transformation the transformation matrix to apply
  64945. * @returns the new vector
  64946. */
  64947. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  64948. /**
  64949. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  64950. * This methods computes transformed normalized direction vectors only.
  64951. * @param vector the vector to transform
  64952. * @param transformation the transformation matrix to apply
  64953. * @param result the vector to store the result in
  64954. */
  64955. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  64956. /**
  64957. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  64958. * This methods computes transformed normalized direction vectors only.
  64959. * @param x value to transform
  64960. * @param y value to transform
  64961. * @param z value to transform
  64962. * @param w value to transform
  64963. * @param transformation the transformation matrix to apply
  64964. * @param result the vector to store the results in
  64965. */
  64966. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  64967. /**
  64968. * Creates a new Vector4 from a Vector3
  64969. * @param source defines the source data
  64970. * @param w defines the 4th component (default is 0)
  64971. * @returns a new Vector4
  64972. */
  64973. static FromVector3(source: Vector3, w?: number): Vector4;
  64974. }
  64975. /**
  64976. * Interface for the size containing width and height
  64977. */
  64978. export interface ISize {
  64979. /**
  64980. * Width
  64981. */
  64982. width: number;
  64983. /**
  64984. * Heighht
  64985. */
  64986. height: number;
  64987. }
  64988. /**
  64989. * Size containing widht and height
  64990. */
  64991. export class Size implements ISize {
  64992. /**
  64993. * Width
  64994. */
  64995. width: number;
  64996. /**
  64997. * Height
  64998. */
  64999. height: number;
  65000. /**
  65001. * Creates a Size object from the given width and height (floats).
  65002. * @param width width of the new size
  65003. * @param height height of the new size
  65004. */
  65005. constructor(width: number, height: number);
  65006. /**
  65007. * Returns a string with the Size width and height
  65008. * @returns a string with the Size width and height
  65009. */
  65010. toString(): string;
  65011. /**
  65012. * "Size"
  65013. * @returns the string "Size"
  65014. */
  65015. getClassName(): string;
  65016. /**
  65017. * Returns the Size hash code.
  65018. * @returns a hash code for a unique width and height
  65019. */
  65020. getHashCode(): number;
  65021. /**
  65022. * Updates the current size from the given one.
  65023. * @param src the given size
  65024. */
  65025. copyFrom(src: Size): void;
  65026. /**
  65027. * Updates in place the current Size from the given floats.
  65028. * @param width width of the new size
  65029. * @param height height of the new size
  65030. * @returns the updated Size.
  65031. */
  65032. copyFromFloats(width: number, height: number): Size;
  65033. /**
  65034. * Updates in place the current Size from the given floats.
  65035. * @param width width to set
  65036. * @param height height to set
  65037. * @returns the updated Size.
  65038. */
  65039. set(width: number, height: number): Size;
  65040. /**
  65041. * Multiplies the width and height by numbers
  65042. * @param w factor to multiple the width by
  65043. * @param h factor to multiple the height by
  65044. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  65045. */
  65046. multiplyByFloats(w: number, h: number): Size;
  65047. /**
  65048. * Clones the size
  65049. * @returns a new Size copied from the given one.
  65050. */
  65051. clone(): Size;
  65052. /**
  65053. * True if the current Size and the given one width and height are strictly equal.
  65054. * @param other the other size to compare against
  65055. * @returns True if the current Size and the given one width and height are strictly equal.
  65056. */
  65057. equals(other: Size): boolean;
  65058. /**
  65059. * The surface of the Size : width * height (float).
  65060. */
  65061. readonly surface: number;
  65062. /**
  65063. * Create a new size of zero
  65064. * @returns a new Size set to (0.0, 0.0)
  65065. */
  65066. static Zero(): Size;
  65067. /**
  65068. * Sums the width and height of two sizes
  65069. * @param otherSize size to add to this size
  65070. * @returns a new Size set as the addition result of the current Size and the given one.
  65071. */
  65072. add(otherSize: Size): Size;
  65073. /**
  65074. * Subtracts the width and height of two
  65075. * @param otherSize size to subtract to this size
  65076. * @returns a new Size set as the subtraction result of the given one from the current Size.
  65077. */
  65078. subtract(otherSize: Size): Size;
  65079. /**
  65080. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  65081. * @param start starting size to lerp between
  65082. * @param end end size to lerp between
  65083. * @param amount amount to lerp between the start and end values
  65084. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  65085. */
  65086. static Lerp(start: Size, end: Size, amount: number): Size;
  65087. }
  65088. /**
  65089. * Class used to store quaternion data
  65090. * @see https://en.wikipedia.org/wiki/Quaternion
  65091. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  65092. */
  65093. export class Quaternion {
  65094. /** defines the first component (0 by default) */
  65095. x: number;
  65096. /** defines the second component (0 by default) */
  65097. y: number;
  65098. /** defines the third component (0 by default) */
  65099. z: number;
  65100. /** defines the fourth component (1.0 by default) */
  65101. w: number;
  65102. /**
  65103. * Creates a new Quaternion from the given floats
  65104. * @param x defines the first component (0 by default)
  65105. * @param y defines the second component (0 by default)
  65106. * @param z defines the third component (0 by default)
  65107. * @param w defines the fourth component (1.0 by default)
  65108. */
  65109. constructor(
  65110. /** defines the first component (0 by default) */
  65111. x?: number,
  65112. /** defines the second component (0 by default) */
  65113. y?: number,
  65114. /** defines the third component (0 by default) */
  65115. z?: number,
  65116. /** defines the fourth component (1.0 by default) */
  65117. w?: number);
  65118. /**
  65119. * Gets a string representation for the current quaternion
  65120. * @returns a string with the Quaternion coordinates
  65121. */
  65122. toString(): string;
  65123. /**
  65124. * Gets the class name of the quaternion
  65125. * @returns the string "Quaternion"
  65126. */
  65127. getClassName(): string;
  65128. /**
  65129. * Gets a hash code for this quaternion
  65130. * @returns the quaternion hash code
  65131. */
  65132. getHashCode(): number;
  65133. /**
  65134. * Copy the quaternion to an array
  65135. * @returns a new array populated with 4 elements from the quaternion coordinates
  65136. */
  65137. asArray(): number[];
  65138. /**
  65139. * Check if two quaternions are equals
  65140. * @param otherQuaternion defines the second operand
  65141. * @return true if the current quaternion and the given one coordinates are strictly equals
  65142. */
  65143. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  65144. /**
  65145. * Clone the current quaternion
  65146. * @returns a new quaternion copied from the current one
  65147. */
  65148. clone(): Quaternion;
  65149. /**
  65150. * Copy a quaternion to the current one
  65151. * @param other defines the other quaternion
  65152. * @returns the updated current quaternion
  65153. */
  65154. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  65155. /**
  65156. * Updates the current quaternion with the given float coordinates
  65157. * @param x defines the x coordinate
  65158. * @param y defines the y coordinate
  65159. * @param z defines the z coordinate
  65160. * @param w defines the w coordinate
  65161. * @returns the updated current quaternion
  65162. */
  65163. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  65164. /**
  65165. * Updates the current quaternion from the given float coordinates
  65166. * @param x defines the x coordinate
  65167. * @param y defines the y coordinate
  65168. * @param z defines the z coordinate
  65169. * @param w defines the w coordinate
  65170. * @returns the updated current quaternion
  65171. */
  65172. set(x: number, y: number, z: number, w: number): Quaternion;
  65173. /**
  65174. * Adds two quaternions
  65175. * @param other defines the second operand
  65176. * @returns a new quaternion as the addition result of the given one and the current quaternion
  65177. */
  65178. add(other: DeepImmutable<Quaternion>): Quaternion;
  65179. /**
  65180. * Add a quaternion to the current one
  65181. * @param other defines the quaternion to add
  65182. * @returns the current quaternion
  65183. */
  65184. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  65185. /**
  65186. * Subtract two quaternions
  65187. * @param other defines the second operand
  65188. * @returns a new quaternion as the subtraction result of the given one from the current one
  65189. */
  65190. subtract(other: Quaternion): Quaternion;
  65191. /**
  65192. * Multiplies the current quaternion by a scale factor
  65193. * @param value defines the scale factor
  65194. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  65195. */
  65196. scale(value: number): Quaternion;
  65197. /**
  65198. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  65199. * @param scale defines the scale factor
  65200. * @param result defines the Quaternion object where to store the result
  65201. * @returns the unmodified current quaternion
  65202. */
  65203. scaleToRef(scale: number, result: Quaternion): Quaternion;
  65204. /**
  65205. * Multiplies in place the current quaternion by a scale factor
  65206. * @param value defines the scale factor
  65207. * @returns the current modified quaternion
  65208. */
  65209. scaleInPlace(value: number): Quaternion;
  65210. /**
  65211. * Scale the current quaternion values by a factor and add the result to a given quaternion
  65212. * @param scale defines the scale factor
  65213. * @param result defines the Quaternion object where to store the result
  65214. * @returns the unmodified current quaternion
  65215. */
  65216. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  65217. /**
  65218. * Multiplies two quaternions
  65219. * @param q1 defines the second operand
  65220. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  65221. */
  65222. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  65223. /**
  65224. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  65225. * @param q1 defines the second operand
  65226. * @param result defines the target quaternion
  65227. * @returns the current quaternion
  65228. */
  65229. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  65230. /**
  65231. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  65232. * @param q1 defines the second operand
  65233. * @returns the currentupdated quaternion
  65234. */
  65235. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  65236. /**
  65237. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  65238. * @param ref defines the target quaternion
  65239. * @returns the current quaternion
  65240. */
  65241. conjugateToRef(ref: Quaternion): Quaternion;
  65242. /**
  65243. * Conjugates in place (1-q) the current quaternion
  65244. * @returns the current updated quaternion
  65245. */
  65246. conjugateInPlace(): Quaternion;
  65247. /**
  65248. * Conjugates in place (1-q) the current quaternion
  65249. * @returns a new quaternion
  65250. */
  65251. conjugate(): Quaternion;
  65252. /**
  65253. * Gets length of current quaternion
  65254. * @returns the quaternion length (float)
  65255. */
  65256. length(): number;
  65257. /**
  65258. * Normalize in place the current quaternion
  65259. * @returns the current updated quaternion
  65260. */
  65261. normalize(): Quaternion;
  65262. /**
  65263. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  65264. * @param order is a reserved parameter and is ignore for now
  65265. * @returns a new Vector3 containing the Euler angles
  65266. */
  65267. toEulerAngles(order?: string): Vector3;
  65268. /**
  65269. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  65270. * @param result defines the vector which will be filled with the Euler angles
  65271. * @param order is a reserved parameter and is ignore for now
  65272. * @returns the current unchanged quaternion
  65273. */
  65274. toEulerAnglesToRef(result: Vector3): Quaternion;
  65275. /**
  65276. * Updates the given rotation matrix with the current quaternion values
  65277. * @param result defines the target matrix
  65278. * @returns the current unchanged quaternion
  65279. */
  65280. toRotationMatrix(result: Matrix): Quaternion;
  65281. /**
  65282. * Updates the current quaternion from the given rotation matrix values
  65283. * @param matrix defines the source matrix
  65284. * @returns the current updated quaternion
  65285. */
  65286. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  65287. /**
  65288. * Creates a new quaternion from a rotation matrix
  65289. * @param matrix defines the source matrix
  65290. * @returns a new quaternion created from the given rotation matrix values
  65291. */
  65292. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  65293. /**
  65294. * Updates the given quaternion with the given rotation matrix values
  65295. * @param matrix defines the source matrix
  65296. * @param result defines the target quaternion
  65297. */
  65298. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  65299. /**
  65300. * Returns the dot product (float) between the quaternions "left" and "right"
  65301. * @param left defines the left operand
  65302. * @param right defines the right operand
  65303. * @returns the dot product
  65304. */
  65305. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  65306. /**
  65307. * Checks if the two quaternions are close to each other
  65308. * @param quat0 defines the first quaternion to check
  65309. * @param quat1 defines the second quaternion to check
  65310. * @returns true if the two quaternions are close to each other
  65311. */
  65312. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  65313. /**
  65314. * Creates an empty quaternion
  65315. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  65316. */
  65317. static Zero(): Quaternion;
  65318. /**
  65319. * Inverse a given quaternion
  65320. * @param q defines the source quaternion
  65321. * @returns a new quaternion as the inverted current quaternion
  65322. */
  65323. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  65324. /**
  65325. * Inverse a given quaternion
  65326. * @param q defines the source quaternion
  65327. * @param result the quaternion the result will be stored in
  65328. * @returns the result quaternion
  65329. */
  65330. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  65331. /**
  65332. * Creates an identity quaternion
  65333. * @returns the identity quaternion
  65334. */
  65335. static Identity(): Quaternion;
  65336. /**
  65337. * Gets a boolean indicating if the given quaternion is identity
  65338. * @param quaternion defines the quaternion to check
  65339. * @returns true if the quaternion is identity
  65340. */
  65341. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  65342. /**
  65343. * Creates a quaternion from a rotation around an axis
  65344. * @param axis defines the axis to use
  65345. * @param angle defines the angle to use
  65346. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  65347. */
  65348. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  65349. /**
  65350. * Creates a rotation around an axis and stores it into the given quaternion
  65351. * @param axis defines the axis to use
  65352. * @param angle defines the angle to use
  65353. * @param result defines the target quaternion
  65354. * @returns the target quaternion
  65355. */
  65356. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  65357. /**
  65358. * Creates a new quaternion from data stored into an array
  65359. * @param array defines the data source
  65360. * @param offset defines the offset in the source array where the data starts
  65361. * @returns a new quaternion
  65362. */
  65363. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  65364. /**
  65365. * Create a quaternion from Euler rotation angles
  65366. * @param x Pitch
  65367. * @param y Yaw
  65368. * @param z Roll
  65369. * @returns the new Quaternion
  65370. */
  65371. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  65372. /**
  65373. * Updates a quaternion from Euler rotation angles
  65374. * @param x Pitch
  65375. * @param y Yaw
  65376. * @param z Roll
  65377. * @param result the quaternion to store the result
  65378. * @returns the updated quaternion
  65379. */
  65380. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  65381. /**
  65382. * Create a quaternion from Euler rotation vector
  65383. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  65384. * @returns the new Quaternion
  65385. */
  65386. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  65387. /**
  65388. * Updates a quaternion from Euler rotation vector
  65389. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  65390. * @param result the quaternion to store the result
  65391. * @returns the updated quaternion
  65392. */
  65393. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  65394. /**
  65395. * Creates a new quaternion from the given Euler float angles (y, x, z)
  65396. * @param yaw defines the rotation around Y axis
  65397. * @param pitch defines the rotation around X axis
  65398. * @param roll defines the rotation around Z axis
  65399. * @returns the new quaternion
  65400. */
  65401. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  65402. /**
  65403. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  65404. * @param yaw defines the rotation around Y axis
  65405. * @param pitch defines the rotation around X axis
  65406. * @param roll defines the rotation around Z axis
  65407. * @param result defines the target quaternion
  65408. */
  65409. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  65410. /**
  65411. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  65412. * @param alpha defines the rotation around first axis
  65413. * @param beta defines the rotation around second axis
  65414. * @param gamma defines the rotation around third axis
  65415. * @returns the new quaternion
  65416. */
  65417. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  65418. /**
  65419. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  65420. * @param alpha defines the rotation around first axis
  65421. * @param beta defines the rotation around second axis
  65422. * @param gamma defines the rotation around third axis
  65423. * @param result defines the target quaternion
  65424. */
  65425. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  65426. /**
  65427. * 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)
  65428. * @param axis1 defines the first axis
  65429. * @param axis2 defines the second axis
  65430. * @param axis3 defines the third axis
  65431. * @returns the new quaternion
  65432. */
  65433. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  65434. /**
  65435. * 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
  65436. * @param axis1 defines the first axis
  65437. * @param axis2 defines the second axis
  65438. * @param axis3 defines the third axis
  65439. * @param ref defines the target quaternion
  65440. */
  65441. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  65442. /**
  65443. * Interpolates between two quaternions
  65444. * @param left defines first quaternion
  65445. * @param right defines second quaternion
  65446. * @param amount defines the gradient to use
  65447. * @returns the new interpolated quaternion
  65448. */
  65449. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  65450. /**
  65451. * Interpolates between two quaternions and stores it into a target quaternion
  65452. * @param left defines first quaternion
  65453. * @param right defines second quaternion
  65454. * @param amount defines the gradient to use
  65455. * @param result defines the target quaternion
  65456. */
  65457. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  65458. /**
  65459. * Interpolate between two quaternions using Hermite interpolation
  65460. * @param value1 defines first quaternion
  65461. * @param tangent1 defines the incoming tangent
  65462. * @param value2 defines second quaternion
  65463. * @param tangent2 defines the outgoing tangent
  65464. * @param amount defines the target quaternion
  65465. * @returns the new interpolated quaternion
  65466. */
  65467. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  65468. }
  65469. /**
  65470. * Class used to store matrix data (4x4)
  65471. */
  65472. export class Matrix {
  65473. private static _updateFlagSeed;
  65474. private static _identityReadOnly;
  65475. private _isIdentity;
  65476. private _isIdentityDirty;
  65477. private _isIdentity3x2;
  65478. private _isIdentity3x2Dirty;
  65479. /**
  65480. * Gets the update flag of the matrix which is an unique number for the matrix.
  65481. * It will be incremented every time the matrix data change.
  65482. * You can use it to speed the comparison between two versions of the same matrix.
  65483. */
  65484. updateFlag: number;
  65485. private readonly _m;
  65486. /**
  65487. * Gets the internal data of the matrix
  65488. */
  65489. readonly m: DeepImmutable<Float32Array>;
  65490. /** @hidden */
  65491. _markAsUpdated(): void;
  65492. /** @hidden */
  65493. private _updateIdentityStatus;
  65494. /**
  65495. * Creates an empty matrix (filled with zeros)
  65496. */
  65497. constructor();
  65498. /**
  65499. * Check if the current matrix is identity
  65500. * @returns true is the matrix is the identity matrix
  65501. */
  65502. isIdentity(): boolean;
  65503. /**
  65504. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  65505. * @returns true is the matrix is the identity matrix
  65506. */
  65507. isIdentityAs3x2(): boolean;
  65508. /**
  65509. * Gets the determinant of the matrix
  65510. * @returns the matrix determinant
  65511. */
  65512. determinant(): number;
  65513. /**
  65514. * Returns the matrix as a Float32Array
  65515. * @returns the matrix underlying array
  65516. */
  65517. toArray(): DeepImmutable<Float32Array>;
  65518. /**
  65519. * Returns the matrix as a Float32Array
  65520. * @returns the matrix underlying array.
  65521. */
  65522. asArray(): DeepImmutable<Float32Array>;
  65523. /**
  65524. * Inverts the current matrix in place
  65525. * @returns the current inverted matrix
  65526. */
  65527. invert(): Matrix;
  65528. /**
  65529. * Sets all the matrix elements to zero
  65530. * @returns the current matrix
  65531. */
  65532. reset(): Matrix;
  65533. /**
  65534. * Adds the current matrix with a second one
  65535. * @param other defines the matrix to add
  65536. * @returns a new matrix as the addition of the current matrix and the given one
  65537. */
  65538. add(other: DeepImmutable<Matrix>): Matrix;
  65539. /**
  65540. * Sets the given matrix "result" to the addition of the current matrix and the given one
  65541. * @param other defines the matrix to add
  65542. * @param result defines the target matrix
  65543. * @returns the current matrix
  65544. */
  65545. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  65546. /**
  65547. * Adds in place the given matrix to the current matrix
  65548. * @param other defines the second operand
  65549. * @returns the current updated matrix
  65550. */
  65551. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  65552. /**
  65553. * Sets the given matrix to the current inverted Matrix
  65554. * @param other defines the target matrix
  65555. * @returns the unmodified current matrix
  65556. */
  65557. invertToRef(other: Matrix): Matrix;
  65558. /**
  65559. * add a value at the specified position in the current Matrix
  65560. * @param index the index of the value within the matrix. between 0 and 15.
  65561. * @param value the value to be added
  65562. * @returns the current updated matrix
  65563. */
  65564. addAtIndex(index: number, value: number): Matrix;
  65565. /**
  65566. * mutiply the specified position in the current Matrix by a value
  65567. * @param index the index of the value within the matrix. between 0 and 15.
  65568. * @param value the value to be added
  65569. * @returns the current updated matrix
  65570. */
  65571. multiplyAtIndex(index: number, value: number): Matrix;
  65572. /**
  65573. * Inserts the translation vector (using 3 floats) in the current matrix
  65574. * @param x defines the 1st component of the translation
  65575. * @param y defines the 2nd component of the translation
  65576. * @param z defines the 3rd component of the translation
  65577. * @returns the current updated matrix
  65578. */
  65579. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  65580. /**
  65581. * Adds the translation vector (using 3 floats) in the current matrix
  65582. * @param x defines the 1st component of the translation
  65583. * @param y defines the 2nd component of the translation
  65584. * @param z defines the 3rd component of the translation
  65585. * @returns the current updated matrix
  65586. */
  65587. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  65588. /**
  65589. * Inserts the translation vector in the current matrix
  65590. * @param vector3 defines the translation to insert
  65591. * @returns the current updated matrix
  65592. */
  65593. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  65594. /**
  65595. * Gets the translation value of the current matrix
  65596. * @returns a new Vector3 as the extracted translation from the matrix
  65597. */
  65598. getTranslation(): Vector3;
  65599. /**
  65600. * Fill a Vector3 with the extracted translation from the matrix
  65601. * @param result defines the Vector3 where to store the translation
  65602. * @returns the current matrix
  65603. */
  65604. getTranslationToRef(result: Vector3): Matrix;
  65605. /**
  65606. * Remove rotation and scaling part from the matrix
  65607. * @returns the updated matrix
  65608. */
  65609. removeRotationAndScaling(): Matrix;
  65610. /**
  65611. * Multiply two matrices
  65612. * @param other defines the second operand
  65613. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  65614. */
  65615. multiply(other: DeepImmutable<Matrix>): Matrix;
  65616. /**
  65617. * Copy the current matrix from the given one
  65618. * @param other defines the source matrix
  65619. * @returns the current updated matrix
  65620. */
  65621. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  65622. /**
  65623. * Populates the given array from the starting index with the current matrix values
  65624. * @param array defines the target array
  65625. * @param offset defines the offset in the target array where to start storing values
  65626. * @returns the current matrix
  65627. */
  65628. copyToArray(array: Float32Array, offset?: number): Matrix;
  65629. /**
  65630. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  65631. * @param other defines the second operand
  65632. * @param result defines the matrix where to store the multiplication
  65633. * @returns the current matrix
  65634. */
  65635. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  65636. /**
  65637. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  65638. * @param other defines the second operand
  65639. * @param result defines the array where to store the multiplication
  65640. * @param offset defines the offset in the target array where to start storing values
  65641. * @returns the current matrix
  65642. */
  65643. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  65644. /**
  65645. * Check equality between this matrix and a second one
  65646. * @param value defines the second matrix to compare
  65647. * @returns true is the current matrix and the given one values are strictly equal
  65648. */
  65649. equals(value: DeepImmutable<Matrix>): boolean;
  65650. /**
  65651. * Clone the current matrix
  65652. * @returns a new matrix from the current matrix
  65653. */
  65654. clone(): Matrix;
  65655. /**
  65656. * Returns the name of the current matrix class
  65657. * @returns the string "Matrix"
  65658. */
  65659. getClassName(): string;
  65660. /**
  65661. * Gets the hash code of the current matrix
  65662. * @returns the hash code
  65663. */
  65664. getHashCode(): number;
  65665. /**
  65666. * Decomposes the current Matrix into a translation, rotation and scaling components
  65667. * @param scale defines the scale vector3 given as a reference to update
  65668. * @param rotation defines the rotation quaternion given as a reference to update
  65669. * @param translation defines the translation vector3 given as a reference to update
  65670. * @returns true if operation was successful
  65671. */
  65672. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  65673. /**
  65674. * Gets specific row of the matrix
  65675. * @param index defines the number of the row to get
  65676. * @returns the index-th row of the current matrix as a new Vector4
  65677. */
  65678. getRow(index: number): Nullable<Vector4>;
  65679. /**
  65680. * Sets the index-th row of the current matrix to the vector4 values
  65681. * @param index defines the number of the row to set
  65682. * @param row defines the target vector4
  65683. * @returns the updated current matrix
  65684. */
  65685. setRow(index: number, row: Vector4): Matrix;
  65686. /**
  65687. * Compute the transpose of the matrix
  65688. * @returns the new transposed matrix
  65689. */
  65690. transpose(): Matrix;
  65691. /**
  65692. * Compute the transpose of the matrix and store it in a given matrix
  65693. * @param result defines the target matrix
  65694. * @returns the current matrix
  65695. */
  65696. transposeToRef(result: Matrix): Matrix;
  65697. /**
  65698. * Sets the index-th row of the current matrix with the given 4 x float values
  65699. * @param index defines the row index
  65700. * @param x defines the x component to set
  65701. * @param y defines the y component to set
  65702. * @param z defines the z component to set
  65703. * @param w defines the w component to set
  65704. * @returns the updated current matrix
  65705. */
  65706. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  65707. /**
  65708. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  65709. * @param scale defines the scale factor
  65710. * @returns a new matrix
  65711. */
  65712. scale(scale: number): Matrix;
  65713. /**
  65714. * Scale the current matrix values by a factor to a given result matrix
  65715. * @param scale defines the scale factor
  65716. * @param result defines the matrix to store the result
  65717. * @returns the current matrix
  65718. */
  65719. scaleToRef(scale: number, result: Matrix): Matrix;
  65720. /**
  65721. * Scale the current matrix values by a factor and add the result to a given matrix
  65722. * @param scale defines the scale factor
  65723. * @param result defines the Matrix to store the result
  65724. * @returns the current matrix
  65725. */
  65726. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  65727. /**
  65728. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  65729. * @param ref matrix to store the result
  65730. */
  65731. toNormalMatrix(ref: Matrix): void;
  65732. /**
  65733. * Gets only rotation part of the current matrix
  65734. * @returns a new matrix sets to the extracted rotation matrix from the current one
  65735. */
  65736. getRotationMatrix(): Matrix;
  65737. /**
  65738. * Extracts the rotation matrix from the current one and sets it as the given "result"
  65739. * @param result defines the target matrix to store data to
  65740. * @returns the current matrix
  65741. */
  65742. getRotationMatrixToRef(result: Matrix): Matrix;
  65743. /**
  65744. * Toggles model matrix from being right handed to left handed in place and vice versa
  65745. */
  65746. toggleModelMatrixHandInPlace(): void;
  65747. /**
  65748. * Toggles projection matrix from being right handed to left handed in place and vice versa
  65749. */
  65750. toggleProjectionMatrixHandInPlace(): void;
  65751. /**
  65752. * Creates a matrix from an array
  65753. * @param array defines the source array
  65754. * @param offset defines an offset in the source array
  65755. * @returns a new Matrix set from the starting index of the given array
  65756. */
  65757. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  65758. /**
  65759. * Copy the content of an array into a given matrix
  65760. * @param array defines the source array
  65761. * @param offset defines an offset in the source array
  65762. * @param result defines the target matrix
  65763. */
  65764. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  65765. /**
  65766. * Stores an array into a matrix after having multiplied each component by a given factor
  65767. * @param array defines the source array
  65768. * @param offset defines the offset in the source array
  65769. * @param scale defines the scaling factor
  65770. * @param result defines the target matrix
  65771. */
  65772. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  65773. /**
  65774. * Gets an identity matrix that must not be updated
  65775. */
  65776. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  65777. /**
  65778. * Stores a list of values (16) inside a given matrix
  65779. * @param initialM11 defines 1st value of 1st row
  65780. * @param initialM12 defines 2nd value of 1st row
  65781. * @param initialM13 defines 3rd value of 1st row
  65782. * @param initialM14 defines 4th value of 1st row
  65783. * @param initialM21 defines 1st value of 2nd row
  65784. * @param initialM22 defines 2nd value of 2nd row
  65785. * @param initialM23 defines 3rd value of 2nd row
  65786. * @param initialM24 defines 4th value of 2nd row
  65787. * @param initialM31 defines 1st value of 3rd row
  65788. * @param initialM32 defines 2nd value of 3rd row
  65789. * @param initialM33 defines 3rd value of 3rd row
  65790. * @param initialM34 defines 4th value of 3rd row
  65791. * @param initialM41 defines 1st value of 4th row
  65792. * @param initialM42 defines 2nd value of 4th row
  65793. * @param initialM43 defines 3rd value of 4th row
  65794. * @param initialM44 defines 4th value of 4th row
  65795. * @param result defines the target matrix
  65796. */
  65797. 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;
  65798. /**
  65799. * Creates new matrix from a list of values (16)
  65800. * @param initialM11 defines 1st value of 1st row
  65801. * @param initialM12 defines 2nd value of 1st row
  65802. * @param initialM13 defines 3rd value of 1st row
  65803. * @param initialM14 defines 4th value of 1st row
  65804. * @param initialM21 defines 1st value of 2nd row
  65805. * @param initialM22 defines 2nd value of 2nd row
  65806. * @param initialM23 defines 3rd value of 2nd row
  65807. * @param initialM24 defines 4th value of 2nd row
  65808. * @param initialM31 defines 1st value of 3rd row
  65809. * @param initialM32 defines 2nd value of 3rd row
  65810. * @param initialM33 defines 3rd value of 3rd row
  65811. * @param initialM34 defines 4th value of 3rd row
  65812. * @param initialM41 defines 1st value of 4th row
  65813. * @param initialM42 defines 2nd value of 4th row
  65814. * @param initialM43 defines 3rd value of 4th row
  65815. * @param initialM44 defines 4th value of 4th row
  65816. * @returns the new matrix
  65817. */
  65818. 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;
  65819. /**
  65820. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  65821. * @param scale defines the scale vector3
  65822. * @param rotation defines the rotation quaternion
  65823. * @param translation defines the translation vector3
  65824. * @returns a new matrix
  65825. */
  65826. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  65827. /**
  65828. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  65829. * @param scale defines the scale vector3
  65830. * @param rotation defines the rotation quaternion
  65831. * @param translation defines the translation vector3
  65832. * @param result defines the target matrix
  65833. */
  65834. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  65835. /**
  65836. * Creates a new identity matrix
  65837. * @returns a new identity matrix
  65838. */
  65839. static Identity(): Matrix;
  65840. /**
  65841. * Creates a new identity matrix and stores the result in a given matrix
  65842. * @param result defines the target matrix
  65843. */
  65844. static IdentityToRef(result: Matrix): void;
  65845. /**
  65846. * Creates a new zero matrix
  65847. * @returns a new zero matrix
  65848. */
  65849. static Zero(): Matrix;
  65850. /**
  65851. * Creates a new rotation matrix for "angle" radians around the X axis
  65852. * @param angle defines the angle (in radians) to use
  65853. * @return the new matrix
  65854. */
  65855. static RotationX(angle: number): Matrix;
  65856. /**
  65857. * Creates a new matrix as the invert of a given matrix
  65858. * @param source defines the source matrix
  65859. * @returns the new matrix
  65860. */
  65861. static Invert(source: DeepImmutable<Matrix>): Matrix;
  65862. /**
  65863. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  65864. * @param angle defines the angle (in radians) to use
  65865. * @param result defines the target matrix
  65866. */
  65867. static RotationXToRef(angle: number, result: Matrix): void;
  65868. /**
  65869. * Creates a new rotation matrix for "angle" radians around the Y axis
  65870. * @param angle defines the angle (in radians) to use
  65871. * @return the new matrix
  65872. */
  65873. static RotationY(angle: number): Matrix;
  65874. /**
  65875. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  65876. * @param angle defines the angle (in radians) to use
  65877. * @param result defines the target matrix
  65878. */
  65879. static RotationYToRef(angle: number, result: Matrix): void;
  65880. /**
  65881. * Creates a new rotation matrix for "angle" radians around the Z axis
  65882. * @param angle defines the angle (in radians) to use
  65883. * @return the new matrix
  65884. */
  65885. static RotationZ(angle: number): Matrix;
  65886. /**
  65887. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  65888. * @param angle defines the angle (in radians) to use
  65889. * @param result defines the target matrix
  65890. */
  65891. static RotationZToRef(angle: number, result: Matrix): void;
  65892. /**
  65893. * Creates a new rotation matrix for "angle" radians around the given axis
  65894. * @param axis defines the axis to use
  65895. * @param angle defines the angle (in radians) to use
  65896. * @return the new matrix
  65897. */
  65898. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  65899. /**
  65900. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  65901. * @param axis defines the axis to use
  65902. * @param angle defines the angle (in radians) to use
  65903. * @param result defines the target matrix
  65904. */
  65905. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  65906. /**
  65907. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  65908. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  65909. * @param from defines the vector to align
  65910. * @param to defines the vector to align to
  65911. * @param result defines the target matrix
  65912. */
  65913. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  65914. /**
  65915. * Creates a rotation matrix
  65916. * @param yaw defines the yaw angle in radians (Y axis)
  65917. * @param pitch defines the pitch angle in radians (X axis)
  65918. * @param roll defines the roll angle in radians (X axis)
  65919. * @returns the new rotation matrix
  65920. */
  65921. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  65922. /**
  65923. * Creates a rotation matrix and stores it in a given matrix
  65924. * @param yaw defines the yaw angle in radians (Y axis)
  65925. * @param pitch defines the pitch angle in radians (X axis)
  65926. * @param roll defines the roll angle in radians (X axis)
  65927. * @param result defines the target matrix
  65928. */
  65929. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  65930. /**
  65931. * Creates a scaling matrix
  65932. * @param x defines the scale factor on X axis
  65933. * @param y defines the scale factor on Y axis
  65934. * @param z defines the scale factor on Z axis
  65935. * @returns the new matrix
  65936. */
  65937. static Scaling(x: number, y: number, z: number): Matrix;
  65938. /**
  65939. * Creates a scaling matrix and stores it in a given matrix
  65940. * @param x defines the scale factor on X axis
  65941. * @param y defines the scale factor on Y axis
  65942. * @param z defines the scale factor on Z axis
  65943. * @param result defines the target matrix
  65944. */
  65945. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  65946. /**
  65947. * Creates a translation matrix
  65948. * @param x defines the translation on X axis
  65949. * @param y defines the translation on Y axis
  65950. * @param z defines the translationon Z axis
  65951. * @returns the new matrix
  65952. */
  65953. static Translation(x: number, y: number, z: number): Matrix;
  65954. /**
  65955. * Creates a translation matrix and stores it in a given matrix
  65956. * @param x defines the translation on X axis
  65957. * @param y defines the translation on Y axis
  65958. * @param z defines the translationon Z axis
  65959. * @param result defines the target matrix
  65960. */
  65961. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  65962. /**
  65963. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  65964. * @param startValue defines the start value
  65965. * @param endValue defines the end value
  65966. * @param gradient defines the gradient factor
  65967. * @returns the new matrix
  65968. */
  65969. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  65970. /**
  65971. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  65972. * @param startValue defines the start value
  65973. * @param endValue defines the end value
  65974. * @param gradient defines the gradient factor
  65975. * @param result defines the Matrix object where to store data
  65976. */
  65977. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  65978. /**
  65979. * Builds a new matrix whose values are computed by:
  65980. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  65981. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  65982. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  65983. * @param startValue defines the first matrix
  65984. * @param endValue defines the second matrix
  65985. * @param gradient defines the gradient between the two matrices
  65986. * @returns the new matrix
  65987. */
  65988. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  65989. /**
  65990. * Update a matrix to values which are computed by:
  65991. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  65992. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  65993. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  65994. * @param startValue defines the first matrix
  65995. * @param endValue defines the second matrix
  65996. * @param gradient defines the gradient between the two matrices
  65997. * @param result defines the target matrix
  65998. */
  65999. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  66000. /**
  66001. * 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"
  66002. * This function works in left handed mode
  66003. * @param eye defines the final position of the entity
  66004. * @param target defines where the entity should look at
  66005. * @param up defines the up vector for the entity
  66006. * @returns the new matrix
  66007. */
  66008. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  66009. /**
  66010. * 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".
  66011. * This function works in left handed mode
  66012. * @param eye defines the final position of the entity
  66013. * @param target defines where the entity should look at
  66014. * @param up defines the up vector for the entity
  66015. * @param result defines the target matrix
  66016. */
  66017. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  66018. /**
  66019. * 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"
  66020. * This function works in right handed mode
  66021. * @param eye defines the final position of the entity
  66022. * @param target defines where the entity should look at
  66023. * @param up defines the up vector for the entity
  66024. * @returns the new matrix
  66025. */
  66026. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  66027. /**
  66028. * 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".
  66029. * This function works in right handed mode
  66030. * @param eye defines the final position of the entity
  66031. * @param target defines where the entity should look at
  66032. * @param up defines the up vector for the entity
  66033. * @param result defines the target matrix
  66034. */
  66035. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  66036. /**
  66037. * Create a left-handed orthographic projection matrix
  66038. * @param width defines the viewport width
  66039. * @param height defines the viewport height
  66040. * @param znear defines the near clip plane
  66041. * @param zfar defines the far clip plane
  66042. * @returns a new matrix as a left-handed orthographic projection matrix
  66043. */
  66044. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  66045. /**
  66046. * Store a left-handed orthographic projection to a given matrix
  66047. * @param width defines the viewport width
  66048. * @param height defines the viewport height
  66049. * @param znear defines the near clip plane
  66050. * @param zfar defines the far clip plane
  66051. * @param result defines the target matrix
  66052. */
  66053. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  66054. /**
  66055. * Create a left-handed orthographic projection matrix
  66056. * @param left defines the viewport left coordinate
  66057. * @param right defines the viewport right coordinate
  66058. * @param bottom defines the viewport bottom coordinate
  66059. * @param top defines the viewport top coordinate
  66060. * @param znear defines the near clip plane
  66061. * @param zfar defines the far clip plane
  66062. * @returns a new matrix as a left-handed orthographic projection matrix
  66063. */
  66064. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  66065. /**
  66066. * Stores a left-handed orthographic projection into a given matrix
  66067. * @param left defines the viewport left coordinate
  66068. * @param right defines the viewport right coordinate
  66069. * @param bottom defines the viewport bottom coordinate
  66070. * @param top defines the viewport top coordinate
  66071. * @param znear defines the near clip plane
  66072. * @param zfar defines the far clip plane
  66073. * @param result defines the target matrix
  66074. */
  66075. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  66076. /**
  66077. * Creates a right-handed orthographic projection matrix
  66078. * @param left defines the viewport left coordinate
  66079. * @param right defines the viewport right coordinate
  66080. * @param bottom defines the viewport bottom coordinate
  66081. * @param top defines the viewport top coordinate
  66082. * @param znear defines the near clip plane
  66083. * @param zfar defines the far clip plane
  66084. * @returns a new matrix as a right-handed orthographic projection matrix
  66085. */
  66086. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  66087. /**
  66088. * Stores a right-handed orthographic projection into a given matrix
  66089. * @param left defines the viewport left coordinate
  66090. * @param right defines the viewport right coordinate
  66091. * @param bottom defines the viewport bottom coordinate
  66092. * @param top defines the viewport top coordinate
  66093. * @param znear defines the near clip plane
  66094. * @param zfar defines the far clip plane
  66095. * @param result defines the target matrix
  66096. */
  66097. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  66098. /**
  66099. * Creates a left-handed perspective projection matrix
  66100. * @param width defines the viewport width
  66101. * @param height defines the viewport height
  66102. * @param znear defines the near clip plane
  66103. * @param zfar defines the far clip plane
  66104. * @returns a new matrix as a left-handed perspective projection matrix
  66105. */
  66106. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  66107. /**
  66108. * Creates a left-handed perspective projection matrix
  66109. * @param fov defines the horizontal field of view
  66110. * @param aspect defines the aspect ratio
  66111. * @param znear defines the near clip plane
  66112. * @param zfar defines the far clip plane
  66113. * @returns a new matrix as a left-handed perspective projection matrix
  66114. */
  66115. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  66116. /**
  66117. * Stores a left-handed perspective projection into a given matrix
  66118. * @param fov defines the horizontal field of view
  66119. * @param aspect defines the aspect ratio
  66120. * @param znear defines the near clip plane
  66121. * @param zfar defines the far clip plane
  66122. * @param result defines the target matrix
  66123. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  66124. */
  66125. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  66126. /**
  66127. * Creates a right-handed perspective projection matrix
  66128. * @param fov defines the horizontal field of view
  66129. * @param aspect defines the aspect ratio
  66130. * @param znear defines the near clip plane
  66131. * @param zfar defines the far clip plane
  66132. * @returns a new matrix as a right-handed perspective projection matrix
  66133. */
  66134. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  66135. /**
  66136. * Stores a right-handed perspective projection into a given matrix
  66137. * @param fov defines the horizontal field of view
  66138. * @param aspect defines the aspect ratio
  66139. * @param znear defines the near clip plane
  66140. * @param zfar defines the far clip plane
  66141. * @param result defines the target matrix
  66142. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  66143. */
  66144. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  66145. /**
  66146. * Stores a perspective projection for WebVR info a given matrix
  66147. * @param fov defines the field of view
  66148. * @param znear defines the near clip plane
  66149. * @param zfar defines the far clip plane
  66150. * @param result defines the target matrix
  66151. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  66152. */
  66153. static PerspectiveFovWebVRToRef(fov: {
  66154. upDegrees: number;
  66155. downDegrees: number;
  66156. leftDegrees: number;
  66157. rightDegrees: number;
  66158. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  66159. /**
  66160. * Computes a complete transformation matrix
  66161. * @param viewport defines the viewport to use
  66162. * @param world defines the world matrix
  66163. * @param view defines the view matrix
  66164. * @param projection defines the projection matrix
  66165. * @param zmin defines the near clip plane
  66166. * @param zmax defines the far clip plane
  66167. * @returns the transformation matrix
  66168. */
  66169. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  66170. /**
  66171. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  66172. * @param matrix defines the matrix to use
  66173. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  66174. */
  66175. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  66176. /**
  66177. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  66178. * @param matrix defines the matrix to use
  66179. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  66180. */
  66181. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  66182. /**
  66183. * Compute the transpose of a given matrix
  66184. * @param matrix defines the matrix to transpose
  66185. * @returns the new matrix
  66186. */
  66187. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  66188. /**
  66189. * Compute the transpose of a matrix and store it in a target matrix
  66190. * @param matrix defines the matrix to transpose
  66191. * @param result defines the target matrix
  66192. */
  66193. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  66194. /**
  66195. * Computes a reflection matrix from a plane
  66196. * @param plane defines the reflection plane
  66197. * @returns a new matrix
  66198. */
  66199. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  66200. /**
  66201. * Computes a reflection matrix from a plane
  66202. * @param plane defines the reflection plane
  66203. * @param result defines the target matrix
  66204. */
  66205. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  66206. /**
  66207. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  66208. * @param xaxis defines the value of the 1st axis
  66209. * @param yaxis defines the value of the 2nd axis
  66210. * @param zaxis defines the value of the 3rd axis
  66211. * @param result defines the target matrix
  66212. */
  66213. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  66214. /**
  66215. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  66216. * @param quat defines the quaternion to use
  66217. * @param result defines the target matrix
  66218. */
  66219. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  66220. }
  66221. /**
  66222. * Represens a plane by the equation ax + by + cz + d = 0
  66223. */
  66224. export class Plane {
  66225. /**
  66226. * Normal of the plane (a,b,c)
  66227. */
  66228. normal: Vector3;
  66229. /**
  66230. * d component of the plane
  66231. */
  66232. d: number;
  66233. /**
  66234. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  66235. * @param a a component of the plane
  66236. * @param b b component of the plane
  66237. * @param c c component of the plane
  66238. * @param d d component of the plane
  66239. */
  66240. constructor(a: number, b: number, c: number, d: number);
  66241. /**
  66242. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  66243. */
  66244. asArray(): number[];
  66245. /**
  66246. * @returns a new plane copied from the current Plane.
  66247. */
  66248. clone(): Plane;
  66249. /**
  66250. * @returns the string "Plane".
  66251. */
  66252. getClassName(): string;
  66253. /**
  66254. * @returns the Plane hash code.
  66255. */
  66256. getHashCode(): number;
  66257. /**
  66258. * Normalize the current Plane in place.
  66259. * @returns the updated Plane.
  66260. */
  66261. normalize(): Plane;
  66262. /**
  66263. * Applies a transformation the plane and returns the result
  66264. * @param transformation the transformation matrix to be applied to the plane
  66265. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  66266. */
  66267. transform(transformation: DeepImmutable<Matrix>): Plane;
  66268. /**
  66269. * Calcualtte the dot product between the point and the plane normal
  66270. * @param point point to calculate the dot product with
  66271. * @returns the dot product (float) of the point coordinates and the plane normal.
  66272. */
  66273. dotCoordinate(point: DeepImmutable<Vector3>): number;
  66274. /**
  66275. * Updates the current Plane from the plane defined by the three given points.
  66276. * @param point1 one of the points used to contruct the plane
  66277. * @param point2 one of the points used to contruct the plane
  66278. * @param point3 one of the points used to contruct the plane
  66279. * @returns the updated Plane.
  66280. */
  66281. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  66282. /**
  66283. * Checks if the plane is facing a given direction
  66284. * @param direction the direction to check if the plane is facing
  66285. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  66286. * @returns True is the vector "direction" is the same side than the plane normal.
  66287. */
  66288. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  66289. /**
  66290. * Calculates the distance to a point
  66291. * @param point point to calculate distance to
  66292. * @returns the signed distance (float) from the given point to the Plane.
  66293. */
  66294. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  66295. /**
  66296. * Creates a plane from an array
  66297. * @param array the array to create a plane from
  66298. * @returns a new Plane from the given array.
  66299. */
  66300. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  66301. /**
  66302. * Creates a plane from three points
  66303. * @param point1 point used to create the plane
  66304. * @param point2 point used to create the plane
  66305. * @param point3 point used to create the plane
  66306. * @returns a new Plane defined by the three given points.
  66307. */
  66308. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  66309. /**
  66310. * Creates a plane from an origin point and a normal
  66311. * @param origin origin of the plane to be constructed
  66312. * @param normal normal of the plane to be constructed
  66313. * @returns a new Plane the normal vector to this plane at the given origin point.
  66314. * Note : the vector "normal" is updated because normalized.
  66315. */
  66316. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  66317. /**
  66318. * Calculates the distance from a plane and a point
  66319. * @param origin origin of the plane to be constructed
  66320. * @param normal normal of the plane to be constructed
  66321. * @param point point to calculate distance to
  66322. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  66323. */
  66324. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  66325. }
  66326. /**
  66327. * Class used to represent a viewport on screen
  66328. */
  66329. export class Viewport {
  66330. /** viewport left coordinate */
  66331. x: number;
  66332. /** viewport top coordinate */
  66333. y: number;
  66334. /**viewport width */
  66335. width: number;
  66336. /** viewport height */
  66337. height: number;
  66338. /**
  66339. * Creates a Viewport object located at (x, y) and sized (width, height)
  66340. * @param x defines viewport left coordinate
  66341. * @param y defines viewport top coordinate
  66342. * @param width defines the viewport width
  66343. * @param height defines the viewport height
  66344. */
  66345. constructor(
  66346. /** viewport left coordinate */
  66347. x: number,
  66348. /** viewport top coordinate */
  66349. y: number,
  66350. /**viewport width */
  66351. width: number,
  66352. /** viewport height */
  66353. height: number);
  66354. /**
  66355. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  66356. * @param renderWidth defines the rendering width
  66357. * @param renderHeight defines the rendering height
  66358. * @returns a new Viewport
  66359. */
  66360. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  66361. /**
  66362. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  66363. * @param renderWidth defines the rendering width
  66364. * @param renderHeight defines the rendering height
  66365. * @param ref defines the target viewport
  66366. * @returns the current viewport
  66367. */
  66368. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  66369. /**
  66370. * Returns a new Viewport copied from the current one
  66371. * @returns a new Viewport
  66372. */
  66373. clone(): Viewport;
  66374. }
  66375. /**
  66376. * Reprasents a camera frustum
  66377. */
  66378. export class Frustum {
  66379. /**
  66380. * Gets the planes representing the frustum
  66381. * @param transform matrix to be applied to the returned planes
  66382. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  66383. */
  66384. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  66385. /**
  66386. * Gets the near frustum plane transformed by the transform matrix
  66387. * @param transform transformation matrix to be applied to the resulting frustum plane
  66388. * @param frustumPlane the resuling frustum plane
  66389. */
  66390. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66391. /**
  66392. * Gets the far frustum plane transformed by the transform matrix
  66393. * @param transform transformation matrix to be applied to the resulting frustum plane
  66394. * @param frustumPlane the resuling frustum plane
  66395. */
  66396. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66397. /**
  66398. * Gets the left frustum plane transformed by the transform matrix
  66399. * @param transform transformation matrix to be applied to the resulting frustum plane
  66400. * @param frustumPlane the resuling frustum plane
  66401. */
  66402. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66403. /**
  66404. * Gets the right frustum plane transformed by the transform matrix
  66405. * @param transform transformation matrix to be applied to the resulting frustum plane
  66406. * @param frustumPlane the resuling frustum plane
  66407. */
  66408. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66409. /**
  66410. * Gets the top frustum plane transformed by the transform matrix
  66411. * @param transform transformation matrix to be applied to the resulting frustum plane
  66412. * @param frustumPlane the resuling frustum plane
  66413. */
  66414. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66415. /**
  66416. * Gets the bottom frustum plane transformed by the transform matrix
  66417. * @param transform transformation matrix to be applied to the resulting frustum plane
  66418. * @param frustumPlane the resuling frustum plane
  66419. */
  66420. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66421. /**
  66422. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  66423. * @param transform transformation matrix to be applied to the resulting frustum planes
  66424. * @param frustumPlanes the resuling frustum planes
  66425. */
  66426. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  66427. }
  66428. /** Defines supported spaces */
  66429. export enum Space {
  66430. /** Local (object) space */
  66431. LOCAL = 0,
  66432. /** World space */
  66433. WORLD = 1,
  66434. /** Bone space */
  66435. BONE = 2
  66436. }
  66437. /** Defines the 3 main axes */
  66438. export class Axis {
  66439. /** X axis */
  66440. static X: Vector3;
  66441. /** Y axis */
  66442. static Y: Vector3;
  66443. /** Z axis */
  66444. static Z: Vector3;
  66445. }
  66446. /** Class used to represent a Bezier curve */
  66447. export class BezierCurve {
  66448. /**
  66449. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  66450. * @param t defines the time
  66451. * @param x1 defines the left coordinate on X axis
  66452. * @param y1 defines the left coordinate on Y axis
  66453. * @param x2 defines the right coordinate on X axis
  66454. * @param y2 defines the right coordinate on Y axis
  66455. * @returns the interpolated value
  66456. */
  66457. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  66458. }
  66459. /**
  66460. * Defines potential orientation for back face culling
  66461. */
  66462. export enum Orientation {
  66463. /**
  66464. * Clockwise
  66465. */
  66466. CW = 0,
  66467. /** Counter clockwise */
  66468. CCW = 1
  66469. }
  66470. /**
  66471. * Defines angle representation
  66472. */
  66473. export class Angle {
  66474. private _radians;
  66475. /**
  66476. * Creates an Angle object of "radians" radians (float).
  66477. * @param radians the angle in radians
  66478. */
  66479. constructor(radians: number);
  66480. /**
  66481. * Get value in degrees
  66482. * @returns the Angle value in degrees (float)
  66483. */
  66484. degrees(): number;
  66485. /**
  66486. * Get value in radians
  66487. * @returns the Angle value in radians (float)
  66488. */
  66489. radians(): number;
  66490. /**
  66491. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  66492. * @param a defines first vector
  66493. * @param b defines second vector
  66494. * @returns a new Angle
  66495. */
  66496. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  66497. /**
  66498. * Gets a new Angle object from the given float in radians
  66499. * @param radians defines the angle value in radians
  66500. * @returns a new Angle
  66501. */
  66502. static FromRadians(radians: number): Angle;
  66503. /**
  66504. * Gets a new Angle object from the given float in degrees
  66505. * @param degrees defines the angle value in degrees
  66506. * @returns a new Angle
  66507. */
  66508. static FromDegrees(degrees: number): Angle;
  66509. }
  66510. /**
  66511. * This represents an arc in a 2d space.
  66512. */
  66513. export class Arc2 {
  66514. /** Defines the start point of the arc */
  66515. startPoint: Vector2;
  66516. /** Defines the mid point of the arc */
  66517. midPoint: Vector2;
  66518. /** Defines the end point of the arc */
  66519. endPoint: Vector2;
  66520. /**
  66521. * Defines the center point of the arc.
  66522. */
  66523. centerPoint: Vector2;
  66524. /**
  66525. * Defines the radius of the arc.
  66526. */
  66527. radius: number;
  66528. /**
  66529. * Defines the angle of the arc (from mid point to end point).
  66530. */
  66531. angle: Angle;
  66532. /**
  66533. * Defines the start angle of the arc (from start point to middle point).
  66534. */
  66535. startAngle: Angle;
  66536. /**
  66537. * Defines the orientation of the arc (clock wise/counter clock wise).
  66538. */
  66539. orientation: Orientation;
  66540. /**
  66541. * Creates an Arc object from the three given points : start, middle and end.
  66542. * @param startPoint Defines the start point of the arc
  66543. * @param midPoint Defines the midlle point of the arc
  66544. * @param endPoint Defines the end point of the arc
  66545. */
  66546. constructor(
  66547. /** Defines the start point of the arc */
  66548. startPoint: Vector2,
  66549. /** Defines the mid point of the arc */
  66550. midPoint: Vector2,
  66551. /** Defines the end point of the arc */
  66552. endPoint: Vector2);
  66553. }
  66554. /**
  66555. * Represents a 2D path made up of multiple 2D points
  66556. */
  66557. export class Path2 {
  66558. private _points;
  66559. private _length;
  66560. /**
  66561. * If the path start and end point are the same
  66562. */
  66563. closed: boolean;
  66564. /**
  66565. * Creates a Path2 object from the starting 2D coordinates x and y.
  66566. * @param x the starting points x value
  66567. * @param y the starting points y value
  66568. */
  66569. constructor(x: number, y: number);
  66570. /**
  66571. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  66572. * @param x the added points x value
  66573. * @param y the added points y value
  66574. * @returns the updated Path2.
  66575. */
  66576. addLineTo(x: number, y: number): Path2;
  66577. /**
  66578. * 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.
  66579. * @param midX middle point x value
  66580. * @param midY middle point y value
  66581. * @param endX end point x value
  66582. * @param endY end point y value
  66583. * @param numberOfSegments (default: 36)
  66584. * @returns the updated Path2.
  66585. */
  66586. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  66587. /**
  66588. * Closes the Path2.
  66589. * @returns the Path2.
  66590. */
  66591. close(): Path2;
  66592. /**
  66593. * Gets the sum of the distance between each sequential point in the path
  66594. * @returns the Path2 total length (float).
  66595. */
  66596. length(): number;
  66597. /**
  66598. * Gets the points which construct the path
  66599. * @returns the Path2 internal array of points.
  66600. */
  66601. getPoints(): Vector2[];
  66602. /**
  66603. * Retreives the point at the distance aways from the starting point
  66604. * @param normalizedLengthPosition the length along the path to retreive the point from
  66605. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  66606. */
  66607. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  66608. /**
  66609. * Creates a new path starting from an x and y position
  66610. * @param x starting x value
  66611. * @param y starting y value
  66612. * @returns a new Path2 starting at the coordinates (x, y).
  66613. */
  66614. static StartingAt(x: number, y: number): Path2;
  66615. }
  66616. /**
  66617. * Represents a 3D path made up of multiple 3D points
  66618. */
  66619. export class Path3D {
  66620. /**
  66621. * an array of Vector3, the curve axis of the Path3D
  66622. */
  66623. path: Vector3[];
  66624. private _curve;
  66625. private _distances;
  66626. private _tangents;
  66627. private _normals;
  66628. private _binormals;
  66629. private _raw;
  66630. /**
  66631. * new Path3D(path, normal, raw)
  66632. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  66633. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  66634. * @param path an array of Vector3, the curve axis of the Path3D
  66635. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  66636. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  66637. */
  66638. constructor(
  66639. /**
  66640. * an array of Vector3, the curve axis of the Path3D
  66641. */
  66642. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  66643. /**
  66644. * Returns the Path3D array of successive Vector3 designing its curve.
  66645. * @returns the Path3D array of successive Vector3 designing its curve.
  66646. */
  66647. getCurve(): Vector3[];
  66648. /**
  66649. * Returns an array populated with tangent vectors on each Path3D curve point.
  66650. * @returns an array populated with tangent vectors on each Path3D curve point.
  66651. */
  66652. getTangents(): Vector3[];
  66653. /**
  66654. * Returns an array populated with normal vectors on each Path3D curve point.
  66655. * @returns an array populated with normal vectors on each Path3D curve point.
  66656. */
  66657. getNormals(): Vector3[];
  66658. /**
  66659. * Returns an array populated with binormal vectors on each Path3D curve point.
  66660. * @returns an array populated with binormal vectors on each Path3D curve point.
  66661. */
  66662. getBinormals(): Vector3[];
  66663. /**
  66664. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  66665. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  66666. */
  66667. getDistances(): number[];
  66668. /**
  66669. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  66670. * @param path path which all values are copied into the curves points
  66671. * @param firstNormal which should be projected onto the curve
  66672. * @returns the same object updated.
  66673. */
  66674. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  66675. private _compute;
  66676. private _getFirstNonNullVector;
  66677. private _getLastNonNullVector;
  66678. private _normalVector;
  66679. }
  66680. /**
  66681. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  66682. * A Curve3 is designed from a series of successive Vector3.
  66683. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  66684. */
  66685. export class Curve3 {
  66686. private _points;
  66687. private _length;
  66688. /**
  66689. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  66690. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  66691. * @param v1 (Vector3) the control point
  66692. * @param v2 (Vector3) the end point of the Quadratic Bezier
  66693. * @param nbPoints (integer) the wanted number of points in the curve
  66694. * @returns the created Curve3
  66695. */
  66696. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  66697. /**
  66698. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  66699. * @param v0 (Vector3) the origin point of the Cubic Bezier
  66700. * @param v1 (Vector3) the first control point
  66701. * @param v2 (Vector3) the second control point
  66702. * @param v3 (Vector3) the end point of the Cubic Bezier
  66703. * @param nbPoints (integer) the wanted number of points in the curve
  66704. * @returns the created Curve3
  66705. */
  66706. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  66707. /**
  66708. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  66709. * @param p1 (Vector3) the origin point of the Hermite Spline
  66710. * @param t1 (Vector3) the tangent vector at the origin point
  66711. * @param p2 (Vector3) the end point of the Hermite Spline
  66712. * @param t2 (Vector3) the tangent vector at the end point
  66713. * @param nbPoints (integer) the wanted number of points in the curve
  66714. * @returns the created Curve3
  66715. */
  66716. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  66717. /**
  66718. * Returns a Curve3 object along a CatmullRom Spline curve :
  66719. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  66720. * @param nbPoints (integer) the wanted number of points between each curve control points
  66721. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  66722. * @returns the created Curve3
  66723. */
  66724. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  66725. /**
  66726. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  66727. * A Curve3 is designed from a series of successive Vector3.
  66728. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  66729. * @param points points which make up the curve
  66730. */
  66731. constructor(points: Vector3[]);
  66732. /**
  66733. * @returns the Curve3 stored array of successive Vector3
  66734. */
  66735. getPoints(): Vector3[];
  66736. /**
  66737. * @returns the computed length (float) of the curve.
  66738. */
  66739. length(): number;
  66740. /**
  66741. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  66742. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  66743. * curveA and curveB keep unchanged.
  66744. * @param curve the curve to continue from this curve
  66745. * @returns the newly constructed curve
  66746. */
  66747. continue(curve: DeepImmutable<Curve3>): Curve3;
  66748. private _computeLength;
  66749. }
  66750. /**
  66751. * Contains position and normal vectors for a vertex
  66752. */
  66753. export class PositionNormalVertex {
  66754. /** the position of the vertex (defaut: 0,0,0) */
  66755. position: Vector3;
  66756. /** the normal of the vertex (defaut: 0,1,0) */
  66757. normal: Vector3;
  66758. /**
  66759. * Creates a PositionNormalVertex
  66760. * @param position the position of the vertex (defaut: 0,0,0)
  66761. * @param normal the normal of the vertex (defaut: 0,1,0)
  66762. */
  66763. constructor(
  66764. /** the position of the vertex (defaut: 0,0,0) */
  66765. position?: Vector3,
  66766. /** the normal of the vertex (defaut: 0,1,0) */
  66767. normal?: Vector3);
  66768. /**
  66769. * Clones the PositionNormalVertex
  66770. * @returns the cloned PositionNormalVertex
  66771. */
  66772. clone(): PositionNormalVertex;
  66773. }
  66774. /**
  66775. * Contains position, normal and uv vectors for a vertex
  66776. */
  66777. export class PositionNormalTextureVertex {
  66778. /** the position of the vertex (defaut: 0,0,0) */
  66779. position: Vector3;
  66780. /** the normal of the vertex (defaut: 0,1,0) */
  66781. normal: Vector3;
  66782. /** the uv of the vertex (default: 0,0) */
  66783. uv: Vector2;
  66784. /**
  66785. * Creates a PositionNormalTextureVertex
  66786. * @param position the position of the vertex (defaut: 0,0,0)
  66787. * @param normal the normal of the vertex (defaut: 0,1,0)
  66788. * @param uv the uv of the vertex (default: 0,0)
  66789. */
  66790. constructor(
  66791. /** the position of the vertex (defaut: 0,0,0) */
  66792. position?: Vector3,
  66793. /** the normal of the vertex (defaut: 0,1,0) */
  66794. normal?: Vector3,
  66795. /** the uv of the vertex (default: 0,0) */
  66796. uv?: Vector2);
  66797. /**
  66798. * Clones the PositionNormalTextureVertex
  66799. * @returns the cloned PositionNormalTextureVertex
  66800. */
  66801. clone(): PositionNormalTextureVertex;
  66802. }
  66803. /**
  66804. * @hidden
  66805. */
  66806. export class Tmp {
  66807. static Color3: Color3[];
  66808. static Color4: Color4[];
  66809. static Vector2: Vector2[];
  66810. static Vector3: Vector3[];
  66811. static Vector4: Vector4[];
  66812. static Quaternion: Quaternion[];
  66813. static Matrix: Matrix[];
  66814. }
  66815. }
  66816. declare module BABYLON {
  66817. /**
  66818. * Class used to enable access to offline support
  66819. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  66820. */
  66821. export interface IOfflineProvider {
  66822. /**
  66823. * Gets a boolean indicating if scene must be saved in the database
  66824. */
  66825. enableSceneOffline: boolean;
  66826. /**
  66827. * Gets a boolean indicating if textures must be saved in the database
  66828. */
  66829. enableTexturesOffline: boolean;
  66830. /**
  66831. * Open the offline support and make it available
  66832. * @param successCallback defines the callback to call on success
  66833. * @param errorCallback defines the callback to call on error
  66834. */
  66835. open(successCallback: () => void, errorCallback: () => void): void;
  66836. /**
  66837. * Loads an image from the offline support
  66838. * @param url defines the url to load from
  66839. * @param image defines the target DOM image
  66840. */
  66841. loadImage(url: string, image: HTMLImageElement): void;
  66842. /**
  66843. * Loads a file from offline support
  66844. * @param url defines the URL to load from
  66845. * @param sceneLoaded defines a callback to call on success
  66846. * @param progressCallBack defines a callback to call when progress changed
  66847. * @param errorCallback defines a callback to call on error
  66848. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  66849. */
  66850. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  66851. }
  66852. }
  66853. declare module BABYLON {
  66854. /**
  66855. * A class serves as a medium between the observable and its observers
  66856. */
  66857. export class EventState {
  66858. /**
  66859. * Create a new EventState
  66860. * @param mask defines the mask associated with this state
  66861. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  66862. * @param target defines the original target of the state
  66863. * @param currentTarget defines the current target of the state
  66864. */
  66865. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  66866. /**
  66867. * Initialize the current event state
  66868. * @param mask defines the mask associated with this state
  66869. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  66870. * @param target defines the original target of the state
  66871. * @param currentTarget defines the current target of the state
  66872. * @returns the current event state
  66873. */
  66874. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  66875. /**
  66876. * An Observer can set this property to true to prevent subsequent observers of being notified
  66877. */
  66878. skipNextObservers: boolean;
  66879. /**
  66880. * Get the mask value that were used to trigger the event corresponding to this EventState object
  66881. */
  66882. mask: number;
  66883. /**
  66884. * The object that originally notified the event
  66885. */
  66886. target?: any;
  66887. /**
  66888. * The current object in the bubbling phase
  66889. */
  66890. currentTarget?: any;
  66891. /**
  66892. * This will be populated with the return value of the last function that was executed.
  66893. * If it is the first function in the callback chain it will be the event data.
  66894. */
  66895. lastReturnValue?: any;
  66896. }
  66897. /**
  66898. * Represent an Observer registered to a given Observable object.
  66899. */
  66900. export class Observer<T> {
  66901. /**
  66902. * Defines the callback to call when the observer is notified
  66903. */
  66904. callback: (eventData: T, eventState: EventState) => void;
  66905. /**
  66906. * Defines the mask of the observer (used to filter notifications)
  66907. */
  66908. mask: number;
  66909. /**
  66910. * Defines the current scope used to restore the JS context
  66911. */
  66912. scope: any;
  66913. /** @hidden */
  66914. _willBeUnregistered: boolean;
  66915. /**
  66916. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  66917. */
  66918. unregisterOnNextCall: boolean;
  66919. /**
  66920. * Creates a new observer
  66921. * @param callback defines the callback to call when the observer is notified
  66922. * @param mask defines the mask of the observer (used to filter notifications)
  66923. * @param scope defines the current scope used to restore the JS context
  66924. */
  66925. constructor(
  66926. /**
  66927. * Defines the callback to call when the observer is notified
  66928. */
  66929. callback: (eventData: T, eventState: EventState) => void,
  66930. /**
  66931. * Defines the mask of the observer (used to filter notifications)
  66932. */
  66933. mask: number,
  66934. /**
  66935. * Defines the current scope used to restore the JS context
  66936. */
  66937. scope?: any);
  66938. }
  66939. /**
  66940. * Represent a list of observers registered to multiple Observables object.
  66941. */
  66942. export class MultiObserver<T> {
  66943. private _observers;
  66944. private _observables;
  66945. /**
  66946. * Release associated resources
  66947. */
  66948. dispose(): void;
  66949. /**
  66950. * Raise a callback when one of the observable will notify
  66951. * @param observables defines a list of observables to watch
  66952. * @param callback defines the callback to call on notification
  66953. * @param mask defines the mask used to filter notifications
  66954. * @param scope defines the current scope used to restore the JS context
  66955. * @returns the new MultiObserver
  66956. */
  66957. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  66958. }
  66959. /**
  66960. * The Observable class is a simple implementation of the Observable pattern.
  66961. *
  66962. * 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.
  66963. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  66964. * 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).
  66965. * 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.
  66966. */
  66967. export class Observable<T> {
  66968. private _observers;
  66969. private _eventState;
  66970. private _onObserverAdded;
  66971. /**
  66972. * Creates a new observable
  66973. * @param onObserverAdded defines a callback to call when a new observer is added
  66974. */
  66975. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  66976. /**
  66977. * Create a new Observer with the specified callback
  66978. * @param callback the callback that will be executed for that Observer
  66979. * @param mask the mask used to filter observers
  66980. * @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.
  66981. * @param scope optional scope for the callback to be called from
  66982. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  66983. * @returns the new observer created for the callback
  66984. */
  66985. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  66986. /**
  66987. * Create a new Observer with the specified callback and unregisters after the next notification
  66988. * @param callback the callback that will be executed for that Observer
  66989. * @returns the new observer created for the callback
  66990. */
  66991. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  66992. /**
  66993. * Remove an Observer from the Observable object
  66994. * @param observer the instance of the Observer to remove
  66995. * @returns false if it doesn't belong to this Observable
  66996. */
  66997. remove(observer: Nullable<Observer<T>>): boolean;
  66998. /**
  66999. * Remove a callback from the Observable object
  67000. * @param callback the callback to remove
  67001. * @param scope optional scope. If used only the callbacks with this scope will be removed
  67002. * @returns false if it doesn't belong to this Observable
  67003. */
  67004. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  67005. private _deferUnregister;
  67006. private _remove;
  67007. /**
  67008. * Moves the observable to the top of the observer list making it get called first when notified
  67009. * @param observer the observer to move
  67010. */
  67011. makeObserverTopPriority(observer: Observer<T>): void;
  67012. /**
  67013. * Moves the observable to the bottom of the observer list making it get called last when notified
  67014. * @param observer the observer to move
  67015. */
  67016. makeObserverBottomPriority(observer: Observer<T>): void;
  67017. /**
  67018. * Notify all Observers by calling their respective callback with the given data
  67019. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  67020. * @param eventData defines the data to send to all observers
  67021. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  67022. * @param target defines the original target of the state
  67023. * @param currentTarget defines the current target of the state
  67024. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  67025. */
  67026. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  67027. /**
  67028. * Calling this will execute each callback, expecting it to be a promise or return a value.
  67029. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  67030. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  67031. * and it is crucial that all callbacks will be executed.
  67032. * The order of the callbacks is kept, callbacks are not executed parallel.
  67033. *
  67034. * @param eventData The data to be sent to each callback
  67035. * @param mask is used to filter observers defaults to -1
  67036. * @param target defines the callback target (see EventState)
  67037. * @param currentTarget defines he current object in the bubbling phase
  67038. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  67039. */
  67040. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  67041. /**
  67042. * Notify a specific observer
  67043. * @param observer defines the observer to notify
  67044. * @param eventData defines the data to be sent to each callback
  67045. * @param mask is used to filter observers defaults to -1
  67046. */
  67047. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  67048. /**
  67049. * Gets a boolean indicating if the observable has at least one observer
  67050. * @returns true is the Observable has at least one Observer registered
  67051. */
  67052. hasObservers(): boolean;
  67053. /**
  67054. * Clear the list of observers
  67055. */
  67056. clear(): void;
  67057. /**
  67058. * Clone the current observable
  67059. * @returns a new observable
  67060. */
  67061. clone(): Observable<T>;
  67062. /**
  67063. * Does this observable handles observer registered with a given mask
  67064. * @param mask defines the mask to be tested
  67065. * @return whether or not one observer registered with the given mask is handeled
  67066. **/
  67067. hasSpecificMask(mask?: number): boolean;
  67068. }
  67069. }
  67070. declare module BABYLON {
  67071. /**
  67072. * Class used to help managing file picking and drag'n'drop
  67073. * File Storage
  67074. */
  67075. export class FilesInputStore {
  67076. /**
  67077. * List of files ready to be loaded
  67078. */
  67079. static FilesToLoad: {
  67080. [key: string]: File;
  67081. };
  67082. }
  67083. }
  67084. declare module BABYLON {
  67085. /** Defines the cross module used constants to avoid circular dependncies */
  67086. export class Constants {
  67087. /** Defines that alpha blending is disabled */
  67088. static readonly ALPHA_DISABLE: number;
  67089. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  67090. static readonly ALPHA_ADD: number;
  67091. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  67092. static readonly ALPHA_COMBINE: number;
  67093. /** Defines that alpha blending to DEST - SRC * DEST */
  67094. static readonly ALPHA_SUBTRACT: number;
  67095. /** Defines that alpha blending to SRC * DEST */
  67096. static readonly ALPHA_MULTIPLY: number;
  67097. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  67098. static readonly ALPHA_MAXIMIZED: number;
  67099. /** Defines that alpha blending to SRC + DEST */
  67100. static readonly ALPHA_ONEONE: number;
  67101. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  67102. static readonly ALPHA_PREMULTIPLIED: number;
  67103. /**
  67104. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  67105. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  67106. */
  67107. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  67108. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  67109. static readonly ALPHA_INTERPOLATE: number;
  67110. /**
  67111. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  67112. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  67113. */
  67114. static readonly ALPHA_SCREENMODE: number;
  67115. /** Defines that the ressource is not delayed*/
  67116. static readonly DELAYLOADSTATE_NONE: number;
  67117. /** Defines that the ressource was successfully delay loaded */
  67118. static readonly DELAYLOADSTATE_LOADED: number;
  67119. /** Defines that the ressource is currently delay loading */
  67120. static readonly DELAYLOADSTATE_LOADING: number;
  67121. /** Defines that the ressource is delayed and has not started loading */
  67122. static readonly DELAYLOADSTATE_NOTLOADED: number;
  67123. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  67124. static readonly NEVER: number;
  67125. /** 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 */
  67126. static readonly ALWAYS: number;
  67127. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  67128. static readonly LESS: number;
  67129. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  67130. static readonly EQUAL: number;
  67131. /** 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 */
  67132. static readonly LEQUAL: number;
  67133. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  67134. static readonly GREATER: number;
  67135. /** 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 */
  67136. static readonly GEQUAL: number;
  67137. /** 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 */
  67138. static readonly NOTEQUAL: number;
  67139. /** Passed to stencilOperation to specify that stencil value must be kept */
  67140. static readonly KEEP: number;
  67141. /** Passed to stencilOperation to specify that stencil value must be replaced */
  67142. static readonly REPLACE: number;
  67143. /** Passed to stencilOperation to specify that stencil value must be incremented */
  67144. static readonly INCR: number;
  67145. /** Passed to stencilOperation to specify that stencil value must be decremented */
  67146. static readonly DECR: number;
  67147. /** Passed to stencilOperation to specify that stencil value must be inverted */
  67148. static readonly INVERT: number;
  67149. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  67150. static readonly INCR_WRAP: number;
  67151. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  67152. static readonly DECR_WRAP: number;
  67153. /** Texture is not repeating outside of 0..1 UVs */
  67154. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  67155. /** Texture is repeating outside of 0..1 UVs */
  67156. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  67157. /** Texture is repeating and mirrored */
  67158. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  67159. /** ALPHA */
  67160. static readonly TEXTUREFORMAT_ALPHA: number;
  67161. /** LUMINANCE */
  67162. static readonly TEXTUREFORMAT_LUMINANCE: number;
  67163. /** LUMINANCE_ALPHA */
  67164. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  67165. /** RGB */
  67166. static readonly TEXTUREFORMAT_RGB: number;
  67167. /** RGBA */
  67168. static readonly TEXTUREFORMAT_RGBA: number;
  67169. /** RED */
  67170. static readonly TEXTUREFORMAT_RED: number;
  67171. /** RED (2nd reference) */
  67172. static readonly TEXTUREFORMAT_R: number;
  67173. /** RG */
  67174. static readonly TEXTUREFORMAT_RG: number;
  67175. /** RED_INTEGER */
  67176. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  67177. /** RED_INTEGER (2nd reference) */
  67178. static readonly TEXTUREFORMAT_R_INTEGER: number;
  67179. /** RG_INTEGER */
  67180. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  67181. /** RGB_INTEGER */
  67182. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  67183. /** RGBA_INTEGER */
  67184. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  67185. /** UNSIGNED_BYTE */
  67186. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  67187. /** UNSIGNED_BYTE (2nd reference) */
  67188. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  67189. /** FLOAT */
  67190. static readonly TEXTURETYPE_FLOAT: number;
  67191. /** HALF_FLOAT */
  67192. static readonly TEXTURETYPE_HALF_FLOAT: number;
  67193. /** BYTE */
  67194. static readonly TEXTURETYPE_BYTE: number;
  67195. /** SHORT */
  67196. static readonly TEXTURETYPE_SHORT: number;
  67197. /** UNSIGNED_SHORT */
  67198. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  67199. /** INT */
  67200. static readonly TEXTURETYPE_INT: number;
  67201. /** UNSIGNED_INT */
  67202. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  67203. /** UNSIGNED_SHORT_4_4_4_4 */
  67204. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  67205. /** UNSIGNED_SHORT_5_5_5_1 */
  67206. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  67207. /** UNSIGNED_SHORT_5_6_5 */
  67208. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  67209. /** UNSIGNED_INT_2_10_10_10_REV */
  67210. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  67211. /** UNSIGNED_INT_24_8 */
  67212. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  67213. /** UNSIGNED_INT_10F_11F_11F_REV */
  67214. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  67215. /** UNSIGNED_INT_5_9_9_9_REV */
  67216. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  67217. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  67218. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  67219. /** nearest is mag = nearest and min = nearest and mip = linear */
  67220. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  67221. /** Bilinear is mag = linear and min = linear and mip = nearest */
  67222. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  67223. /** Trilinear is mag = linear and min = linear and mip = linear */
  67224. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  67225. /** nearest is mag = nearest and min = nearest and mip = linear */
  67226. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  67227. /** Bilinear is mag = linear and min = linear and mip = nearest */
  67228. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  67229. /** Trilinear is mag = linear and min = linear and mip = linear */
  67230. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  67231. /** mag = nearest and min = nearest and mip = nearest */
  67232. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  67233. /** mag = nearest and min = linear and mip = nearest */
  67234. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  67235. /** mag = nearest and min = linear and mip = linear */
  67236. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  67237. /** mag = nearest and min = linear and mip = none */
  67238. static readonly TEXTURE_NEAREST_LINEAR: number;
  67239. /** mag = nearest and min = nearest and mip = none */
  67240. static readonly TEXTURE_NEAREST_NEAREST: number;
  67241. /** mag = linear and min = nearest and mip = nearest */
  67242. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  67243. /** mag = linear and min = nearest and mip = linear */
  67244. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  67245. /** mag = linear and min = linear and mip = none */
  67246. static readonly TEXTURE_LINEAR_LINEAR: number;
  67247. /** mag = linear and min = nearest and mip = none */
  67248. static readonly TEXTURE_LINEAR_NEAREST: number;
  67249. /** Explicit coordinates mode */
  67250. static readonly TEXTURE_EXPLICIT_MODE: number;
  67251. /** Spherical coordinates mode */
  67252. static readonly TEXTURE_SPHERICAL_MODE: number;
  67253. /** Planar coordinates mode */
  67254. static readonly TEXTURE_PLANAR_MODE: number;
  67255. /** Cubic coordinates mode */
  67256. static readonly TEXTURE_CUBIC_MODE: number;
  67257. /** Projection coordinates mode */
  67258. static readonly TEXTURE_PROJECTION_MODE: number;
  67259. /** Skybox coordinates mode */
  67260. static readonly TEXTURE_SKYBOX_MODE: number;
  67261. /** Inverse Cubic coordinates mode */
  67262. static readonly TEXTURE_INVCUBIC_MODE: number;
  67263. /** Equirectangular coordinates mode */
  67264. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  67265. /** Equirectangular Fixed coordinates mode */
  67266. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  67267. /** Equirectangular Fixed Mirrored coordinates mode */
  67268. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  67269. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  67270. static readonly SCALEMODE_FLOOR: number;
  67271. /** Defines that texture rescaling will look for the nearest power of 2 size */
  67272. static readonly SCALEMODE_NEAREST: number;
  67273. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  67274. static readonly SCALEMODE_CEILING: number;
  67275. /**
  67276. * The dirty texture flag value
  67277. */
  67278. static readonly MATERIAL_TextureDirtyFlag: number;
  67279. /**
  67280. * The dirty light flag value
  67281. */
  67282. static readonly MATERIAL_LightDirtyFlag: number;
  67283. /**
  67284. * The dirty fresnel flag value
  67285. */
  67286. static readonly MATERIAL_FresnelDirtyFlag: number;
  67287. /**
  67288. * The dirty attribute flag value
  67289. */
  67290. static readonly MATERIAL_AttributesDirtyFlag: number;
  67291. /**
  67292. * The dirty misc flag value
  67293. */
  67294. static readonly MATERIAL_MiscDirtyFlag: number;
  67295. /**
  67296. * The all dirty flag value
  67297. */
  67298. static readonly MATERIAL_AllDirtyFlag: number;
  67299. /**
  67300. * Returns the triangle fill mode
  67301. */
  67302. static readonly MATERIAL_TriangleFillMode: number;
  67303. /**
  67304. * Returns the wireframe mode
  67305. */
  67306. static readonly MATERIAL_WireFrameFillMode: number;
  67307. /**
  67308. * Returns the point fill mode
  67309. */
  67310. static readonly MATERIAL_PointFillMode: number;
  67311. /**
  67312. * Returns the point list draw mode
  67313. */
  67314. static readonly MATERIAL_PointListDrawMode: number;
  67315. /**
  67316. * Returns the line list draw mode
  67317. */
  67318. static readonly MATERIAL_LineListDrawMode: number;
  67319. /**
  67320. * Returns the line loop draw mode
  67321. */
  67322. static readonly MATERIAL_LineLoopDrawMode: number;
  67323. /**
  67324. * Returns the line strip draw mode
  67325. */
  67326. static readonly MATERIAL_LineStripDrawMode: number;
  67327. /**
  67328. * Returns the triangle strip draw mode
  67329. */
  67330. static readonly MATERIAL_TriangleStripDrawMode: number;
  67331. /**
  67332. * Returns the triangle fan draw mode
  67333. */
  67334. static readonly MATERIAL_TriangleFanDrawMode: number;
  67335. /**
  67336. * Stores the clock-wise side orientation
  67337. */
  67338. static readonly MATERIAL_ClockWiseSideOrientation: number;
  67339. /**
  67340. * Stores the counter clock-wise side orientation
  67341. */
  67342. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  67343. /**
  67344. * Nothing
  67345. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67346. */
  67347. static readonly ACTION_NothingTrigger: number;
  67348. /**
  67349. * On pick
  67350. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67351. */
  67352. static readonly ACTION_OnPickTrigger: number;
  67353. /**
  67354. * On left pick
  67355. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67356. */
  67357. static readonly ACTION_OnLeftPickTrigger: number;
  67358. /**
  67359. * On right pick
  67360. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67361. */
  67362. static readonly ACTION_OnRightPickTrigger: number;
  67363. /**
  67364. * On center pick
  67365. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67366. */
  67367. static readonly ACTION_OnCenterPickTrigger: number;
  67368. /**
  67369. * On pick down
  67370. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67371. */
  67372. static readonly ACTION_OnPickDownTrigger: number;
  67373. /**
  67374. * On double pick
  67375. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67376. */
  67377. static readonly ACTION_OnDoublePickTrigger: number;
  67378. /**
  67379. * On pick up
  67380. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67381. */
  67382. static readonly ACTION_OnPickUpTrigger: number;
  67383. /**
  67384. * On pick out.
  67385. * This trigger will only be raised if you also declared a OnPickDown
  67386. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67387. */
  67388. static readonly ACTION_OnPickOutTrigger: number;
  67389. /**
  67390. * On long press
  67391. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67392. */
  67393. static readonly ACTION_OnLongPressTrigger: number;
  67394. /**
  67395. * On pointer over
  67396. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67397. */
  67398. static readonly ACTION_OnPointerOverTrigger: number;
  67399. /**
  67400. * On pointer out
  67401. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67402. */
  67403. static readonly ACTION_OnPointerOutTrigger: number;
  67404. /**
  67405. * On every frame
  67406. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67407. */
  67408. static readonly ACTION_OnEveryFrameTrigger: number;
  67409. /**
  67410. * On intersection enter
  67411. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67412. */
  67413. static readonly ACTION_OnIntersectionEnterTrigger: number;
  67414. /**
  67415. * On intersection exit
  67416. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67417. */
  67418. static readonly ACTION_OnIntersectionExitTrigger: number;
  67419. /**
  67420. * On key down
  67421. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67422. */
  67423. static readonly ACTION_OnKeyDownTrigger: number;
  67424. /**
  67425. * On key up
  67426. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67427. */
  67428. static readonly ACTION_OnKeyUpTrigger: number;
  67429. /**
  67430. * Billboard mode will only apply to Y axis
  67431. */
  67432. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  67433. /**
  67434. * Billboard mode will apply to all axes
  67435. */
  67436. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  67437. /**
  67438. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  67439. */
  67440. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  67441. /**
  67442. * Gets or sets base Assets URL
  67443. */
  67444. static PARTICLES_BaseAssetsUrl: string;
  67445. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  67446. * Test order :
  67447. * Is the bounding sphere outside the frustum ?
  67448. * If not, are the bounding box vertices outside the frustum ?
  67449. * It not, then the cullable object is in the frustum.
  67450. */
  67451. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  67452. /** Culling strategy : Bounding Sphere Only.
  67453. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  67454. * It's also less accurate than the standard because some not visible objects can still be selected.
  67455. * Test : is the bounding sphere outside the frustum ?
  67456. * If not, then the cullable object is in the frustum.
  67457. */
  67458. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  67459. /** Culling strategy : Optimistic Inclusion.
  67460. * This in an inclusion test first, then the standard exclusion test.
  67461. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  67462. * 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.
  67463. * Anyway, it's as accurate as the standard strategy.
  67464. * Test :
  67465. * Is the cullable object bounding sphere center in the frustum ?
  67466. * If not, apply the default culling strategy.
  67467. */
  67468. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  67469. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  67470. * This in an inclusion test first, then the bounding sphere only exclusion test.
  67471. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  67472. * 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.
  67473. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  67474. * Test :
  67475. * Is the cullable object bounding sphere center in the frustum ?
  67476. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  67477. */
  67478. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  67479. /**
  67480. * No logging while loading
  67481. */
  67482. static readonly SCENELOADER_NO_LOGGING: number;
  67483. /**
  67484. * Minimal logging while loading
  67485. */
  67486. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  67487. /**
  67488. * Summary logging while loading
  67489. */
  67490. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  67491. /**
  67492. * Detailled logging while loading
  67493. */
  67494. static readonly SCENELOADER_DETAILED_LOGGING: number;
  67495. }
  67496. }
  67497. declare module BABYLON {
  67498. /**
  67499. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  67500. * Babylon.js
  67501. */
  67502. export class DomManagement {
  67503. /**
  67504. * Checks if the window object exists
  67505. * @returns true if the window object exists
  67506. */
  67507. static IsWindowObjectExist(): boolean;
  67508. /**
  67509. * Extracts text content from a DOM element hierarchy
  67510. * @param element defines the root element
  67511. * @returns a string
  67512. */
  67513. static GetDOMTextContent(element: HTMLElement): string;
  67514. }
  67515. }
  67516. declare module BABYLON {
  67517. /**
  67518. * Logger used througouht the application to allow configuration of
  67519. * the log level required for the messages.
  67520. */
  67521. export class Logger {
  67522. /**
  67523. * No log
  67524. */
  67525. static readonly NoneLogLevel: number;
  67526. /**
  67527. * Only message logs
  67528. */
  67529. static readonly MessageLogLevel: number;
  67530. /**
  67531. * Only warning logs
  67532. */
  67533. static readonly WarningLogLevel: number;
  67534. /**
  67535. * Only error logs
  67536. */
  67537. static readonly ErrorLogLevel: number;
  67538. /**
  67539. * All logs
  67540. */
  67541. static readonly AllLogLevel: number;
  67542. private static _LogCache;
  67543. /**
  67544. * Gets a value indicating the number of loading errors
  67545. * @ignorenaming
  67546. */
  67547. static errorsCount: number;
  67548. /**
  67549. * Callback called when a new log is added
  67550. */
  67551. static OnNewCacheEntry: (entry: string) => void;
  67552. private static _AddLogEntry;
  67553. private static _FormatMessage;
  67554. private static _LogDisabled;
  67555. private static _LogEnabled;
  67556. private static _WarnDisabled;
  67557. private static _WarnEnabled;
  67558. private static _ErrorDisabled;
  67559. private static _ErrorEnabled;
  67560. /**
  67561. * Log a message to the console
  67562. */
  67563. static Log: (message: string) => void;
  67564. /**
  67565. * Write a warning message to the console
  67566. */
  67567. static Warn: (message: string) => void;
  67568. /**
  67569. * Write an error message to the console
  67570. */
  67571. static Error: (message: string) => void;
  67572. /**
  67573. * Gets current log cache (list of logs)
  67574. */
  67575. static readonly LogCache: string;
  67576. /**
  67577. * Clears the log cache
  67578. */
  67579. static ClearLogCache(): void;
  67580. /**
  67581. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  67582. */
  67583. static LogLevels: number;
  67584. }
  67585. }
  67586. declare module BABYLON {
  67587. /** @hidden */
  67588. export class _TypeStore {
  67589. /** @hidden */
  67590. static RegisteredTypes: {
  67591. [key: string]: Object;
  67592. };
  67593. /** @hidden */
  67594. static GetClass(fqdn: string): any;
  67595. }
  67596. }
  67597. declare module BABYLON {
  67598. /**
  67599. * Class containing a set of static utilities functions for deep copy.
  67600. */
  67601. export class DeepCopier {
  67602. /**
  67603. * Tries to copy an object by duplicating every property
  67604. * @param source defines the source object
  67605. * @param destination defines the target object
  67606. * @param doNotCopyList defines a list of properties to avoid
  67607. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  67608. */
  67609. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  67610. }
  67611. }
  67612. declare module BABYLON {
  67613. /**
  67614. * Class containing a set of static utilities functions for precision date
  67615. */
  67616. export class PrecisionDate {
  67617. /**
  67618. * Gets either window.performance.now() if supported or Date.now() else
  67619. */
  67620. static readonly Now: number;
  67621. }
  67622. }
  67623. declare module BABYLON {
  67624. /** @hidden */
  67625. export class _DevTools {
  67626. static WarnImport(name: string): string;
  67627. }
  67628. }
  67629. declare module BABYLON {
  67630. /**
  67631. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  67632. */
  67633. export class WebRequest {
  67634. private _xhr;
  67635. /**
  67636. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  67637. * i.e. when loading files, where the server/service expects an Authorization header
  67638. */
  67639. static CustomRequestHeaders: {
  67640. [key: string]: string;
  67641. };
  67642. /**
  67643. * Add callback functions in this array to update all the requests before they get sent to the network
  67644. */
  67645. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  67646. private _injectCustomRequestHeaders;
  67647. /**
  67648. * Gets or sets a function to be called when loading progress changes
  67649. */
  67650. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  67651. /**
  67652. * Returns client's state
  67653. */
  67654. readonly readyState: number;
  67655. /**
  67656. * Returns client's status
  67657. */
  67658. readonly status: number;
  67659. /**
  67660. * Returns client's status as a text
  67661. */
  67662. readonly statusText: string;
  67663. /**
  67664. * Returns client's response
  67665. */
  67666. readonly response: any;
  67667. /**
  67668. * Returns client's response url
  67669. */
  67670. readonly responseURL: string;
  67671. /**
  67672. * Returns client's response as text
  67673. */
  67674. readonly responseText: string;
  67675. /**
  67676. * Gets or sets the expected response type
  67677. */
  67678. responseType: XMLHttpRequestResponseType;
  67679. /** @hidden */
  67680. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  67681. /** @hidden */
  67682. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  67683. /**
  67684. * Cancels any network activity
  67685. */
  67686. abort(): void;
  67687. /**
  67688. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  67689. * @param body defines an optional request body
  67690. */
  67691. send(body?: Document | BodyInit | null): void;
  67692. /**
  67693. * Sets the request method, request URL
  67694. * @param method defines the method to use (GET, POST, etc..)
  67695. * @param url defines the url to connect with
  67696. */
  67697. open(method: string, url: string): void;
  67698. }
  67699. }
  67700. declare module BABYLON {
  67701. /**
  67702. * Class used to evalaute queries containing `and` and `or` operators
  67703. */
  67704. export class AndOrNotEvaluator {
  67705. /**
  67706. * Evaluate a query
  67707. * @param query defines the query to evaluate
  67708. * @param evaluateCallback defines the callback used to filter result
  67709. * @returns true if the query matches
  67710. */
  67711. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  67712. private static _HandleParenthesisContent;
  67713. private static _SimplifyNegation;
  67714. }
  67715. }
  67716. declare module BABYLON {
  67717. /**
  67718. * Class used to store custom tags
  67719. */
  67720. export class Tags {
  67721. /**
  67722. * Adds support for tags on the given object
  67723. * @param obj defines the object to use
  67724. */
  67725. static EnableFor(obj: any): void;
  67726. /**
  67727. * Removes tags support
  67728. * @param obj defines the object to use
  67729. */
  67730. static DisableFor(obj: any): void;
  67731. /**
  67732. * Gets a boolean indicating if the given object has tags
  67733. * @param obj defines the object to use
  67734. * @returns a boolean
  67735. */
  67736. static HasTags(obj: any): boolean;
  67737. /**
  67738. * Gets the tags available on a given object
  67739. * @param obj defines the object to use
  67740. * @param asString defines if the tags must be returned as a string instead of an array of strings
  67741. * @returns the tags
  67742. */
  67743. static GetTags(obj: any, asString?: boolean): any;
  67744. /**
  67745. * Adds tags to an object
  67746. * @param obj defines the object to use
  67747. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  67748. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  67749. */
  67750. static AddTagsTo(obj: any, tagsString: string): void;
  67751. /**
  67752. * @hidden
  67753. */
  67754. static _AddTagTo(obj: any, tag: string): void;
  67755. /**
  67756. * Removes specific tags from a specific object
  67757. * @param obj defines the object to use
  67758. * @param tagsString defines the tags to remove
  67759. */
  67760. static RemoveTagsFrom(obj: any, tagsString: string): void;
  67761. /**
  67762. * @hidden
  67763. */
  67764. static _RemoveTagFrom(obj: any, tag: string): void;
  67765. /**
  67766. * Defines if tags hosted on an object match a given query
  67767. * @param obj defines the object to use
  67768. * @param tagsQuery defines the tag query
  67769. * @returns a boolean
  67770. */
  67771. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  67772. }
  67773. }
  67774. declare module BABYLON {
  67775. /**
  67776. * Manages the defines for the Material
  67777. */
  67778. export class MaterialDefines {
  67779. /** @hidden */
  67780. protected _keys: string[];
  67781. private _isDirty;
  67782. /** @hidden */
  67783. _renderId: number;
  67784. /** @hidden */
  67785. _areLightsDirty: boolean;
  67786. /** @hidden */
  67787. _areAttributesDirty: boolean;
  67788. /** @hidden */
  67789. _areTexturesDirty: boolean;
  67790. /** @hidden */
  67791. _areFresnelDirty: boolean;
  67792. /** @hidden */
  67793. _areMiscDirty: boolean;
  67794. /** @hidden */
  67795. _areImageProcessingDirty: boolean;
  67796. /** @hidden */
  67797. _normals: boolean;
  67798. /** @hidden */
  67799. _uvs: boolean;
  67800. /** @hidden */
  67801. _needNormals: boolean;
  67802. /** @hidden */
  67803. _needUVs: boolean;
  67804. [id: string]: any;
  67805. /**
  67806. * Specifies if the material needs to be re-calculated
  67807. */
  67808. readonly isDirty: boolean;
  67809. /**
  67810. * Marks the material to indicate that it has been re-calculated
  67811. */
  67812. markAsProcessed(): void;
  67813. /**
  67814. * Marks the material to indicate that it needs to be re-calculated
  67815. */
  67816. markAsUnprocessed(): void;
  67817. /**
  67818. * Marks the material to indicate all of its defines need to be re-calculated
  67819. */
  67820. markAllAsDirty(): void;
  67821. /**
  67822. * Marks the material to indicate that image processing needs to be re-calculated
  67823. */
  67824. markAsImageProcessingDirty(): void;
  67825. /**
  67826. * Marks the material to indicate the lights need to be re-calculated
  67827. */
  67828. markAsLightDirty(): void;
  67829. /**
  67830. * Marks the attribute state as changed
  67831. */
  67832. markAsAttributesDirty(): void;
  67833. /**
  67834. * Marks the texture state as changed
  67835. */
  67836. markAsTexturesDirty(): void;
  67837. /**
  67838. * Marks the fresnel state as changed
  67839. */
  67840. markAsFresnelDirty(): void;
  67841. /**
  67842. * Marks the misc state as changed
  67843. */
  67844. markAsMiscDirty(): void;
  67845. /**
  67846. * Rebuilds the material defines
  67847. */
  67848. rebuild(): void;
  67849. /**
  67850. * Specifies if two material defines are equal
  67851. * @param other - A material define instance to compare to
  67852. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  67853. */
  67854. isEqual(other: MaterialDefines): boolean;
  67855. /**
  67856. * Clones this instance's defines to another instance
  67857. * @param other - material defines to clone values to
  67858. */
  67859. cloneTo(other: MaterialDefines): void;
  67860. /**
  67861. * Resets the material define values
  67862. */
  67863. reset(): void;
  67864. /**
  67865. * Converts the material define values to a string
  67866. * @returns - String of material define information
  67867. */
  67868. toString(): string;
  67869. }
  67870. }
  67871. declare module BABYLON {
  67872. /**
  67873. * Class used to store and describe the pipeline context associated with an effect
  67874. */
  67875. export interface IPipelineContext {
  67876. /**
  67877. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  67878. */
  67879. isAsync: boolean;
  67880. /**
  67881. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  67882. */
  67883. isReady: boolean;
  67884. /** @hidden */
  67885. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  67886. }
  67887. }
  67888. declare module BABYLON {
  67889. /**
  67890. * Class used to store gfx data (like WebGLBuffer)
  67891. */
  67892. export class DataBuffer {
  67893. /**
  67894. * Gets or sets the number of objects referencing this buffer
  67895. */
  67896. references: number;
  67897. /** Gets or sets the size of the underlying buffer */
  67898. capacity: number;
  67899. /**
  67900. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  67901. */
  67902. is32Bits: boolean;
  67903. /**
  67904. * Gets the underlying buffer
  67905. */
  67906. readonly underlyingResource: any;
  67907. }
  67908. }
  67909. declare module BABYLON {
  67910. /** @hidden */
  67911. export interface IShaderProcessor {
  67912. attributeProcessor?: (attribute: string) => string;
  67913. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  67914. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  67915. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  67916. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  67917. lineProcessor?: (line: string, isFragment: boolean) => string;
  67918. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  67919. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  67920. }
  67921. }
  67922. declare module BABYLON {
  67923. /** @hidden */
  67924. export interface ProcessingOptions {
  67925. defines: string[];
  67926. indexParameters: any;
  67927. isFragment: boolean;
  67928. shouldUseHighPrecisionShader: boolean;
  67929. supportsUniformBuffers: boolean;
  67930. shadersRepository: string;
  67931. includesShadersStore: {
  67932. [key: string]: string;
  67933. };
  67934. processor?: IShaderProcessor;
  67935. version: string;
  67936. platformName: string;
  67937. lookForClosingBracketForUniformBuffer?: boolean;
  67938. }
  67939. }
  67940. declare module BABYLON {
  67941. /** @hidden */
  67942. export class ShaderCodeNode {
  67943. line: string;
  67944. children: ShaderCodeNode[];
  67945. additionalDefineKey?: string;
  67946. additionalDefineValue?: string;
  67947. isValid(preprocessors: {
  67948. [key: string]: string;
  67949. }): boolean;
  67950. process(preprocessors: {
  67951. [key: string]: string;
  67952. }, options: ProcessingOptions): string;
  67953. }
  67954. }
  67955. declare module BABYLON {
  67956. /** @hidden */
  67957. export class ShaderCodeCursor {
  67958. private _lines;
  67959. lineIndex: number;
  67960. readonly currentLine: string;
  67961. readonly canRead: boolean;
  67962. lines: string[];
  67963. }
  67964. }
  67965. declare module BABYLON {
  67966. /** @hidden */
  67967. export class ShaderCodeConditionNode extends ShaderCodeNode {
  67968. process(preprocessors: {
  67969. [key: string]: string;
  67970. }, options: ProcessingOptions): string;
  67971. }
  67972. }
  67973. declare module BABYLON {
  67974. /** @hidden */
  67975. export class ShaderDefineExpression {
  67976. isTrue(preprocessors: {
  67977. [key: string]: string;
  67978. }): boolean;
  67979. }
  67980. }
  67981. declare module BABYLON {
  67982. /** @hidden */
  67983. export class ShaderCodeTestNode extends ShaderCodeNode {
  67984. testExpression: ShaderDefineExpression;
  67985. isValid(preprocessors: {
  67986. [key: string]: string;
  67987. }): boolean;
  67988. }
  67989. }
  67990. declare module BABYLON {
  67991. /** @hidden */
  67992. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  67993. define: string;
  67994. not: boolean;
  67995. constructor(define: string, not?: boolean);
  67996. isTrue(preprocessors: {
  67997. [key: string]: string;
  67998. }): boolean;
  67999. }
  68000. }
  68001. declare module BABYLON {
  68002. /** @hidden */
  68003. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  68004. leftOperand: ShaderDefineExpression;
  68005. rightOperand: ShaderDefineExpression;
  68006. isTrue(preprocessors: {
  68007. [key: string]: string;
  68008. }): boolean;
  68009. }
  68010. }
  68011. declare module BABYLON {
  68012. /** @hidden */
  68013. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  68014. leftOperand: ShaderDefineExpression;
  68015. rightOperand: ShaderDefineExpression;
  68016. isTrue(preprocessors: {
  68017. [key: string]: string;
  68018. }): boolean;
  68019. }
  68020. }
  68021. declare module BABYLON {
  68022. /** @hidden */
  68023. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  68024. define: string;
  68025. operand: string;
  68026. testValue: string;
  68027. constructor(define: string, operand: string, testValue: string);
  68028. isTrue(preprocessors: {
  68029. [key: string]: string;
  68030. }): boolean;
  68031. }
  68032. }
  68033. declare module BABYLON {
  68034. /** @hidden */
  68035. export class ShaderProcessor {
  68036. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  68037. private static _ProcessPrecision;
  68038. private static _ExtractOperation;
  68039. private static _BuildSubExpression;
  68040. private static _BuildExpression;
  68041. private static _MoveCursorWithinIf;
  68042. private static _MoveCursor;
  68043. private static _EvaluatePreProcessors;
  68044. private static _PreparePreProcessors;
  68045. private static _ProcessShaderConversion;
  68046. private static _ProcessIncludes;
  68047. }
  68048. }
  68049. declare module BABYLON {
  68050. /**
  68051. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  68052. */
  68053. export class PerformanceMonitor {
  68054. private _enabled;
  68055. private _rollingFrameTime;
  68056. private _lastFrameTimeMs;
  68057. /**
  68058. * constructor
  68059. * @param frameSampleSize The number of samples required to saturate the sliding window
  68060. */
  68061. constructor(frameSampleSize?: number);
  68062. /**
  68063. * Samples current frame
  68064. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  68065. */
  68066. sampleFrame(timeMs?: number): void;
  68067. /**
  68068. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  68069. */
  68070. readonly averageFrameTime: number;
  68071. /**
  68072. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  68073. */
  68074. readonly averageFrameTimeVariance: number;
  68075. /**
  68076. * Returns the frame time of the most recent frame
  68077. */
  68078. readonly instantaneousFrameTime: number;
  68079. /**
  68080. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  68081. */
  68082. readonly averageFPS: number;
  68083. /**
  68084. * Returns the average framerate in frames per second using the most recent frame time
  68085. */
  68086. readonly instantaneousFPS: number;
  68087. /**
  68088. * Returns true if enough samples have been taken to completely fill the sliding window
  68089. */
  68090. readonly isSaturated: boolean;
  68091. /**
  68092. * Enables contributions to the sliding window sample set
  68093. */
  68094. enable(): void;
  68095. /**
  68096. * Disables contributions to the sliding window sample set
  68097. * Samples will not be interpolated over the disabled period
  68098. */
  68099. disable(): void;
  68100. /**
  68101. * Returns true if sampling is enabled
  68102. */
  68103. readonly isEnabled: boolean;
  68104. /**
  68105. * Resets performance monitor
  68106. */
  68107. reset(): void;
  68108. }
  68109. /**
  68110. * RollingAverage
  68111. *
  68112. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  68113. */
  68114. export class RollingAverage {
  68115. /**
  68116. * Current average
  68117. */
  68118. average: number;
  68119. /**
  68120. * Current variance
  68121. */
  68122. variance: number;
  68123. protected _samples: Array<number>;
  68124. protected _sampleCount: number;
  68125. protected _pos: number;
  68126. protected _m2: number;
  68127. /**
  68128. * constructor
  68129. * @param length The number of samples required to saturate the sliding window
  68130. */
  68131. constructor(length: number);
  68132. /**
  68133. * Adds a sample to the sample set
  68134. * @param v The sample value
  68135. */
  68136. add(v: number): void;
  68137. /**
  68138. * Returns previously added values or null if outside of history or outside the sliding window domain
  68139. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  68140. * @return Value previously recorded with add() or null if outside of range
  68141. */
  68142. history(i: number): number;
  68143. /**
  68144. * Returns true if enough samples have been taken to completely fill the sliding window
  68145. * @return true if sample-set saturated
  68146. */
  68147. isSaturated(): boolean;
  68148. /**
  68149. * Resets the rolling average (equivalent to 0 samples taken so far)
  68150. */
  68151. reset(): void;
  68152. /**
  68153. * Wraps a value around the sample range boundaries
  68154. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  68155. * @return Wrapped position in sample range
  68156. */
  68157. protected _wrapPosition(i: number): number;
  68158. }
  68159. }
  68160. declare module BABYLON {
  68161. /**
  68162. * This class implement a typical dictionary using a string as key and the generic type T as value.
  68163. * The underlying implementation relies on an associative array to ensure the best performances.
  68164. * The value can be anything including 'null' but except 'undefined'
  68165. */
  68166. export class StringDictionary<T> {
  68167. /**
  68168. * This will clear this dictionary and copy the content from the 'source' one.
  68169. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  68170. * @param source the dictionary to take the content from and copy to this dictionary
  68171. */
  68172. copyFrom(source: StringDictionary<T>): void;
  68173. /**
  68174. * Get a value based from its key
  68175. * @param key the given key to get the matching value from
  68176. * @return the value if found, otherwise undefined is returned
  68177. */
  68178. get(key: string): T | undefined;
  68179. /**
  68180. * Get a value from its key or add it if it doesn't exist.
  68181. * This method will ensure you that a given key/data will be present in the dictionary.
  68182. * @param key the given key to get the matching value from
  68183. * @param factory the factory that will create the value if the key is not present in the dictionary.
  68184. * The factory will only be invoked if there's no data for the given key.
  68185. * @return the value corresponding to the key.
  68186. */
  68187. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  68188. /**
  68189. * Get a value from its key if present in the dictionary otherwise add it
  68190. * @param key the key to get the value from
  68191. * @param val if there's no such key/value pair in the dictionary add it with this value
  68192. * @return the value corresponding to the key
  68193. */
  68194. getOrAdd(key: string, val: T): T;
  68195. /**
  68196. * Check if there's a given key in the dictionary
  68197. * @param key the key to check for
  68198. * @return true if the key is present, false otherwise
  68199. */
  68200. contains(key: string): boolean;
  68201. /**
  68202. * Add a new key and its corresponding value
  68203. * @param key the key to add
  68204. * @param value the value corresponding to the key
  68205. * @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
  68206. */
  68207. add(key: string, value: T): boolean;
  68208. /**
  68209. * Update a specific value associated to a key
  68210. * @param key defines the key to use
  68211. * @param value defines the value to store
  68212. * @returns true if the value was updated (or false if the key was not found)
  68213. */
  68214. set(key: string, value: T): boolean;
  68215. /**
  68216. * Get the element of the given key and remove it from the dictionary
  68217. * @param key defines the key to search
  68218. * @returns the value associated with the key or null if not found
  68219. */
  68220. getAndRemove(key: string): Nullable<T>;
  68221. /**
  68222. * Remove a key/value from the dictionary.
  68223. * @param key the key to remove
  68224. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  68225. */
  68226. remove(key: string): boolean;
  68227. /**
  68228. * Clear the whole content of the dictionary
  68229. */
  68230. clear(): void;
  68231. /**
  68232. * Gets the current count
  68233. */
  68234. readonly count: number;
  68235. /**
  68236. * Execute a callback on each key/val of the dictionary.
  68237. * Note that you can remove any element in this dictionary in the callback implementation
  68238. * @param callback the callback to execute on a given key/value pair
  68239. */
  68240. forEach(callback: (key: string, val: T) => void): void;
  68241. /**
  68242. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  68243. * If the callback returns null or undefined the method will iterate to the next key/value pair
  68244. * Note that you can remove any element in this dictionary in the callback implementation
  68245. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  68246. * @returns the first item
  68247. */
  68248. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  68249. private _count;
  68250. private _data;
  68251. }
  68252. }
  68253. declare module BABYLON {
  68254. /**
  68255. * Helper class that provides a small promise polyfill
  68256. */
  68257. export class PromisePolyfill {
  68258. /**
  68259. * Static function used to check if the polyfill is required
  68260. * If this is the case then the function will inject the polyfill to window.Promise
  68261. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  68262. */
  68263. static Apply(force?: boolean): void;
  68264. }
  68265. }
  68266. declare module BABYLON {
  68267. /**
  68268. * Class used to store data that will be store in GPU memory
  68269. */
  68270. export class Buffer {
  68271. private _engine;
  68272. private _buffer;
  68273. /** @hidden */
  68274. _data: Nullable<DataArray>;
  68275. private _updatable;
  68276. private _instanced;
  68277. /**
  68278. * Gets the byte stride.
  68279. */
  68280. readonly byteStride: number;
  68281. /**
  68282. * Constructor
  68283. * @param engine the engine
  68284. * @param data the data to use for this buffer
  68285. * @param updatable whether the data is updatable
  68286. * @param stride the stride (optional)
  68287. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  68288. * @param instanced whether the buffer is instanced (optional)
  68289. * @param useBytes set to true if the stride in in bytes (optional)
  68290. */
  68291. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  68292. /**
  68293. * Create a new VertexBuffer based on the current buffer
  68294. * @param kind defines the vertex buffer kind (position, normal, etc.)
  68295. * @param offset defines offset in the buffer (0 by default)
  68296. * @param size defines the size in floats of attributes (position is 3 for instance)
  68297. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  68298. * @param instanced defines if the vertex buffer contains indexed data
  68299. * @param useBytes defines if the offset and stride are in bytes
  68300. * @returns the new vertex buffer
  68301. */
  68302. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  68303. /**
  68304. * Gets a boolean indicating if the Buffer is updatable?
  68305. * @returns true if the buffer is updatable
  68306. */
  68307. isUpdatable(): boolean;
  68308. /**
  68309. * Gets current buffer's data
  68310. * @returns a DataArray or null
  68311. */
  68312. getData(): Nullable<DataArray>;
  68313. /**
  68314. * Gets underlying native buffer
  68315. * @returns underlying native buffer
  68316. */
  68317. getBuffer(): Nullable<DataBuffer>;
  68318. /**
  68319. * Gets the stride in float32 units (i.e. byte stride / 4).
  68320. * May not be an integer if the byte stride is not divisible by 4.
  68321. * DEPRECATED. Use byteStride instead.
  68322. * @returns the stride in float32 units
  68323. */
  68324. getStrideSize(): number;
  68325. /**
  68326. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  68327. * @param data defines the data to store
  68328. */
  68329. create(data?: Nullable<DataArray>): void;
  68330. /** @hidden */
  68331. _rebuild(): void;
  68332. /**
  68333. * Update current buffer data
  68334. * @param data defines the data to store
  68335. */
  68336. update(data: DataArray): void;
  68337. /**
  68338. * Updates the data directly.
  68339. * @param data the new data
  68340. * @param offset the new offset
  68341. * @param vertexCount the vertex count (optional)
  68342. * @param useBytes set to true if the offset is in bytes
  68343. */
  68344. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  68345. /**
  68346. * Release all resources
  68347. */
  68348. dispose(): void;
  68349. }
  68350. /**
  68351. * Specialized buffer used to store vertex data
  68352. */
  68353. export class VertexBuffer {
  68354. /** @hidden */
  68355. _buffer: Buffer;
  68356. private _kind;
  68357. private _size;
  68358. private _ownsBuffer;
  68359. private _instanced;
  68360. private _instanceDivisor;
  68361. /**
  68362. * The byte type.
  68363. */
  68364. static readonly BYTE: number;
  68365. /**
  68366. * The unsigned byte type.
  68367. */
  68368. static readonly UNSIGNED_BYTE: number;
  68369. /**
  68370. * The short type.
  68371. */
  68372. static readonly SHORT: number;
  68373. /**
  68374. * The unsigned short type.
  68375. */
  68376. static readonly UNSIGNED_SHORT: number;
  68377. /**
  68378. * The integer type.
  68379. */
  68380. static readonly INT: number;
  68381. /**
  68382. * The unsigned integer type.
  68383. */
  68384. static readonly UNSIGNED_INT: number;
  68385. /**
  68386. * The float type.
  68387. */
  68388. static readonly FLOAT: number;
  68389. /**
  68390. * Gets or sets the instance divisor when in instanced mode
  68391. */
  68392. instanceDivisor: number;
  68393. /**
  68394. * Gets the byte stride.
  68395. */
  68396. readonly byteStride: number;
  68397. /**
  68398. * Gets the byte offset.
  68399. */
  68400. readonly byteOffset: number;
  68401. /**
  68402. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  68403. */
  68404. readonly normalized: boolean;
  68405. /**
  68406. * Gets the data type of each component in the array.
  68407. */
  68408. readonly type: number;
  68409. /**
  68410. * Constructor
  68411. * @param engine the engine
  68412. * @param data the data to use for this vertex buffer
  68413. * @param kind the vertex buffer kind
  68414. * @param updatable whether the data is updatable
  68415. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  68416. * @param stride the stride (optional)
  68417. * @param instanced whether the buffer is instanced (optional)
  68418. * @param offset the offset of the data (optional)
  68419. * @param size the number of components (optional)
  68420. * @param type the type of the component (optional)
  68421. * @param normalized whether the data contains normalized data (optional)
  68422. * @param useBytes set to true if stride and offset are in bytes (optional)
  68423. */
  68424. 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);
  68425. /** @hidden */
  68426. _rebuild(): void;
  68427. /**
  68428. * Returns the kind of the VertexBuffer (string)
  68429. * @returns a string
  68430. */
  68431. getKind(): string;
  68432. /**
  68433. * Gets a boolean indicating if the VertexBuffer is updatable?
  68434. * @returns true if the buffer is updatable
  68435. */
  68436. isUpdatable(): boolean;
  68437. /**
  68438. * Gets current buffer's data
  68439. * @returns a DataArray or null
  68440. */
  68441. getData(): Nullable<DataArray>;
  68442. /**
  68443. * Gets underlying native buffer
  68444. * @returns underlying native buffer
  68445. */
  68446. getBuffer(): Nullable<DataBuffer>;
  68447. /**
  68448. * Gets the stride in float32 units (i.e. byte stride / 4).
  68449. * May not be an integer if the byte stride is not divisible by 4.
  68450. * DEPRECATED. Use byteStride instead.
  68451. * @returns the stride in float32 units
  68452. */
  68453. getStrideSize(): number;
  68454. /**
  68455. * Returns the offset as a multiple of the type byte length.
  68456. * DEPRECATED. Use byteOffset instead.
  68457. * @returns the offset in bytes
  68458. */
  68459. getOffset(): number;
  68460. /**
  68461. * Returns the number of components per vertex attribute (integer)
  68462. * @returns the size in float
  68463. */
  68464. getSize(): number;
  68465. /**
  68466. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  68467. * @returns true if this buffer is instanced
  68468. */
  68469. getIsInstanced(): boolean;
  68470. /**
  68471. * Returns the instancing divisor, zero for non-instanced (integer).
  68472. * @returns a number
  68473. */
  68474. getInstanceDivisor(): number;
  68475. /**
  68476. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  68477. * @param data defines the data to store
  68478. */
  68479. create(data?: DataArray): void;
  68480. /**
  68481. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  68482. * This function will create a new buffer if the current one is not updatable
  68483. * @param data defines the data to store
  68484. */
  68485. update(data: DataArray): void;
  68486. /**
  68487. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  68488. * Returns the directly updated WebGLBuffer.
  68489. * @param data the new data
  68490. * @param offset the new offset
  68491. * @param useBytes set to true if the offset is in bytes
  68492. */
  68493. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  68494. /**
  68495. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  68496. */
  68497. dispose(): void;
  68498. /**
  68499. * Enumerates each value of this vertex buffer as numbers.
  68500. * @param count the number of values to enumerate
  68501. * @param callback the callback function called for each value
  68502. */
  68503. forEach(count: number, callback: (value: number, index: number) => void): void;
  68504. /**
  68505. * Positions
  68506. */
  68507. static readonly PositionKind: string;
  68508. /**
  68509. * Normals
  68510. */
  68511. static readonly NormalKind: string;
  68512. /**
  68513. * Tangents
  68514. */
  68515. static readonly TangentKind: string;
  68516. /**
  68517. * Texture coordinates
  68518. */
  68519. static readonly UVKind: string;
  68520. /**
  68521. * Texture coordinates 2
  68522. */
  68523. static readonly UV2Kind: string;
  68524. /**
  68525. * Texture coordinates 3
  68526. */
  68527. static readonly UV3Kind: string;
  68528. /**
  68529. * Texture coordinates 4
  68530. */
  68531. static readonly UV4Kind: string;
  68532. /**
  68533. * Texture coordinates 5
  68534. */
  68535. static readonly UV5Kind: string;
  68536. /**
  68537. * Texture coordinates 6
  68538. */
  68539. static readonly UV6Kind: string;
  68540. /**
  68541. * Colors
  68542. */
  68543. static readonly ColorKind: string;
  68544. /**
  68545. * Matrix indices (for bones)
  68546. */
  68547. static readonly MatricesIndicesKind: string;
  68548. /**
  68549. * Matrix weights (for bones)
  68550. */
  68551. static readonly MatricesWeightsKind: string;
  68552. /**
  68553. * Additional matrix indices (for bones)
  68554. */
  68555. static readonly MatricesIndicesExtraKind: string;
  68556. /**
  68557. * Additional matrix weights (for bones)
  68558. */
  68559. static readonly MatricesWeightsExtraKind: string;
  68560. /**
  68561. * Deduces the stride given a kind.
  68562. * @param kind The kind string to deduce
  68563. * @returns The deduced stride
  68564. */
  68565. static DeduceStride(kind: string): number;
  68566. /**
  68567. * Gets the byte length of the given type.
  68568. * @param type the type
  68569. * @returns the number of bytes
  68570. */
  68571. static GetTypeByteLength(type: number): number;
  68572. /**
  68573. * Enumerates each value of the given parameters as numbers.
  68574. * @param data the data to enumerate
  68575. * @param byteOffset the byte offset of the data
  68576. * @param byteStride the byte stride of the data
  68577. * @param componentCount the number of components per element
  68578. * @param componentType the type of the component
  68579. * @param count the number of values to enumerate
  68580. * @param normalized whether the data is normalized
  68581. * @param callback the callback function called for each value
  68582. */
  68583. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  68584. private static _GetFloatValue;
  68585. }
  68586. }
  68587. declare module BABYLON {
  68588. /**
  68589. * Class representing spherical harmonics coefficients to the 3rd degree
  68590. */
  68591. export class SphericalHarmonics {
  68592. /**
  68593. * Defines whether or not the harmonics have been prescaled for rendering.
  68594. */
  68595. preScaled: boolean;
  68596. /**
  68597. * The l0,0 coefficients of the spherical harmonics
  68598. */
  68599. l00: Vector3;
  68600. /**
  68601. * The l1,-1 coefficients of the spherical harmonics
  68602. */
  68603. l1_1: Vector3;
  68604. /**
  68605. * The l1,0 coefficients of the spherical harmonics
  68606. */
  68607. l10: Vector3;
  68608. /**
  68609. * The l1,1 coefficients of the spherical harmonics
  68610. */
  68611. l11: Vector3;
  68612. /**
  68613. * The l2,-2 coefficients of the spherical harmonics
  68614. */
  68615. l2_2: Vector3;
  68616. /**
  68617. * The l2,-1 coefficients of the spherical harmonics
  68618. */
  68619. l2_1: Vector3;
  68620. /**
  68621. * The l2,0 coefficients of the spherical harmonics
  68622. */
  68623. l20: Vector3;
  68624. /**
  68625. * The l2,1 coefficients of the spherical harmonics
  68626. */
  68627. l21: Vector3;
  68628. /**
  68629. * The l2,2 coefficients of the spherical harmonics
  68630. */
  68631. l22: Vector3;
  68632. /**
  68633. * Adds a light to the spherical harmonics
  68634. * @param direction the direction of the light
  68635. * @param color the color of the light
  68636. * @param deltaSolidAngle the delta solid angle of the light
  68637. */
  68638. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  68639. /**
  68640. * Scales the spherical harmonics by the given amount
  68641. * @param scale the amount to scale
  68642. */
  68643. scaleInPlace(scale: number): void;
  68644. /**
  68645. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  68646. *
  68647. * ```
  68648. * E_lm = A_l * L_lm
  68649. * ```
  68650. *
  68651. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  68652. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  68653. * the scaling factors are given in equation 9.
  68654. */
  68655. convertIncidentRadianceToIrradiance(): void;
  68656. /**
  68657. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  68658. *
  68659. * ```
  68660. * L = (1/pi) * E * rho
  68661. * ```
  68662. *
  68663. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  68664. */
  68665. convertIrradianceToLambertianRadiance(): void;
  68666. /**
  68667. * Integrates the reconstruction coefficients directly in to the SH preventing further
  68668. * required operations at run time.
  68669. *
  68670. * This is simply done by scaling back the SH with Ylm constants parameter.
  68671. * The trigonometric part being applied by the shader at run time.
  68672. */
  68673. preScaleForRendering(): void;
  68674. /**
  68675. * Constructs a spherical harmonics from an array.
  68676. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  68677. * @returns the spherical harmonics
  68678. */
  68679. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  68680. /**
  68681. * Gets the spherical harmonics from polynomial
  68682. * @param polynomial the spherical polynomial
  68683. * @returns the spherical harmonics
  68684. */
  68685. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  68686. }
  68687. /**
  68688. * Class representing spherical polynomial coefficients to the 3rd degree
  68689. */
  68690. export class SphericalPolynomial {
  68691. private _harmonics;
  68692. /**
  68693. * The spherical harmonics used to create the polynomials.
  68694. */
  68695. readonly preScaledHarmonics: SphericalHarmonics;
  68696. /**
  68697. * The x coefficients of the spherical polynomial
  68698. */
  68699. x: Vector3;
  68700. /**
  68701. * The y coefficients of the spherical polynomial
  68702. */
  68703. y: Vector3;
  68704. /**
  68705. * The z coefficients of the spherical polynomial
  68706. */
  68707. z: Vector3;
  68708. /**
  68709. * The xx coefficients of the spherical polynomial
  68710. */
  68711. xx: Vector3;
  68712. /**
  68713. * The yy coefficients of the spherical polynomial
  68714. */
  68715. yy: Vector3;
  68716. /**
  68717. * The zz coefficients of the spherical polynomial
  68718. */
  68719. zz: Vector3;
  68720. /**
  68721. * The xy coefficients of the spherical polynomial
  68722. */
  68723. xy: Vector3;
  68724. /**
  68725. * The yz coefficients of the spherical polynomial
  68726. */
  68727. yz: Vector3;
  68728. /**
  68729. * The zx coefficients of the spherical polynomial
  68730. */
  68731. zx: Vector3;
  68732. /**
  68733. * Adds an ambient color to the spherical polynomial
  68734. * @param color the color to add
  68735. */
  68736. addAmbient(color: Color3): void;
  68737. /**
  68738. * Scales the spherical polynomial by the given amount
  68739. * @param scale the amount to scale
  68740. */
  68741. scaleInPlace(scale: number): void;
  68742. /**
  68743. * Gets the spherical polynomial from harmonics
  68744. * @param harmonics the spherical harmonics
  68745. * @returns the spherical polynomial
  68746. */
  68747. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  68748. /**
  68749. * Constructs a spherical polynomial from an array.
  68750. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  68751. * @returns the spherical polynomial
  68752. */
  68753. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  68754. }
  68755. }
  68756. declare module BABYLON {
  68757. /**
  68758. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  68759. */
  68760. export interface CubeMapInfo {
  68761. /**
  68762. * The pixel array for the front face.
  68763. * This is stored in format, left to right, up to down format.
  68764. */
  68765. front: Nullable<ArrayBufferView>;
  68766. /**
  68767. * The pixel array for the back face.
  68768. * This is stored in format, left to right, up to down format.
  68769. */
  68770. back: Nullable<ArrayBufferView>;
  68771. /**
  68772. * The pixel array for the left face.
  68773. * This is stored in format, left to right, up to down format.
  68774. */
  68775. left: Nullable<ArrayBufferView>;
  68776. /**
  68777. * The pixel array for the right face.
  68778. * This is stored in format, left to right, up to down format.
  68779. */
  68780. right: Nullable<ArrayBufferView>;
  68781. /**
  68782. * The pixel array for the up face.
  68783. * This is stored in format, left to right, up to down format.
  68784. */
  68785. up: Nullable<ArrayBufferView>;
  68786. /**
  68787. * The pixel array for the down face.
  68788. * This is stored in format, left to right, up to down format.
  68789. */
  68790. down: Nullable<ArrayBufferView>;
  68791. /**
  68792. * The size of the cubemap stored.
  68793. *
  68794. * Each faces will be size * size pixels.
  68795. */
  68796. size: number;
  68797. /**
  68798. * The format of the texture.
  68799. *
  68800. * RGBA, RGB.
  68801. */
  68802. format: number;
  68803. /**
  68804. * The type of the texture data.
  68805. *
  68806. * UNSIGNED_INT, FLOAT.
  68807. */
  68808. type: number;
  68809. /**
  68810. * Specifies whether the texture is in gamma space.
  68811. */
  68812. gammaSpace: boolean;
  68813. }
  68814. /**
  68815. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  68816. */
  68817. export class PanoramaToCubeMapTools {
  68818. private static FACE_FRONT;
  68819. private static FACE_BACK;
  68820. private static FACE_RIGHT;
  68821. private static FACE_LEFT;
  68822. private static FACE_DOWN;
  68823. private static FACE_UP;
  68824. /**
  68825. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  68826. *
  68827. * @param float32Array The source data.
  68828. * @param inputWidth The width of the input panorama.
  68829. * @param inputHeight The height of the input panorama.
  68830. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  68831. * @return The cubemap data
  68832. */
  68833. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  68834. private static CreateCubemapTexture;
  68835. private static CalcProjectionSpherical;
  68836. }
  68837. }
  68838. declare module BABYLON {
  68839. /**
  68840. * Helper class dealing with the extraction of spherical polynomial dataArray
  68841. * from a cube map.
  68842. */
  68843. export class CubeMapToSphericalPolynomialTools {
  68844. private static FileFaces;
  68845. /**
  68846. * Converts a texture to the according Spherical Polynomial data.
  68847. * This extracts the first 3 orders only as they are the only one used in the lighting.
  68848. *
  68849. * @param texture The texture to extract the information from.
  68850. * @return The Spherical Polynomial data.
  68851. */
  68852. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  68853. /**
  68854. * Converts a cubemap to the according Spherical Polynomial data.
  68855. * This extracts the first 3 orders only as they are the only one used in the lighting.
  68856. *
  68857. * @param cubeInfo The Cube map to extract the information from.
  68858. * @return The Spherical Polynomial data.
  68859. */
  68860. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  68861. }
  68862. }
  68863. declare module BABYLON {
  68864. /**
  68865. * The engine store class is responsible to hold all the instances of Engine and Scene created
  68866. * during the life time of the application.
  68867. */
  68868. export class EngineStore {
  68869. /** Gets the list of created engines */
  68870. static Instances: Engine[];
  68871. /** @hidden */
  68872. static _LastCreatedScene: Nullable<Scene>;
  68873. /**
  68874. * Gets the latest created engine
  68875. */
  68876. static readonly LastCreatedEngine: Nullable<Engine>;
  68877. /**
  68878. * Gets the latest created scene
  68879. */
  68880. static readonly LastCreatedScene: Nullable<Scene>;
  68881. }
  68882. }
  68883. declare module BABYLON {
  68884. /**
  68885. * Define options used to create a render target texture
  68886. */
  68887. export class RenderTargetCreationOptions {
  68888. /**
  68889. * Specifies is mipmaps must be generated
  68890. */
  68891. generateMipMaps?: boolean;
  68892. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  68893. generateDepthBuffer?: boolean;
  68894. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  68895. generateStencilBuffer?: boolean;
  68896. /** Defines texture type (int by default) */
  68897. type?: number;
  68898. /** Defines sampling mode (trilinear by default) */
  68899. samplingMode?: number;
  68900. /** Defines format (RGBA by default) */
  68901. format?: number;
  68902. }
  68903. }
  68904. declare module BABYLON {
  68905. /**
  68906. * @hidden
  68907. **/
  68908. export class _AlphaState {
  68909. private _isAlphaBlendDirty;
  68910. private _isBlendFunctionParametersDirty;
  68911. private _isBlendEquationParametersDirty;
  68912. private _isBlendConstantsDirty;
  68913. private _alphaBlend;
  68914. private _blendFunctionParameters;
  68915. private _blendEquationParameters;
  68916. private _blendConstants;
  68917. /**
  68918. * Initializes the state.
  68919. */
  68920. constructor();
  68921. readonly isDirty: boolean;
  68922. alphaBlend: boolean;
  68923. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  68924. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  68925. setAlphaEquationParameters(rgb: number, alpha: number): void;
  68926. reset(): void;
  68927. apply(gl: WebGLRenderingContext): void;
  68928. }
  68929. }
  68930. declare module BABYLON {
  68931. /**
  68932. * @hidden
  68933. **/
  68934. export class _DepthCullingState {
  68935. private _isDepthTestDirty;
  68936. private _isDepthMaskDirty;
  68937. private _isDepthFuncDirty;
  68938. private _isCullFaceDirty;
  68939. private _isCullDirty;
  68940. private _isZOffsetDirty;
  68941. private _isFrontFaceDirty;
  68942. private _depthTest;
  68943. private _depthMask;
  68944. private _depthFunc;
  68945. private _cull;
  68946. private _cullFace;
  68947. private _zOffset;
  68948. private _frontFace;
  68949. /**
  68950. * Initializes the state.
  68951. */
  68952. constructor();
  68953. readonly isDirty: boolean;
  68954. zOffset: number;
  68955. cullFace: Nullable<number>;
  68956. cull: Nullable<boolean>;
  68957. depthFunc: Nullable<number>;
  68958. depthMask: boolean;
  68959. depthTest: boolean;
  68960. frontFace: Nullable<number>;
  68961. reset(): void;
  68962. apply(gl: WebGLRenderingContext): void;
  68963. }
  68964. }
  68965. declare module BABYLON {
  68966. /**
  68967. * @hidden
  68968. **/
  68969. export class _StencilState {
  68970. /** 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 */
  68971. static readonly ALWAYS: number;
  68972. /** Passed to stencilOperation to specify that stencil value must be kept */
  68973. static readonly KEEP: number;
  68974. /** Passed to stencilOperation to specify that stencil value must be replaced */
  68975. static readonly REPLACE: number;
  68976. private _isStencilTestDirty;
  68977. private _isStencilMaskDirty;
  68978. private _isStencilFuncDirty;
  68979. private _isStencilOpDirty;
  68980. private _stencilTest;
  68981. private _stencilMask;
  68982. private _stencilFunc;
  68983. private _stencilFuncRef;
  68984. private _stencilFuncMask;
  68985. private _stencilOpStencilFail;
  68986. private _stencilOpDepthFail;
  68987. private _stencilOpStencilDepthPass;
  68988. readonly isDirty: boolean;
  68989. stencilFunc: number;
  68990. stencilFuncRef: number;
  68991. stencilFuncMask: number;
  68992. stencilOpStencilFail: number;
  68993. stencilOpDepthFail: number;
  68994. stencilOpStencilDepthPass: number;
  68995. stencilMask: number;
  68996. stencilTest: boolean;
  68997. constructor();
  68998. reset(): void;
  68999. apply(gl: WebGLRenderingContext): void;
  69000. }
  69001. }
  69002. declare module BABYLON {
  69003. /**
  69004. * @hidden
  69005. **/
  69006. export class _TimeToken {
  69007. _startTimeQuery: Nullable<WebGLQuery>;
  69008. _endTimeQuery: Nullable<WebGLQuery>;
  69009. _timeElapsedQuery: Nullable<WebGLQuery>;
  69010. _timeElapsedQueryEnded: boolean;
  69011. }
  69012. }
  69013. declare module BABYLON {
  69014. /**
  69015. * Class used to store data associated with WebGL texture data for the engine
  69016. * This class should not be used directly
  69017. */
  69018. export class InternalTexture {
  69019. /** @hidden */
  69020. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  69021. /**
  69022. * The source of the texture data is unknown
  69023. */
  69024. static DATASOURCE_UNKNOWN: number;
  69025. /**
  69026. * Texture data comes from an URL
  69027. */
  69028. static DATASOURCE_URL: number;
  69029. /**
  69030. * Texture data is only used for temporary storage
  69031. */
  69032. static DATASOURCE_TEMP: number;
  69033. /**
  69034. * Texture data comes from raw data (ArrayBuffer)
  69035. */
  69036. static DATASOURCE_RAW: number;
  69037. /**
  69038. * Texture content is dynamic (video or dynamic texture)
  69039. */
  69040. static DATASOURCE_DYNAMIC: number;
  69041. /**
  69042. * Texture content is generated by rendering to it
  69043. */
  69044. static DATASOURCE_RENDERTARGET: number;
  69045. /**
  69046. * Texture content is part of a multi render target process
  69047. */
  69048. static DATASOURCE_MULTIRENDERTARGET: number;
  69049. /**
  69050. * Texture data comes from a cube data file
  69051. */
  69052. static DATASOURCE_CUBE: number;
  69053. /**
  69054. * Texture data comes from a raw cube data
  69055. */
  69056. static DATASOURCE_CUBERAW: number;
  69057. /**
  69058. * Texture data come from a prefiltered cube data file
  69059. */
  69060. static DATASOURCE_CUBEPREFILTERED: number;
  69061. /**
  69062. * Texture content is raw 3D data
  69063. */
  69064. static DATASOURCE_RAW3D: number;
  69065. /**
  69066. * Texture content is a depth texture
  69067. */
  69068. static DATASOURCE_DEPTHTEXTURE: number;
  69069. /**
  69070. * Texture data comes from a raw cube data encoded with RGBD
  69071. */
  69072. static DATASOURCE_CUBERAW_RGBD: number;
  69073. /**
  69074. * Defines if the texture is ready
  69075. */
  69076. isReady: boolean;
  69077. /**
  69078. * Defines if the texture is a cube texture
  69079. */
  69080. isCube: boolean;
  69081. /**
  69082. * Defines if the texture contains 3D data
  69083. */
  69084. is3D: boolean;
  69085. /**
  69086. * Defines if the texture contains multiview data
  69087. */
  69088. isMultiview: boolean;
  69089. /**
  69090. * Gets the URL used to load this texture
  69091. */
  69092. url: string;
  69093. /**
  69094. * Gets the sampling mode of the texture
  69095. */
  69096. samplingMode: number;
  69097. /**
  69098. * Gets a boolean indicating if the texture needs mipmaps generation
  69099. */
  69100. generateMipMaps: boolean;
  69101. /**
  69102. * Gets the number of samples used by the texture (WebGL2+ only)
  69103. */
  69104. samples: number;
  69105. /**
  69106. * Gets the type of the texture (int, float...)
  69107. */
  69108. type: number;
  69109. /**
  69110. * Gets the format of the texture (RGB, RGBA...)
  69111. */
  69112. format: number;
  69113. /**
  69114. * Observable called when the texture is loaded
  69115. */
  69116. onLoadedObservable: Observable<InternalTexture>;
  69117. /**
  69118. * Gets the width of the texture
  69119. */
  69120. width: number;
  69121. /**
  69122. * Gets the height of the texture
  69123. */
  69124. height: number;
  69125. /**
  69126. * Gets the depth of the texture
  69127. */
  69128. depth: number;
  69129. /**
  69130. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  69131. */
  69132. baseWidth: number;
  69133. /**
  69134. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  69135. */
  69136. baseHeight: number;
  69137. /**
  69138. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  69139. */
  69140. baseDepth: number;
  69141. /**
  69142. * Gets a boolean indicating if the texture is inverted on Y axis
  69143. */
  69144. invertY: boolean;
  69145. /** @hidden */
  69146. _invertVScale: boolean;
  69147. /** @hidden */
  69148. _associatedChannel: number;
  69149. /** @hidden */
  69150. _dataSource: number;
  69151. /** @hidden */
  69152. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  69153. /** @hidden */
  69154. _bufferView: Nullable<ArrayBufferView>;
  69155. /** @hidden */
  69156. _bufferViewArray: Nullable<ArrayBufferView[]>;
  69157. /** @hidden */
  69158. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  69159. /** @hidden */
  69160. _size: number;
  69161. /** @hidden */
  69162. _extension: string;
  69163. /** @hidden */
  69164. _files: Nullable<string[]>;
  69165. /** @hidden */
  69166. _workingCanvas: Nullable<HTMLCanvasElement>;
  69167. /** @hidden */
  69168. _workingContext: Nullable<CanvasRenderingContext2D>;
  69169. /** @hidden */
  69170. _framebuffer: Nullable<WebGLFramebuffer>;
  69171. /** @hidden */
  69172. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  69173. /** @hidden */
  69174. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  69175. /** @hidden */
  69176. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  69177. /** @hidden */
  69178. _attachments: Nullable<number[]>;
  69179. /** @hidden */
  69180. _cachedCoordinatesMode: Nullable<number>;
  69181. /** @hidden */
  69182. _cachedWrapU: Nullable<number>;
  69183. /** @hidden */
  69184. _cachedWrapV: Nullable<number>;
  69185. /** @hidden */
  69186. _cachedWrapR: Nullable<number>;
  69187. /** @hidden */
  69188. _cachedAnisotropicFilteringLevel: Nullable<number>;
  69189. /** @hidden */
  69190. _isDisabled: boolean;
  69191. /** @hidden */
  69192. _compression: Nullable<string>;
  69193. /** @hidden */
  69194. _generateStencilBuffer: boolean;
  69195. /** @hidden */
  69196. _generateDepthBuffer: boolean;
  69197. /** @hidden */
  69198. _comparisonFunction: number;
  69199. /** @hidden */
  69200. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  69201. /** @hidden */
  69202. _lodGenerationScale: number;
  69203. /** @hidden */
  69204. _lodGenerationOffset: number;
  69205. /** @hidden */
  69206. _colorTextureArray: Nullable<WebGLTexture>;
  69207. /** @hidden */
  69208. _depthStencilTextureArray: Nullable<WebGLTexture>;
  69209. /** @hidden */
  69210. _lodTextureHigh: Nullable<BaseTexture>;
  69211. /** @hidden */
  69212. _lodTextureMid: Nullable<BaseTexture>;
  69213. /** @hidden */
  69214. _lodTextureLow: Nullable<BaseTexture>;
  69215. /** @hidden */
  69216. _isRGBD: boolean;
  69217. /** @hidden */
  69218. _linearSpecularLOD: boolean;
  69219. /** @hidden */
  69220. _irradianceTexture: Nullable<BaseTexture>;
  69221. /** @hidden */
  69222. _webGLTexture: Nullable<WebGLTexture>;
  69223. /** @hidden */
  69224. _references: number;
  69225. private _engine;
  69226. /**
  69227. * Gets the Engine the texture belongs to.
  69228. * @returns The babylon engine
  69229. */
  69230. getEngine(): Engine;
  69231. /**
  69232. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  69233. */
  69234. readonly dataSource: number;
  69235. /**
  69236. * Creates a new InternalTexture
  69237. * @param engine defines the engine to use
  69238. * @param dataSource defines the type of data that will be used
  69239. * @param delayAllocation if the texture allocation should be delayed (default: false)
  69240. */
  69241. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  69242. /**
  69243. * Increments the number of references (ie. the number of Texture that point to it)
  69244. */
  69245. incrementReferences(): void;
  69246. /**
  69247. * Change the size of the texture (not the size of the content)
  69248. * @param width defines the new width
  69249. * @param height defines the new height
  69250. * @param depth defines the new depth (1 by default)
  69251. */
  69252. updateSize(width: int, height: int, depth?: int): void;
  69253. /** @hidden */
  69254. _rebuild(): void;
  69255. /** @hidden */
  69256. _swapAndDie(target: InternalTexture): void;
  69257. /**
  69258. * Dispose the current allocated resources
  69259. */
  69260. dispose(): void;
  69261. }
  69262. }
  69263. declare module BABYLON {
  69264. /**
  69265. * This represents the main contract an easing function should follow.
  69266. * Easing functions are used throughout the animation system.
  69267. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69268. */
  69269. export interface IEasingFunction {
  69270. /**
  69271. * Given an input gradient between 0 and 1, this returns the corrseponding value
  69272. * of the easing function.
  69273. * The link below provides some of the most common examples of easing functions.
  69274. * @see https://easings.net/
  69275. * @param gradient Defines the value between 0 and 1 we want the easing value for
  69276. * @returns the corresponding value on the curve defined by the easing function
  69277. */
  69278. ease(gradient: number): number;
  69279. }
  69280. /**
  69281. * Base class used for every default easing function.
  69282. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69283. */
  69284. export class EasingFunction implements IEasingFunction {
  69285. /**
  69286. * Interpolation follows the mathematical formula associated with the easing function.
  69287. */
  69288. static readonly EASINGMODE_EASEIN: number;
  69289. /**
  69290. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  69291. */
  69292. static readonly EASINGMODE_EASEOUT: number;
  69293. /**
  69294. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  69295. */
  69296. static readonly EASINGMODE_EASEINOUT: number;
  69297. private _easingMode;
  69298. /**
  69299. * Sets the easing mode of the current function.
  69300. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  69301. */
  69302. setEasingMode(easingMode: number): void;
  69303. /**
  69304. * Gets the current easing mode.
  69305. * @returns the easing mode
  69306. */
  69307. getEasingMode(): number;
  69308. /**
  69309. * @hidden
  69310. */
  69311. easeInCore(gradient: number): number;
  69312. /**
  69313. * Given an input gradient between 0 and 1, this returns the corrseponding value
  69314. * of the easing function.
  69315. * @param gradient Defines the value between 0 and 1 we want the easing value for
  69316. * @returns the corresponding value on the curve defined by the easing function
  69317. */
  69318. ease(gradient: number): number;
  69319. }
  69320. /**
  69321. * Easing function with a circle shape (see link below).
  69322. * @see https://easings.net/#easeInCirc
  69323. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69324. */
  69325. export class CircleEase extends EasingFunction implements IEasingFunction {
  69326. /** @hidden */
  69327. easeInCore(gradient: number): number;
  69328. }
  69329. /**
  69330. * Easing function with a ease back shape (see link below).
  69331. * @see https://easings.net/#easeInBack
  69332. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69333. */
  69334. export class BackEase extends EasingFunction implements IEasingFunction {
  69335. /** Defines the amplitude of the function */
  69336. amplitude: number;
  69337. /**
  69338. * Instantiates a back ease easing
  69339. * @see https://easings.net/#easeInBack
  69340. * @param amplitude Defines the amplitude of the function
  69341. */
  69342. constructor(
  69343. /** Defines the amplitude of the function */
  69344. amplitude?: number);
  69345. /** @hidden */
  69346. easeInCore(gradient: number): number;
  69347. }
  69348. /**
  69349. * Easing function with a bouncing shape (see link below).
  69350. * @see https://easings.net/#easeInBounce
  69351. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69352. */
  69353. export class BounceEase extends EasingFunction implements IEasingFunction {
  69354. /** Defines the number of bounces */
  69355. bounces: number;
  69356. /** Defines the amplitude of the bounce */
  69357. bounciness: number;
  69358. /**
  69359. * Instantiates a bounce easing
  69360. * @see https://easings.net/#easeInBounce
  69361. * @param bounces Defines the number of bounces
  69362. * @param bounciness Defines the amplitude of the bounce
  69363. */
  69364. constructor(
  69365. /** Defines the number of bounces */
  69366. bounces?: number,
  69367. /** Defines the amplitude of the bounce */
  69368. bounciness?: number);
  69369. /** @hidden */
  69370. easeInCore(gradient: number): number;
  69371. }
  69372. /**
  69373. * Easing function with a power of 3 shape (see link below).
  69374. * @see https://easings.net/#easeInCubic
  69375. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69376. */
  69377. export class CubicEase extends EasingFunction implements IEasingFunction {
  69378. /** @hidden */
  69379. easeInCore(gradient: number): number;
  69380. }
  69381. /**
  69382. * Easing function with an elastic shape (see link below).
  69383. * @see https://easings.net/#easeInElastic
  69384. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69385. */
  69386. export class ElasticEase extends EasingFunction implements IEasingFunction {
  69387. /** Defines the number of oscillations*/
  69388. oscillations: number;
  69389. /** Defines the amplitude of the oscillations*/
  69390. springiness: number;
  69391. /**
  69392. * Instantiates an elastic easing function
  69393. * @see https://easings.net/#easeInElastic
  69394. * @param oscillations Defines the number of oscillations
  69395. * @param springiness Defines the amplitude of the oscillations
  69396. */
  69397. constructor(
  69398. /** Defines the number of oscillations*/
  69399. oscillations?: number,
  69400. /** Defines the amplitude of the oscillations*/
  69401. springiness?: number);
  69402. /** @hidden */
  69403. easeInCore(gradient: number): number;
  69404. }
  69405. /**
  69406. * Easing function with an exponential shape (see link below).
  69407. * @see https://easings.net/#easeInExpo
  69408. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69409. */
  69410. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  69411. /** Defines the exponent of the function */
  69412. exponent: number;
  69413. /**
  69414. * Instantiates an exponential easing function
  69415. * @see https://easings.net/#easeInExpo
  69416. * @param exponent Defines the exponent of the function
  69417. */
  69418. constructor(
  69419. /** Defines the exponent of the function */
  69420. exponent?: number);
  69421. /** @hidden */
  69422. easeInCore(gradient: number): number;
  69423. }
  69424. /**
  69425. * Easing function with a power shape (see link below).
  69426. * @see https://easings.net/#easeInQuad
  69427. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69428. */
  69429. export class PowerEase extends EasingFunction implements IEasingFunction {
  69430. /** Defines the power of the function */
  69431. power: number;
  69432. /**
  69433. * Instantiates an power base easing function
  69434. * @see https://easings.net/#easeInQuad
  69435. * @param power Defines the power of the function
  69436. */
  69437. constructor(
  69438. /** Defines the power of the function */
  69439. power?: number);
  69440. /** @hidden */
  69441. easeInCore(gradient: number): number;
  69442. }
  69443. /**
  69444. * Easing function with a power of 2 shape (see link below).
  69445. * @see https://easings.net/#easeInQuad
  69446. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69447. */
  69448. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  69449. /** @hidden */
  69450. easeInCore(gradient: number): number;
  69451. }
  69452. /**
  69453. * Easing function with a power of 4 shape (see link below).
  69454. * @see https://easings.net/#easeInQuart
  69455. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69456. */
  69457. export class QuarticEase extends EasingFunction implements IEasingFunction {
  69458. /** @hidden */
  69459. easeInCore(gradient: number): number;
  69460. }
  69461. /**
  69462. * Easing function with a power of 5 shape (see link below).
  69463. * @see https://easings.net/#easeInQuint
  69464. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69465. */
  69466. export class QuinticEase extends EasingFunction implements IEasingFunction {
  69467. /** @hidden */
  69468. easeInCore(gradient: number): number;
  69469. }
  69470. /**
  69471. * Easing function with a sin shape (see link below).
  69472. * @see https://easings.net/#easeInSine
  69473. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69474. */
  69475. export class SineEase extends EasingFunction implements IEasingFunction {
  69476. /** @hidden */
  69477. easeInCore(gradient: number): number;
  69478. }
  69479. /**
  69480. * Easing function with a bezier shape (see link below).
  69481. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  69482. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69483. */
  69484. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  69485. /** Defines the x component of the start tangent in the bezier curve */
  69486. x1: number;
  69487. /** Defines the y component of the start tangent in the bezier curve */
  69488. y1: number;
  69489. /** Defines the x component of the end tangent in the bezier curve */
  69490. x2: number;
  69491. /** Defines the y component of the end tangent in the bezier curve */
  69492. y2: number;
  69493. /**
  69494. * Instantiates a bezier function
  69495. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  69496. * @param x1 Defines the x component of the start tangent in the bezier curve
  69497. * @param y1 Defines the y component of the start tangent in the bezier curve
  69498. * @param x2 Defines the x component of the end tangent in the bezier curve
  69499. * @param y2 Defines the y component of the end tangent in the bezier curve
  69500. */
  69501. constructor(
  69502. /** Defines the x component of the start tangent in the bezier curve */
  69503. x1?: number,
  69504. /** Defines the y component of the start tangent in the bezier curve */
  69505. y1?: number,
  69506. /** Defines the x component of the end tangent in the bezier curve */
  69507. x2?: number,
  69508. /** Defines the y component of the end tangent in the bezier curve */
  69509. y2?: number);
  69510. /** @hidden */
  69511. easeInCore(gradient: number): number;
  69512. }
  69513. }
  69514. declare module BABYLON {
  69515. /**
  69516. * Defines an interface which represents an animation key frame
  69517. */
  69518. export interface IAnimationKey {
  69519. /**
  69520. * Frame of the key frame
  69521. */
  69522. frame: number;
  69523. /**
  69524. * Value at the specifies key frame
  69525. */
  69526. value: any;
  69527. /**
  69528. * The input tangent for the cubic hermite spline
  69529. */
  69530. inTangent?: any;
  69531. /**
  69532. * The output tangent for the cubic hermite spline
  69533. */
  69534. outTangent?: any;
  69535. /**
  69536. * The animation interpolation type
  69537. */
  69538. interpolation?: AnimationKeyInterpolation;
  69539. }
  69540. /**
  69541. * Enum for the animation key frame interpolation type
  69542. */
  69543. export enum AnimationKeyInterpolation {
  69544. /**
  69545. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  69546. */
  69547. STEP = 1
  69548. }
  69549. }
  69550. declare module BABYLON {
  69551. /**
  69552. * Represents the range of an animation
  69553. */
  69554. export class AnimationRange {
  69555. /**The name of the animation range**/
  69556. name: string;
  69557. /**The starting frame of the animation */
  69558. from: number;
  69559. /**The ending frame of the animation*/
  69560. to: number;
  69561. /**
  69562. * Initializes the range of an animation
  69563. * @param name The name of the animation range
  69564. * @param from The starting frame of the animation
  69565. * @param to The ending frame of the animation
  69566. */
  69567. constructor(
  69568. /**The name of the animation range**/
  69569. name: string,
  69570. /**The starting frame of the animation */
  69571. from: number,
  69572. /**The ending frame of the animation*/
  69573. to: number);
  69574. /**
  69575. * Makes a copy of the animation range
  69576. * @returns A copy of the animation range
  69577. */
  69578. clone(): AnimationRange;
  69579. }
  69580. }
  69581. declare module BABYLON {
  69582. /**
  69583. * Composed of a frame, and an action function
  69584. */
  69585. export class AnimationEvent {
  69586. /** The frame for which the event is triggered **/
  69587. frame: number;
  69588. /** The event to perform when triggered **/
  69589. action: (currentFrame: number) => void;
  69590. /** Specifies if the event should be triggered only once**/
  69591. onlyOnce?: boolean | undefined;
  69592. /**
  69593. * Specifies if the animation event is done
  69594. */
  69595. isDone: boolean;
  69596. /**
  69597. * Initializes the animation event
  69598. * @param frame The frame for which the event is triggered
  69599. * @param action The event to perform when triggered
  69600. * @param onlyOnce Specifies if the event should be triggered only once
  69601. */
  69602. constructor(
  69603. /** The frame for which the event is triggered **/
  69604. frame: number,
  69605. /** The event to perform when triggered **/
  69606. action: (currentFrame: number) => void,
  69607. /** Specifies if the event should be triggered only once**/
  69608. onlyOnce?: boolean | undefined);
  69609. /** @hidden */
  69610. _clone(): AnimationEvent;
  69611. }
  69612. }
  69613. declare module BABYLON {
  69614. /**
  69615. * Interface used to define a behavior
  69616. */
  69617. export interface Behavior<T> {
  69618. /** gets or sets behavior's name */
  69619. name: string;
  69620. /**
  69621. * Function called when the behavior needs to be initialized (after attaching it to a target)
  69622. */
  69623. init(): void;
  69624. /**
  69625. * Called when the behavior is attached to a target
  69626. * @param target defines the target where the behavior is attached to
  69627. */
  69628. attach(target: T): void;
  69629. /**
  69630. * Called when the behavior is detached from its target
  69631. */
  69632. detach(): void;
  69633. }
  69634. /**
  69635. * Interface implemented by classes supporting behaviors
  69636. */
  69637. export interface IBehaviorAware<T> {
  69638. /**
  69639. * Attach a behavior
  69640. * @param behavior defines the behavior to attach
  69641. * @returns the current host
  69642. */
  69643. addBehavior(behavior: Behavior<T>): T;
  69644. /**
  69645. * Remove a behavior from the current object
  69646. * @param behavior defines the behavior to detach
  69647. * @returns the current host
  69648. */
  69649. removeBehavior(behavior: Behavior<T>): T;
  69650. /**
  69651. * Gets a behavior using its name to search
  69652. * @param name defines the name to search
  69653. * @returns the behavior or null if not found
  69654. */
  69655. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  69656. }
  69657. }
  69658. declare module BABYLON {
  69659. /**
  69660. * @hidden
  69661. */
  69662. export class IntersectionInfo {
  69663. bu: Nullable<number>;
  69664. bv: Nullable<number>;
  69665. distance: number;
  69666. faceId: number;
  69667. subMeshId: number;
  69668. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  69669. }
  69670. }
  69671. declare module BABYLON {
  69672. /**
  69673. * Class used to store bounding sphere information
  69674. */
  69675. export class BoundingSphere {
  69676. /**
  69677. * Gets the center of the bounding sphere in local space
  69678. */
  69679. readonly center: Vector3;
  69680. /**
  69681. * Radius of the bounding sphere in local space
  69682. */
  69683. radius: number;
  69684. /**
  69685. * Gets the center of the bounding sphere in world space
  69686. */
  69687. readonly centerWorld: Vector3;
  69688. /**
  69689. * Radius of the bounding sphere in world space
  69690. */
  69691. radiusWorld: number;
  69692. /**
  69693. * Gets the minimum vector in local space
  69694. */
  69695. readonly minimum: Vector3;
  69696. /**
  69697. * Gets the maximum vector in local space
  69698. */
  69699. readonly maximum: Vector3;
  69700. private _worldMatrix;
  69701. private static readonly TmpVector3;
  69702. /**
  69703. * Creates a new bounding sphere
  69704. * @param min defines the minimum vector (in local space)
  69705. * @param max defines the maximum vector (in local space)
  69706. * @param worldMatrix defines the new world matrix
  69707. */
  69708. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  69709. /**
  69710. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  69711. * @param min defines the new minimum vector (in local space)
  69712. * @param max defines the new maximum vector (in local space)
  69713. * @param worldMatrix defines the new world matrix
  69714. */
  69715. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  69716. /**
  69717. * Scale the current bounding sphere by applying a scale factor
  69718. * @param factor defines the scale factor to apply
  69719. * @returns the current bounding box
  69720. */
  69721. scale(factor: number): BoundingSphere;
  69722. /**
  69723. * Gets the world matrix of the bounding box
  69724. * @returns a matrix
  69725. */
  69726. getWorldMatrix(): DeepImmutable<Matrix>;
  69727. /** @hidden */
  69728. _update(worldMatrix: DeepImmutable<Matrix>): void;
  69729. /**
  69730. * Tests if the bounding sphere is intersecting the frustum planes
  69731. * @param frustumPlanes defines the frustum planes to test
  69732. * @returns true if there is an intersection
  69733. */
  69734. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  69735. /**
  69736. * Tests if the bounding sphere center is in between the frustum planes.
  69737. * Used for optimistic fast inclusion.
  69738. * @param frustumPlanes defines the frustum planes to test
  69739. * @returns true if the sphere center is in between the frustum planes
  69740. */
  69741. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  69742. /**
  69743. * Tests if a point is inside the bounding sphere
  69744. * @param point defines the point to test
  69745. * @returns true if the point is inside the bounding sphere
  69746. */
  69747. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  69748. /**
  69749. * Checks if two sphere intersct
  69750. * @param sphere0 sphere 0
  69751. * @param sphere1 sphere 1
  69752. * @returns true if the speres intersect
  69753. */
  69754. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  69755. }
  69756. }
  69757. declare module BABYLON {
  69758. /**
  69759. * Class used to store bounding box information
  69760. */
  69761. export class BoundingBox implements ICullable {
  69762. /**
  69763. * Gets the 8 vectors representing the bounding box in local space
  69764. */
  69765. readonly vectors: Vector3[];
  69766. /**
  69767. * Gets the center of the bounding box in local space
  69768. */
  69769. readonly center: Vector3;
  69770. /**
  69771. * Gets the center of the bounding box in world space
  69772. */
  69773. readonly centerWorld: Vector3;
  69774. /**
  69775. * Gets the extend size in local space
  69776. */
  69777. readonly extendSize: Vector3;
  69778. /**
  69779. * Gets the extend size in world space
  69780. */
  69781. readonly extendSizeWorld: Vector3;
  69782. /**
  69783. * Gets the OBB (object bounding box) directions
  69784. */
  69785. readonly directions: Vector3[];
  69786. /**
  69787. * Gets the 8 vectors representing the bounding box in world space
  69788. */
  69789. readonly vectorsWorld: Vector3[];
  69790. /**
  69791. * Gets the minimum vector in world space
  69792. */
  69793. readonly minimumWorld: Vector3;
  69794. /**
  69795. * Gets the maximum vector in world space
  69796. */
  69797. readonly maximumWorld: Vector3;
  69798. /**
  69799. * Gets the minimum vector in local space
  69800. */
  69801. readonly minimum: Vector3;
  69802. /**
  69803. * Gets the maximum vector in local space
  69804. */
  69805. readonly maximum: Vector3;
  69806. private _worldMatrix;
  69807. private static readonly TmpVector3;
  69808. /**
  69809. * @hidden
  69810. */
  69811. _tag: number;
  69812. /**
  69813. * Creates a new bounding box
  69814. * @param min defines the minimum vector (in local space)
  69815. * @param max defines the maximum vector (in local space)
  69816. * @param worldMatrix defines the new world matrix
  69817. */
  69818. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  69819. /**
  69820. * Recreates the entire bounding box from scratch as if we call the constructor in place
  69821. * @param min defines the new minimum vector (in local space)
  69822. * @param max defines the new maximum vector (in local space)
  69823. * @param worldMatrix defines the new world matrix
  69824. */
  69825. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  69826. /**
  69827. * Scale the current bounding box by applying a scale factor
  69828. * @param factor defines the scale factor to apply
  69829. * @returns the current bounding box
  69830. */
  69831. scale(factor: number): BoundingBox;
  69832. /**
  69833. * Gets the world matrix of the bounding box
  69834. * @returns a matrix
  69835. */
  69836. getWorldMatrix(): DeepImmutable<Matrix>;
  69837. /** @hidden */
  69838. _update(world: DeepImmutable<Matrix>): void;
  69839. /**
  69840. * Tests if the bounding box is intersecting the frustum planes
  69841. * @param frustumPlanes defines the frustum planes to test
  69842. * @returns true if there is an intersection
  69843. */
  69844. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  69845. /**
  69846. * Tests if the bounding box is entirely inside the frustum planes
  69847. * @param frustumPlanes defines the frustum planes to test
  69848. * @returns true if there is an inclusion
  69849. */
  69850. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  69851. /**
  69852. * Tests if a point is inside the bounding box
  69853. * @param point defines the point to test
  69854. * @returns true if the point is inside the bounding box
  69855. */
  69856. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  69857. /**
  69858. * Tests if the bounding box intersects with a bounding sphere
  69859. * @param sphere defines the sphere to test
  69860. * @returns true if there is an intersection
  69861. */
  69862. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  69863. /**
  69864. * Tests if the bounding box intersects with a box defined by a min and max vectors
  69865. * @param min defines the min vector to use
  69866. * @param max defines the max vector to use
  69867. * @returns true if there is an intersection
  69868. */
  69869. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  69870. /**
  69871. * Tests if two bounding boxes are intersections
  69872. * @param box0 defines the first box to test
  69873. * @param box1 defines the second box to test
  69874. * @returns true if there is an intersection
  69875. */
  69876. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  69877. /**
  69878. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  69879. * @param minPoint defines the minimum vector of the bounding box
  69880. * @param maxPoint defines the maximum vector of the bounding box
  69881. * @param sphereCenter defines the sphere center
  69882. * @param sphereRadius defines the sphere radius
  69883. * @returns true if there is an intersection
  69884. */
  69885. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  69886. /**
  69887. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  69888. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  69889. * @param frustumPlanes defines the frustum planes to test
  69890. * @return true if there is an inclusion
  69891. */
  69892. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  69893. /**
  69894. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  69895. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  69896. * @param frustumPlanes defines the frustum planes to test
  69897. * @return true if there is an intersection
  69898. */
  69899. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  69900. }
  69901. }
  69902. declare module BABYLON {
  69903. /** @hidden */
  69904. export class Collider {
  69905. /** Define if a collision was found */
  69906. collisionFound: boolean;
  69907. /**
  69908. * Define last intersection point in local space
  69909. */
  69910. intersectionPoint: Vector3;
  69911. /**
  69912. * Define last collided mesh
  69913. */
  69914. collidedMesh: Nullable<AbstractMesh>;
  69915. private _collisionPoint;
  69916. private _planeIntersectionPoint;
  69917. private _tempVector;
  69918. private _tempVector2;
  69919. private _tempVector3;
  69920. private _tempVector4;
  69921. private _edge;
  69922. private _baseToVertex;
  69923. private _destinationPoint;
  69924. private _slidePlaneNormal;
  69925. private _displacementVector;
  69926. /** @hidden */
  69927. _radius: Vector3;
  69928. /** @hidden */
  69929. _retry: number;
  69930. private _velocity;
  69931. private _basePoint;
  69932. private _epsilon;
  69933. /** @hidden */
  69934. _velocityWorldLength: number;
  69935. /** @hidden */
  69936. _basePointWorld: Vector3;
  69937. private _velocityWorld;
  69938. private _normalizedVelocity;
  69939. /** @hidden */
  69940. _initialVelocity: Vector3;
  69941. /** @hidden */
  69942. _initialPosition: Vector3;
  69943. private _nearestDistance;
  69944. private _collisionMask;
  69945. collisionMask: number;
  69946. /**
  69947. * Gets the plane normal used to compute the sliding response (in local space)
  69948. */
  69949. readonly slidePlaneNormal: Vector3;
  69950. /** @hidden */
  69951. _initialize(source: Vector3, dir: Vector3, e: number): void;
  69952. /** @hidden */
  69953. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  69954. /** @hidden */
  69955. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  69956. /** @hidden */
  69957. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  69958. /** @hidden */
  69959. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  69960. /** @hidden */
  69961. _getResponse(pos: Vector3, vel: Vector3): void;
  69962. }
  69963. }
  69964. declare module BABYLON {
  69965. /**
  69966. * Interface for cullable objects
  69967. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  69968. */
  69969. export interface ICullable {
  69970. /**
  69971. * Checks if the object or part of the object is in the frustum
  69972. * @param frustumPlanes Camera near/planes
  69973. * @returns true if the object is in frustum otherwise false
  69974. */
  69975. isInFrustum(frustumPlanes: Plane[]): boolean;
  69976. /**
  69977. * Checks if a cullable object (mesh...) is in the camera frustum
  69978. * Unlike isInFrustum this cheks the full bounding box
  69979. * @param frustumPlanes Camera near/planes
  69980. * @returns true if the object is in frustum otherwise false
  69981. */
  69982. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  69983. }
  69984. /**
  69985. * Info for a bounding data of a mesh
  69986. */
  69987. export class BoundingInfo implements ICullable {
  69988. /**
  69989. * Bounding box for the mesh
  69990. */
  69991. readonly boundingBox: BoundingBox;
  69992. /**
  69993. * Bounding sphere for the mesh
  69994. */
  69995. readonly boundingSphere: BoundingSphere;
  69996. private _isLocked;
  69997. private static readonly TmpVector3;
  69998. /**
  69999. * Constructs bounding info
  70000. * @param minimum min vector of the bounding box/sphere
  70001. * @param maximum max vector of the bounding box/sphere
  70002. * @param worldMatrix defines the new world matrix
  70003. */
  70004. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  70005. /**
  70006. * Recreates the entire bounding info from scratch as if we call the constructor in place
  70007. * @param min defines the new minimum vector (in local space)
  70008. * @param max defines the new maximum vector (in local space)
  70009. * @param worldMatrix defines the new world matrix
  70010. */
  70011. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  70012. /**
  70013. * min vector of the bounding box/sphere
  70014. */
  70015. readonly minimum: Vector3;
  70016. /**
  70017. * max vector of the bounding box/sphere
  70018. */
  70019. readonly maximum: Vector3;
  70020. /**
  70021. * If the info is locked and won't be updated to avoid perf overhead
  70022. */
  70023. isLocked: boolean;
  70024. /**
  70025. * Updates the bounding sphere and box
  70026. * @param world world matrix to be used to update
  70027. */
  70028. update(world: DeepImmutable<Matrix>): void;
  70029. /**
  70030. * Recreate the bounding info to be centered around a specific point given a specific extend.
  70031. * @param center New center of the bounding info
  70032. * @param extend New extend of the bounding info
  70033. * @returns the current bounding info
  70034. */
  70035. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  70036. /**
  70037. * Scale the current bounding info by applying a scale factor
  70038. * @param factor defines the scale factor to apply
  70039. * @returns the current bounding info
  70040. */
  70041. scale(factor: number): BoundingInfo;
  70042. /**
  70043. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  70044. * @param frustumPlanes defines the frustum to test
  70045. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  70046. * @returns true if the bounding info is in the frustum planes
  70047. */
  70048. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  70049. /**
  70050. * Gets the world distance between the min and max points of the bounding box
  70051. */
  70052. readonly diagonalLength: number;
  70053. /**
  70054. * Checks if a cullable object (mesh...) is in the camera frustum
  70055. * Unlike isInFrustum this cheks the full bounding box
  70056. * @param frustumPlanes Camera near/planes
  70057. * @returns true if the object is in frustum otherwise false
  70058. */
  70059. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70060. /** @hidden */
  70061. _checkCollision(collider: Collider): boolean;
  70062. /**
  70063. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  70064. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  70065. * @param point the point to check intersection with
  70066. * @returns if the point intersects
  70067. */
  70068. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  70069. /**
  70070. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  70071. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  70072. * @param boundingInfo the bounding info to check intersection with
  70073. * @param precise if the intersection should be done using OBB
  70074. * @returns if the bounding info intersects
  70075. */
  70076. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  70077. }
  70078. }
  70079. declare module BABYLON {
  70080. /**
  70081. * Defines an array and its length.
  70082. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  70083. */
  70084. export interface ISmartArrayLike<T> {
  70085. /**
  70086. * The data of the array.
  70087. */
  70088. data: Array<T>;
  70089. /**
  70090. * The active length of the array.
  70091. */
  70092. length: number;
  70093. }
  70094. /**
  70095. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  70096. */
  70097. export class SmartArray<T> implements ISmartArrayLike<T> {
  70098. /**
  70099. * The full set of data from the array.
  70100. */
  70101. data: Array<T>;
  70102. /**
  70103. * The active length of the array.
  70104. */
  70105. length: number;
  70106. protected _id: number;
  70107. /**
  70108. * Instantiates a Smart Array.
  70109. * @param capacity defines the default capacity of the array.
  70110. */
  70111. constructor(capacity: number);
  70112. /**
  70113. * Pushes a value at the end of the active data.
  70114. * @param value defines the object to push in the array.
  70115. */
  70116. push(value: T): void;
  70117. /**
  70118. * Iterates over the active data and apply the lambda to them.
  70119. * @param func defines the action to apply on each value.
  70120. */
  70121. forEach(func: (content: T) => void): void;
  70122. /**
  70123. * Sorts the full sets of data.
  70124. * @param compareFn defines the comparison function to apply.
  70125. */
  70126. sort(compareFn: (a: T, b: T) => number): void;
  70127. /**
  70128. * Resets the active data to an empty array.
  70129. */
  70130. reset(): void;
  70131. /**
  70132. * Releases all the data from the array as well as the array.
  70133. */
  70134. dispose(): void;
  70135. /**
  70136. * Concats the active data with a given array.
  70137. * @param array defines the data to concatenate with.
  70138. */
  70139. concat(array: any): void;
  70140. /**
  70141. * Returns the position of a value in the active data.
  70142. * @param value defines the value to find the index for
  70143. * @returns the index if found in the active data otherwise -1
  70144. */
  70145. indexOf(value: T): number;
  70146. /**
  70147. * Returns whether an element is part of the active data.
  70148. * @param value defines the value to look for
  70149. * @returns true if found in the active data otherwise false
  70150. */
  70151. contains(value: T): boolean;
  70152. private static _GlobalId;
  70153. }
  70154. /**
  70155. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  70156. * The data in this array can only be present once
  70157. */
  70158. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  70159. private _duplicateId;
  70160. /**
  70161. * Pushes a value at the end of the active data.
  70162. * THIS DOES NOT PREVENT DUPPLICATE DATA
  70163. * @param value defines the object to push in the array.
  70164. */
  70165. push(value: T): void;
  70166. /**
  70167. * Pushes a value at the end of the active data.
  70168. * If the data is already present, it won t be added again
  70169. * @param value defines the object to push in the array.
  70170. * @returns true if added false if it was already present
  70171. */
  70172. pushNoDuplicate(value: T): boolean;
  70173. /**
  70174. * Resets the active data to an empty array.
  70175. */
  70176. reset(): void;
  70177. /**
  70178. * Concats the active data with a given array.
  70179. * This ensures no dupplicate will be present in the result.
  70180. * @param array defines the data to concatenate with.
  70181. */
  70182. concatWithNoDuplicate(array: any): void;
  70183. }
  70184. }
  70185. declare module BABYLON {
  70186. /**
  70187. * Enum that determines the text-wrapping mode to use.
  70188. */
  70189. export enum InspectableType {
  70190. /**
  70191. * Checkbox for booleans
  70192. */
  70193. Checkbox = 0,
  70194. /**
  70195. * Sliders for numbers
  70196. */
  70197. Slider = 1,
  70198. /**
  70199. * Vector3
  70200. */
  70201. Vector3 = 2,
  70202. /**
  70203. * Quaternions
  70204. */
  70205. Quaternion = 3,
  70206. /**
  70207. * Color3
  70208. */
  70209. Color3 = 4
  70210. }
  70211. /**
  70212. * Interface used to define custom inspectable properties.
  70213. * This interface is used by the inspector to display custom property grids
  70214. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  70215. */
  70216. export interface IInspectable {
  70217. /**
  70218. * Gets the label to display
  70219. */
  70220. label: string;
  70221. /**
  70222. * Gets the name of the property to edit
  70223. */
  70224. propertyName: string;
  70225. /**
  70226. * Gets the type of the editor to use
  70227. */
  70228. type: InspectableType;
  70229. /**
  70230. * Gets the minimum value of the property when using in "slider" mode
  70231. */
  70232. min?: number;
  70233. /**
  70234. * Gets the maximum value of the property when using in "slider" mode
  70235. */
  70236. max?: number;
  70237. /**
  70238. * Gets the setp to use when using in "slider" mode
  70239. */
  70240. step?: number;
  70241. }
  70242. }
  70243. declare module BABYLON {
  70244. /**
  70245. * This represents the required contract to create a new type of texture loader.
  70246. */
  70247. export interface IInternalTextureLoader {
  70248. /**
  70249. * Defines wether the loader supports cascade loading the different faces.
  70250. */
  70251. supportCascades: boolean;
  70252. /**
  70253. * This returns if the loader support the current file information.
  70254. * @param extension defines the file extension of the file being loaded
  70255. * @param textureFormatInUse defines the current compressed format in use iun the engine
  70256. * @param fallback defines the fallback internal texture if any
  70257. * @param isBase64 defines whether the texture is encoded as a base64
  70258. * @param isBuffer defines whether the texture data are stored as a buffer
  70259. * @returns true if the loader can load the specified file
  70260. */
  70261. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  70262. /**
  70263. * Transform the url before loading if required.
  70264. * @param rootUrl the url of the texture
  70265. * @param textureFormatInUse defines the current compressed format in use iun the engine
  70266. * @returns the transformed texture
  70267. */
  70268. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  70269. /**
  70270. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  70271. * @param rootUrl the url of the texture
  70272. * @param textureFormatInUse defines the current compressed format in use iun the engine
  70273. * @returns the fallback texture
  70274. */
  70275. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  70276. /**
  70277. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  70278. * @param data contains the texture data
  70279. * @param texture defines the BabylonJS internal texture
  70280. * @param createPolynomials will be true if polynomials have been requested
  70281. * @param onLoad defines the callback to trigger once the texture is ready
  70282. * @param onError defines the callback to trigger in case of error
  70283. */
  70284. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  70285. /**
  70286. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  70287. * @param data contains the texture data
  70288. * @param texture defines the BabylonJS internal texture
  70289. * @param callback defines the method to call once ready to upload
  70290. */
  70291. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  70292. }
  70293. }
  70294. declare module BABYLON {
  70295. interface Engine {
  70296. /**
  70297. * Creates a depth stencil cube texture.
  70298. * This is only available in WebGL 2.
  70299. * @param size The size of face edge in the cube texture.
  70300. * @param options The options defining the cube texture.
  70301. * @returns The cube texture
  70302. */
  70303. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  70304. /**
  70305. * Creates a cube texture
  70306. * @param rootUrl defines the url where the files to load is located
  70307. * @param scene defines the current scene
  70308. * @param files defines the list of files to load (1 per face)
  70309. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  70310. * @param onLoad defines an optional callback raised when the texture is loaded
  70311. * @param onError defines an optional callback raised if there is an issue to load the texture
  70312. * @param format defines the format of the data
  70313. * @param forcedExtension defines the extension to use to pick the right loader
  70314. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  70315. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  70316. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  70317. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  70318. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  70319. * @returns the cube texture as an InternalTexture
  70320. */
  70321. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  70322. /**
  70323. * Creates a cube texture
  70324. * @param rootUrl defines the url where the files to load is located
  70325. * @param scene defines the current scene
  70326. * @param files defines the list of files to load (1 per face)
  70327. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  70328. * @param onLoad defines an optional callback raised when the texture is loaded
  70329. * @param onError defines an optional callback raised if there is an issue to load the texture
  70330. * @param format defines the format of the data
  70331. * @param forcedExtension defines the extension to use to pick the right loader
  70332. * @returns the cube texture as an InternalTexture
  70333. */
  70334. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  70335. /**
  70336. * Creates a cube texture
  70337. * @param rootUrl defines the url where the files to load is located
  70338. * @param scene defines the current scene
  70339. * @param files defines the list of files to load (1 per face)
  70340. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  70341. * @param onLoad defines an optional callback raised when the texture is loaded
  70342. * @param onError defines an optional callback raised if there is an issue to load the texture
  70343. * @param format defines the format of the data
  70344. * @param forcedExtension defines the extension to use to pick the right loader
  70345. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  70346. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  70347. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  70348. * @returns the cube texture as an InternalTexture
  70349. */
  70350. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  70351. /** @hidden */
  70352. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  70353. /** @hidden */
  70354. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  70355. /** @hidden */
  70356. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  70357. /** @hidden */
  70358. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  70359. }
  70360. }
  70361. declare module BABYLON {
  70362. /**
  70363. * Class for creating a cube texture
  70364. */
  70365. export class CubeTexture extends BaseTexture {
  70366. private _delayedOnLoad;
  70367. /**
  70368. * The url of the texture
  70369. */
  70370. url: string;
  70371. /**
  70372. * Gets or sets the center of the bounding box associated with the cube texture.
  70373. * It must define where the camera used to render the texture was set
  70374. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  70375. */
  70376. boundingBoxPosition: Vector3;
  70377. private _boundingBoxSize;
  70378. /**
  70379. * Gets or sets the size of the bounding box associated with the cube texture
  70380. * When defined, the cubemap will switch to local mode
  70381. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  70382. * @example https://www.babylonjs-playground.com/#RNASML
  70383. */
  70384. /**
  70385. * Returns the bounding box size
  70386. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  70387. */
  70388. boundingBoxSize: Vector3;
  70389. protected _rotationY: number;
  70390. /**
  70391. * Sets texture matrix rotation angle around Y axis in radians.
  70392. */
  70393. /**
  70394. * Gets texture matrix rotation angle around Y axis radians.
  70395. */
  70396. rotationY: number;
  70397. /**
  70398. * Are mip maps generated for this texture or not.
  70399. */
  70400. readonly noMipmap: boolean;
  70401. private _noMipmap;
  70402. private _files;
  70403. private _extensions;
  70404. private _textureMatrix;
  70405. private _format;
  70406. private _createPolynomials;
  70407. /** @hidden */
  70408. _prefiltered: boolean;
  70409. /**
  70410. * Creates a cube texture from an array of image urls
  70411. * @param files defines an array of image urls
  70412. * @param scene defines the hosting scene
  70413. * @param noMipmap specifies if mip maps are not used
  70414. * @returns a cube texture
  70415. */
  70416. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  70417. /**
  70418. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  70419. * @param url defines the url of the prefiltered texture
  70420. * @param scene defines the scene the texture is attached to
  70421. * @param forcedExtension defines the extension of the file if different from the url
  70422. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  70423. * @return the prefiltered texture
  70424. */
  70425. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  70426. /**
  70427. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  70428. * as prefiltered data.
  70429. * @param rootUrl defines the url of the texture or the root name of the six images
  70430. * @param scene defines the scene the texture is attached to
  70431. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  70432. * @param noMipmap defines if mipmaps should be created or not
  70433. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  70434. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  70435. * @param onError defines a callback triggered in case of error during load
  70436. * @param format defines the internal format to use for the texture once loaded
  70437. * @param prefiltered defines whether or not the texture is created from prefiltered data
  70438. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  70439. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  70440. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  70441. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  70442. * @return the cube texture
  70443. */
  70444. 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);
  70445. /**
  70446. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  70447. */
  70448. readonly isPrefiltered: boolean;
  70449. /**
  70450. * Get the current class name of the texture useful for serialization or dynamic coding.
  70451. * @returns "CubeTexture"
  70452. */
  70453. getClassName(): string;
  70454. /**
  70455. * Update the url (and optional buffer) of this texture if url was null during construction.
  70456. * @param url the url of the texture
  70457. * @param forcedExtension defines the extension to use
  70458. * @param onLoad callback called when the texture is loaded (defaults to null)
  70459. */
  70460. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  70461. /**
  70462. * Delays loading of the cube texture
  70463. * @param forcedExtension defines the extension to use
  70464. */
  70465. delayLoad(forcedExtension?: string): void;
  70466. /**
  70467. * Returns the reflection texture matrix
  70468. * @returns the reflection texture matrix
  70469. */
  70470. getReflectionTextureMatrix(): Matrix;
  70471. /**
  70472. * Sets the reflection texture matrix
  70473. * @param value Reflection texture matrix
  70474. */
  70475. setReflectionTextureMatrix(value: Matrix): void;
  70476. /**
  70477. * Parses text to create a cube texture
  70478. * @param parsedTexture define the serialized text to read from
  70479. * @param scene defines the hosting scene
  70480. * @param rootUrl defines the root url of the cube texture
  70481. * @returns a cube texture
  70482. */
  70483. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  70484. /**
  70485. * Makes a clone, or deep copy, of the cube texture
  70486. * @returns a new cube texture
  70487. */
  70488. clone(): CubeTexture;
  70489. }
  70490. }
  70491. declare module BABYLON {
  70492. /** @hidden */
  70493. export var postprocessVertexShader: {
  70494. name: string;
  70495. shader: string;
  70496. };
  70497. }
  70498. declare module BABYLON {
  70499. /**
  70500. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  70501. * This is the base of the follow, arc rotate cameras and Free camera
  70502. * @see http://doc.babylonjs.com/features/cameras
  70503. */
  70504. export class TargetCamera extends Camera {
  70505. private static _RigCamTransformMatrix;
  70506. private static _TargetTransformMatrix;
  70507. private static _TargetFocalPoint;
  70508. /**
  70509. * Define the current direction the camera is moving to
  70510. */
  70511. cameraDirection: Vector3;
  70512. /**
  70513. * Define the current rotation the camera is rotating to
  70514. */
  70515. cameraRotation: Vector2;
  70516. /**
  70517. * When set, the up vector of the camera will be updated by the rotation of the camera
  70518. */
  70519. updateUpVectorFromRotation: boolean;
  70520. private _tmpQuaternion;
  70521. /**
  70522. * Define the current rotation of the camera
  70523. */
  70524. rotation: Vector3;
  70525. /**
  70526. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  70527. */
  70528. rotationQuaternion: Quaternion;
  70529. /**
  70530. * Define the current speed of the camera
  70531. */
  70532. speed: number;
  70533. /**
  70534. * Add cconstraint to the camera to prevent it to move freely in all directions and
  70535. * around all axis.
  70536. */
  70537. noRotationConstraint: boolean;
  70538. /**
  70539. * Define the current target of the camera as an object or a position.
  70540. */
  70541. lockedTarget: any;
  70542. /** @hidden */
  70543. _currentTarget: Vector3;
  70544. /** @hidden */
  70545. _initialFocalDistance: number;
  70546. /** @hidden */
  70547. _viewMatrix: Matrix;
  70548. /** @hidden */
  70549. _camMatrix: Matrix;
  70550. /** @hidden */
  70551. _cameraTransformMatrix: Matrix;
  70552. /** @hidden */
  70553. _cameraRotationMatrix: Matrix;
  70554. /** @hidden */
  70555. _referencePoint: Vector3;
  70556. /** @hidden */
  70557. _transformedReferencePoint: Vector3;
  70558. protected _globalCurrentTarget: Vector3;
  70559. protected _globalCurrentUpVector: Vector3;
  70560. /** @hidden */
  70561. _reset: () => void;
  70562. private _defaultUp;
  70563. /**
  70564. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  70565. * This is the base of the follow, arc rotate cameras and Free camera
  70566. * @see http://doc.babylonjs.com/features/cameras
  70567. * @param name Defines the name of the camera in the scene
  70568. * @param position Defines the start position of the camera in the scene
  70569. * @param scene Defines the scene the camera belongs to
  70570. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  70571. */
  70572. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  70573. /**
  70574. * Gets the position in front of the camera at a given distance.
  70575. * @param distance The distance from the camera we want the position to be
  70576. * @returns the position
  70577. */
  70578. getFrontPosition(distance: number): Vector3;
  70579. /** @hidden */
  70580. _getLockedTargetPosition(): Nullable<Vector3>;
  70581. private _storedPosition;
  70582. private _storedRotation;
  70583. private _storedRotationQuaternion;
  70584. /**
  70585. * Store current camera state of the camera (fov, position, rotation, etc..)
  70586. * @returns the camera
  70587. */
  70588. storeState(): Camera;
  70589. /**
  70590. * Restored camera state. You must call storeState() first
  70591. * @returns whether it was successful or not
  70592. * @hidden
  70593. */
  70594. _restoreStateValues(): boolean;
  70595. /** @hidden */
  70596. _initCache(): void;
  70597. /** @hidden */
  70598. _updateCache(ignoreParentClass?: boolean): void;
  70599. /** @hidden */
  70600. _isSynchronizedViewMatrix(): boolean;
  70601. /** @hidden */
  70602. _computeLocalCameraSpeed(): number;
  70603. /**
  70604. * Defines the target the camera should look at.
  70605. * This will automatically adapt alpha beta and radius to fit within the new target.
  70606. * @param target Defines the new target as a Vector or a mesh
  70607. */
  70608. setTarget(target: Vector3): void;
  70609. /**
  70610. * Return the current target position of the camera. This value is expressed in local space.
  70611. * @returns the target position
  70612. */
  70613. getTarget(): Vector3;
  70614. /** @hidden */
  70615. _decideIfNeedsToMove(): boolean;
  70616. /** @hidden */
  70617. _updatePosition(): void;
  70618. /** @hidden */
  70619. _checkInputs(): void;
  70620. protected _updateCameraRotationMatrix(): void;
  70621. /**
  70622. * 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)
  70623. * @returns the current camera
  70624. */
  70625. private _rotateUpVectorWithCameraRotationMatrix;
  70626. private _cachedRotationZ;
  70627. private _cachedQuaternionRotationZ;
  70628. /** @hidden */
  70629. _getViewMatrix(): Matrix;
  70630. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  70631. /**
  70632. * @hidden
  70633. */
  70634. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  70635. /**
  70636. * @hidden
  70637. */
  70638. _updateRigCameras(): void;
  70639. private _getRigCamPositionAndTarget;
  70640. /**
  70641. * Gets the current object class name.
  70642. * @return the class name
  70643. */
  70644. getClassName(): string;
  70645. }
  70646. }
  70647. declare module BABYLON {
  70648. /**
  70649. * @ignore
  70650. * This is a list of all the different input types that are available in the application.
  70651. * Fo instance: ArcRotateCameraGamepadInput...
  70652. */
  70653. export var CameraInputTypes: {};
  70654. /**
  70655. * This is the contract to implement in order to create a new input class.
  70656. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  70657. */
  70658. export interface ICameraInput<TCamera extends Camera> {
  70659. /**
  70660. * Defines the camera the input is attached to.
  70661. */
  70662. camera: Nullable<TCamera>;
  70663. /**
  70664. * Gets the class name of the current intput.
  70665. * @returns the class name
  70666. */
  70667. getClassName(): string;
  70668. /**
  70669. * Get the friendly name associated with the input class.
  70670. * @returns the input friendly name
  70671. */
  70672. getSimpleName(): string;
  70673. /**
  70674. * Attach the input controls to a specific dom element to get the input from.
  70675. * @param element Defines the element the controls should be listened from
  70676. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70677. */
  70678. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  70679. /**
  70680. * Detach the current controls from the specified dom element.
  70681. * @param element Defines the element to stop listening the inputs from
  70682. */
  70683. detachControl(element: Nullable<HTMLElement>): void;
  70684. /**
  70685. * Update the current camera state depending on the inputs that have been used this frame.
  70686. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  70687. */
  70688. checkInputs?: () => void;
  70689. }
  70690. /**
  70691. * Represents a map of input types to input instance or input index to input instance.
  70692. */
  70693. export interface CameraInputsMap<TCamera extends Camera> {
  70694. /**
  70695. * Accessor to the input by input type.
  70696. */
  70697. [name: string]: ICameraInput<TCamera>;
  70698. /**
  70699. * Accessor to the input by input index.
  70700. */
  70701. [idx: number]: ICameraInput<TCamera>;
  70702. }
  70703. /**
  70704. * This represents the input manager used within a camera.
  70705. * It helps dealing with all the different kind of input attached to a camera.
  70706. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  70707. */
  70708. export class CameraInputsManager<TCamera extends Camera> {
  70709. /**
  70710. * Defines the list of inputs attahed to the camera.
  70711. */
  70712. attached: CameraInputsMap<TCamera>;
  70713. /**
  70714. * Defines the dom element the camera is collecting inputs from.
  70715. * This is null if the controls have not been attached.
  70716. */
  70717. attachedElement: Nullable<HTMLElement>;
  70718. /**
  70719. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70720. */
  70721. noPreventDefault: boolean;
  70722. /**
  70723. * Defined the camera the input manager belongs to.
  70724. */
  70725. camera: TCamera;
  70726. /**
  70727. * Update the current camera state depending on the inputs that have been used this frame.
  70728. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  70729. */
  70730. checkInputs: () => void;
  70731. /**
  70732. * Instantiate a new Camera Input Manager.
  70733. * @param camera Defines the camera the input manager blongs to
  70734. */
  70735. constructor(camera: TCamera);
  70736. /**
  70737. * Add an input method to a camera
  70738. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  70739. * @param input camera input method
  70740. */
  70741. add(input: ICameraInput<TCamera>): void;
  70742. /**
  70743. * Remove a specific input method from a camera
  70744. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  70745. * @param inputToRemove camera input method
  70746. */
  70747. remove(inputToRemove: ICameraInput<TCamera>): void;
  70748. /**
  70749. * Remove a specific input type from a camera
  70750. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  70751. * @param inputType the type of the input to remove
  70752. */
  70753. removeByType(inputType: string): void;
  70754. private _addCheckInputs;
  70755. /**
  70756. * Attach the input controls to the currently attached dom element to listen the events from.
  70757. * @param input Defines the input to attach
  70758. */
  70759. attachInput(input: ICameraInput<TCamera>): void;
  70760. /**
  70761. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  70762. * @param element Defines the dom element to collect the events from
  70763. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70764. */
  70765. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  70766. /**
  70767. * Detach the current manager inputs controls from a specific dom element.
  70768. * @param element Defines the dom element to collect the events from
  70769. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  70770. */
  70771. detachElement(element: HTMLElement, disconnect?: boolean): void;
  70772. /**
  70773. * Rebuild the dynamic inputCheck function from the current list of
  70774. * defined inputs in the manager.
  70775. */
  70776. rebuildInputCheck(): void;
  70777. /**
  70778. * Remove all attached input methods from a camera
  70779. */
  70780. clear(): void;
  70781. /**
  70782. * Serialize the current input manager attached to a camera.
  70783. * This ensures than once parsed,
  70784. * the input associated to the camera will be identical to the current ones
  70785. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  70786. */
  70787. serialize(serializedCamera: any): void;
  70788. /**
  70789. * Parses an input manager serialized JSON to restore the previous list of inputs
  70790. * and states associated to a camera.
  70791. * @param parsedCamera Defines the JSON to parse
  70792. */
  70793. parse(parsedCamera: any): void;
  70794. }
  70795. }
  70796. declare module BABYLON {
  70797. /**
  70798. * Gather the list of keyboard event types as constants.
  70799. */
  70800. export class KeyboardEventTypes {
  70801. /**
  70802. * The keydown event is fired when a key becomes active (pressed).
  70803. */
  70804. static readonly KEYDOWN: number;
  70805. /**
  70806. * The keyup event is fired when a key has been released.
  70807. */
  70808. static readonly KEYUP: number;
  70809. }
  70810. /**
  70811. * This class is used to store keyboard related info for the onKeyboardObservable event.
  70812. */
  70813. export class KeyboardInfo {
  70814. /**
  70815. * Defines the type of event (KeyboardEventTypes)
  70816. */
  70817. type: number;
  70818. /**
  70819. * Defines the related dom event
  70820. */
  70821. event: KeyboardEvent;
  70822. /**
  70823. * Instantiates a new keyboard info.
  70824. * This class is used to store keyboard related info for the onKeyboardObservable event.
  70825. * @param type Defines the type of event (KeyboardEventTypes)
  70826. * @param event Defines the related dom event
  70827. */
  70828. constructor(
  70829. /**
  70830. * Defines the type of event (KeyboardEventTypes)
  70831. */
  70832. type: number,
  70833. /**
  70834. * Defines the related dom event
  70835. */
  70836. event: KeyboardEvent);
  70837. }
  70838. /**
  70839. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  70840. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  70841. */
  70842. export class KeyboardInfoPre extends KeyboardInfo {
  70843. /**
  70844. * Defines the type of event (KeyboardEventTypes)
  70845. */
  70846. type: number;
  70847. /**
  70848. * Defines the related dom event
  70849. */
  70850. event: KeyboardEvent;
  70851. /**
  70852. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  70853. */
  70854. skipOnPointerObservable: boolean;
  70855. /**
  70856. * Instantiates a new keyboard pre info.
  70857. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  70858. * @param type Defines the type of event (KeyboardEventTypes)
  70859. * @param event Defines the related dom event
  70860. */
  70861. constructor(
  70862. /**
  70863. * Defines the type of event (KeyboardEventTypes)
  70864. */
  70865. type: number,
  70866. /**
  70867. * Defines the related dom event
  70868. */
  70869. event: KeyboardEvent);
  70870. }
  70871. }
  70872. declare module BABYLON {
  70873. /**
  70874. * Manage the keyboard inputs to control the movement of a free camera.
  70875. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  70876. */
  70877. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  70878. /**
  70879. * Defines the camera the input is attached to.
  70880. */
  70881. camera: FreeCamera;
  70882. /**
  70883. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  70884. */
  70885. keysUp: number[];
  70886. /**
  70887. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  70888. */
  70889. keysDown: number[];
  70890. /**
  70891. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  70892. */
  70893. keysLeft: number[];
  70894. /**
  70895. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  70896. */
  70897. keysRight: number[];
  70898. private _keys;
  70899. private _onCanvasBlurObserver;
  70900. private _onKeyboardObserver;
  70901. private _engine;
  70902. private _scene;
  70903. /**
  70904. * Attach the input controls to a specific dom element to get the input from.
  70905. * @param element Defines the element the controls should be listened from
  70906. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70907. */
  70908. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  70909. /**
  70910. * Detach the current controls from the specified dom element.
  70911. * @param element Defines the element to stop listening the inputs from
  70912. */
  70913. detachControl(element: Nullable<HTMLElement>): void;
  70914. /**
  70915. * Update the current camera state depending on the inputs that have been used this frame.
  70916. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  70917. */
  70918. checkInputs(): void;
  70919. /**
  70920. * Gets the class name of the current intput.
  70921. * @returns the class name
  70922. */
  70923. getClassName(): string;
  70924. /** @hidden */
  70925. _onLostFocus(): void;
  70926. /**
  70927. * Get the friendly name associated with the input class.
  70928. * @returns the input friendly name
  70929. */
  70930. getSimpleName(): string;
  70931. }
  70932. }
  70933. declare module BABYLON {
  70934. /**
  70935. * A multi-material is used to apply different materials to different parts of the same object without the need of
  70936. * separate meshes. This can be use to improve performances.
  70937. * @see http://doc.babylonjs.com/how_to/multi_materials
  70938. */
  70939. export class MultiMaterial extends Material {
  70940. private _subMaterials;
  70941. /**
  70942. * Gets or Sets the list of Materials used within the multi material.
  70943. * They need to be ordered according to the submeshes order in the associated mesh
  70944. */
  70945. subMaterials: Nullable<Material>[];
  70946. /**
  70947. * Function used to align with Node.getChildren()
  70948. * @returns the list of Materials used within the multi material
  70949. */
  70950. getChildren(): Nullable<Material>[];
  70951. /**
  70952. * Instantiates a new Multi Material
  70953. * A multi-material is used to apply different materials to different parts of the same object without the need of
  70954. * separate meshes. This can be use to improve performances.
  70955. * @see http://doc.babylonjs.com/how_to/multi_materials
  70956. * @param name Define the name in the scene
  70957. * @param scene Define the scene the material belongs to
  70958. */
  70959. constructor(name: string, scene: Scene);
  70960. private _hookArray;
  70961. /**
  70962. * Get one of the submaterial by its index in the submaterials array
  70963. * @param index The index to look the sub material at
  70964. * @returns The Material if the index has been defined
  70965. */
  70966. getSubMaterial(index: number): Nullable<Material>;
  70967. /**
  70968. * Get the list of active textures for the whole sub materials list.
  70969. * @returns All the textures that will be used during the rendering
  70970. */
  70971. getActiveTextures(): BaseTexture[];
  70972. /**
  70973. * Gets the current class name of the material e.g. "MultiMaterial"
  70974. * Mainly use in serialization.
  70975. * @returns the class name
  70976. */
  70977. getClassName(): string;
  70978. /**
  70979. * Checks if the material is ready to render the requested sub mesh
  70980. * @param mesh Define the mesh the submesh belongs to
  70981. * @param subMesh Define the sub mesh to look readyness for
  70982. * @param useInstances Define whether or not the material is used with instances
  70983. * @returns true if ready, otherwise false
  70984. */
  70985. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  70986. /**
  70987. * Clones the current material and its related sub materials
  70988. * @param name Define the name of the newly cloned material
  70989. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  70990. * @returns the cloned material
  70991. */
  70992. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  70993. /**
  70994. * Serializes the materials into a JSON representation.
  70995. * @returns the JSON representation
  70996. */
  70997. serialize(): any;
  70998. /**
  70999. * Dispose the material and release its associated resources
  71000. * @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)
  71001. * @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)
  71002. * @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)
  71003. */
  71004. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  71005. /**
  71006. * Creates a MultiMaterial from parsed MultiMaterial data.
  71007. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  71008. * @param scene defines the hosting scene
  71009. * @returns a new MultiMaterial
  71010. */
  71011. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  71012. }
  71013. }
  71014. declare module BABYLON {
  71015. /**
  71016. * Class used to represent data loading progression
  71017. */
  71018. export class SceneLoaderFlags {
  71019. private static _ForceFullSceneLoadingForIncremental;
  71020. private static _ShowLoadingScreen;
  71021. private static _CleanBoneMatrixWeights;
  71022. private static _loggingLevel;
  71023. /**
  71024. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  71025. */
  71026. static ForceFullSceneLoadingForIncremental: boolean;
  71027. /**
  71028. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  71029. */
  71030. static ShowLoadingScreen: boolean;
  71031. /**
  71032. * Defines the current logging level (while loading the scene)
  71033. * @ignorenaming
  71034. */
  71035. static loggingLevel: number;
  71036. /**
  71037. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  71038. */
  71039. static CleanBoneMatrixWeights: boolean;
  71040. }
  71041. }
  71042. declare module BABYLON {
  71043. /**
  71044. * 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.
  71045. * @see https://doc.babylonjs.com/how_to/transformnode
  71046. */
  71047. export class TransformNode extends Node {
  71048. /**
  71049. * Object will not rotate to face the camera
  71050. */
  71051. static BILLBOARDMODE_NONE: number;
  71052. /**
  71053. * Object will rotate to face the camera but only on the x axis
  71054. */
  71055. static BILLBOARDMODE_X: number;
  71056. /**
  71057. * Object will rotate to face the camera but only on the y axis
  71058. */
  71059. static BILLBOARDMODE_Y: number;
  71060. /**
  71061. * Object will rotate to face the camera but only on the z axis
  71062. */
  71063. static BILLBOARDMODE_Z: number;
  71064. /**
  71065. * Object will rotate to face the camera
  71066. */
  71067. static BILLBOARDMODE_ALL: number;
  71068. private _forward;
  71069. private _forwardInverted;
  71070. private _up;
  71071. private _right;
  71072. private _rightInverted;
  71073. private _position;
  71074. private _rotation;
  71075. private _rotationQuaternion;
  71076. protected _scaling: Vector3;
  71077. protected _isDirty: boolean;
  71078. private _transformToBoneReferal;
  71079. private _billboardMode;
  71080. /**
  71081. * Gets or sets the billboard mode. Default is 0.
  71082. *
  71083. * | Value | Type | Description |
  71084. * | --- | --- | --- |
  71085. * | 0 | BILLBOARDMODE_NONE | |
  71086. * | 1 | BILLBOARDMODE_X | |
  71087. * | 2 | BILLBOARDMODE_Y | |
  71088. * | 4 | BILLBOARDMODE_Z | |
  71089. * | 7 | BILLBOARDMODE_ALL | |
  71090. *
  71091. */
  71092. billboardMode: number;
  71093. private _preserveParentRotationForBillboard;
  71094. /**
  71095. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  71096. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  71097. */
  71098. preserveParentRotationForBillboard: boolean;
  71099. /**
  71100. * 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
  71101. */
  71102. scalingDeterminant: number;
  71103. private _infiniteDistance;
  71104. /**
  71105. * Gets or sets the distance of the object to max, often used by skybox
  71106. */
  71107. infiniteDistance: boolean;
  71108. /**
  71109. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  71110. * By default the system will update normals to compensate
  71111. */
  71112. ignoreNonUniformScaling: boolean;
  71113. /**
  71114. * 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
  71115. */
  71116. reIntegrateRotationIntoRotationQuaternion: boolean;
  71117. /** @hidden */
  71118. _poseMatrix: Nullable<Matrix>;
  71119. /** @hidden */
  71120. _localMatrix: Matrix;
  71121. private _usePivotMatrix;
  71122. private _absolutePosition;
  71123. private _pivotMatrix;
  71124. private _pivotMatrixInverse;
  71125. protected _postMultiplyPivotMatrix: boolean;
  71126. protected _isWorldMatrixFrozen: boolean;
  71127. /** @hidden */
  71128. _indexInSceneTransformNodesArray: number;
  71129. /**
  71130. * An event triggered after the world matrix is updated
  71131. */
  71132. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  71133. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  71134. /**
  71135. * Gets a string identifying the name of the class
  71136. * @returns "TransformNode" string
  71137. */
  71138. getClassName(): string;
  71139. /**
  71140. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  71141. */
  71142. position: Vector3;
  71143. /**
  71144. * 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)).
  71145. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  71146. */
  71147. rotation: Vector3;
  71148. /**
  71149. * 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)).
  71150. */
  71151. scaling: Vector3;
  71152. /**
  71153. * 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).
  71154. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  71155. */
  71156. rotationQuaternion: Nullable<Quaternion>;
  71157. /**
  71158. * The forward direction of that transform in world space.
  71159. */
  71160. readonly forward: Vector3;
  71161. /**
  71162. * The up direction of that transform in world space.
  71163. */
  71164. readonly up: Vector3;
  71165. /**
  71166. * The right direction of that transform in world space.
  71167. */
  71168. readonly right: Vector3;
  71169. /**
  71170. * Copies the parameter passed Matrix into the mesh Pose matrix.
  71171. * @param matrix the matrix to copy the pose from
  71172. * @returns this TransformNode.
  71173. */
  71174. updatePoseMatrix(matrix: Matrix): TransformNode;
  71175. /**
  71176. * Returns the mesh Pose matrix.
  71177. * @returns the pose matrix
  71178. */
  71179. getPoseMatrix(): Matrix;
  71180. /** @hidden */
  71181. _isSynchronized(): boolean;
  71182. /** @hidden */
  71183. _initCache(): void;
  71184. /**
  71185. * Flag the transform node as dirty (Forcing it to update everything)
  71186. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  71187. * @returns this transform node
  71188. */
  71189. markAsDirty(property: string): TransformNode;
  71190. /**
  71191. * Returns the current mesh absolute position.
  71192. * Returns a Vector3.
  71193. */
  71194. readonly absolutePosition: Vector3;
  71195. /**
  71196. * Sets a new matrix to apply before all other transformation
  71197. * @param matrix defines the transform matrix
  71198. * @returns the current TransformNode
  71199. */
  71200. setPreTransformMatrix(matrix: Matrix): TransformNode;
  71201. /**
  71202. * Sets a new pivot matrix to the current node
  71203. * @param matrix defines the new pivot matrix to use
  71204. * @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
  71205. * @returns the current TransformNode
  71206. */
  71207. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  71208. /**
  71209. * Returns the mesh pivot matrix.
  71210. * Default : Identity.
  71211. * @returns the matrix
  71212. */
  71213. getPivotMatrix(): Matrix;
  71214. /**
  71215. * Prevents the World matrix to be computed any longer.
  71216. * @returns the TransformNode.
  71217. */
  71218. freezeWorldMatrix(): TransformNode;
  71219. /**
  71220. * Allows back the World matrix computation.
  71221. * @returns the TransformNode.
  71222. */
  71223. unfreezeWorldMatrix(): this;
  71224. /**
  71225. * True if the World matrix has been frozen.
  71226. */
  71227. readonly isWorldMatrixFrozen: boolean;
  71228. /**
  71229. * Retuns the mesh absolute position in the World.
  71230. * @returns a Vector3.
  71231. */
  71232. getAbsolutePosition(): Vector3;
  71233. /**
  71234. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  71235. * @param absolutePosition the absolute position to set
  71236. * @returns the TransformNode.
  71237. */
  71238. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  71239. /**
  71240. * Sets the mesh position in its local space.
  71241. * @param vector3 the position to set in localspace
  71242. * @returns the TransformNode.
  71243. */
  71244. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  71245. /**
  71246. * Returns the mesh position in the local space from the current World matrix values.
  71247. * @returns a new Vector3.
  71248. */
  71249. getPositionExpressedInLocalSpace(): Vector3;
  71250. /**
  71251. * Translates the mesh along the passed Vector3 in its local space.
  71252. * @param vector3 the distance to translate in localspace
  71253. * @returns the TransformNode.
  71254. */
  71255. locallyTranslate(vector3: Vector3): TransformNode;
  71256. private static _lookAtVectorCache;
  71257. /**
  71258. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  71259. * @param targetPoint the position (must be in same space as current mesh) to look at
  71260. * @param yawCor optional yaw (y-axis) correction in radians
  71261. * @param pitchCor optional pitch (x-axis) correction in radians
  71262. * @param rollCor optional roll (z-axis) correction in radians
  71263. * @param space the choosen space of the target
  71264. * @returns the TransformNode.
  71265. */
  71266. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  71267. /**
  71268. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  71269. * This Vector3 is expressed in the World space.
  71270. * @param localAxis axis to rotate
  71271. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  71272. */
  71273. getDirection(localAxis: Vector3): Vector3;
  71274. /**
  71275. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  71276. * localAxis is expressed in the mesh local space.
  71277. * result is computed in the Wordl space from the mesh World matrix.
  71278. * @param localAxis axis to rotate
  71279. * @param result the resulting transformnode
  71280. * @returns this TransformNode.
  71281. */
  71282. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  71283. /**
  71284. * Sets this transform node rotation to the given local axis.
  71285. * @param localAxis the axis in local space
  71286. * @param yawCor optional yaw (y-axis) correction in radians
  71287. * @param pitchCor optional pitch (x-axis) correction in radians
  71288. * @param rollCor optional roll (z-axis) correction in radians
  71289. * @returns this TransformNode
  71290. */
  71291. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  71292. /**
  71293. * Sets a new pivot point to the current node
  71294. * @param point defines the new pivot point to use
  71295. * @param space defines if the point is in world or local space (local by default)
  71296. * @returns the current TransformNode
  71297. */
  71298. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  71299. /**
  71300. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  71301. * @returns the pivot point
  71302. */
  71303. getPivotPoint(): Vector3;
  71304. /**
  71305. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  71306. * @param result the vector3 to store the result
  71307. * @returns this TransformNode.
  71308. */
  71309. getPivotPointToRef(result: Vector3): TransformNode;
  71310. /**
  71311. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  71312. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  71313. */
  71314. getAbsolutePivotPoint(): Vector3;
  71315. /**
  71316. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  71317. * @param result vector3 to store the result
  71318. * @returns this TransformNode.
  71319. */
  71320. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  71321. /**
  71322. * Defines the passed node as the parent of the current node.
  71323. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  71324. * @see https://doc.babylonjs.com/how_to/parenting
  71325. * @param node the node ot set as the parent
  71326. * @returns this TransformNode.
  71327. */
  71328. setParent(node: Nullable<Node>): TransformNode;
  71329. private _nonUniformScaling;
  71330. /**
  71331. * True if the scaling property of this object is non uniform eg. (1,2,1)
  71332. */
  71333. readonly nonUniformScaling: boolean;
  71334. /** @hidden */
  71335. _updateNonUniformScalingState(value: boolean): boolean;
  71336. /**
  71337. * Attach the current TransformNode to another TransformNode associated with a bone
  71338. * @param bone Bone affecting the TransformNode
  71339. * @param affectedTransformNode TransformNode associated with the bone
  71340. * @returns this object
  71341. */
  71342. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  71343. /**
  71344. * Detach the transform node if its associated with a bone
  71345. * @returns this object
  71346. */
  71347. detachFromBone(): TransformNode;
  71348. private static _rotationAxisCache;
  71349. /**
  71350. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  71351. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  71352. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  71353. * The passed axis is also normalized.
  71354. * @param axis the axis to rotate around
  71355. * @param amount the amount to rotate in radians
  71356. * @param space Space to rotate in (Default: local)
  71357. * @returns the TransformNode.
  71358. */
  71359. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  71360. /**
  71361. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  71362. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  71363. * The passed axis is also normalized. .
  71364. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  71365. * @param point the point to rotate around
  71366. * @param axis the axis to rotate around
  71367. * @param amount the amount to rotate in radians
  71368. * @returns the TransformNode
  71369. */
  71370. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  71371. /**
  71372. * Translates the mesh along the axis vector for the passed distance in the given space.
  71373. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  71374. * @param axis the axis to translate in
  71375. * @param distance the distance to translate
  71376. * @param space Space to rotate in (Default: local)
  71377. * @returns the TransformNode.
  71378. */
  71379. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  71380. /**
  71381. * Adds a rotation step to the mesh current rotation.
  71382. * x, y, z are Euler angles expressed in radians.
  71383. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  71384. * This means this rotation is made in the mesh local space only.
  71385. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  71386. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  71387. * ```javascript
  71388. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  71389. * ```
  71390. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  71391. * 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.
  71392. * @param x Rotation to add
  71393. * @param y Rotation to add
  71394. * @param z Rotation to add
  71395. * @returns the TransformNode.
  71396. */
  71397. addRotation(x: number, y: number, z: number): TransformNode;
  71398. /**
  71399. * @hidden
  71400. */
  71401. protected _getEffectiveParent(): Nullable<Node>;
  71402. /**
  71403. * Computes the world matrix of the node
  71404. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  71405. * @returns the world matrix
  71406. */
  71407. computeWorldMatrix(force?: boolean): Matrix;
  71408. protected _afterComputeWorldMatrix(): void;
  71409. /**
  71410. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  71411. * @param func callback function to add
  71412. *
  71413. * @returns the TransformNode.
  71414. */
  71415. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  71416. /**
  71417. * Removes a registered callback function.
  71418. * @param func callback function to remove
  71419. * @returns the TransformNode.
  71420. */
  71421. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  71422. /**
  71423. * Gets the position of the current mesh in camera space
  71424. * @param camera defines the camera to use
  71425. * @returns a position
  71426. */
  71427. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  71428. /**
  71429. * Returns the distance from the mesh to the active camera
  71430. * @param camera defines the camera to use
  71431. * @returns the distance
  71432. */
  71433. getDistanceToCamera(camera?: Nullable<Camera>): number;
  71434. /**
  71435. * Clone the current transform node
  71436. * @param name Name of the new clone
  71437. * @param newParent New parent for the clone
  71438. * @param doNotCloneChildren Do not clone children hierarchy
  71439. * @returns the new transform node
  71440. */
  71441. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  71442. /**
  71443. * Serializes the objects information.
  71444. * @param currentSerializationObject defines the object to serialize in
  71445. * @returns the serialized object
  71446. */
  71447. serialize(currentSerializationObject?: any): any;
  71448. /**
  71449. * Returns a new TransformNode object parsed from the source provided.
  71450. * @param parsedTransformNode is the source.
  71451. * @param scene the scne the object belongs to
  71452. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  71453. * @returns a new TransformNode object parsed from the source provided.
  71454. */
  71455. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  71456. /**
  71457. * Get all child-transformNodes of this node
  71458. * @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
  71459. * @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
  71460. * @returns an array of TransformNode
  71461. */
  71462. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  71463. /**
  71464. * Releases resources associated with this transform node.
  71465. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  71466. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  71467. */
  71468. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  71469. /**
  71470. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  71471. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  71472. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  71473. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  71474. * @returns the current mesh
  71475. */
  71476. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  71477. }
  71478. }
  71479. declare module BABYLON {
  71480. /**
  71481. * Class used to override all child animations of a given target
  71482. */
  71483. export class AnimationPropertiesOverride {
  71484. /**
  71485. * Gets or sets a value indicating if animation blending must be used
  71486. */
  71487. enableBlending: boolean;
  71488. /**
  71489. * Gets or sets the blending speed to use when enableBlending is true
  71490. */
  71491. blendingSpeed: number;
  71492. /**
  71493. * Gets or sets the default loop mode to use
  71494. */
  71495. loopMode: number;
  71496. }
  71497. }
  71498. declare module BABYLON {
  71499. /**
  71500. * Class used to store bone information
  71501. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  71502. */
  71503. export class Bone extends Node {
  71504. /**
  71505. * defines the bone name
  71506. */
  71507. name: string;
  71508. private static _tmpVecs;
  71509. private static _tmpQuat;
  71510. private static _tmpMats;
  71511. /**
  71512. * Gets the list of child bones
  71513. */
  71514. children: Bone[];
  71515. /** Gets the animations associated with this bone */
  71516. animations: Animation[];
  71517. /**
  71518. * Gets or sets bone length
  71519. */
  71520. length: number;
  71521. /**
  71522. * @hidden Internal only
  71523. * Set this value to map this bone to a different index in the transform matrices
  71524. * Set this value to -1 to exclude the bone from the transform matrices
  71525. */
  71526. _index: Nullable<number>;
  71527. private _skeleton;
  71528. private _localMatrix;
  71529. private _restPose;
  71530. private _baseMatrix;
  71531. private _absoluteTransform;
  71532. private _invertedAbsoluteTransform;
  71533. private _parent;
  71534. private _scalingDeterminant;
  71535. private _worldTransform;
  71536. private _localScaling;
  71537. private _localRotation;
  71538. private _localPosition;
  71539. private _needToDecompose;
  71540. private _needToCompose;
  71541. /** @hidden */
  71542. _linkedTransformNode: Nullable<TransformNode>;
  71543. /** @hidden */
  71544. _waitingTransformNodeId: Nullable<string>;
  71545. /** @hidden */
  71546. /** @hidden */
  71547. _matrix: Matrix;
  71548. /**
  71549. * Create a new bone
  71550. * @param name defines the bone name
  71551. * @param skeleton defines the parent skeleton
  71552. * @param parentBone defines the parent (can be null if the bone is the root)
  71553. * @param localMatrix defines the local matrix
  71554. * @param restPose defines the rest pose matrix
  71555. * @param baseMatrix defines the base matrix
  71556. * @param index defines index of the bone in the hiearchy
  71557. */
  71558. constructor(
  71559. /**
  71560. * defines the bone name
  71561. */
  71562. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  71563. /**
  71564. * Gets the current object class name.
  71565. * @return the class name
  71566. */
  71567. getClassName(): string;
  71568. /**
  71569. * Gets the parent skeleton
  71570. * @returns a skeleton
  71571. */
  71572. getSkeleton(): Skeleton;
  71573. /**
  71574. * Gets parent bone
  71575. * @returns a bone or null if the bone is the root of the bone hierarchy
  71576. */
  71577. getParent(): Nullable<Bone>;
  71578. /**
  71579. * Returns an array containing the root bones
  71580. * @returns an array containing the root bones
  71581. */
  71582. getChildren(): Array<Bone>;
  71583. /**
  71584. * Sets the parent bone
  71585. * @param parent defines the parent (can be null if the bone is the root)
  71586. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  71587. */
  71588. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  71589. /**
  71590. * Gets the local matrix
  71591. * @returns a matrix
  71592. */
  71593. getLocalMatrix(): Matrix;
  71594. /**
  71595. * Gets the base matrix (initial matrix which remains unchanged)
  71596. * @returns a matrix
  71597. */
  71598. getBaseMatrix(): Matrix;
  71599. /**
  71600. * Gets the rest pose matrix
  71601. * @returns a matrix
  71602. */
  71603. getRestPose(): Matrix;
  71604. /**
  71605. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  71606. */
  71607. getWorldMatrix(): Matrix;
  71608. /**
  71609. * Sets the local matrix to rest pose matrix
  71610. */
  71611. returnToRest(): void;
  71612. /**
  71613. * Gets the inverse of the absolute transform matrix.
  71614. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  71615. * @returns a matrix
  71616. */
  71617. getInvertedAbsoluteTransform(): Matrix;
  71618. /**
  71619. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  71620. * @returns a matrix
  71621. */
  71622. getAbsoluteTransform(): Matrix;
  71623. /**
  71624. * Links with the given transform node.
  71625. * The local matrix of this bone is copied from the transform node every frame.
  71626. * @param transformNode defines the transform node to link to
  71627. */
  71628. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  71629. /** Gets or sets current position (in local space) */
  71630. position: Vector3;
  71631. /** Gets or sets current rotation (in local space) */
  71632. rotation: Vector3;
  71633. /** Gets or sets current rotation quaternion (in local space) */
  71634. rotationQuaternion: Quaternion;
  71635. /** Gets or sets current scaling (in local space) */
  71636. scaling: Vector3;
  71637. /**
  71638. * Gets the animation properties override
  71639. */
  71640. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  71641. private _decompose;
  71642. private _compose;
  71643. /**
  71644. * Update the base and local matrices
  71645. * @param matrix defines the new base or local matrix
  71646. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  71647. * @param updateLocalMatrix defines if the local matrix should be updated
  71648. */
  71649. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  71650. /** @hidden */
  71651. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  71652. /**
  71653. * Flag the bone as dirty (Forcing it to update everything)
  71654. */
  71655. markAsDirty(): void;
  71656. /** @hidden */
  71657. _markAsDirtyAndCompose(): void;
  71658. private _markAsDirtyAndDecompose;
  71659. /**
  71660. * Translate the bone in local or world space
  71661. * @param vec The amount to translate the bone
  71662. * @param space The space that the translation is in
  71663. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71664. */
  71665. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  71666. /**
  71667. * Set the postion of the bone in local or world space
  71668. * @param position The position to set the bone
  71669. * @param space The space that the position is in
  71670. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71671. */
  71672. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  71673. /**
  71674. * Set the absolute position of the bone (world space)
  71675. * @param position The position to set the bone
  71676. * @param mesh The mesh that this bone is attached to
  71677. */
  71678. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  71679. /**
  71680. * Scale the bone on the x, y and z axes (in local space)
  71681. * @param x The amount to scale the bone on the x axis
  71682. * @param y The amount to scale the bone on the y axis
  71683. * @param z The amount to scale the bone on the z axis
  71684. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  71685. */
  71686. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  71687. /**
  71688. * Set the bone scaling in local space
  71689. * @param scale defines the scaling vector
  71690. */
  71691. setScale(scale: Vector3): void;
  71692. /**
  71693. * Gets the current scaling in local space
  71694. * @returns the current scaling vector
  71695. */
  71696. getScale(): Vector3;
  71697. /**
  71698. * Gets the current scaling in local space and stores it in a target vector
  71699. * @param result defines the target vector
  71700. */
  71701. getScaleToRef(result: Vector3): void;
  71702. /**
  71703. * Set the yaw, pitch, and roll of the bone in local or world space
  71704. * @param yaw The rotation of the bone on the y axis
  71705. * @param pitch The rotation of the bone on the x axis
  71706. * @param roll The rotation of the bone on the z axis
  71707. * @param space The space that the axes of rotation are in
  71708. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71709. */
  71710. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  71711. /**
  71712. * Add a rotation to the bone on an axis in local or world space
  71713. * @param axis The axis to rotate the bone on
  71714. * @param amount The amount to rotate the bone
  71715. * @param space The space that the axis is in
  71716. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71717. */
  71718. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  71719. /**
  71720. * Set the rotation of the bone to a particular axis angle in local or world space
  71721. * @param axis The axis to rotate the bone on
  71722. * @param angle The angle that the bone should be rotated to
  71723. * @param space The space that the axis is in
  71724. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71725. */
  71726. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  71727. /**
  71728. * Set the euler rotation of the bone in local of world space
  71729. * @param rotation The euler rotation that the bone should be set to
  71730. * @param space The space that the rotation is in
  71731. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71732. */
  71733. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  71734. /**
  71735. * Set the quaternion rotation of the bone in local of world space
  71736. * @param quat The quaternion rotation that the bone should be set to
  71737. * @param space The space that the rotation is in
  71738. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71739. */
  71740. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  71741. /**
  71742. * Set the rotation matrix of the bone in local of world space
  71743. * @param rotMat The rotation matrix that the bone should be set to
  71744. * @param space The space that the rotation is in
  71745. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71746. */
  71747. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  71748. private _rotateWithMatrix;
  71749. private _getNegativeRotationToRef;
  71750. /**
  71751. * Get the position of the bone in local or world space
  71752. * @param space The space that the returned position is in
  71753. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71754. * @returns The position of the bone
  71755. */
  71756. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  71757. /**
  71758. * Copy the position of the bone to a vector3 in local or world space
  71759. * @param space The space that the returned position is in
  71760. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71761. * @param result The vector3 to copy the position to
  71762. */
  71763. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  71764. /**
  71765. * Get the absolute position of the bone (world space)
  71766. * @param mesh The mesh that this bone is attached to
  71767. * @returns The absolute position of the bone
  71768. */
  71769. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  71770. /**
  71771. * Copy the absolute position of the bone (world space) to the result param
  71772. * @param mesh The mesh that this bone is attached to
  71773. * @param result The vector3 to copy the absolute position to
  71774. */
  71775. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  71776. /**
  71777. * Compute the absolute transforms of this bone and its children
  71778. */
  71779. computeAbsoluteTransforms(): void;
  71780. /**
  71781. * Get the world direction from an axis that is in the local space of the bone
  71782. * @param localAxis The local direction that is used to compute the world direction
  71783. * @param mesh The mesh that this bone is attached to
  71784. * @returns The world direction
  71785. */
  71786. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  71787. /**
  71788. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  71789. * @param localAxis The local direction that is used to compute the world direction
  71790. * @param mesh The mesh that this bone is attached to
  71791. * @param result The vector3 that the world direction will be copied to
  71792. */
  71793. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  71794. /**
  71795. * Get the euler rotation of the bone in local or world space
  71796. * @param space The space that the rotation should be in
  71797. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71798. * @returns The euler rotation
  71799. */
  71800. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  71801. /**
  71802. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  71803. * @param space The space that the rotation should be in
  71804. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71805. * @param result The vector3 that the rotation should be copied to
  71806. */
  71807. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  71808. /**
  71809. * Get the quaternion rotation of the bone in either local or world space
  71810. * @param space The space that the rotation should be in
  71811. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71812. * @returns The quaternion rotation
  71813. */
  71814. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  71815. /**
  71816. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  71817. * @param space The space that the rotation should be in
  71818. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71819. * @param result The quaternion that the rotation should be copied to
  71820. */
  71821. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  71822. /**
  71823. * Get the rotation matrix of the bone in local or world space
  71824. * @param space The space that the rotation should be in
  71825. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71826. * @returns The rotation matrix
  71827. */
  71828. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  71829. /**
  71830. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  71831. * @param space The space that the rotation should be in
  71832. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71833. * @param result The quaternion that the rotation should be copied to
  71834. */
  71835. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  71836. /**
  71837. * Get the world position of a point that is in the local space of the bone
  71838. * @param position The local position
  71839. * @param mesh The mesh that this bone is attached to
  71840. * @returns The world position
  71841. */
  71842. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  71843. /**
  71844. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  71845. * @param position The local position
  71846. * @param mesh The mesh that this bone is attached to
  71847. * @param result The vector3 that the world position should be copied to
  71848. */
  71849. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  71850. /**
  71851. * Get the local position of a point that is in world space
  71852. * @param position The world position
  71853. * @param mesh The mesh that this bone is attached to
  71854. * @returns The local position
  71855. */
  71856. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  71857. /**
  71858. * Get the local position of a point that is in world space and copy it to the result param
  71859. * @param position The world position
  71860. * @param mesh The mesh that this bone is attached to
  71861. * @param result The vector3 that the local position should be copied to
  71862. */
  71863. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  71864. }
  71865. }
  71866. declare module BABYLON {
  71867. interface Engine {
  71868. /**
  71869. * Creates a raw texture
  71870. * @param data defines the data to store in the texture
  71871. * @param width defines the width of the texture
  71872. * @param height defines the height of the texture
  71873. * @param format defines the format of the data
  71874. * @param generateMipMaps defines if the engine should generate the mip levels
  71875. * @param invertY defines if data must be stored with Y axis inverted
  71876. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  71877. * @param compression defines the compression used (null by default)
  71878. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  71879. * @returns the raw texture inside an InternalTexture
  71880. */
  71881. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  71882. /**
  71883. * Update a raw texture
  71884. * @param texture defines the texture to update
  71885. * @param data defines the data to store in the texture
  71886. * @param format defines the format of the data
  71887. * @param invertY defines if data must be stored with Y axis inverted
  71888. */
  71889. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  71890. /**
  71891. * Update a raw texture
  71892. * @param texture defines the texture to update
  71893. * @param data defines the data to store in the texture
  71894. * @param format defines the format of the data
  71895. * @param invertY defines if data must be stored with Y axis inverted
  71896. * @param compression defines the compression used (null by default)
  71897. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  71898. */
  71899. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  71900. /**
  71901. * Creates a new raw cube texture
  71902. * @param data defines the array of data to use to create each face
  71903. * @param size defines the size of the textures
  71904. * @param format defines the format of the data
  71905. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  71906. * @param generateMipMaps defines if the engine should generate the mip levels
  71907. * @param invertY defines if data must be stored with Y axis inverted
  71908. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  71909. * @param compression defines the compression used (null by default)
  71910. * @returns the cube texture as an InternalTexture
  71911. */
  71912. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  71913. /**
  71914. * Update a raw cube texture
  71915. * @param texture defines the texture to udpdate
  71916. * @param data defines the data to store
  71917. * @param format defines the data format
  71918. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  71919. * @param invertY defines if data must be stored with Y axis inverted
  71920. */
  71921. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  71922. /**
  71923. * Update a raw cube texture
  71924. * @param texture defines the texture to udpdate
  71925. * @param data defines the data to store
  71926. * @param format defines the data format
  71927. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  71928. * @param invertY defines if data must be stored with Y axis inverted
  71929. * @param compression defines the compression used (null by default)
  71930. */
  71931. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  71932. /**
  71933. * Update a raw cube texture
  71934. * @param texture defines the texture to udpdate
  71935. * @param data defines the data to store
  71936. * @param format defines the data format
  71937. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  71938. * @param invertY defines if data must be stored with Y axis inverted
  71939. * @param compression defines the compression used (null by default)
  71940. * @param level defines which level of the texture to update
  71941. */
  71942. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  71943. /**
  71944. * Creates a new raw cube texture from a specified url
  71945. * @param url defines the url where the data is located
  71946. * @param scene defines the current scene
  71947. * @param size defines the size of the textures
  71948. * @param format defines the format of the data
  71949. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  71950. * @param noMipmap defines if the engine should avoid generating the mip levels
  71951. * @param callback defines a callback used to extract texture data from loaded data
  71952. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  71953. * @param onLoad defines a callback called when texture is loaded
  71954. * @param onError defines a callback called if there is an error
  71955. * @returns the cube texture as an InternalTexture
  71956. */
  71957. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  71958. /**
  71959. * Creates a new raw cube texture from a specified url
  71960. * @param url defines the url where the data is located
  71961. * @param scene defines the current scene
  71962. * @param size defines the size of the textures
  71963. * @param format defines the format of the data
  71964. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  71965. * @param noMipmap defines if the engine should avoid generating the mip levels
  71966. * @param callback defines a callback used to extract texture data from loaded data
  71967. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  71968. * @param onLoad defines a callback called when texture is loaded
  71969. * @param onError defines a callback called if there is an error
  71970. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  71971. * @param invertY defines if data must be stored with Y axis inverted
  71972. * @returns the cube texture as an InternalTexture
  71973. */
  71974. 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;
  71975. /**
  71976. * Creates a new raw 3D texture
  71977. * @param data defines the data used to create the texture
  71978. * @param width defines the width of the texture
  71979. * @param height defines the height of the texture
  71980. * @param depth defines the depth of the texture
  71981. * @param format defines the format of the texture
  71982. * @param generateMipMaps defines if the engine must generate mip levels
  71983. * @param invertY defines if data must be stored with Y axis inverted
  71984. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  71985. * @param compression defines the compressed used (can be null)
  71986. * @param textureType defines the compressed used (can be null)
  71987. * @returns a new raw 3D texture (stored in an InternalTexture)
  71988. */
  71989. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  71990. /**
  71991. * Update a raw 3D texture
  71992. * @param texture defines the texture to update
  71993. * @param data defines the data to store
  71994. * @param format defines the data format
  71995. * @param invertY defines if data must be stored with Y axis inverted
  71996. */
  71997. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  71998. /**
  71999. * Update a raw 3D texture
  72000. * @param texture defines the texture to update
  72001. * @param data defines the data to store
  72002. * @param format defines the data format
  72003. * @param invertY defines if data must be stored with Y axis inverted
  72004. * @param compression defines the used compression (can be null)
  72005. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  72006. */
  72007. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  72008. }
  72009. }
  72010. declare module BABYLON {
  72011. /**
  72012. * Raw texture can help creating a texture directly from an array of data.
  72013. * This can be super useful if you either get the data from an uncompressed source or
  72014. * if you wish to create your texture pixel by pixel.
  72015. */
  72016. export class RawTexture extends Texture {
  72017. /**
  72018. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  72019. */
  72020. format: number;
  72021. private _engine;
  72022. /**
  72023. * Instantiates a new RawTexture.
  72024. * Raw texture can help creating a texture directly from an array of data.
  72025. * This can be super useful if you either get the data from an uncompressed source or
  72026. * if you wish to create your texture pixel by pixel.
  72027. * @param data define the array of data to use to create the texture
  72028. * @param width define the width of the texture
  72029. * @param height define the height of the texture
  72030. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  72031. * @param scene define the scene the texture belongs to
  72032. * @param generateMipMaps define whether mip maps should be generated or not
  72033. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  72034. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  72035. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  72036. */
  72037. constructor(data: ArrayBufferView, width: number, height: number,
  72038. /**
  72039. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  72040. */
  72041. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  72042. /**
  72043. * Updates the texture underlying data.
  72044. * @param data Define the new data of the texture
  72045. */
  72046. update(data: ArrayBufferView): void;
  72047. /**
  72048. * Creates a luminance texture from some data.
  72049. * @param data Define the texture data
  72050. * @param width Define the width of the texture
  72051. * @param height Define the height of the texture
  72052. * @param scene Define the scene the texture belongs to
  72053. * @param generateMipMaps Define whether or not to create mip maps for the texture
  72054. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  72055. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  72056. * @returns the luminance texture
  72057. */
  72058. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  72059. /**
  72060. * Creates a luminance alpha texture from some data.
  72061. * @param data Define the texture data
  72062. * @param width Define the width of the texture
  72063. * @param height Define the height of the texture
  72064. * @param scene Define the scene the texture belongs to
  72065. * @param generateMipMaps Define whether or not to create mip maps for the texture
  72066. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  72067. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  72068. * @returns the luminance alpha texture
  72069. */
  72070. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  72071. /**
  72072. * Creates an alpha texture from some data.
  72073. * @param data Define the texture data
  72074. * @param width Define the width of the texture
  72075. * @param height Define the height of the texture
  72076. * @param scene Define the scene the texture belongs to
  72077. * @param generateMipMaps Define whether or not to create mip maps for the texture
  72078. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  72079. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  72080. * @returns the alpha texture
  72081. */
  72082. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  72083. /**
  72084. * Creates a RGB texture from some data.
  72085. * @param data Define the texture data
  72086. * @param width Define the width of the texture
  72087. * @param height Define the height of the texture
  72088. * @param scene Define the scene the texture belongs to
  72089. * @param generateMipMaps Define whether or not to create mip maps for the texture
  72090. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  72091. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  72092. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  72093. * @returns the RGB alpha texture
  72094. */
  72095. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  72096. /**
  72097. * Creates a RGBA texture from some data.
  72098. * @param data Define the texture data
  72099. * @param width Define the width of the texture
  72100. * @param height Define the height of the texture
  72101. * @param scene Define the scene the texture belongs to
  72102. * @param generateMipMaps Define whether or not to create mip maps for the texture
  72103. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  72104. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  72105. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  72106. * @returns the RGBA texture
  72107. */
  72108. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  72109. /**
  72110. * Creates a R texture from some data.
  72111. * @param data Define the texture data
  72112. * @param width Define the width of the texture
  72113. * @param height Define the height of the texture
  72114. * @param scene Define the scene the texture belongs to
  72115. * @param generateMipMaps Define whether or not to create mip maps for the texture
  72116. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  72117. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  72118. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  72119. * @returns the R texture
  72120. */
  72121. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  72122. }
  72123. }
  72124. declare module BABYLON {
  72125. /**
  72126. * Defines a runtime animation
  72127. */
  72128. export class RuntimeAnimation {
  72129. private _events;
  72130. /**
  72131. * The current frame of the runtime animation
  72132. */
  72133. private _currentFrame;
  72134. /**
  72135. * The animation used by the runtime animation
  72136. */
  72137. private _animation;
  72138. /**
  72139. * The target of the runtime animation
  72140. */
  72141. private _target;
  72142. /**
  72143. * The initiating animatable
  72144. */
  72145. private _host;
  72146. /**
  72147. * The original value of the runtime animation
  72148. */
  72149. private _originalValue;
  72150. /**
  72151. * The original blend value of the runtime animation
  72152. */
  72153. private _originalBlendValue;
  72154. /**
  72155. * The offsets cache of the runtime animation
  72156. */
  72157. private _offsetsCache;
  72158. /**
  72159. * The high limits cache of the runtime animation
  72160. */
  72161. private _highLimitsCache;
  72162. /**
  72163. * Specifies if the runtime animation has been stopped
  72164. */
  72165. private _stopped;
  72166. /**
  72167. * The blending factor of the runtime animation
  72168. */
  72169. private _blendingFactor;
  72170. /**
  72171. * The BabylonJS scene
  72172. */
  72173. private _scene;
  72174. /**
  72175. * The current value of the runtime animation
  72176. */
  72177. private _currentValue;
  72178. /** @hidden */
  72179. _animationState: _IAnimationState;
  72180. /**
  72181. * The active target of the runtime animation
  72182. */
  72183. private _activeTargets;
  72184. private _currentActiveTarget;
  72185. private _directTarget;
  72186. /**
  72187. * The target path of the runtime animation
  72188. */
  72189. private _targetPath;
  72190. /**
  72191. * The weight of the runtime animation
  72192. */
  72193. private _weight;
  72194. /**
  72195. * The ratio offset of the runtime animation
  72196. */
  72197. private _ratioOffset;
  72198. /**
  72199. * The previous delay of the runtime animation
  72200. */
  72201. private _previousDelay;
  72202. /**
  72203. * The previous ratio of the runtime animation
  72204. */
  72205. private _previousRatio;
  72206. private _enableBlending;
  72207. private _keys;
  72208. private _minFrame;
  72209. private _maxFrame;
  72210. private _minValue;
  72211. private _maxValue;
  72212. private _targetIsArray;
  72213. /**
  72214. * Gets the current frame of the runtime animation
  72215. */
  72216. readonly currentFrame: number;
  72217. /**
  72218. * Gets the weight of the runtime animation
  72219. */
  72220. readonly weight: number;
  72221. /**
  72222. * Gets the current value of the runtime animation
  72223. */
  72224. readonly currentValue: any;
  72225. /**
  72226. * Gets the target path of the runtime animation
  72227. */
  72228. readonly targetPath: string;
  72229. /**
  72230. * Gets the actual target of the runtime animation
  72231. */
  72232. readonly target: any;
  72233. /** @hidden */
  72234. _onLoop: () => void;
  72235. /**
  72236. * Create a new RuntimeAnimation object
  72237. * @param target defines the target of the animation
  72238. * @param animation defines the source animation object
  72239. * @param scene defines the hosting scene
  72240. * @param host defines the initiating Animatable
  72241. */
  72242. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  72243. private _preparePath;
  72244. /**
  72245. * Gets the animation from the runtime animation
  72246. */
  72247. readonly animation: Animation;
  72248. /**
  72249. * Resets the runtime animation to the beginning
  72250. * @param restoreOriginal defines whether to restore the target property to the original value
  72251. */
  72252. reset(restoreOriginal?: boolean): void;
  72253. /**
  72254. * Specifies if the runtime animation is stopped
  72255. * @returns Boolean specifying if the runtime animation is stopped
  72256. */
  72257. isStopped(): boolean;
  72258. /**
  72259. * Disposes of the runtime animation
  72260. */
  72261. dispose(): void;
  72262. /**
  72263. * Apply the interpolated value to the target
  72264. * @param currentValue defines the value computed by the animation
  72265. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  72266. */
  72267. setValue(currentValue: any, weight: number): void;
  72268. private _getOriginalValues;
  72269. private _setValue;
  72270. /**
  72271. * Gets the loop pmode of the runtime animation
  72272. * @returns Loop Mode
  72273. */
  72274. private _getCorrectLoopMode;
  72275. /**
  72276. * Move the current animation to a given frame
  72277. * @param frame defines the frame to move to
  72278. */
  72279. goToFrame(frame: number): void;
  72280. /**
  72281. * @hidden Internal use only
  72282. */
  72283. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  72284. /**
  72285. * Execute the current animation
  72286. * @param delay defines the delay to add to the current frame
  72287. * @param from defines the lower bound of the animation range
  72288. * @param to defines the upper bound of the animation range
  72289. * @param loop defines if the current animation must loop
  72290. * @param speedRatio defines the current speed ratio
  72291. * @param weight defines the weight of the animation (default is -1 so no weight)
  72292. * @param onLoop optional callback called when animation loops
  72293. * @returns a boolean indicating if the animation is running
  72294. */
  72295. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  72296. }
  72297. }
  72298. declare module BABYLON {
  72299. /**
  72300. * Class used to store an actual running animation
  72301. */
  72302. export class Animatable {
  72303. /** defines the target object */
  72304. target: any;
  72305. /** defines the starting frame number (default is 0) */
  72306. fromFrame: number;
  72307. /** defines the ending frame number (default is 100) */
  72308. toFrame: number;
  72309. /** defines if the animation must loop (default is false) */
  72310. loopAnimation: boolean;
  72311. /** defines a callback to call when animation ends if it is not looping */
  72312. onAnimationEnd?: (() => void) | null | undefined;
  72313. /** defines a callback to call when animation loops */
  72314. onAnimationLoop?: (() => void) | null | undefined;
  72315. private _localDelayOffset;
  72316. private _pausedDelay;
  72317. private _runtimeAnimations;
  72318. private _paused;
  72319. private _scene;
  72320. private _speedRatio;
  72321. private _weight;
  72322. private _syncRoot;
  72323. /**
  72324. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  72325. * This will only apply for non looping animation (default is true)
  72326. */
  72327. disposeOnEnd: boolean;
  72328. /**
  72329. * Gets a boolean indicating if the animation has started
  72330. */
  72331. animationStarted: boolean;
  72332. /**
  72333. * Observer raised when the animation ends
  72334. */
  72335. onAnimationEndObservable: Observable<Animatable>;
  72336. /**
  72337. * Observer raised when the animation loops
  72338. */
  72339. onAnimationLoopObservable: Observable<Animatable>;
  72340. /**
  72341. * Gets the root Animatable used to synchronize and normalize animations
  72342. */
  72343. readonly syncRoot: Nullable<Animatable>;
  72344. /**
  72345. * Gets the current frame of the first RuntimeAnimation
  72346. * Used to synchronize Animatables
  72347. */
  72348. readonly masterFrame: number;
  72349. /**
  72350. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  72351. */
  72352. weight: number;
  72353. /**
  72354. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  72355. */
  72356. speedRatio: number;
  72357. /**
  72358. * Creates a new Animatable
  72359. * @param scene defines the hosting scene
  72360. * @param target defines the target object
  72361. * @param fromFrame defines the starting frame number (default is 0)
  72362. * @param toFrame defines the ending frame number (default is 100)
  72363. * @param loopAnimation defines if the animation must loop (default is false)
  72364. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  72365. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  72366. * @param animations defines a group of animation to add to the new Animatable
  72367. * @param onAnimationLoop defines a callback to call when animation loops
  72368. */
  72369. constructor(scene: Scene,
  72370. /** defines the target object */
  72371. target: any,
  72372. /** defines the starting frame number (default is 0) */
  72373. fromFrame?: number,
  72374. /** defines the ending frame number (default is 100) */
  72375. toFrame?: number,
  72376. /** defines if the animation must loop (default is false) */
  72377. loopAnimation?: boolean, speedRatio?: number,
  72378. /** defines a callback to call when animation ends if it is not looping */
  72379. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  72380. /** defines a callback to call when animation loops */
  72381. onAnimationLoop?: (() => void) | null | undefined);
  72382. /**
  72383. * Synchronize and normalize current Animatable with a source Animatable
  72384. * This is useful when using animation weights and when animations are not of the same length
  72385. * @param root defines the root Animatable to synchronize with
  72386. * @returns the current Animatable
  72387. */
  72388. syncWith(root: Animatable): Animatable;
  72389. /**
  72390. * Gets the list of runtime animations
  72391. * @returns an array of RuntimeAnimation
  72392. */
  72393. getAnimations(): RuntimeAnimation[];
  72394. /**
  72395. * Adds more animations to the current animatable
  72396. * @param target defines the target of the animations
  72397. * @param animations defines the new animations to add
  72398. */
  72399. appendAnimations(target: any, animations: Animation[]): void;
  72400. /**
  72401. * Gets the source animation for a specific property
  72402. * @param property defines the propertyu to look for
  72403. * @returns null or the source animation for the given property
  72404. */
  72405. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  72406. /**
  72407. * Gets the runtime animation for a specific property
  72408. * @param property defines the propertyu to look for
  72409. * @returns null or the runtime animation for the given property
  72410. */
  72411. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  72412. /**
  72413. * Resets the animatable to its original state
  72414. */
  72415. reset(): void;
  72416. /**
  72417. * Allows the animatable to blend with current running animations
  72418. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  72419. * @param blendingSpeed defines the blending speed to use
  72420. */
  72421. enableBlending(blendingSpeed: number): void;
  72422. /**
  72423. * Disable animation blending
  72424. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  72425. */
  72426. disableBlending(): void;
  72427. /**
  72428. * Jump directly to a given frame
  72429. * @param frame defines the frame to jump to
  72430. */
  72431. goToFrame(frame: number): void;
  72432. /**
  72433. * Pause the animation
  72434. */
  72435. pause(): void;
  72436. /**
  72437. * Restart the animation
  72438. */
  72439. restart(): void;
  72440. private _raiseOnAnimationEnd;
  72441. /**
  72442. * Stop and delete the current animation
  72443. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  72444. * @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)
  72445. */
  72446. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  72447. /**
  72448. * Wait asynchronously for the animation to end
  72449. * @returns a promise which will be fullfilled when the animation ends
  72450. */
  72451. waitAsync(): Promise<Animatable>;
  72452. /** @hidden */
  72453. _animate(delay: number): boolean;
  72454. }
  72455. interface Scene {
  72456. /** @hidden */
  72457. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  72458. /** @hidden */
  72459. _processLateAnimationBindingsForMatrices(holder: {
  72460. totalWeight: number;
  72461. animations: RuntimeAnimation[];
  72462. originalValue: Matrix;
  72463. }): any;
  72464. /** @hidden */
  72465. _processLateAnimationBindingsForQuaternions(holder: {
  72466. totalWeight: number;
  72467. animations: RuntimeAnimation[];
  72468. originalValue: Quaternion;
  72469. }, refQuaternion: Quaternion): Quaternion;
  72470. /** @hidden */
  72471. _processLateAnimationBindings(): void;
  72472. /**
  72473. * Will start the animation sequence of a given target
  72474. * @param target defines the target
  72475. * @param from defines from which frame should animation start
  72476. * @param to defines until which frame should animation run.
  72477. * @param weight defines the weight to apply to the animation (1.0 by default)
  72478. * @param loop defines if the animation loops
  72479. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  72480. * @param onAnimationEnd defines the function to be executed when the animation ends
  72481. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  72482. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  72483. * @param onAnimationLoop defines the callback to call when an animation loops
  72484. * @returns the animatable object created for this animation
  72485. */
  72486. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  72487. /**
  72488. * Will start the animation sequence of a given target
  72489. * @param target defines the target
  72490. * @param from defines from which frame should animation start
  72491. * @param to defines until which frame should animation run.
  72492. * @param loop defines if the animation loops
  72493. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  72494. * @param onAnimationEnd defines the function to be executed when the animation ends
  72495. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  72496. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  72497. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  72498. * @param onAnimationLoop defines the callback to call when an animation loops
  72499. * @returns the animatable object created for this animation
  72500. */
  72501. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  72502. /**
  72503. * Will start the animation sequence of a given target and its hierarchy
  72504. * @param target defines the target
  72505. * @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.
  72506. * @param from defines from which frame should animation start
  72507. * @param to defines until which frame should animation run.
  72508. * @param loop defines if the animation loops
  72509. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  72510. * @param onAnimationEnd defines the function to be executed when the animation ends
  72511. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  72512. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  72513. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  72514. * @param onAnimationLoop defines the callback to call when an animation loops
  72515. * @returns the list of created animatables
  72516. */
  72517. 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[];
  72518. /**
  72519. * Begin a new animation on a given node
  72520. * @param target defines the target where the animation will take place
  72521. * @param animations defines the list of animations to start
  72522. * @param from defines the initial value
  72523. * @param to defines the final value
  72524. * @param loop defines if you want animation to loop (off by default)
  72525. * @param speedRatio defines the speed ratio to apply to all animations
  72526. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  72527. * @param onAnimationLoop defines the callback to call when an animation loops
  72528. * @returns the list of created animatables
  72529. */
  72530. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  72531. /**
  72532. * Begin a new animation on a given node and its hierarchy
  72533. * @param target defines the root node where the animation will take place
  72534. * @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.
  72535. * @param animations defines the list of animations to start
  72536. * @param from defines the initial value
  72537. * @param to defines the final value
  72538. * @param loop defines if you want animation to loop (off by default)
  72539. * @param speedRatio defines the speed ratio to apply to all animations
  72540. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  72541. * @param onAnimationLoop defines the callback to call when an animation loops
  72542. * @returns the list of animatables created for all nodes
  72543. */
  72544. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  72545. /**
  72546. * Gets the animatable associated with a specific target
  72547. * @param target defines the target of the animatable
  72548. * @returns the required animatable if found
  72549. */
  72550. getAnimatableByTarget(target: any): Nullable<Animatable>;
  72551. /**
  72552. * Gets all animatables associated with a given target
  72553. * @param target defines the target to look animatables for
  72554. * @returns an array of Animatables
  72555. */
  72556. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  72557. /**
  72558. * Stops and removes all animations that have been applied to the scene
  72559. */
  72560. stopAllAnimations(): void;
  72561. }
  72562. interface Bone {
  72563. /**
  72564. * Copy an animation range from another bone
  72565. * @param source defines the source bone
  72566. * @param rangeName defines the range name to copy
  72567. * @param frameOffset defines the frame offset
  72568. * @param rescaleAsRequired defines if rescaling must be applied if required
  72569. * @param skelDimensionsRatio defines the scaling ratio
  72570. * @returns true if operation was successful
  72571. */
  72572. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  72573. }
  72574. }
  72575. declare module BABYLON {
  72576. /**
  72577. * Class used to handle skinning animations
  72578. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  72579. */
  72580. export class Skeleton implements IAnimatable {
  72581. /** defines the skeleton name */
  72582. name: string;
  72583. /** defines the skeleton Id */
  72584. id: string;
  72585. /**
  72586. * Defines the list of child bones
  72587. */
  72588. bones: Bone[];
  72589. /**
  72590. * Defines an estimate of the dimension of the skeleton at rest
  72591. */
  72592. dimensionsAtRest: Vector3;
  72593. /**
  72594. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  72595. */
  72596. needInitialSkinMatrix: boolean;
  72597. /**
  72598. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  72599. */
  72600. overrideMesh: Nullable<AbstractMesh>;
  72601. /**
  72602. * Gets the list of animations attached to this skeleton
  72603. */
  72604. animations: Array<Animation>;
  72605. private _scene;
  72606. private _isDirty;
  72607. private _transformMatrices;
  72608. private _transformMatrixTexture;
  72609. private _meshesWithPoseMatrix;
  72610. private _animatables;
  72611. private _identity;
  72612. private _synchronizedWithMesh;
  72613. private _ranges;
  72614. private _lastAbsoluteTransformsUpdateId;
  72615. private _canUseTextureForBones;
  72616. private _uniqueId;
  72617. /** @hidden */
  72618. _numBonesWithLinkedTransformNode: number;
  72619. /** @hidden */
  72620. _hasWaitingData: Nullable<boolean>;
  72621. /**
  72622. * Specifies if the skeleton should be serialized
  72623. */
  72624. doNotSerialize: boolean;
  72625. private _useTextureToStoreBoneMatrices;
  72626. /**
  72627. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  72628. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  72629. */
  72630. useTextureToStoreBoneMatrices: boolean;
  72631. private _animationPropertiesOverride;
  72632. /**
  72633. * Gets or sets the animation properties override
  72634. */
  72635. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  72636. /**
  72637. * List of inspectable custom properties (used by the Inspector)
  72638. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  72639. */
  72640. inspectableCustomProperties: IInspectable[];
  72641. /**
  72642. * An observable triggered before computing the skeleton's matrices
  72643. */
  72644. onBeforeComputeObservable: Observable<Skeleton>;
  72645. /**
  72646. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  72647. */
  72648. readonly isUsingTextureForMatrices: boolean;
  72649. /**
  72650. * Gets the unique ID of this skeleton
  72651. */
  72652. readonly uniqueId: number;
  72653. /**
  72654. * Creates a new skeleton
  72655. * @param name defines the skeleton name
  72656. * @param id defines the skeleton Id
  72657. * @param scene defines the hosting scene
  72658. */
  72659. constructor(
  72660. /** defines the skeleton name */
  72661. name: string,
  72662. /** defines the skeleton Id */
  72663. id: string, scene: Scene);
  72664. /**
  72665. * Gets the current object class name.
  72666. * @return the class name
  72667. */
  72668. getClassName(): string;
  72669. /**
  72670. * Returns an array containing the root bones
  72671. * @returns an array containing the root bones
  72672. */
  72673. getChildren(): Array<Bone>;
  72674. /**
  72675. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  72676. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  72677. * @returns a Float32Array containing matrices data
  72678. */
  72679. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  72680. /**
  72681. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  72682. * @returns a raw texture containing the data
  72683. */
  72684. getTransformMatrixTexture(): Nullable<RawTexture>;
  72685. /**
  72686. * Gets the current hosting scene
  72687. * @returns a scene object
  72688. */
  72689. getScene(): Scene;
  72690. /**
  72691. * Gets a string representing the current skeleton data
  72692. * @param fullDetails defines a boolean indicating if we want a verbose version
  72693. * @returns a string representing the current skeleton data
  72694. */
  72695. toString(fullDetails?: boolean): string;
  72696. /**
  72697. * Get bone's index searching by name
  72698. * @param name defines bone's name to search for
  72699. * @return the indice of the bone. Returns -1 if not found
  72700. */
  72701. getBoneIndexByName(name: string): number;
  72702. /**
  72703. * Creater a new animation range
  72704. * @param name defines the name of the range
  72705. * @param from defines the start key
  72706. * @param to defines the end key
  72707. */
  72708. createAnimationRange(name: string, from: number, to: number): void;
  72709. /**
  72710. * Delete a specific animation range
  72711. * @param name defines the name of the range
  72712. * @param deleteFrames defines if frames must be removed as well
  72713. */
  72714. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  72715. /**
  72716. * Gets a specific animation range
  72717. * @param name defines the name of the range to look for
  72718. * @returns the requested animation range or null if not found
  72719. */
  72720. getAnimationRange(name: string): Nullable<AnimationRange>;
  72721. /**
  72722. * Gets the list of all animation ranges defined on this skeleton
  72723. * @returns an array
  72724. */
  72725. getAnimationRanges(): Nullable<AnimationRange>[];
  72726. /**
  72727. * Copy animation range from a source skeleton.
  72728. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  72729. * @param source defines the source skeleton
  72730. * @param name defines the name of the range to copy
  72731. * @param rescaleAsRequired defines if rescaling must be applied if required
  72732. * @returns true if operation was successful
  72733. */
  72734. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  72735. /**
  72736. * Forces the skeleton to go to rest pose
  72737. */
  72738. returnToRest(): void;
  72739. private _getHighestAnimationFrame;
  72740. /**
  72741. * Begin a specific animation range
  72742. * @param name defines the name of the range to start
  72743. * @param loop defines if looping must be turned on (false by default)
  72744. * @param speedRatio defines the speed ratio to apply (1 by default)
  72745. * @param onAnimationEnd defines a callback which will be called when animation will end
  72746. * @returns a new animatable
  72747. */
  72748. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  72749. /** @hidden */
  72750. _markAsDirty(): void;
  72751. /** @hidden */
  72752. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  72753. /** @hidden */
  72754. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  72755. private _computeTransformMatrices;
  72756. /**
  72757. * Build all resources required to render a skeleton
  72758. */
  72759. prepare(): void;
  72760. /**
  72761. * Gets the list of animatables currently running for this skeleton
  72762. * @returns an array of animatables
  72763. */
  72764. getAnimatables(): IAnimatable[];
  72765. /**
  72766. * Clone the current skeleton
  72767. * @param name defines the name of the new skeleton
  72768. * @param id defines the id of the new skeleton
  72769. * @returns the new skeleton
  72770. */
  72771. clone(name: string, id: string): Skeleton;
  72772. /**
  72773. * Enable animation blending for this skeleton
  72774. * @param blendingSpeed defines the blending speed to apply
  72775. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  72776. */
  72777. enableBlending(blendingSpeed?: number): void;
  72778. /**
  72779. * Releases all resources associated with the current skeleton
  72780. */
  72781. dispose(): void;
  72782. /**
  72783. * Serialize the skeleton in a JSON object
  72784. * @returns a JSON object
  72785. */
  72786. serialize(): any;
  72787. /**
  72788. * Creates a new skeleton from serialized data
  72789. * @param parsedSkeleton defines the serialized data
  72790. * @param scene defines the hosting scene
  72791. * @returns a new skeleton
  72792. */
  72793. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  72794. /**
  72795. * Compute all node absolute transforms
  72796. * @param forceUpdate defines if computation must be done even if cache is up to date
  72797. */
  72798. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  72799. /**
  72800. * Gets the root pose matrix
  72801. * @returns a matrix
  72802. */
  72803. getPoseMatrix(): Nullable<Matrix>;
  72804. /**
  72805. * Sorts bones per internal index
  72806. */
  72807. sortBones(): void;
  72808. private _sortBones;
  72809. }
  72810. }
  72811. declare module BABYLON {
  72812. /**
  72813. * Defines a target to use with MorphTargetManager
  72814. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  72815. */
  72816. export class MorphTarget implements IAnimatable {
  72817. /** defines the name of the target */
  72818. name: string;
  72819. /**
  72820. * Gets or sets the list of animations
  72821. */
  72822. animations: Animation[];
  72823. private _scene;
  72824. private _positions;
  72825. private _normals;
  72826. private _tangents;
  72827. private _influence;
  72828. /**
  72829. * Observable raised when the influence changes
  72830. */
  72831. onInfluenceChanged: Observable<boolean>;
  72832. /** @hidden */
  72833. _onDataLayoutChanged: Observable<void>;
  72834. /**
  72835. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  72836. */
  72837. influence: number;
  72838. /**
  72839. * Gets or sets the id of the morph Target
  72840. */
  72841. id: string;
  72842. private _animationPropertiesOverride;
  72843. /**
  72844. * Gets or sets the animation properties override
  72845. */
  72846. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  72847. /**
  72848. * Creates a new MorphTarget
  72849. * @param name defines the name of the target
  72850. * @param influence defines the influence to use
  72851. * @param scene defines the scene the morphtarget belongs to
  72852. */
  72853. constructor(
  72854. /** defines the name of the target */
  72855. name: string, influence?: number, scene?: Nullable<Scene>);
  72856. /**
  72857. * Gets a boolean defining if the target contains position data
  72858. */
  72859. readonly hasPositions: boolean;
  72860. /**
  72861. * Gets a boolean defining if the target contains normal data
  72862. */
  72863. readonly hasNormals: boolean;
  72864. /**
  72865. * Gets a boolean defining if the target contains tangent data
  72866. */
  72867. readonly hasTangents: boolean;
  72868. /**
  72869. * Affects position data to this target
  72870. * @param data defines the position data to use
  72871. */
  72872. setPositions(data: Nullable<FloatArray>): void;
  72873. /**
  72874. * Gets the position data stored in this target
  72875. * @returns a FloatArray containing the position data (or null if not present)
  72876. */
  72877. getPositions(): Nullable<FloatArray>;
  72878. /**
  72879. * Affects normal data to this target
  72880. * @param data defines the normal data to use
  72881. */
  72882. setNormals(data: Nullable<FloatArray>): void;
  72883. /**
  72884. * Gets the normal data stored in this target
  72885. * @returns a FloatArray containing the normal data (or null if not present)
  72886. */
  72887. getNormals(): Nullable<FloatArray>;
  72888. /**
  72889. * Affects tangent data to this target
  72890. * @param data defines the tangent data to use
  72891. */
  72892. setTangents(data: Nullable<FloatArray>): void;
  72893. /**
  72894. * Gets the tangent data stored in this target
  72895. * @returns a FloatArray containing the tangent data (or null if not present)
  72896. */
  72897. getTangents(): Nullable<FloatArray>;
  72898. /**
  72899. * Serializes the current target into a Serialization object
  72900. * @returns the serialized object
  72901. */
  72902. serialize(): any;
  72903. /**
  72904. * Returns the string "MorphTarget"
  72905. * @returns "MorphTarget"
  72906. */
  72907. getClassName(): string;
  72908. /**
  72909. * Creates a new target from serialized data
  72910. * @param serializationObject defines the serialized data to use
  72911. * @returns a new MorphTarget
  72912. */
  72913. static Parse(serializationObject: any): MorphTarget;
  72914. /**
  72915. * Creates a MorphTarget from mesh data
  72916. * @param mesh defines the source mesh
  72917. * @param name defines the name to use for the new target
  72918. * @param influence defines the influence to attach to the target
  72919. * @returns a new MorphTarget
  72920. */
  72921. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  72922. }
  72923. }
  72924. declare module BABYLON {
  72925. /**
  72926. * This class is used to deform meshes using morphing between different targets
  72927. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  72928. */
  72929. export class MorphTargetManager {
  72930. private _targets;
  72931. private _targetInfluenceChangedObservers;
  72932. private _targetDataLayoutChangedObservers;
  72933. private _activeTargets;
  72934. private _scene;
  72935. private _influences;
  72936. private _supportsNormals;
  72937. private _supportsTangents;
  72938. private _vertexCount;
  72939. private _uniqueId;
  72940. private _tempInfluences;
  72941. /**
  72942. * Creates a new MorphTargetManager
  72943. * @param scene defines the current scene
  72944. */
  72945. constructor(scene?: Nullable<Scene>);
  72946. /**
  72947. * Gets the unique ID of this manager
  72948. */
  72949. readonly uniqueId: number;
  72950. /**
  72951. * Gets the number of vertices handled by this manager
  72952. */
  72953. readonly vertexCount: number;
  72954. /**
  72955. * Gets a boolean indicating if this manager supports morphing of normals
  72956. */
  72957. readonly supportsNormals: boolean;
  72958. /**
  72959. * Gets a boolean indicating if this manager supports morphing of tangents
  72960. */
  72961. readonly supportsTangents: boolean;
  72962. /**
  72963. * Gets the number of targets stored in this manager
  72964. */
  72965. readonly numTargets: number;
  72966. /**
  72967. * Gets the number of influencers (ie. the number of targets with influences > 0)
  72968. */
  72969. readonly numInfluencers: number;
  72970. /**
  72971. * Gets the list of influences (one per target)
  72972. */
  72973. readonly influences: Float32Array;
  72974. /**
  72975. * Gets the active target at specified index. An active target is a target with an influence > 0
  72976. * @param index defines the index to check
  72977. * @returns the requested target
  72978. */
  72979. getActiveTarget(index: number): MorphTarget;
  72980. /**
  72981. * Gets the target at specified index
  72982. * @param index defines the index to check
  72983. * @returns the requested target
  72984. */
  72985. getTarget(index: number): MorphTarget;
  72986. /**
  72987. * Add a new target to this manager
  72988. * @param target defines the target to add
  72989. */
  72990. addTarget(target: MorphTarget): void;
  72991. /**
  72992. * Removes a target from the manager
  72993. * @param target defines the target to remove
  72994. */
  72995. removeTarget(target: MorphTarget): void;
  72996. /**
  72997. * Serializes the current manager into a Serialization object
  72998. * @returns the serialized object
  72999. */
  73000. serialize(): any;
  73001. private _syncActiveTargets;
  73002. /**
  73003. * Syncrhonize the targets with all the meshes using this morph target manager
  73004. */
  73005. synchronize(): void;
  73006. /**
  73007. * Creates a new MorphTargetManager from serialized data
  73008. * @param serializationObject defines the serialized data
  73009. * @param scene defines the hosting scene
  73010. * @returns the new MorphTargetManager
  73011. */
  73012. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  73013. }
  73014. }
  73015. declare module BABYLON {
  73016. /**
  73017. * Groups all the scene component constants in one place to ease maintenance.
  73018. * @hidden
  73019. */
  73020. export class SceneComponentConstants {
  73021. static readonly NAME_EFFECTLAYER: string;
  73022. static readonly NAME_LAYER: string;
  73023. static readonly NAME_LENSFLARESYSTEM: string;
  73024. static readonly NAME_BOUNDINGBOXRENDERER: string;
  73025. static readonly NAME_PARTICLESYSTEM: string;
  73026. static readonly NAME_GAMEPAD: string;
  73027. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  73028. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  73029. static readonly NAME_DEPTHRENDERER: string;
  73030. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  73031. static readonly NAME_SPRITE: string;
  73032. static readonly NAME_OUTLINERENDERER: string;
  73033. static readonly NAME_PROCEDURALTEXTURE: string;
  73034. static readonly NAME_SHADOWGENERATOR: string;
  73035. static readonly NAME_OCTREE: string;
  73036. static readonly NAME_PHYSICSENGINE: string;
  73037. static readonly NAME_AUDIO: string;
  73038. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  73039. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  73040. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  73041. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  73042. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  73043. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  73044. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  73045. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  73046. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  73047. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  73048. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  73049. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  73050. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  73051. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  73052. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  73053. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  73054. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  73055. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  73056. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  73057. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  73058. static readonly STEP_AFTERRENDER_AUDIO: number;
  73059. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  73060. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  73061. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  73062. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  73063. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  73064. static readonly STEP_POINTERMOVE_SPRITE: number;
  73065. static readonly STEP_POINTERDOWN_SPRITE: number;
  73066. static readonly STEP_POINTERUP_SPRITE: number;
  73067. }
  73068. /**
  73069. * This represents a scene component.
  73070. *
  73071. * This is used to decouple the dependency the scene is having on the different workloads like
  73072. * layers, post processes...
  73073. */
  73074. export interface ISceneComponent {
  73075. /**
  73076. * The name of the component. Each component must have a unique name.
  73077. */
  73078. name: string;
  73079. /**
  73080. * The scene the component belongs to.
  73081. */
  73082. scene: Scene;
  73083. /**
  73084. * Register the component to one instance of a scene.
  73085. */
  73086. register(): void;
  73087. /**
  73088. * Rebuilds the elements related to this component in case of
  73089. * context lost for instance.
  73090. */
  73091. rebuild(): void;
  73092. /**
  73093. * Disposes the component and the associated ressources.
  73094. */
  73095. dispose(): void;
  73096. }
  73097. /**
  73098. * This represents a SERIALIZABLE scene component.
  73099. *
  73100. * This extends Scene Component to add Serialization methods on top.
  73101. */
  73102. export interface ISceneSerializableComponent extends ISceneComponent {
  73103. /**
  73104. * Adds all the elements from the container to the scene
  73105. * @param container the container holding the elements
  73106. */
  73107. addFromContainer(container: AbstractScene): void;
  73108. /**
  73109. * Removes all the elements in the container from the scene
  73110. * @param container contains the elements to remove
  73111. * @param dispose if the removed element should be disposed (default: false)
  73112. */
  73113. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  73114. /**
  73115. * Serializes the component data to the specified json object
  73116. * @param serializationObject The object to serialize to
  73117. */
  73118. serialize(serializationObject: any): void;
  73119. }
  73120. /**
  73121. * Strong typing of a Mesh related stage step action
  73122. */
  73123. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  73124. /**
  73125. * Strong typing of a Evaluate Sub Mesh related stage step action
  73126. */
  73127. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  73128. /**
  73129. * Strong typing of a Active Mesh related stage step action
  73130. */
  73131. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  73132. /**
  73133. * Strong typing of a Camera related stage step action
  73134. */
  73135. export type CameraStageAction = (camera: Camera) => void;
  73136. /**
  73137. * Strong typing of a Camera Frame buffer related stage step action
  73138. */
  73139. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  73140. /**
  73141. * Strong typing of a Render Target related stage step action
  73142. */
  73143. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  73144. /**
  73145. * Strong typing of a RenderingGroup related stage step action
  73146. */
  73147. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  73148. /**
  73149. * Strong typing of a Mesh Render related stage step action
  73150. */
  73151. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  73152. /**
  73153. * Strong typing of a simple stage step action
  73154. */
  73155. export type SimpleStageAction = () => void;
  73156. /**
  73157. * Strong typing of a render target action.
  73158. */
  73159. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  73160. /**
  73161. * Strong typing of a pointer move action.
  73162. */
  73163. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  73164. /**
  73165. * Strong typing of a pointer up/down action.
  73166. */
  73167. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  73168. /**
  73169. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  73170. * @hidden
  73171. */
  73172. export class Stage<T extends Function> extends Array<{
  73173. index: number;
  73174. component: ISceneComponent;
  73175. action: T;
  73176. }> {
  73177. /**
  73178. * Hide ctor from the rest of the world.
  73179. * @param items The items to add.
  73180. */
  73181. private constructor();
  73182. /**
  73183. * Creates a new Stage.
  73184. * @returns A new instance of a Stage
  73185. */
  73186. static Create<T extends Function>(): Stage<T>;
  73187. /**
  73188. * Registers a step in an ordered way in the targeted stage.
  73189. * @param index Defines the position to register the step in
  73190. * @param component Defines the component attached to the step
  73191. * @param action Defines the action to launch during the step
  73192. */
  73193. registerStep(index: number, component: ISceneComponent, action: T): void;
  73194. /**
  73195. * Clears all the steps from the stage.
  73196. */
  73197. clear(): void;
  73198. }
  73199. }
  73200. declare module BABYLON {
  73201. /**
  73202. * Class used to represent a specific level of detail of a mesh
  73203. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  73204. */
  73205. export class MeshLODLevel {
  73206. /** Defines the distance where this level should star being displayed */
  73207. distance: number;
  73208. /** Defines the mesh to use to render this level */
  73209. mesh: Nullable<Mesh>;
  73210. /**
  73211. * Creates a new LOD level
  73212. * @param distance defines the distance where this level should star being displayed
  73213. * @param mesh defines the mesh to use to render this level
  73214. */
  73215. constructor(
  73216. /** Defines the distance where this level should star being displayed */
  73217. distance: number,
  73218. /** Defines the mesh to use to render this level */
  73219. mesh: Nullable<Mesh>);
  73220. }
  73221. }
  73222. declare module BABYLON {
  73223. /**
  73224. * Interface describing all the common properties and methods a shadow light needs to implement.
  73225. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  73226. * as well as binding the different shadow properties to the effects.
  73227. */
  73228. export interface IShadowLight extends Light {
  73229. /**
  73230. * The light id in the scene (used in scene.findLighById for instance)
  73231. */
  73232. id: string;
  73233. /**
  73234. * The position the shdow will be casted from.
  73235. */
  73236. position: Vector3;
  73237. /**
  73238. * In 2d mode (needCube being false), the direction used to cast the shadow.
  73239. */
  73240. direction: Vector3;
  73241. /**
  73242. * The transformed position. Position of the light in world space taking parenting in account.
  73243. */
  73244. transformedPosition: Vector3;
  73245. /**
  73246. * The transformed direction. Direction of the light in world space taking parenting in account.
  73247. */
  73248. transformedDirection: Vector3;
  73249. /**
  73250. * The friendly name of the light in the scene.
  73251. */
  73252. name: string;
  73253. /**
  73254. * Defines the shadow projection clipping minimum z value.
  73255. */
  73256. shadowMinZ: number;
  73257. /**
  73258. * Defines the shadow projection clipping maximum z value.
  73259. */
  73260. shadowMaxZ: number;
  73261. /**
  73262. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  73263. * @returns true if the information has been computed, false if it does not need to (no parenting)
  73264. */
  73265. computeTransformedInformation(): boolean;
  73266. /**
  73267. * Gets the scene the light belongs to.
  73268. * @returns The scene
  73269. */
  73270. getScene(): Scene;
  73271. /**
  73272. * Callback defining a custom Projection Matrix Builder.
  73273. * This can be used to override the default projection matrix computation.
  73274. */
  73275. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  73276. /**
  73277. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  73278. * @param matrix The materix to updated with the projection information
  73279. * @param viewMatrix The transform matrix of the light
  73280. * @param renderList The list of mesh to render in the map
  73281. * @returns The current light
  73282. */
  73283. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  73284. /**
  73285. * Gets the current depth scale used in ESM.
  73286. * @returns The scale
  73287. */
  73288. getDepthScale(): number;
  73289. /**
  73290. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  73291. * @returns true if a cube texture needs to be use
  73292. */
  73293. needCube(): boolean;
  73294. /**
  73295. * Detects if the projection matrix requires to be recomputed this frame.
  73296. * @returns true if it requires to be recomputed otherwise, false.
  73297. */
  73298. needProjectionMatrixCompute(): boolean;
  73299. /**
  73300. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  73301. */
  73302. forceProjectionMatrixCompute(): void;
  73303. /**
  73304. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  73305. * @param faceIndex The index of the face we are computed the direction to generate shadow
  73306. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  73307. */
  73308. getShadowDirection(faceIndex?: number): Vector3;
  73309. /**
  73310. * Gets the minZ used for shadow according to both the scene and the light.
  73311. * @param activeCamera The camera we are returning the min for
  73312. * @returns the depth min z
  73313. */
  73314. getDepthMinZ(activeCamera: Camera): number;
  73315. /**
  73316. * Gets the maxZ used for shadow according to both the scene and the light.
  73317. * @param activeCamera The camera we are returning the max for
  73318. * @returns the depth max z
  73319. */
  73320. getDepthMaxZ(activeCamera: Camera): number;
  73321. }
  73322. /**
  73323. * Base implementation IShadowLight
  73324. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  73325. */
  73326. export abstract class ShadowLight extends Light implements IShadowLight {
  73327. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  73328. protected _position: Vector3;
  73329. protected _setPosition(value: Vector3): void;
  73330. /**
  73331. * Sets the position the shadow will be casted from. Also use as the light position for both
  73332. * point and spot lights.
  73333. */
  73334. /**
  73335. * Sets the position the shadow will be casted from. Also use as the light position for both
  73336. * point and spot lights.
  73337. */
  73338. position: Vector3;
  73339. protected _direction: Vector3;
  73340. protected _setDirection(value: Vector3): void;
  73341. /**
  73342. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  73343. * Also use as the light direction on spot and directional lights.
  73344. */
  73345. /**
  73346. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  73347. * Also use as the light direction on spot and directional lights.
  73348. */
  73349. direction: Vector3;
  73350. private _shadowMinZ;
  73351. /**
  73352. * Gets the shadow projection clipping minimum z value.
  73353. */
  73354. /**
  73355. * Sets the shadow projection clipping minimum z value.
  73356. */
  73357. shadowMinZ: number;
  73358. private _shadowMaxZ;
  73359. /**
  73360. * Sets the shadow projection clipping maximum z value.
  73361. */
  73362. /**
  73363. * Gets the shadow projection clipping maximum z value.
  73364. */
  73365. shadowMaxZ: number;
  73366. /**
  73367. * Callback defining a custom Projection Matrix Builder.
  73368. * This can be used to override the default projection matrix computation.
  73369. */
  73370. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  73371. /**
  73372. * The transformed position. Position of the light in world space taking parenting in account.
  73373. */
  73374. transformedPosition: Vector3;
  73375. /**
  73376. * The transformed direction. Direction of the light in world space taking parenting in account.
  73377. */
  73378. transformedDirection: Vector3;
  73379. private _needProjectionMatrixCompute;
  73380. /**
  73381. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  73382. * @returns true if the information has been computed, false if it does not need to (no parenting)
  73383. */
  73384. computeTransformedInformation(): boolean;
  73385. /**
  73386. * Return the depth scale used for the shadow map.
  73387. * @returns the depth scale.
  73388. */
  73389. getDepthScale(): number;
  73390. /**
  73391. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  73392. * @param faceIndex The index of the face we are computed the direction to generate shadow
  73393. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  73394. */
  73395. getShadowDirection(faceIndex?: number): Vector3;
  73396. /**
  73397. * Returns the ShadowLight absolute position in the World.
  73398. * @returns the position vector in world space
  73399. */
  73400. getAbsolutePosition(): Vector3;
  73401. /**
  73402. * Sets the ShadowLight direction toward the passed target.
  73403. * @param target The point to target in local space
  73404. * @returns the updated ShadowLight direction
  73405. */
  73406. setDirectionToTarget(target: Vector3): Vector3;
  73407. /**
  73408. * Returns the light rotation in euler definition.
  73409. * @returns the x y z rotation in local space.
  73410. */
  73411. getRotation(): Vector3;
  73412. /**
  73413. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  73414. * @returns true if a cube texture needs to be use
  73415. */
  73416. needCube(): boolean;
  73417. /**
  73418. * Detects if the projection matrix requires to be recomputed this frame.
  73419. * @returns true if it requires to be recomputed otherwise, false.
  73420. */
  73421. needProjectionMatrixCompute(): boolean;
  73422. /**
  73423. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  73424. */
  73425. forceProjectionMatrixCompute(): void;
  73426. /** @hidden */
  73427. _initCache(): void;
  73428. /** @hidden */
  73429. _isSynchronized(): boolean;
  73430. /**
  73431. * Computes the world matrix of the node
  73432. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  73433. * @returns the world matrix
  73434. */
  73435. computeWorldMatrix(force?: boolean): Matrix;
  73436. /**
  73437. * Gets the minZ used for shadow according to both the scene and the light.
  73438. * @param activeCamera The camera we are returning the min for
  73439. * @returns the depth min z
  73440. */
  73441. getDepthMinZ(activeCamera: Camera): number;
  73442. /**
  73443. * Gets the maxZ used for shadow according to both the scene and the light.
  73444. * @param activeCamera The camera we are returning the max for
  73445. * @returns the depth max z
  73446. */
  73447. getDepthMaxZ(activeCamera: Camera): number;
  73448. /**
  73449. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  73450. * @param matrix The materix to updated with the projection information
  73451. * @param viewMatrix The transform matrix of the light
  73452. * @param renderList The list of mesh to render in the map
  73453. * @returns The current light
  73454. */
  73455. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  73456. }
  73457. }
  73458. declare module BABYLON {
  73459. /**
  73460. * "Static Class" containing the most commonly used helper while dealing with material for
  73461. * rendering purpose.
  73462. *
  73463. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  73464. *
  73465. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  73466. */
  73467. export class MaterialHelper {
  73468. /**
  73469. * Bind the current view position to an effect.
  73470. * @param effect The effect to be bound
  73471. * @param scene The scene the eyes position is used from
  73472. */
  73473. static BindEyePosition(effect: Effect, scene: Scene): void;
  73474. /**
  73475. * Helps preparing the defines values about the UVs in used in the effect.
  73476. * UVs are shared as much as we can accross channels in the shaders.
  73477. * @param texture The texture we are preparing the UVs for
  73478. * @param defines The defines to update
  73479. * @param key The channel key "diffuse", "specular"... used in the shader
  73480. */
  73481. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  73482. /**
  73483. * Binds a texture matrix value to its corrsponding uniform
  73484. * @param texture The texture to bind the matrix for
  73485. * @param uniformBuffer The uniform buffer receivin the data
  73486. * @param key The channel key "diffuse", "specular"... used in the shader
  73487. */
  73488. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  73489. /**
  73490. * Gets the current status of the fog (should it be enabled?)
  73491. * @param mesh defines the mesh to evaluate for fog support
  73492. * @param scene defines the hosting scene
  73493. * @returns true if fog must be enabled
  73494. */
  73495. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  73496. /**
  73497. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  73498. * @param mesh defines the current mesh
  73499. * @param scene defines the current scene
  73500. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  73501. * @param pointsCloud defines if point cloud rendering has to be turned on
  73502. * @param fogEnabled defines if fog has to be turned on
  73503. * @param alphaTest defines if alpha testing has to be turned on
  73504. * @param defines defines the current list of defines
  73505. */
  73506. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  73507. /**
  73508. * Helper used to prepare the list of defines associated with frame values for shader compilation
  73509. * @param scene defines the current scene
  73510. * @param engine defines the current engine
  73511. * @param defines specifies the list of active defines
  73512. * @param useInstances defines if instances have to be turned on
  73513. * @param useClipPlane defines if clip plane have to be turned on
  73514. */
  73515. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  73516. /**
  73517. * Prepares the defines for bones
  73518. * @param mesh The mesh containing the geometry data we will draw
  73519. * @param defines The defines to update
  73520. */
  73521. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  73522. /**
  73523. * Prepares the defines for morph targets
  73524. * @param mesh The mesh containing the geometry data we will draw
  73525. * @param defines The defines to update
  73526. */
  73527. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  73528. /**
  73529. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  73530. * @param mesh The mesh containing the geometry data we will draw
  73531. * @param defines The defines to update
  73532. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  73533. * @param useBones Precise whether bones should be used or not (override mesh info)
  73534. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  73535. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  73536. * @returns false if defines are considered not dirty and have not been checked
  73537. */
  73538. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  73539. /**
  73540. * Prepares the defines related to multiview
  73541. * @param scene The scene we are intending to draw
  73542. * @param defines The defines to update
  73543. */
  73544. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  73545. /**
  73546. * Prepares the defines related to the light information passed in parameter
  73547. * @param scene The scene we are intending to draw
  73548. * @param mesh The mesh the effect is compiling for
  73549. * @param defines The defines to update
  73550. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  73551. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  73552. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  73553. * @returns true if normals will be required for the rest of the effect
  73554. */
  73555. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  73556. /**
  73557. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  73558. * that won t be acctive due to defines being turned off.
  73559. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  73560. * @param samplersList The samplers list
  73561. * @param defines The defines helping in the list generation
  73562. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  73563. */
  73564. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  73565. /**
  73566. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  73567. * @param defines The defines to update while falling back
  73568. * @param fallbacks The authorized effect fallbacks
  73569. * @param maxSimultaneousLights The maximum number of lights allowed
  73570. * @param rank the current rank of the Effect
  73571. * @returns The newly affected rank
  73572. */
  73573. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  73574. /**
  73575. * Prepares the list of attributes required for morph targets according to the effect defines.
  73576. * @param attribs The current list of supported attribs
  73577. * @param mesh The mesh to prepare the morph targets attributes for
  73578. * @param defines The current Defines of the effect
  73579. */
  73580. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  73581. /**
  73582. * Prepares the list of attributes required for bones according to the effect defines.
  73583. * @param attribs The current list of supported attribs
  73584. * @param mesh The mesh to prepare the bones attributes for
  73585. * @param defines The current Defines of the effect
  73586. * @param fallbacks The current efffect fallback strategy
  73587. */
  73588. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  73589. /**
  73590. * Check and prepare the list of attributes required for instances according to the effect defines.
  73591. * @param attribs The current list of supported attribs
  73592. * @param defines The current MaterialDefines of the effect
  73593. */
  73594. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  73595. /**
  73596. * Add the list of attributes required for instances to the attribs array.
  73597. * @param attribs The current list of supported attribs
  73598. */
  73599. static PushAttributesForInstances(attribs: string[]): void;
  73600. /**
  73601. * Binds the light shadow information to the effect for the given mesh.
  73602. * @param light The light containing the generator
  73603. * @param scene The scene the lights belongs to
  73604. * @param mesh The mesh we are binding the information to render
  73605. * @param lightIndex The light index in the effect used to render the mesh
  73606. * @param effect The effect we are binding the data to
  73607. */
  73608. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  73609. /**
  73610. * Binds the light information to the effect.
  73611. * @param light The light containing the generator
  73612. * @param effect The effect we are binding the data to
  73613. * @param lightIndex The light index in the effect used to render
  73614. */
  73615. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  73616. /**
  73617. * Binds the lights information from the scene to the effect for the given mesh.
  73618. * @param scene The scene the lights belongs to
  73619. * @param mesh The mesh we are binding the information to render
  73620. * @param effect The effect we are binding the data to
  73621. * @param defines The generated defines for the effect
  73622. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  73623. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  73624. */
  73625. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  73626. private static _tempFogColor;
  73627. /**
  73628. * Binds the fog information from the scene to the effect for the given mesh.
  73629. * @param scene The scene the lights belongs to
  73630. * @param mesh The mesh we are binding the information to render
  73631. * @param effect The effect we are binding the data to
  73632. * @param linearSpace Defines if the fog effect is applied in linear space
  73633. */
  73634. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  73635. /**
  73636. * Binds the bones information from the mesh to the effect.
  73637. * @param mesh The mesh we are binding the information to render
  73638. * @param effect The effect we are binding the data to
  73639. */
  73640. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  73641. /**
  73642. * Binds the morph targets information from the mesh to the effect.
  73643. * @param abstractMesh The mesh we are binding the information to render
  73644. * @param effect The effect we are binding the data to
  73645. */
  73646. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  73647. /**
  73648. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  73649. * @param defines The generated defines used in the effect
  73650. * @param effect The effect we are binding the data to
  73651. * @param scene The scene we are willing to render with logarithmic scale for
  73652. */
  73653. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  73654. /**
  73655. * Binds the clip plane information from the scene to the effect.
  73656. * @param scene The scene the clip plane information are extracted from
  73657. * @param effect The effect we are binding the data to
  73658. */
  73659. static BindClipPlane(effect: Effect, scene: Scene): void;
  73660. }
  73661. }
  73662. declare module BABYLON {
  73663. /** @hidden */
  73664. export var shadowMapPixelShader: {
  73665. name: string;
  73666. shader: string;
  73667. };
  73668. }
  73669. declare module BABYLON {
  73670. /** @hidden */
  73671. export var bonesDeclaration: {
  73672. name: string;
  73673. shader: string;
  73674. };
  73675. }
  73676. declare module BABYLON {
  73677. /** @hidden */
  73678. export var morphTargetsVertexGlobalDeclaration: {
  73679. name: string;
  73680. shader: string;
  73681. };
  73682. }
  73683. declare module BABYLON {
  73684. /** @hidden */
  73685. export var morphTargetsVertexDeclaration: {
  73686. name: string;
  73687. shader: string;
  73688. };
  73689. }
  73690. declare module BABYLON {
  73691. /** @hidden */
  73692. export var instancesDeclaration: {
  73693. name: string;
  73694. shader: string;
  73695. };
  73696. }
  73697. declare module BABYLON {
  73698. /** @hidden */
  73699. export var helperFunctions: {
  73700. name: string;
  73701. shader: string;
  73702. };
  73703. }
  73704. declare module BABYLON {
  73705. /** @hidden */
  73706. export var morphTargetsVertex: {
  73707. name: string;
  73708. shader: string;
  73709. };
  73710. }
  73711. declare module BABYLON {
  73712. /** @hidden */
  73713. export var instancesVertex: {
  73714. name: string;
  73715. shader: string;
  73716. };
  73717. }
  73718. declare module BABYLON {
  73719. /** @hidden */
  73720. export var bonesVertex: {
  73721. name: string;
  73722. shader: string;
  73723. };
  73724. }
  73725. declare module BABYLON {
  73726. /** @hidden */
  73727. export var shadowMapVertexShader: {
  73728. name: string;
  73729. shader: string;
  73730. };
  73731. }
  73732. declare module BABYLON {
  73733. /** @hidden */
  73734. export var depthBoxBlurPixelShader: {
  73735. name: string;
  73736. shader: string;
  73737. };
  73738. }
  73739. declare module BABYLON {
  73740. /**
  73741. * Defines the options associated with the creation of a custom shader for a shadow generator.
  73742. */
  73743. export interface ICustomShaderOptions {
  73744. /**
  73745. * Gets or sets the custom shader name to use
  73746. */
  73747. shaderName: string;
  73748. /**
  73749. * The list of attribute names used in the shader
  73750. */
  73751. attributes?: string[];
  73752. /**
  73753. * The list of unifrom names used in the shader
  73754. */
  73755. uniforms?: string[];
  73756. /**
  73757. * The list of sampler names used in the shader
  73758. */
  73759. samplers?: string[];
  73760. /**
  73761. * The list of defines used in the shader
  73762. */
  73763. defines?: string[];
  73764. }
  73765. /**
  73766. * Interface to implement to create a shadow generator compatible with BJS.
  73767. */
  73768. export interface IShadowGenerator {
  73769. /**
  73770. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  73771. * @returns The render target texture if present otherwise, null
  73772. */
  73773. getShadowMap(): Nullable<RenderTargetTexture>;
  73774. /**
  73775. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  73776. * @returns The render target texture if the shadow map is present otherwise, null
  73777. */
  73778. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  73779. /**
  73780. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  73781. * @param subMesh The submesh we want to render in the shadow map
  73782. * @param useInstances Defines wether will draw in the map using instances
  73783. * @returns true if ready otherwise, false
  73784. */
  73785. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  73786. /**
  73787. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  73788. * @param defines Defines of the material we want to update
  73789. * @param lightIndex Index of the light in the enabled light list of the material
  73790. */
  73791. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  73792. /**
  73793. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  73794. * defined in the generator but impacting the effect).
  73795. * It implies the unifroms available on the materials are the standard BJS ones.
  73796. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  73797. * @param effect The effect we are binfing the information for
  73798. */
  73799. bindShadowLight(lightIndex: string, effect: Effect): void;
  73800. /**
  73801. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  73802. * (eq to shadow prjection matrix * light transform matrix)
  73803. * @returns The transform matrix used to create the shadow map
  73804. */
  73805. getTransformMatrix(): Matrix;
  73806. /**
  73807. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  73808. * Cube and 2D textures for instance.
  73809. */
  73810. recreateShadowMap(): void;
  73811. /**
  73812. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  73813. * @param onCompiled Callback triggered at the and of the effects compilation
  73814. * @param options Sets of optional options forcing the compilation with different modes
  73815. */
  73816. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  73817. useInstances: boolean;
  73818. }>): void;
  73819. /**
  73820. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  73821. * @param options Sets of optional options forcing the compilation with different modes
  73822. * @returns A promise that resolves when the compilation completes
  73823. */
  73824. forceCompilationAsync(options?: Partial<{
  73825. useInstances: boolean;
  73826. }>): Promise<void>;
  73827. /**
  73828. * Serializes the shadow generator setup to a json object.
  73829. * @returns The serialized JSON object
  73830. */
  73831. serialize(): any;
  73832. /**
  73833. * Disposes the Shadow map and related Textures and effects.
  73834. */
  73835. dispose(): void;
  73836. }
  73837. /**
  73838. * Default implementation IShadowGenerator.
  73839. * This is the main object responsible of generating shadows in the framework.
  73840. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  73841. */
  73842. export class ShadowGenerator implements IShadowGenerator {
  73843. /**
  73844. * Shadow generator mode None: no filtering applied.
  73845. */
  73846. static readonly FILTER_NONE: number;
  73847. /**
  73848. * Shadow generator mode ESM: Exponential Shadow Mapping.
  73849. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  73850. */
  73851. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  73852. /**
  73853. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  73854. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  73855. */
  73856. static readonly FILTER_POISSONSAMPLING: number;
  73857. /**
  73858. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  73859. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  73860. */
  73861. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  73862. /**
  73863. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  73864. * edge artifacts on steep falloff.
  73865. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  73866. */
  73867. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  73868. /**
  73869. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  73870. * edge artifacts on steep falloff.
  73871. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  73872. */
  73873. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  73874. /**
  73875. * Shadow generator mode PCF: Percentage Closer Filtering
  73876. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  73877. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  73878. */
  73879. static readonly FILTER_PCF: number;
  73880. /**
  73881. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  73882. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  73883. * Contact Hardening
  73884. */
  73885. static readonly FILTER_PCSS: number;
  73886. /**
  73887. * Reserved for PCF and PCSS
  73888. * Highest Quality.
  73889. *
  73890. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  73891. *
  73892. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  73893. */
  73894. static readonly QUALITY_HIGH: number;
  73895. /**
  73896. * Reserved for PCF and PCSS
  73897. * Good tradeoff for quality/perf cross devices
  73898. *
  73899. * Execute PCF on a 3*3 kernel.
  73900. *
  73901. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  73902. */
  73903. static readonly QUALITY_MEDIUM: number;
  73904. /**
  73905. * Reserved for PCF and PCSS
  73906. * The lowest quality but the fastest.
  73907. *
  73908. * Execute PCF on a 1*1 kernel.
  73909. *
  73910. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  73911. */
  73912. static readonly QUALITY_LOW: number;
  73913. /** Gets or sets the custom shader name to use */
  73914. customShaderOptions: ICustomShaderOptions;
  73915. /**
  73916. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  73917. */
  73918. onBeforeShadowMapRenderObservable: Observable<Effect>;
  73919. /**
  73920. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  73921. */
  73922. onAfterShadowMapRenderObservable: Observable<Effect>;
  73923. /**
  73924. * Observable triggered before a mesh is rendered in the shadow map.
  73925. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  73926. */
  73927. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  73928. /**
  73929. * Observable triggered after a mesh is rendered in the shadow map.
  73930. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  73931. */
  73932. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  73933. private _bias;
  73934. /**
  73935. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  73936. */
  73937. /**
  73938. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  73939. */
  73940. bias: number;
  73941. private _normalBias;
  73942. /**
  73943. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  73944. */
  73945. /**
  73946. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  73947. */
  73948. normalBias: number;
  73949. private _blurBoxOffset;
  73950. /**
  73951. * Gets the blur box offset: offset applied during the blur pass.
  73952. * Only useful if useKernelBlur = false
  73953. */
  73954. /**
  73955. * Sets the blur box offset: offset applied during the blur pass.
  73956. * Only useful if useKernelBlur = false
  73957. */
  73958. blurBoxOffset: number;
  73959. private _blurScale;
  73960. /**
  73961. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  73962. * 2 means half of the size.
  73963. */
  73964. /**
  73965. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  73966. * 2 means half of the size.
  73967. */
  73968. blurScale: number;
  73969. private _blurKernel;
  73970. /**
  73971. * Gets the blur kernel: kernel size of the blur pass.
  73972. * Only useful if useKernelBlur = true
  73973. */
  73974. /**
  73975. * Sets the blur kernel: kernel size of the blur pass.
  73976. * Only useful if useKernelBlur = true
  73977. */
  73978. blurKernel: number;
  73979. private _useKernelBlur;
  73980. /**
  73981. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  73982. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  73983. */
  73984. /**
  73985. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  73986. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  73987. */
  73988. useKernelBlur: boolean;
  73989. private _depthScale;
  73990. /**
  73991. * Gets the depth scale used in ESM mode.
  73992. */
  73993. /**
  73994. * Sets the depth scale used in ESM mode.
  73995. * This can override the scale stored on the light.
  73996. */
  73997. depthScale: number;
  73998. private _filter;
  73999. /**
  74000. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  74001. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  74002. */
  74003. /**
  74004. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  74005. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  74006. */
  74007. filter: number;
  74008. /**
  74009. * Gets if the current filter is set to Poisson Sampling.
  74010. */
  74011. /**
  74012. * Sets the current filter to Poisson Sampling.
  74013. */
  74014. usePoissonSampling: boolean;
  74015. /**
  74016. * Gets if the current filter is set to ESM.
  74017. */
  74018. /**
  74019. * Sets the current filter is to ESM.
  74020. */
  74021. useExponentialShadowMap: boolean;
  74022. /**
  74023. * Gets if the current filter is set to filtered ESM.
  74024. */
  74025. /**
  74026. * Gets if the current filter is set to filtered ESM.
  74027. */
  74028. useBlurExponentialShadowMap: boolean;
  74029. /**
  74030. * Gets if the current filter is set to "close ESM" (using the inverse of the
  74031. * exponential to prevent steep falloff artifacts).
  74032. */
  74033. /**
  74034. * Sets the current filter to "close ESM" (using the inverse of the
  74035. * exponential to prevent steep falloff artifacts).
  74036. */
  74037. useCloseExponentialShadowMap: boolean;
  74038. /**
  74039. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  74040. * exponential to prevent steep falloff artifacts).
  74041. */
  74042. /**
  74043. * Sets the current filter to filtered "close ESM" (using the inverse of the
  74044. * exponential to prevent steep falloff artifacts).
  74045. */
  74046. useBlurCloseExponentialShadowMap: boolean;
  74047. /**
  74048. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  74049. */
  74050. /**
  74051. * Sets the current filter to "PCF" (percentage closer filtering).
  74052. */
  74053. usePercentageCloserFiltering: boolean;
  74054. private _filteringQuality;
  74055. /**
  74056. * Gets the PCF or PCSS Quality.
  74057. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  74058. */
  74059. /**
  74060. * Sets the PCF or PCSS Quality.
  74061. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  74062. */
  74063. filteringQuality: number;
  74064. /**
  74065. * Gets if the current filter is set to "PCSS" (contact hardening).
  74066. */
  74067. /**
  74068. * Sets the current filter to "PCSS" (contact hardening).
  74069. */
  74070. useContactHardeningShadow: boolean;
  74071. private _contactHardeningLightSizeUVRatio;
  74072. /**
  74073. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  74074. * Using a ratio helps keeping shape stability independently of the map size.
  74075. *
  74076. * It does not account for the light projection as it was having too much
  74077. * instability during the light setup or during light position changes.
  74078. *
  74079. * Only valid if useContactHardeningShadow is true.
  74080. */
  74081. /**
  74082. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  74083. * Using a ratio helps keeping shape stability independently of the map size.
  74084. *
  74085. * It does not account for the light projection as it was having too much
  74086. * instability during the light setup or during light position changes.
  74087. *
  74088. * Only valid if useContactHardeningShadow is true.
  74089. */
  74090. contactHardeningLightSizeUVRatio: number;
  74091. private _darkness;
  74092. /** Gets or sets the actual darkness of a shadow */
  74093. darkness: number;
  74094. /**
  74095. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  74096. * 0 means strongest and 1 would means no shadow.
  74097. * @returns the darkness.
  74098. */
  74099. getDarkness(): number;
  74100. /**
  74101. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  74102. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  74103. * @returns the shadow generator allowing fluent coding.
  74104. */
  74105. setDarkness(darkness: number): ShadowGenerator;
  74106. private _transparencyShadow;
  74107. /** Gets or sets the ability to have transparent shadow */
  74108. transparencyShadow: boolean;
  74109. /**
  74110. * Sets the ability to have transparent shadow (boolean).
  74111. * @param transparent True if transparent else False
  74112. * @returns the shadow generator allowing fluent coding
  74113. */
  74114. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  74115. private _shadowMap;
  74116. private _shadowMap2;
  74117. /**
  74118. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  74119. * @returns The render target texture if present otherwise, null
  74120. */
  74121. getShadowMap(): Nullable<RenderTargetTexture>;
  74122. /**
  74123. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  74124. * @returns The render target texture if the shadow map is present otherwise, null
  74125. */
  74126. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  74127. /**
  74128. * Gets the class name of that object
  74129. * @returns "ShadowGenerator"
  74130. */
  74131. getClassName(): string;
  74132. /**
  74133. * Helper function to add a mesh and its descendants to the list of shadow casters.
  74134. * @param mesh Mesh to add
  74135. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  74136. * @returns the Shadow Generator itself
  74137. */
  74138. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  74139. /**
  74140. * Helper function to remove a mesh and its descendants from the list of shadow casters
  74141. * @param mesh Mesh to remove
  74142. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  74143. * @returns the Shadow Generator itself
  74144. */
  74145. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  74146. /**
  74147. * Controls the extent to which the shadows fade out at the edge of the frustum
  74148. * Used only by directionals and spots
  74149. */
  74150. frustumEdgeFalloff: number;
  74151. private _light;
  74152. /**
  74153. * Returns the associated light object.
  74154. * @returns the light generating the shadow
  74155. */
  74156. getLight(): IShadowLight;
  74157. /**
  74158. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  74159. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  74160. * It might on the other hand introduce peter panning.
  74161. */
  74162. forceBackFacesOnly: boolean;
  74163. private _scene;
  74164. private _lightDirection;
  74165. private _effect;
  74166. private _viewMatrix;
  74167. private _projectionMatrix;
  74168. private _transformMatrix;
  74169. private _cachedPosition;
  74170. private _cachedDirection;
  74171. private _cachedDefines;
  74172. private _currentRenderID;
  74173. private _boxBlurPostprocess;
  74174. private _kernelBlurXPostprocess;
  74175. private _kernelBlurYPostprocess;
  74176. private _blurPostProcesses;
  74177. private _mapSize;
  74178. private _currentFaceIndex;
  74179. private _currentFaceIndexCache;
  74180. private _textureType;
  74181. private _defaultTextureMatrix;
  74182. /** @hidden */
  74183. static _SceneComponentInitialization: (scene: Scene) => void;
  74184. /**
  74185. * Creates a ShadowGenerator object.
  74186. * A ShadowGenerator is the required tool to use the shadows.
  74187. * Each light casting shadows needs to use its own ShadowGenerator.
  74188. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  74189. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  74190. * @param light The light object generating the shadows.
  74191. * @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.
  74192. */
  74193. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  74194. private _initializeGenerator;
  74195. private _initializeShadowMap;
  74196. private _initializeBlurRTTAndPostProcesses;
  74197. private _renderForShadowMap;
  74198. private _renderSubMeshForShadowMap;
  74199. private _applyFilterValues;
  74200. /**
  74201. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  74202. * @param onCompiled Callback triggered at the and of the effects compilation
  74203. * @param options Sets of optional options forcing the compilation with different modes
  74204. */
  74205. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  74206. useInstances: boolean;
  74207. }>): void;
  74208. /**
  74209. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  74210. * @param options Sets of optional options forcing the compilation with different modes
  74211. * @returns A promise that resolves when the compilation completes
  74212. */
  74213. forceCompilationAsync(options?: Partial<{
  74214. useInstances: boolean;
  74215. }>): Promise<void>;
  74216. /**
  74217. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  74218. * @param subMesh The submesh we want to render in the shadow map
  74219. * @param useInstances Defines wether will draw in the map using instances
  74220. * @returns true if ready otherwise, false
  74221. */
  74222. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  74223. /**
  74224. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  74225. * @param defines Defines of the material we want to update
  74226. * @param lightIndex Index of the light in the enabled light list of the material
  74227. */
  74228. prepareDefines(defines: any, lightIndex: number): void;
  74229. /**
  74230. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  74231. * defined in the generator but impacting the effect).
  74232. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  74233. * @param effect The effect we are binfing the information for
  74234. */
  74235. bindShadowLight(lightIndex: string, effect: Effect): void;
  74236. /**
  74237. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  74238. * (eq to shadow prjection matrix * light transform matrix)
  74239. * @returns The transform matrix used to create the shadow map
  74240. */
  74241. getTransformMatrix(): Matrix;
  74242. /**
  74243. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  74244. * Cube and 2D textures for instance.
  74245. */
  74246. recreateShadowMap(): void;
  74247. private _disposeBlurPostProcesses;
  74248. private _disposeRTTandPostProcesses;
  74249. /**
  74250. * Disposes the ShadowGenerator.
  74251. * Returns nothing.
  74252. */
  74253. dispose(): void;
  74254. /**
  74255. * Serializes the shadow generator setup to a json object.
  74256. * @returns The serialized JSON object
  74257. */
  74258. serialize(): any;
  74259. /**
  74260. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  74261. * @param parsedShadowGenerator The JSON object to parse
  74262. * @param scene The scene to create the shadow map for
  74263. * @returns The parsed shadow generator
  74264. */
  74265. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  74266. }
  74267. }
  74268. declare module BABYLON {
  74269. /**
  74270. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  74271. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  74272. * 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.
  74273. */
  74274. export abstract class Light extends Node {
  74275. /**
  74276. * Falloff Default: light is falling off following the material specification:
  74277. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  74278. */
  74279. static readonly FALLOFF_DEFAULT: number;
  74280. /**
  74281. * Falloff Physical: light is falling off following the inverse squared distance law.
  74282. */
  74283. static readonly FALLOFF_PHYSICAL: number;
  74284. /**
  74285. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  74286. * to enhance interoperability with other engines.
  74287. */
  74288. static readonly FALLOFF_GLTF: number;
  74289. /**
  74290. * Falloff Standard: light is falling off like in the standard material
  74291. * to enhance interoperability with other materials.
  74292. */
  74293. static readonly FALLOFF_STANDARD: number;
  74294. /**
  74295. * If every light affecting the material is in this lightmapMode,
  74296. * material.lightmapTexture adds or multiplies
  74297. * (depends on material.useLightmapAsShadowmap)
  74298. * after every other light calculations.
  74299. */
  74300. static readonly LIGHTMAP_DEFAULT: number;
  74301. /**
  74302. * material.lightmapTexture as only diffuse lighting from this light
  74303. * adds only specular lighting from this light
  74304. * adds dynamic shadows
  74305. */
  74306. static readonly LIGHTMAP_SPECULAR: number;
  74307. /**
  74308. * material.lightmapTexture as only lighting
  74309. * no light calculation from this light
  74310. * only adds dynamic shadows from this light
  74311. */
  74312. static readonly LIGHTMAP_SHADOWSONLY: number;
  74313. /**
  74314. * Each light type uses the default quantity according to its type:
  74315. * point/spot lights use luminous intensity
  74316. * directional lights use illuminance
  74317. */
  74318. static readonly INTENSITYMODE_AUTOMATIC: number;
  74319. /**
  74320. * lumen (lm)
  74321. */
  74322. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  74323. /**
  74324. * candela (lm/sr)
  74325. */
  74326. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  74327. /**
  74328. * lux (lm/m^2)
  74329. */
  74330. static readonly INTENSITYMODE_ILLUMINANCE: number;
  74331. /**
  74332. * nit (cd/m^2)
  74333. */
  74334. static readonly INTENSITYMODE_LUMINANCE: number;
  74335. /**
  74336. * Light type const id of the point light.
  74337. */
  74338. static readonly LIGHTTYPEID_POINTLIGHT: number;
  74339. /**
  74340. * Light type const id of the directional light.
  74341. */
  74342. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  74343. /**
  74344. * Light type const id of the spot light.
  74345. */
  74346. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  74347. /**
  74348. * Light type const id of the hemispheric light.
  74349. */
  74350. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  74351. /**
  74352. * Diffuse gives the basic color to an object.
  74353. */
  74354. diffuse: Color3;
  74355. /**
  74356. * Specular produces a highlight color on an object.
  74357. * Note: This is note affecting PBR materials.
  74358. */
  74359. specular: Color3;
  74360. /**
  74361. * Defines the falloff type for this light. This lets overrriding how punctual light are
  74362. * falling off base on range or angle.
  74363. * This can be set to any values in Light.FALLOFF_x.
  74364. *
  74365. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  74366. * other types of materials.
  74367. */
  74368. falloffType: number;
  74369. /**
  74370. * Strength of the light.
  74371. * Note: By default it is define in the framework own unit.
  74372. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  74373. */
  74374. intensity: number;
  74375. private _range;
  74376. protected _inverseSquaredRange: number;
  74377. /**
  74378. * Defines how far from the source the light is impacting in scene units.
  74379. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  74380. */
  74381. /**
  74382. * Defines how far from the source the light is impacting in scene units.
  74383. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  74384. */
  74385. range: number;
  74386. /**
  74387. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  74388. * of light.
  74389. */
  74390. private _photometricScale;
  74391. private _intensityMode;
  74392. /**
  74393. * Gets the photometric scale used to interpret the intensity.
  74394. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  74395. */
  74396. /**
  74397. * Sets the photometric scale used to interpret the intensity.
  74398. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  74399. */
  74400. intensityMode: number;
  74401. private _radius;
  74402. /**
  74403. * Gets the light radius used by PBR Materials to simulate soft area lights.
  74404. */
  74405. /**
  74406. * sets the light radius used by PBR Materials to simulate soft area lights.
  74407. */
  74408. radius: number;
  74409. private _renderPriority;
  74410. /**
  74411. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  74412. * exceeding the number allowed of the materials.
  74413. */
  74414. renderPriority: number;
  74415. private _shadowEnabled;
  74416. /**
  74417. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  74418. * the current shadow generator.
  74419. */
  74420. /**
  74421. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  74422. * the current shadow generator.
  74423. */
  74424. shadowEnabled: boolean;
  74425. private _includedOnlyMeshes;
  74426. /**
  74427. * Gets the only meshes impacted by this light.
  74428. */
  74429. /**
  74430. * Sets the only meshes impacted by this light.
  74431. */
  74432. includedOnlyMeshes: AbstractMesh[];
  74433. private _excludedMeshes;
  74434. /**
  74435. * Gets the meshes not impacted by this light.
  74436. */
  74437. /**
  74438. * Sets the meshes not impacted by this light.
  74439. */
  74440. excludedMeshes: AbstractMesh[];
  74441. private _excludeWithLayerMask;
  74442. /**
  74443. * Gets the layer id use to find what meshes are not impacted by the light.
  74444. * Inactive if 0
  74445. */
  74446. /**
  74447. * Sets the layer id use to find what meshes are not impacted by the light.
  74448. * Inactive if 0
  74449. */
  74450. excludeWithLayerMask: number;
  74451. private _includeOnlyWithLayerMask;
  74452. /**
  74453. * Gets the layer id use to find what meshes are impacted by the light.
  74454. * Inactive if 0
  74455. */
  74456. /**
  74457. * Sets the layer id use to find what meshes are impacted by the light.
  74458. * Inactive if 0
  74459. */
  74460. includeOnlyWithLayerMask: number;
  74461. private _lightmapMode;
  74462. /**
  74463. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  74464. */
  74465. /**
  74466. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  74467. */
  74468. lightmapMode: number;
  74469. /**
  74470. * Shadow generator associted to the light.
  74471. * @hidden Internal use only.
  74472. */
  74473. _shadowGenerator: Nullable<IShadowGenerator>;
  74474. /**
  74475. * @hidden Internal use only.
  74476. */
  74477. _excludedMeshesIds: string[];
  74478. /**
  74479. * @hidden Internal use only.
  74480. */
  74481. _includedOnlyMeshesIds: string[];
  74482. /**
  74483. * The current light unifom buffer.
  74484. * @hidden Internal use only.
  74485. */
  74486. _uniformBuffer: UniformBuffer;
  74487. /**
  74488. * Creates a Light object in the scene.
  74489. * Documentation : https://doc.babylonjs.com/babylon101/lights
  74490. * @param name The firendly name of the light
  74491. * @param scene The scene the light belongs too
  74492. */
  74493. constructor(name: string, scene: Scene);
  74494. protected abstract _buildUniformLayout(): void;
  74495. /**
  74496. * Sets the passed Effect "effect" with the Light information.
  74497. * @param effect The effect to update
  74498. * @param lightIndex The index of the light in the effect to update
  74499. * @returns The light
  74500. */
  74501. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  74502. /**
  74503. * Returns the string "Light".
  74504. * @returns the class name
  74505. */
  74506. getClassName(): string;
  74507. /** @hidden */
  74508. readonly _isLight: boolean;
  74509. /**
  74510. * Converts the light information to a readable string for debug purpose.
  74511. * @param fullDetails Supports for multiple levels of logging within scene loading
  74512. * @returns the human readable light info
  74513. */
  74514. toString(fullDetails?: boolean): string;
  74515. /** @hidden */
  74516. protected _syncParentEnabledState(): void;
  74517. /**
  74518. * Set the enabled state of this node.
  74519. * @param value - the new enabled state
  74520. */
  74521. setEnabled(value: boolean): void;
  74522. /**
  74523. * Returns the Light associated shadow generator if any.
  74524. * @return the associated shadow generator.
  74525. */
  74526. getShadowGenerator(): Nullable<IShadowGenerator>;
  74527. /**
  74528. * Returns a Vector3, the absolute light position in the World.
  74529. * @returns the world space position of the light
  74530. */
  74531. getAbsolutePosition(): Vector3;
  74532. /**
  74533. * Specifies if the light will affect the passed mesh.
  74534. * @param mesh The mesh to test against the light
  74535. * @return true the mesh is affected otherwise, false.
  74536. */
  74537. canAffectMesh(mesh: AbstractMesh): boolean;
  74538. /**
  74539. * Sort function to order lights for rendering.
  74540. * @param a First Light object to compare to second.
  74541. * @param b Second Light object to compare first.
  74542. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  74543. */
  74544. static CompareLightsPriority(a: Light, b: Light): number;
  74545. /**
  74546. * Releases resources associated with this node.
  74547. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  74548. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  74549. */
  74550. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  74551. /**
  74552. * Returns the light type ID (integer).
  74553. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  74554. */
  74555. getTypeID(): number;
  74556. /**
  74557. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  74558. * @returns the scaled intensity in intensity mode unit
  74559. */
  74560. getScaledIntensity(): number;
  74561. /**
  74562. * Returns a new Light object, named "name", from the current one.
  74563. * @param name The name of the cloned light
  74564. * @returns the new created light
  74565. */
  74566. clone(name: string): Nullable<Light>;
  74567. /**
  74568. * Serializes the current light into a Serialization object.
  74569. * @returns the serialized object.
  74570. */
  74571. serialize(): any;
  74572. /**
  74573. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  74574. * This new light is named "name" and added to the passed scene.
  74575. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  74576. * @param name The friendly name of the light
  74577. * @param scene The scene the new light will belong to
  74578. * @returns the constructor function
  74579. */
  74580. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  74581. /**
  74582. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  74583. * @param parsedLight The JSON representation of the light
  74584. * @param scene The scene to create the parsed light in
  74585. * @returns the created light after parsing
  74586. */
  74587. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  74588. private _hookArrayForExcluded;
  74589. private _hookArrayForIncludedOnly;
  74590. private _resyncMeshes;
  74591. /**
  74592. * Forces the meshes to update their light related information in their rendering used effects
  74593. * @hidden Internal Use Only
  74594. */
  74595. _markMeshesAsLightDirty(): void;
  74596. /**
  74597. * Recomputes the cached photometric scale if needed.
  74598. */
  74599. private _computePhotometricScale;
  74600. /**
  74601. * Returns the Photometric Scale according to the light type and intensity mode.
  74602. */
  74603. private _getPhotometricScale;
  74604. /**
  74605. * Reorder the light in the scene according to their defined priority.
  74606. * @hidden Internal Use Only
  74607. */
  74608. _reorderLightsInScene(): void;
  74609. /**
  74610. * Prepares the list of defines specific to the light type.
  74611. * @param defines the list of defines
  74612. * @param lightIndex defines the index of the light for the effect
  74613. */
  74614. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  74615. }
  74616. }
  74617. declare module BABYLON {
  74618. /**
  74619. * Creates an instance based on a source mesh.
  74620. */
  74621. export class InstancedMesh extends AbstractMesh {
  74622. private _sourceMesh;
  74623. private _currentLOD;
  74624. /** @hidden */
  74625. _indexInSourceMeshInstanceArray: number;
  74626. constructor(name: string, source: Mesh);
  74627. /**
  74628. * Returns the string "InstancedMesh".
  74629. */
  74630. getClassName(): string;
  74631. /** Gets the list of lights affecting that mesh */
  74632. readonly lightSources: Light[];
  74633. _resyncLightSources(): void;
  74634. _resyncLighSource(light: Light): void;
  74635. _removeLightSource(light: Light): void;
  74636. /**
  74637. * If the source mesh receives shadows
  74638. */
  74639. readonly receiveShadows: boolean;
  74640. /**
  74641. * The material of the source mesh
  74642. */
  74643. readonly material: Nullable<Material>;
  74644. /**
  74645. * Visibility of the source mesh
  74646. */
  74647. readonly visibility: number;
  74648. /**
  74649. * Skeleton of the source mesh
  74650. */
  74651. readonly skeleton: Nullable<Skeleton>;
  74652. /**
  74653. * Rendering ground id of the source mesh
  74654. */
  74655. renderingGroupId: number;
  74656. /**
  74657. * Returns the total number of vertices (integer).
  74658. */
  74659. getTotalVertices(): number;
  74660. /**
  74661. * Returns a positive integer : the total number of indices in this mesh geometry.
  74662. * @returns the numner of indices or zero if the mesh has no geometry.
  74663. */
  74664. getTotalIndices(): number;
  74665. /**
  74666. * The source mesh of the instance
  74667. */
  74668. readonly sourceMesh: Mesh;
  74669. /**
  74670. * Is this node ready to be used/rendered
  74671. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  74672. * @return {boolean} is it ready
  74673. */
  74674. isReady(completeCheck?: boolean): boolean;
  74675. /**
  74676. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  74677. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  74678. * @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.
  74679. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  74680. */
  74681. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  74682. /**
  74683. * Sets the vertex data of the mesh geometry for the requested `kind`.
  74684. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  74685. * The `data` are either a numeric array either a Float32Array.
  74686. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  74687. * 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).
  74688. * Note that a new underlying VertexBuffer object is created each call.
  74689. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  74690. *
  74691. * Possible `kind` values :
  74692. * - VertexBuffer.PositionKind
  74693. * - VertexBuffer.UVKind
  74694. * - VertexBuffer.UV2Kind
  74695. * - VertexBuffer.UV3Kind
  74696. * - VertexBuffer.UV4Kind
  74697. * - VertexBuffer.UV5Kind
  74698. * - VertexBuffer.UV6Kind
  74699. * - VertexBuffer.ColorKind
  74700. * - VertexBuffer.MatricesIndicesKind
  74701. * - VertexBuffer.MatricesIndicesExtraKind
  74702. * - VertexBuffer.MatricesWeightsKind
  74703. * - VertexBuffer.MatricesWeightsExtraKind
  74704. *
  74705. * Returns the Mesh.
  74706. */
  74707. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  74708. /**
  74709. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  74710. * If the mesh has no geometry, it is simply returned as it is.
  74711. * The `data` are either a numeric array either a Float32Array.
  74712. * No new underlying VertexBuffer object is created.
  74713. * 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.
  74714. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  74715. *
  74716. * Possible `kind` values :
  74717. * - VertexBuffer.PositionKind
  74718. * - VertexBuffer.UVKind
  74719. * - VertexBuffer.UV2Kind
  74720. * - VertexBuffer.UV3Kind
  74721. * - VertexBuffer.UV4Kind
  74722. * - VertexBuffer.UV5Kind
  74723. * - VertexBuffer.UV6Kind
  74724. * - VertexBuffer.ColorKind
  74725. * - VertexBuffer.MatricesIndicesKind
  74726. * - VertexBuffer.MatricesIndicesExtraKind
  74727. * - VertexBuffer.MatricesWeightsKind
  74728. * - VertexBuffer.MatricesWeightsExtraKind
  74729. *
  74730. * Returns the Mesh.
  74731. */
  74732. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  74733. /**
  74734. * Sets the mesh indices.
  74735. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  74736. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  74737. * This method creates a new index buffer each call.
  74738. * Returns the Mesh.
  74739. */
  74740. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  74741. /**
  74742. * Boolean : True if the mesh owns the requested kind of data.
  74743. */
  74744. isVerticesDataPresent(kind: string): boolean;
  74745. /**
  74746. * Returns an array of indices (IndicesArray).
  74747. */
  74748. getIndices(): Nullable<IndicesArray>;
  74749. readonly _positions: Nullable<Vector3[]>;
  74750. /**
  74751. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  74752. * This means the mesh underlying bounding box and sphere are recomputed.
  74753. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  74754. * @returns the current mesh
  74755. */
  74756. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  74757. /** @hidden */
  74758. _preActivate(): InstancedMesh;
  74759. /** @hidden */
  74760. _activate(renderId: number, intermediateRendering: boolean): boolean;
  74761. /** @hidden */
  74762. _postActivate(): void;
  74763. getWorldMatrix(): Matrix;
  74764. readonly isAnInstance: boolean;
  74765. /**
  74766. * Returns the current associated LOD AbstractMesh.
  74767. */
  74768. getLOD(camera: Camera): AbstractMesh;
  74769. /** @hidden */
  74770. _syncSubMeshes(): InstancedMesh;
  74771. /** @hidden */
  74772. _generatePointsArray(): boolean;
  74773. /**
  74774. * Creates a new InstancedMesh from the current mesh.
  74775. * - name (string) : the cloned mesh name
  74776. * - newParent (optional Node) : the optional Node to parent the clone to.
  74777. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  74778. *
  74779. * Returns the clone.
  74780. */
  74781. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  74782. /**
  74783. * Disposes the InstancedMesh.
  74784. * Returns nothing.
  74785. */
  74786. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  74787. }
  74788. }
  74789. declare module BABYLON {
  74790. /**
  74791. * Defines the options associated with the creation of a shader material.
  74792. */
  74793. export interface IShaderMaterialOptions {
  74794. /**
  74795. * Does the material work in alpha blend mode
  74796. */
  74797. needAlphaBlending: boolean;
  74798. /**
  74799. * Does the material work in alpha test mode
  74800. */
  74801. needAlphaTesting: boolean;
  74802. /**
  74803. * The list of attribute names used in the shader
  74804. */
  74805. attributes: string[];
  74806. /**
  74807. * The list of unifrom names used in the shader
  74808. */
  74809. uniforms: string[];
  74810. /**
  74811. * The list of UBO names used in the shader
  74812. */
  74813. uniformBuffers: string[];
  74814. /**
  74815. * The list of sampler names used in the shader
  74816. */
  74817. samplers: string[];
  74818. /**
  74819. * The list of defines used in the shader
  74820. */
  74821. defines: string[];
  74822. }
  74823. /**
  74824. * 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.
  74825. *
  74826. * This returned material effects how the mesh will look based on the code in the shaders.
  74827. *
  74828. * @see http://doc.babylonjs.com/how_to/shader_material
  74829. */
  74830. export class ShaderMaterial extends Material {
  74831. private _shaderPath;
  74832. private _options;
  74833. private _textures;
  74834. private _textureArrays;
  74835. private _floats;
  74836. private _ints;
  74837. private _floatsArrays;
  74838. private _colors3;
  74839. private _colors3Arrays;
  74840. private _colors4;
  74841. private _vectors2;
  74842. private _vectors3;
  74843. private _vectors4;
  74844. private _matrices;
  74845. private _matrices3x3;
  74846. private _matrices2x2;
  74847. private _vectors2Arrays;
  74848. private _vectors3Arrays;
  74849. private _cachedWorldViewMatrix;
  74850. private _cachedWorldViewProjectionMatrix;
  74851. private _renderId;
  74852. /**
  74853. * Instantiate a new shader material.
  74854. * 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.
  74855. * This returned material effects how the mesh will look based on the code in the shaders.
  74856. * @see http://doc.babylonjs.com/how_to/shader_material
  74857. * @param name Define the name of the material in the scene
  74858. * @param scene Define the scene the material belongs to
  74859. * @param shaderPath Defines the route to the shader code in one of three ways:
  74860. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  74861. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  74862. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  74863. * @param options Define the options used to create the shader
  74864. */
  74865. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  74866. /**
  74867. * Gets the options used to compile the shader.
  74868. * They can be modified to trigger a new compilation
  74869. */
  74870. readonly options: IShaderMaterialOptions;
  74871. /**
  74872. * Gets the current class name of the material e.g. "ShaderMaterial"
  74873. * Mainly use in serialization.
  74874. * @returns the class name
  74875. */
  74876. getClassName(): string;
  74877. /**
  74878. * Specifies if the material will require alpha blending
  74879. * @returns a boolean specifying if alpha blending is needed
  74880. */
  74881. needAlphaBlending(): boolean;
  74882. /**
  74883. * Specifies if this material should be rendered in alpha test mode
  74884. * @returns a boolean specifying if an alpha test is needed.
  74885. */
  74886. needAlphaTesting(): boolean;
  74887. private _checkUniform;
  74888. /**
  74889. * Set a texture in the shader.
  74890. * @param name Define the name of the uniform samplers as defined in the shader
  74891. * @param texture Define the texture to bind to this sampler
  74892. * @return the material itself allowing "fluent" like uniform updates
  74893. */
  74894. setTexture(name: string, texture: Texture): ShaderMaterial;
  74895. /**
  74896. * Set a texture array in the shader.
  74897. * @param name Define the name of the uniform sampler array as defined in the shader
  74898. * @param textures Define the list of textures to bind to this sampler
  74899. * @return the material itself allowing "fluent" like uniform updates
  74900. */
  74901. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  74902. /**
  74903. * Set a float in the shader.
  74904. * @param name Define the name of the uniform as defined in the shader
  74905. * @param value Define the value to give to the uniform
  74906. * @return the material itself allowing "fluent" like uniform updates
  74907. */
  74908. setFloat(name: string, value: number): ShaderMaterial;
  74909. /**
  74910. * Set a int in the shader.
  74911. * @param name Define the name of the uniform as defined in the shader
  74912. * @param value Define the value to give to the uniform
  74913. * @return the material itself allowing "fluent" like uniform updates
  74914. */
  74915. setInt(name: string, value: number): ShaderMaterial;
  74916. /**
  74917. * Set an array of floats in the shader.
  74918. * @param name Define the name of the uniform as defined in the shader
  74919. * @param value Define the value to give to the uniform
  74920. * @return the material itself allowing "fluent" like uniform updates
  74921. */
  74922. setFloats(name: string, value: number[]): ShaderMaterial;
  74923. /**
  74924. * Set a vec3 in the shader from a Color3.
  74925. * @param name Define the name of the uniform as defined in the shader
  74926. * @param value Define the value to give to the uniform
  74927. * @return the material itself allowing "fluent" like uniform updates
  74928. */
  74929. setColor3(name: string, value: Color3): ShaderMaterial;
  74930. /**
  74931. * Set a vec3 array in the shader from a Color3 array.
  74932. * @param name Define the name of the uniform as defined in the shader
  74933. * @param value Define the value to give to the uniform
  74934. * @return the material itself allowing "fluent" like uniform updates
  74935. */
  74936. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  74937. /**
  74938. * Set a vec4 in the shader from a Color4.
  74939. * @param name Define the name of the uniform as defined in the shader
  74940. * @param value Define the value to give to the uniform
  74941. * @return the material itself allowing "fluent" like uniform updates
  74942. */
  74943. setColor4(name: string, value: Color4): ShaderMaterial;
  74944. /**
  74945. * Set a vec2 in the shader from a Vector2.
  74946. * @param name Define the name of the uniform as defined in the shader
  74947. * @param value Define the value to give to the uniform
  74948. * @return the material itself allowing "fluent" like uniform updates
  74949. */
  74950. setVector2(name: string, value: Vector2): ShaderMaterial;
  74951. /**
  74952. * Set a vec3 in the shader from a Vector3.
  74953. * @param name Define the name of the uniform as defined in the shader
  74954. * @param value Define the value to give to the uniform
  74955. * @return the material itself allowing "fluent" like uniform updates
  74956. */
  74957. setVector3(name: string, value: Vector3): ShaderMaterial;
  74958. /**
  74959. * Set a vec4 in the shader from a Vector4.
  74960. * @param name Define the name of the uniform as defined in the shader
  74961. * @param value Define the value to give to the uniform
  74962. * @return the material itself allowing "fluent" like uniform updates
  74963. */
  74964. setVector4(name: string, value: Vector4): ShaderMaterial;
  74965. /**
  74966. * Set a mat4 in the shader from a Matrix.
  74967. * @param name Define the name of the uniform as defined in the shader
  74968. * @param value Define the value to give to the uniform
  74969. * @return the material itself allowing "fluent" like uniform updates
  74970. */
  74971. setMatrix(name: string, value: Matrix): ShaderMaterial;
  74972. /**
  74973. * Set a mat3 in the shader from a Float32Array.
  74974. * @param name Define the name of the uniform as defined in the shader
  74975. * @param value Define the value to give to the uniform
  74976. * @return the material itself allowing "fluent" like uniform updates
  74977. */
  74978. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  74979. /**
  74980. * Set a mat2 in the shader from a Float32Array.
  74981. * @param name Define the name of the uniform as defined in the shader
  74982. * @param value Define the value to give to the uniform
  74983. * @return the material itself allowing "fluent" like uniform updates
  74984. */
  74985. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  74986. /**
  74987. * Set a vec2 array in the shader from a number array.
  74988. * @param name Define the name of the uniform as defined in the shader
  74989. * @param value Define the value to give to the uniform
  74990. * @return the material itself allowing "fluent" like uniform updates
  74991. */
  74992. setArray2(name: string, value: number[]): ShaderMaterial;
  74993. /**
  74994. * Set a vec3 array in the shader from a number array.
  74995. * @param name Define the name of the uniform as defined in the shader
  74996. * @param value Define the value to give to the uniform
  74997. * @return the material itself allowing "fluent" like uniform updates
  74998. */
  74999. setArray3(name: string, value: number[]): ShaderMaterial;
  75000. private _checkCache;
  75001. /**
  75002. * Specifies that the submesh is ready to be used
  75003. * @param mesh defines the mesh to check
  75004. * @param subMesh defines which submesh to check
  75005. * @param useInstances specifies that instances should be used
  75006. * @returns a boolean indicating that the submesh is ready or not
  75007. */
  75008. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  75009. /**
  75010. * Checks if the material is ready to render the requested mesh
  75011. * @param mesh Define the mesh to render
  75012. * @param useInstances Define whether or not the material is used with instances
  75013. * @returns true if ready, otherwise false
  75014. */
  75015. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  75016. /**
  75017. * Binds the world matrix to the material
  75018. * @param world defines the world transformation matrix
  75019. */
  75020. bindOnlyWorldMatrix(world: Matrix): void;
  75021. /**
  75022. * Binds the material to the mesh
  75023. * @param world defines the world transformation matrix
  75024. * @param mesh defines the mesh to bind the material to
  75025. */
  75026. bind(world: Matrix, mesh?: Mesh): void;
  75027. /**
  75028. * Gets the active textures from the material
  75029. * @returns an array of textures
  75030. */
  75031. getActiveTextures(): BaseTexture[];
  75032. /**
  75033. * Specifies if the material uses a texture
  75034. * @param texture defines the texture to check against the material
  75035. * @returns a boolean specifying if the material uses the texture
  75036. */
  75037. hasTexture(texture: BaseTexture): boolean;
  75038. /**
  75039. * Makes a duplicate of the material, and gives it a new name
  75040. * @param name defines the new name for the duplicated material
  75041. * @returns the cloned material
  75042. */
  75043. clone(name: string): ShaderMaterial;
  75044. /**
  75045. * Disposes the material
  75046. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  75047. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  75048. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  75049. */
  75050. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  75051. /**
  75052. * Serializes this material in a JSON representation
  75053. * @returns the serialized material object
  75054. */
  75055. serialize(): any;
  75056. /**
  75057. * Creates a shader material from parsed shader material data
  75058. * @param source defines the JSON represnetation of the material
  75059. * @param scene defines the hosting scene
  75060. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  75061. * @returns a new material
  75062. */
  75063. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  75064. }
  75065. }
  75066. declare module BABYLON {
  75067. /** @hidden */
  75068. export var clipPlaneFragmentDeclaration: {
  75069. name: string;
  75070. shader: string;
  75071. };
  75072. }
  75073. declare module BABYLON {
  75074. /** @hidden */
  75075. export var clipPlaneFragment: {
  75076. name: string;
  75077. shader: string;
  75078. };
  75079. }
  75080. declare module BABYLON {
  75081. /** @hidden */
  75082. export var colorPixelShader: {
  75083. name: string;
  75084. shader: string;
  75085. };
  75086. }
  75087. declare module BABYLON {
  75088. /** @hidden */
  75089. export var clipPlaneVertexDeclaration: {
  75090. name: string;
  75091. shader: string;
  75092. };
  75093. }
  75094. declare module BABYLON {
  75095. /** @hidden */
  75096. export var clipPlaneVertex: {
  75097. name: string;
  75098. shader: string;
  75099. };
  75100. }
  75101. declare module BABYLON {
  75102. /** @hidden */
  75103. export var colorVertexShader: {
  75104. name: string;
  75105. shader: string;
  75106. };
  75107. }
  75108. declare module BABYLON {
  75109. /**
  75110. * Line mesh
  75111. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  75112. */
  75113. export class LinesMesh extends Mesh {
  75114. /**
  75115. * If vertex color should be applied to the mesh
  75116. */
  75117. readonly useVertexColor?: boolean | undefined;
  75118. /**
  75119. * If vertex alpha should be applied to the mesh
  75120. */
  75121. readonly useVertexAlpha?: boolean | undefined;
  75122. /**
  75123. * Color of the line (Default: White)
  75124. */
  75125. color: Color3;
  75126. /**
  75127. * Alpha of the line (Default: 1)
  75128. */
  75129. alpha: number;
  75130. /**
  75131. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  75132. * This margin is expressed in world space coordinates, so its value may vary.
  75133. * Default value is 0.1
  75134. */
  75135. intersectionThreshold: number;
  75136. private _colorShader;
  75137. private color4;
  75138. /**
  75139. * Creates a new LinesMesh
  75140. * @param name defines the name
  75141. * @param scene defines the hosting scene
  75142. * @param parent defines the parent mesh if any
  75143. * @param source defines the optional source LinesMesh used to clone data from
  75144. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  75145. * When false, achieved by calling a clone(), also passing False.
  75146. * This will make creation of children, recursive.
  75147. * @param useVertexColor defines if this LinesMesh supports vertex color
  75148. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  75149. */
  75150. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  75151. /**
  75152. * If vertex color should be applied to the mesh
  75153. */
  75154. useVertexColor?: boolean | undefined,
  75155. /**
  75156. * If vertex alpha should be applied to the mesh
  75157. */
  75158. useVertexAlpha?: boolean | undefined);
  75159. private _addClipPlaneDefine;
  75160. private _removeClipPlaneDefine;
  75161. isReady(): boolean;
  75162. /**
  75163. * Returns the string "LineMesh"
  75164. */
  75165. getClassName(): string;
  75166. /**
  75167. * @hidden
  75168. */
  75169. /**
  75170. * @hidden
  75171. */
  75172. material: Material;
  75173. /**
  75174. * @hidden
  75175. */
  75176. readonly checkCollisions: boolean;
  75177. /** @hidden */
  75178. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  75179. /** @hidden */
  75180. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  75181. /**
  75182. * Disposes of the line mesh
  75183. * @param doNotRecurse If children should be disposed
  75184. */
  75185. dispose(doNotRecurse?: boolean): void;
  75186. /**
  75187. * Returns a new LineMesh object cloned from the current one.
  75188. */
  75189. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  75190. /**
  75191. * Creates a new InstancedLinesMesh object from the mesh model.
  75192. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  75193. * @param name defines the name of the new instance
  75194. * @returns a new InstancedLinesMesh
  75195. */
  75196. createInstance(name: string): InstancedLinesMesh;
  75197. }
  75198. /**
  75199. * Creates an instance based on a source LinesMesh
  75200. */
  75201. export class InstancedLinesMesh extends InstancedMesh {
  75202. /**
  75203. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  75204. * This margin is expressed in world space coordinates, so its value may vary.
  75205. * Initilized with the intersectionThreshold value of the source LinesMesh
  75206. */
  75207. intersectionThreshold: number;
  75208. constructor(name: string, source: LinesMesh);
  75209. /**
  75210. * Returns the string "InstancedLinesMesh".
  75211. */
  75212. getClassName(): string;
  75213. }
  75214. }
  75215. declare module BABYLON {
  75216. /**
  75217. * Mesh representing the gorund
  75218. */
  75219. export class GroundMesh extends Mesh {
  75220. /** If octree should be generated */
  75221. generateOctree: boolean;
  75222. private _heightQuads;
  75223. /** @hidden */
  75224. _subdivisionsX: number;
  75225. /** @hidden */
  75226. _subdivisionsY: number;
  75227. /** @hidden */
  75228. _width: number;
  75229. /** @hidden */
  75230. _height: number;
  75231. /** @hidden */
  75232. _minX: number;
  75233. /** @hidden */
  75234. _maxX: number;
  75235. /** @hidden */
  75236. _minZ: number;
  75237. /** @hidden */
  75238. _maxZ: number;
  75239. constructor(name: string, scene: Scene);
  75240. /**
  75241. * "GroundMesh"
  75242. * @returns "GroundMesh"
  75243. */
  75244. getClassName(): string;
  75245. /**
  75246. * The minimum of x and y subdivisions
  75247. */
  75248. readonly subdivisions: number;
  75249. /**
  75250. * X subdivisions
  75251. */
  75252. readonly subdivisionsX: number;
  75253. /**
  75254. * Y subdivisions
  75255. */
  75256. readonly subdivisionsY: number;
  75257. /**
  75258. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  75259. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  75260. * @param chunksCount the number of subdivisions for x and y
  75261. * @param octreeBlocksSize (Default: 32)
  75262. */
  75263. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  75264. /**
  75265. * Returns a height (y) value in the Worl system :
  75266. * the ground altitude at the coordinates (x, z) expressed in the World system.
  75267. * @param x x coordinate
  75268. * @param z z coordinate
  75269. * @returns the ground y position if (x, z) are outside the ground surface.
  75270. */
  75271. getHeightAtCoordinates(x: number, z: number): number;
  75272. /**
  75273. * Returns a normalized vector (Vector3) orthogonal to the ground
  75274. * at the ground coordinates (x, z) expressed in the World system.
  75275. * @param x x coordinate
  75276. * @param z z coordinate
  75277. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  75278. */
  75279. getNormalAtCoordinates(x: number, z: number): Vector3;
  75280. /**
  75281. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  75282. * at the ground coordinates (x, z) expressed in the World system.
  75283. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  75284. * @param x x coordinate
  75285. * @param z z coordinate
  75286. * @param ref vector to store the result
  75287. * @returns the GroundMesh.
  75288. */
  75289. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  75290. /**
  75291. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  75292. * if the ground has been updated.
  75293. * This can be used in the render loop.
  75294. * @returns the GroundMesh.
  75295. */
  75296. updateCoordinateHeights(): GroundMesh;
  75297. private _getFacetAt;
  75298. private _initHeightQuads;
  75299. private _computeHeightQuads;
  75300. /**
  75301. * Serializes this ground mesh
  75302. * @param serializationObject object to write serialization to
  75303. */
  75304. serialize(serializationObject: any): void;
  75305. /**
  75306. * Parses a serialized ground mesh
  75307. * @param parsedMesh the serialized mesh
  75308. * @param scene the scene to create the ground mesh in
  75309. * @returns the created ground mesh
  75310. */
  75311. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  75312. }
  75313. }
  75314. declare module BABYLON {
  75315. /**
  75316. * Interface for Physics-Joint data
  75317. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75318. */
  75319. export interface PhysicsJointData {
  75320. /**
  75321. * The main pivot of the joint
  75322. */
  75323. mainPivot?: Vector3;
  75324. /**
  75325. * The connected pivot of the joint
  75326. */
  75327. connectedPivot?: Vector3;
  75328. /**
  75329. * The main axis of the joint
  75330. */
  75331. mainAxis?: Vector3;
  75332. /**
  75333. * The connected axis of the joint
  75334. */
  75335. connectedAxis?: Vector3;
  75336. /**
  75337. * The collision of the joint
  75338. */
  75339. collision?: boolean;
  75340. /**
  75341. * Native Oimo/Cannon/Energy data
  75342. */
  75343. nativeParams?: any;
  75344. }
  75345. /**
  75346. * This is a holder class for the physics joint created by the physics plugin
  75347. * It holds a set of functions to control the underlying joint
  75348. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75349. */
  75350. export class PhysicsJoint {
  75351. /**
  75352. * The type of the physics joint
  75353. */
  75354. type: number;
  75355. /**
  75356. * The data for the physics joint
  75357. */
  75358. jointData: PhysicsJointData;
  75359. private _physicsJoint;
  75360. protected _physicsPlugin: IPhysicsEnginePlugin;
  75361. /**
  75362. * Initializes the physics joint
  75363. * @param type The type of the physics joint
  75364. * @param jointData The data for the physics joint
  75365. */
  75366. constructor(
  75367. /**
  75368. * The type of the physics joint
  75369. */
  75370. type: number,
  75371. /**
  75372. * The data for the physics joint
  75373. */
  75374. jointData: PhysicsJointData);
  75375. /**
  75376. * Gets the physics joint
  75377. */
  75378. /**
  75379. * Sets the physics joint
  75380. */
  75381. physicsJoint: any;
  75382. /**
  75383. * Sets the physics plugin
  75384. */
  75385. physicsPlugin: IPhysicsEnginePlugin;
  75386. /**
  75387. * Execute a function that is physics-plugin specific.
  75388. * @param {Function} func the function that will be executed.
  75389. * It accepts two parameters: the physics world and the physics joint
  75390. */
  75391. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  75392. /**
  75393. * Distance-Joint type
  75394. */
  75395. static DistanceJoint: number;
  75396. /**
  75397. * Hinge-Joint type
  75398. */
  75399. static HingeJoint: number;
  75400. /**
  75401. * Ball-and-Socket joint type
  75402. */
  75403. static BallAndSocketJoint: number;
  75404. /**
  75405. * Wheel-Joint type
  75406. */
  75407. static WheelJoint: number;
  75408. /**
  75409. * Slider-Joint type
  75410. */
  75411. static SliderJoint: number;
  75412. /**
  75413. * Prismatic-Joint type
  75414. */
  75415. static PrismaticJoint: number;
  75416. /**
  75417. * Universal-Joint type
  75418. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  75419. */
  75420. static UniversalJoint: number;
  75421. /**
  75422. * Hinge-Joint 2 type
  75423. */
  75424. static Hinge2Joint: number;
  75425. /**
  75426. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  75427. */
  75428. static PointToPointJoint: number;
  75429. /**
  75430. * Spring-Joint type
  75431. */
  75432. static SpringJoint: number;
  75433. /**
  75434. * Lock-Joint type
  75435. */
  75436. static LockJoint: number;
  75437. }
  75438. /**
  75439. * A class representing a physics distance joint
  75440. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75441. */
  75442. export class DistanceJoint extends PhysicsJoint {
  75443. /**
  75444. *
  75445. * @param jointData The data for the Distance-Joint
  75446. */
  75447. constructor(jointData: DistanceJointData);
  75448. /**
  75449. * Update the predefined distance.
  75450. * @param maxDistance The maximum preferred distance
  75451. * @param minDistance The minimum preferred distance
  75452. */
  75453. updateDistance(maxDistance: number, minDistance?: number): void;
  75454. }
  75455. /**
  75456. * Represents a Motor-Enabled Joint
  75457. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75458. */
  75459. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  75460. /**
  75461. * Initializes the Motor-Enabled Joint
  75462. * @param type The type of the joint
  75463. * @param jointData The physica joint data for the joint
  75464. */
  75465. constructor(type: number, jointData: PhysicsJointData);
  75466. /**
  75467. * Set the motor values.
  75468. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75469. * @param force the force to apply
  75470. * @param maxForce max force for this motor.
  75471. */
  75472. setMotor(force?: number, maxForce?: number): void;
  75473. /**
  75474. * Set the motor's limits.
  75475. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75476. * @param upperLimit The upper limit of the motor
  75477. * @param lowerLimit The lower limit of the motor
  75478. */
  75479. setLimit(upperLimit: number, lowerLimit?: number): void;
  75480. }
  75481. /**
  75482. * This class represents a single physics Hinge-Joint
  75483. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75484. */
  75485. export class HingeJoint extends MotorEnabledJoint {
  75486. /**
  75487. * Initializes the Hinge-Joint
  75488. * @param jointData The joint data for the Hinge-Joint
  75489. */
  75490. constructor(jointData: PhysicsJointData);
  75491. /**
  75492. * Set the motor values.
  75493. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75494. * @param {number} force the force to apply
  75495. * @param {number} maxForce max force for this motor.
  75496. */
  75497. setMotor(force?: number, maxForce?: number): void;
  75498. /**
  75499. * Set the motor's limits.
  75500. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75501. * @param upperLimit The upper limit of the motor
  75502. * @param lowerLimit The lower limit of the motor
  75503. */
  75504. setLimit(upperLimit: number, lowerLimit?: number): void;
  75505. }
  75506. /**
  75507. * This class represents a dual hinge physics joint (same as wheel joint)
  75508. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75509. */
  75510. export class Hinge2Joint extends MotorEnabledJoint {
  75511. /**
  75512. * Initializes the Hinge2-Joint
  75513. * @param jointData The joint data for the Hinge2-Joint
  75514. */
  75515. constructor(jointData: PhysicsJointData);
  75516. /**
  75517. * Set the motor values.
  75518. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75519. * @param {number} targetSpeed the speed the motor is to reach
  75520. * @param {number} maxForce max force for this motor.
  75521. * @param {motorIndex} the motor's index, 0 or 1.
  75522. */
  75523. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  75524. /**
  75525. * Set the motor limits.
  75526. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75527. * @param {number} upperLimit the upper limit
  75528. * @param {number} lowerLimit lower limit
  75529. * @param {motorIndex} the motor's index, 0 or 1.
  75530. */
  75531. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  75532. }
  75533. /**
  75534. * Interface for a motor enabled joint
  75535. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75536. */
  75537. export interface IMotorEnabledJoint {
  75538. /**
  75539. * Physics joint
  75540. */
  75541. physicsJoint: any;
  75542. /**
  75543. * Sets the motor of the motor-enabled joint
  75544. * @param force The force of the motor
  75545. * @param maxForce The maximum force of the motor
  75546. * @param motorIndex The index of the motor
  75547. */
  75548. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  75549. /**
  75550. * Sets the limit of the motor
  75551. * @param upperLimit The upper limit of the motor
  75552. * @param lowerLimit The lower limit of the motor
  75553. * @param motorIndex The index of the motor
  75554. */
  75555. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  75556. }
  75557. /**
  75558. * Joint data for a Distance-Joint
  75559. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75560. */
  75561. export interface DistanceJointData extends PhysicsJointData {
  75562. /**
  75563. * Max distance the 2 joint objects can be apart
  75564. */
  75565. maxDistance: number;
  75566. }
  75567. /**
  75568. * Joint data from a spring joint
  75569. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75570. */
  75571. export interface SpringJointData extends PhysicsJointData {
  75572. /**
  75573. * Length of the spring
  75574. */
  75575. length: number;
  75576. /**
  75577. * Stiffness of the spring
  75578. */
  75579. stiffness: number;
  75580. /**
  75581. * Damping of the spring
  75582. */
  75583. damping: number;
  75584. /** this callback will be called when applying the force to the impostors. */
  75585. forceApplicationCallback: () => void;
  75586. }
  75587. }
  75588. declare module BABYLON {
  75589. /**
  75590. * Holds the data for the raycast result
  75591. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75592. */
  75593. export class PhysicsRaycastResult {
  75594. private _hasHit;
  75595. private _hitDistance;
  75596. private _hitNormalWorld;
  75597. private _hitPointWorld;
  75598. private _rayFromWorld;
  75599. private _rayToWorld;
  75600. /**
  75601. * Gets if there was a hit
  75602. */
  75603. readonly hasHit: boolean;
  75604. /**
  75605. * Gets the distance from the hit
  75606. */
  75607. readonly hitDistance: number;
  75608. /**
  75609. * Gets the hit normal/direction in the world
  75610. */
  75611. readonly hitNormalWorld: Vector3;
  75612. /**
  75613. * Gets the hit point in the world
  75614. */
  75615. readonly hitPointWorld: Vector3;
  75616. /**
  75617. * Gets the ray "start point" of the ray in the world
  75618. */
  75619. readonly rayFromWorld: Vector3;
  75620. /**
  75621. * Gets the ray "end point" of the ray in the world
  75622. */
  75623. readonly rayToWorld: Vector3;
  75624. /**
  75625. * Sets the hit data (normal & point in world space)
  75626. * @param hitNormalWorld defines the normal in world space
  75627. * @param hitPointWorld defines the point in world space
  75628. */
  75629. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  75630. /**
  75631. * Sets the distance from the start point to the hit point
  75632. * @param distance
  75633. */
  75634. setHitDistance(distance: number): void;
  75635. /**
  75636. * Calculates the distance manually
  75637. */
  75638. calculateHitDistance(): void;
  75639. /**
  75640. * Resets all the values to default
  75641. * @param from The from point on world space
  75642. * @param to The to point on world space
  75643. */
  75644. reset(from?: Vector3, to?: Vector3): void;
  75645. }
  75646. /**
  75647. * Interface for the size containing width and height
  75648. */
  75649. interface IXYZ {
  75650. /**
  75651. * X
  75652. */
  75653. x: number;
  75654. /**
  75655. * Y
  75656. */
  75657. y: number;
  75658. /**
  75659. * Z
  75660. */
  75661. z: number;
  75662. }
  75663. }
  75664. declare module BABYLON {
  75665. /**
  75666. * Interface used to describe a physics joint
  75667. */
  75668. export interface PhysicsImpostorJoint {
  75669. /** Defines the main impostor to which the joint is linked */
  75670. mainImpostor: PhysicsImpostor;
  75671. /** Defines the impostor that is connected to the main impostor using this joint */
  75672. connectedImpostor: PhysicsImpostor;
  75673. /** Defines the joint itself */
  75674. joint: PhysicsJoint;
  75675. }
  75676. /** @hidden */
  75677. export interface IPhysicsEnginePlugin {
  75678. world: any;
  75679. name: string;
  75680. setGravity(gravity: Vector3): void;
  75681. setTimeStep(timeStep: number): void;
  75682. getTimeStep(): number;
  75683. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  75684. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  75685. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  75686. generatePhysicsBody(impostor: PhysicsImpostor): void;
  75687. removePhysicsBody(impostor: PhysicsImpostor): void;
  75688. generateJoint(joint: PhysicsImpostorJoint): void;
  75689. removeJoint(joint: PhysicsImpostorJoint): void;
  75690. isSupported(): boolean;
  75691. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  75692. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  75693. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  75694. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  75695. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  75696. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  75697. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  75698. getBodyMass(impostor: PhysicsImpostor): number;
  75699. getBodyFriction(impostor: PhysicsImpostor): number;
  75700. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  75701. getBodyRestitution(impostor: PhysicsImpostor): number;
  75702. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  75703. getBodyPressure?(impostor: PhysicsImpostor): number;
  75704. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  75705. getBodyStiffness?(impostor: PhysicsImpostor): number;
  75706. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  75707. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  75708. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  75709. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  75710. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  75711. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  75712. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  75713. sleepBody(impostor: PhysicsImpostor): void;
  75714. wakeUpBody(impostor: PhysicsImpostor): void;
  75715. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  75716. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  75717. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  75718. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  75719. getRadius(impostor: PhysicsImpostor): number;
  75720. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  75721. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  75722. dispose(): void;
  75723. }
  75724. /**
  75725. * Interface used to define a physics engine
  75726. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  75727. */
  75728. export interface IPhysicsEngine {
  75729. /**
  75730. * Gets the gravity vector used by the simulation
  75731. */
  75732. gravity: Vector3;
  75733. /**
  75734. * Sets the gravity vector used by the simulation
  75735. * @param gravity defines the gravity vector to use
  75736. */
  75737. setGravity(gravity: Vector3): void;
  75738. /**
  75739. * Set the time step of the physics engine.
  75740. * Default is 1/60.
  75741. * To slow it down, enter 1/600 for example.
  75742. * To speed it up, 1/30
  75743. * @param newTimeStep the new timestep to apply to this world.
  75744. */
  75745. setTimeStep(newTimeStep: number): void;
  75746. /**
  75747. * Get the time step of the physics engine.
  75748. * @returns the current time step
  75749. */
  75750. getTimeStep(): number;
  75751. /**
  75752. * Release all resources
  75753. */
  75754. dispose(): void;
  75755. /**
  75756. * Gets the name of the current physics plugin
  75757. * @returns the name of the plugin
  75758. */
  75759. getPhysicsPluginName(): string;
  75760. /**
  75761. * Adding a new impostor for the impostor tracking.
  75762. * This will be done by the impostor itself.
  75763. * @param impostor the impostor to add
  75764. */
  75765. addImpostor(impostor: PhysicsImpostor): void;
  75766. /**
  75767. * Remove an impostor from the engine.
  75768. * This impostor and its mesh will not longer be updated by the physics engine.
  75769. * @param impostor the impostor to remove
  75770. */
  75771. removeImpostor(impostor: PhysicsImpostor): void;
  75772. /**
  75773. * Add a joint to the physics engine
  75774. * @param mainImpostor defines the main impostor to which the joint is added.
  75775. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  75776. * @param joint defines the joint that will connect both impostors.
  75777. */
  75778. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  75779. /**
  75780. * Removes a joint from the simulation
  75781. * @param mainImpostor defines the impostor used with the joint
  75782. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  75783. * @param joint defines the joint to remove
  75784. */
  75785. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  75786. /**
  75787. * Gets the current plugin used to run the simulation
  75788. * @returns current plugin
  75789. */
  75790. getPhysicsPlugin(): IPhysicsEnginePlugin;
  75791. /**
  75792. * Gets the list of physic impostors
  75793. * @returns an array of PhysicsImpostor
  75794. */
  75795. getImpostors(): Array<PhysicsImpostor>;
  75796. /**
  75797. * Gets the impostor for a physics enabled object
  75798. * @param object defines the object impersonated by the impostor
  75799. * @returns the PhysicsImpostor or null if not found
  75800. */
  75801. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  75802. /**
  75803. * Gets the impostor for a physics body object
  75804. * @param body defines physics body used by the impostor
  75805. * @returns the PhysicsImpostor or null if not found
  75806. */
  75807. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  75808. /**
  75809. * Does a raycast in the physics world
  75810. * @param from when should the ray start?
  75811. * @param to when should the ray end?
  75812. * @returns PhysicsRaycastResult
  75813. */
  75814. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  75815. /**
  75816. * Called by the scene. No need to call it.
  75817. * @param delta defines the timespam between frames
  75818. */
  75819. _step(delta: number): void;
  75820. }
  75821. }
  75822. declare module BABYLON {
  75823. /**
  75824. * The interface for the physics imposter parameters
  75825. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75826. */
  75827. export interface PhysicsImpostorParameters {
  75828. /**
  75829. * The mass of the physics imposter
  75830. */
  75831. mass: number;
  75832. /**
  75833. * The friction of the physics imposter
  75834. */
  75835. friction?: number;
  75836. /**
  75837. * The coefficient of restitution of the physics imposter
  75838. */
  75839. restitution?: number;
  75840. /**
  75841. * The native options of the physics imposter
  75842. */
  75843. nativeOptions?: any;
  75844. /**
  75845. * Specifies if the parent should be ignored
  75846. */
  75847. ignoreParent?: boolean;
  75848. /**
  75849. * Specifies if bi-directional transformations should be disabled
  75850. */
  75851. disableBidirectionalTransformation?: boolean;
  75852. /**
  75853. * The pressure inside the physics imposter, soft object only
  75854. */
  75855. pressure?: number;
  75856. /**
  75857. * The stiffness the physics imposter, soft object only
  75858. */
  75859. stiffness?: number;
  75860. /**
  75861. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  75862. */
  75863. velocityIterations?: number;
  75864. /**
  75865. * The number of iterations used in maintaining consistent vertex positions, soft object only
  75866. */
  75867. positionIterations?: number;
  75868. /**
  75869. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  75870. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  75871. * Add to fix multiple points
  75872. */
  75873. fixedPoints?: number;
  75874. /**
  75875. * The collision margin around a soft object
  75876. */
  75877. margin?: number;
  75878. /**
  75879. * The collision margin around a soft object
  75880. */
  75881. damping?: number;
  75882. /**
  75883. * The path for a rope based on an extrusion
  75884. */
  75885. path?: any;
  75886. /**
  75887. * The shape of an extrusion used for a rope based on an extrusion
  75888. */
  75889. shape?: any;
  75890. }
  75891. /**
  75892. * Interface for a physics-enabled object
  75893. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75894. */
  75895. export interface IPhysicsEnabledObject {
  75896. /**
  75897. * The position of the physics-enabled object
  75898. */
  75899. position: Vector3;
  75900. /**
  75901. * The rotation of the physics-enabled object
  75902. */
  75903. rotationQuaternion: Nullable<Quaternion>;
  75904. /**
  75905. * The scale of the physics-enabled object
  75906. */
  75907. scaling: Vector3;
  75908. /**
  75909. * The rotation of the physics-enabled object
  75910. */
  75911. rotation?: Vector3;
  75912. /**
  75913. * The parent of the physics-enabled object
  75914. */
  75915. parent?: any;
  75916. /**
  75917. * The bounding info of the physics-enabled object
  75918. * @returns The bounding info of the physics-enabled object
  75919. */
  75920. getBoundingInfo(): BoundingInfo;
  75921. /**
  75922. * Computes the world matrix
  75923. * @param force Specifies if the world matrix should be computed by force
  75924. * @returns A world matrix
  75925. */
  75926. computeWorldMatrix(force: boolean): Matrix;
  75927. /**
  75928. * Gets the world matrix
  75929. * @returns A world matrix
  75930. */
  75931. getWorldMatrix?(): Matrix;
  75932. /**
  75933. * Gets the child meshes
  75934. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  75935. * @returns An array of abstract meshes
  75936. */
  75937. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  75938. /**
  75939. * Gets the vertex data
  75940. * @param kind The type of vertex data
  75941. * @returns A nullable array of numbers, or a float32 array
  75942. */
  75943. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  75944. /**
  75945. * Gets the indices from the mesh
  75946. * @returns A nullable array of index arrays
  75947. */
  75948. getIndices?(): Nullable<IndicesArray>;
  75949. /**
  75950. * Gets the scene from the mesh
  75951. * @returns the indices array or null
  75952. */
  75953. getScene?(): Scene;
  75954. /**
  75955. * Gets the absolute position from the mesh
  75956. * @returns the absolute position
  75957. */
  75958. getAbsolutePosition(): Vector3;
  75959. /**
  75960. * Gets the absolute pivot point from the mesh
  75961. * @returns the absolute pivot point
  75962. */
  75963. getAbsolutePivotPoint(): Vector3;
  75964. /**
  75965. * Rotates the mesh
  75966. * @param axis The axis of rotation
  75967. * @param amount The amount of rotation
  75968. * @param space The space of the rotation
  75969. * @returns The rotation transform node
  75970. */
  75971. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  75972. /**
  75973. * Translates the mesh
  75974. * @param axis The axis of translation
  75975. * @param distance The distance of translation
  75976. * @param space The space of the translation
  75977. * @returns The transform node
  75978. */
  75979. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  75980. /**
  75981. * Sets the absolute position of the mesh
  75982. * @param absolutePosition The absolute position of the mesh
  75983. * @returns The transform node
  75984. */
  75985. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  75986. /**
  75987. * Gets the class name of the mesh
  75988. * @returns The class name
  75989. */
  75990. getClassName(): string;
  75991. }
  75992. /**
  75993. * Represents a physics imposter
  75994. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75995. */
  75996. export class PhysicsImpostor {
  75997. /**
  75998. * The physics-enabled object used as the physics imposter
  75999. */
  76000. object: IPhysicsEnabledObject;
  76001. /**
  76002. * The type of the physics imposter
  76003. */
  76004. type: number;
  76005. private _options;
  76006. private _scene?;
  76007. /**
  76008. * The default object size of the imposter
  76009. */
  76010. static DEFAULT_OBJECT_SIZE: Vector3;
  76011. /**
  76012. * The identity quaternion of the imposter
  76013. */
  76014. static IDENTITY_QUATERNION: Quaternion;
  76015. /** @hidden */
  76016. _pluginData: any;
  76017. private _physicsEngine;
  76018. private _physicsBody;
  76019. private _bodyUpdateRequired;
  76020. private _onBeforePhysicsStepCallbacks;
  76021. private _onAfterPhysicsStepCallbacks;
  76022. /** @hidden */
  76023. _onPhysicsCollideCallbacks: Array<{
  76024. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  76025. otherImpostors: Array<PhysicsImpostor>;
  76026. }>;
  76027. private _deltaPosition;
  76028. private _deltaRotation;
  76029. private _deltaRotationConjugated;
  76030. /** @hidden */
  76031. _isFromLine: boolean;
  76032. private _parent;
  76033. private _isDisposed;
  76034. private static _tmpVecs;
  76035. private static _tmpQuat;
  76036. /**
  76037. * Specifies if the physics imposter is disposed
  76038. */
  76039. readonly isDisposed: boolean;
  76040. /**
  76041. * Gets the mass of the physics imposter
  76042. */
  76043. mass: number;
  76044. /**
  76045. * Gets the coefficient of friction
  76046. */
  76047. /**
  76048. * Sets the coefficient of friction
  76049. */
  76050. friction: number;
  76051. /**
  76052. * Gets the coefficient of restitution
  76053. */
  76054. /**
  76055. * Sets the coefficient of restitution
  76056. */
  76057. restitution: number;
  76058. /**
  76059. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  76060. */
  76061. /**
  76062. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  76063. */
  76064. pressure: number;
  76065. /**
  76066. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  76067. */
  76068. /**
  76069. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  76070. */
  76071. stiffness: number;
  76072. /**
  76073. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  76074. */
  76075. /**
  76076. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  76077. */
  76078. velocityIterations: number;
  76079. /**
  76080. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  76081. */
  76082. /**
  76083. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  76084. */
  76085. positionIterations: number;
  76086. /**
  76087. * The unique id of the physics imposter
  76088. * set by the physics engine when adding this impostor to the array
  76089. */
  76090. uniqueId: number;
  76091. /**
  76092. * @hidden
  76093. */
  76094. soft: boolean;
  76095. /**
  76096. * @hidden
  76097. */
  76098. segments: number;
  76099. private _joints;
  76100. /**
  76101. * Initializes the physics imposter
  76102. * @param object The physics-enabled object used as the physics imposter
  76103. * @param type The type of the physics imposter
  76104. * @param _options The options for the physics imposter
  76105. * @param _scene The Babylon scene
  76106. */
  76107. constructor(
  76108. /**
  76109. * The physics-enabled object used as the physics imposter
  76110. */
  76111. object: IPhysicsEnabledObject,
  76112. /**
  76113. * The type of the physics imposter
  76114. */
  76115. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  76116. /**
  76117. * This function will completly initialize this impostor.
  76118. * It will create a new body - but only if this mesh has no parent.
  76119. * If it has, this impostor will not be used other than to define the impostor
  76120. * of the child mesh.
  76121. * @hidden
  76122. */
  76123. _init(): void;
  76124. private _getPhysicsParent;
  76125. /**
  76126. * Should a new body be generated.
  76127. * @returns boolean specifying if body initialization is required
  76128. */
  76129. isBodyInitRequired(): boolean;
  76130. /**
  76131. * Sets the updated scaling
  76132. * @param updated Specifies if the scaling is updated
  76133. */
  76134. setScalingUpdated(): void;
  76135. /**
  76136. * Force a regeneration of this or the parent's impostor's body.
  76137. * Use under cautious - This will remove all joints already implemented.
  76138. */
  76139. forceUpdate(): void;
  76140. /**
  76141. * Gets the body that holds this impostor. Either its own, or its parent.
  76142. */
  76143. /**
  76144. * Set the physics body. Used mainly by the physics engine/plugin
  76145. */
  76146. physicsBody: any;
  76147. /**
  76148. * Get the parent of the physics imposter
  76149. * @returns Physics imposter or null
  76150. */
  76151. /**
  76152. * Sets the parent of the physics imposter
  76153. */
  76154. parent: Nullable<PhysicsImpostor>;
  76155. /**
  76156. * Resets the update flags
  76157. */
  76158. resetUpdateFlags(): void;
  76159. /**
  76160. * Gets the object extend size
  76161. * @returns the object extend size
  76162. */
  76163. getObjectExtendSize(): Vector3;
  76164. /**
  76165. * Gets the object center
  76166. * @returns The object center
  76167. */
  76168. getObjectCenter(): Vector3;
  76169. /**
  76170. * Get a specific parametes from the options parameter
  76171. * @param paramName The object parameter name
  76172. * @returns The object parameter
  76173. */
  76174. getParam(paramName: string): any;
  76175. /**
  76176. * Sets a specific parameter in the options given to the physics plugin
  76177. * @param paramName The parameter name
  76178. * @param value The value of the parameter
  76179. */
  76180. setParam(paramName: string, value: number): void;
  76181. /**
  76182. * Specifically change the body's mass option. Won't recreate the physics body object
  76183. * @param mass The mass of the physics imposter
  76184. */
  76185. setMass(mass: number): void;
  76186. /**
  76187. * Gets the linear velocity
  76188. * @returns linear velocity or null
  76189. */
  76190. getLinearVelocity(): Nullable<Vector3>;
  76191. /**
  76192. * Sets the linear velocity
  76193. * @param velocity linear velocity or null
  76194. */
  76195. setLinearVelocity(velocity: Nullable<Vector3>): void;
  76196. /**
  76197. * Gets the angular velocity
  76198. * @returns angular velocity or null
  76199. */
  76200. getAngularVelocity(): Nullable<Vector3>;
  76201. /**
  76202. * Sets the angular velocity
  76203. * @param velocity The velocity or null
  76204. */
  76205. setAngularVelocity(velocity: Nullable<Vector3>): void;
  76206. /**
  76207. * Execute a function with the physics plugin native code
  76208. * Provide a function the will have two variables - the world object and the physics body object
  76209. * @param func The function to execute with the physics plugin native code
  76210. */
  76211. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  76212. /**
  76213. * Register a function that will be executed before the physics world is stepping forward
  76214. * @param func The function to execute before the physics world is stepped forward
  76215. */
  76216. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  76217. /**
  76218. * Unregister a function that will be executed before the physics world is stepping forward
  76219. * @param func The function to execute before the physics world is stepped forward
  76220. */
  76221. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  76222. /**
  76223. * Register a function that will be executed after the physics step
  76224. * @param func The function to execute after physics step
  76225. */
  76226. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  76227. /**
  76228. * Unregisters a function that will be executed after the physics step
  76229. * @param func The function to execute after physics step
  76230. */
  76231. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  76232. /**
  76233. * register a function that will be executed when this impostor collides against a different body
  76234. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  76235. * @param func Callback that is executed on collision
  76236. */
  76237. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  76238. /**
  76239. * Unregisters the physics imposter on contact
  76240. * @param collideAgainst The physics object to collide against
  76241. * @param func Callback to execute on collision
  76242. */
  76243. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  76244. private _tmpQuat;
  76245. private _tmpQuat2;
  76246. /**
  76247. * Get the parent rotation
  76248. * @returns The parent rotation
  76249. */
  76250. getParentsRotation(): Quaternion;
  76251. /**
  76252. * this function is executed by the physics engine.
  76253. */
  76254. beforeStep: () => void;
  76255. /**
  76256. * this function is executed by the physics engine
  76257. */
  76258. afterStep: () => void;
  76259. /**
  76260. * Legacy collision detection event support
  76261. */
  76262. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  76263. /**
  76264. * event and body object due to cannon's event-based architecture.
  76265. */
  76266. onCollide: (e: {
  76267. body: any;
  76268. }) => void;
  76269. /**
  76270. * Apply a force
  76271. * @param force The force to apply
  76272. * @param contactPoint The contact point for the force
  76273. * @returns The physics imposter
  76274. */
  76275. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  76276. /**
  76277. * Apply an impulse
  76278. * @param force The impulse force
  76279. * @param contactPoint The contact point for the impulse force
  76280. * @returns The physics imposter
  76281. */
  76282. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  76283. /**
  76284. * A help function to create a joint
  76285. * @param otherImpostor A physics imposter used to create a joint
  76286. * @param jointType The type of joint
  76287. * @param jointData The data for the joint
  76288. * @returns The physics imposter
  76289. */
  76290. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  76291. /**
  76292. * Add a joint to this impostor with a different impostor
  76293. * @param otherImpostor A physics imposter used to add a joint
  76294. * @param joint The joint to add
  76295. * @returns The physics imposter
  76296. */
  76297. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  76298. /**
  76299. * Add an anchor to a cloth impostor
  76300. * @param otherImpostor rigid impostor to anchor to
  76301. * @param width ratio across width from 0 to 1
  76302. * @param height ratio up height from 0 to 1
  76303. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  76304. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  76305. * @returns impostor the soft imposter
  76306. */
  76307. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  76308. /**
  76309. * Add a hook to a rope impostor
  76310. * @param otherImpostor rigid impostor to anchor to
  76311. * @param length ratio across rope from 0 to 1
  76312. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  76313. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  76314. * @returns impostor the rope imposter
  76315. */
  76316. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  76317. /**
  76318. * Will keep this body still, in a sleep mode.
  76319. * @returns the physics imposter
  76320. */
  76321. sleep(): PhysicsImpostor;
  76322. /**
  76323. * Wake the body up.
  76324. * @returns The physics imposter
  76325. */
  76326. wakeUp(): PhysicsImpostor;
  76327. /**
  76328. * Clones the physics imposter
  76329. * @param newObject The physics imposter clones to this physics-enabled object
  76330. * @returns A nullable physics imposter
  76331. */
  76332. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  76333. /**
  76334. * Disposes the physics imposter
  76335. */
  76336. dispose(): void;
  76337. /**
  76338. * Sets the delta position
  76339. * @param position The delta position amount
  76340. */
  76341. setDeltaPosition(position: Vector3): void;
  76342. /**
  76343. * Sets the delta rotation
  76344. * @param rotation The delta rotation amount
  76345. */
  76346. setDeltaRotation(rotation: Quaternion): void;
  76347. /**
  76348. * Gets the box size of the physics imposter and stores the result in the input parameter
  76349. * @param result Stores the box size
  76350. * @returns The physics imposter
  76351. */
  76352. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  76353. /**
  76354. * Gets the radius of the physics imposter
  76355. * @returns Radius of the physics imposter
  76356. */
  76357. getRadius(): number;
  76358. /**
  76359. * Sync a bone with this impostor
  76360. * @param bone The bone to sync to the impostor.
  76361. * @param boneMesh The mesh that the bone is influencing.
  76362. * @param jointPivot The pivot of the joint / bone in local space.
  76363. * @param distToJoint Optional distance from the impostor to the joint.
  76364. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  76365. */
  76366. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  76367. /**
  76368. * Sync impostor to a bone
  76369. * @param bone The bone that the impostor will be synced to.
  76370. * @param boneMesh The mesh that the bone is influencing.
  76371. * @param jointPivot The pivot of the joint / bone in local space.
  76372. * @param distToJoint Optional distance from the impostor to the joint.
  76373. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  76374. * @param boneAxis Optional vector3 axis the bone is aligned with
  76375. */
  76376. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  76377. /**
  76378. * No-Imposter type
  76379. */
  76380. static NoImpostor: number;
  76381. /**
  76382. * Sphere-Imposter type
  76383. */
  76384. static SphereImpostor: number;
  76385. /**
  76386. * Box-Imposter type
  76387. */
  76388. static BoxImpostor: number;
  76389. /**
  76390. * Plane-Imposter type
  76391. */
  76392. static PlaneImpostor: number;
  76393. /**
  76394. * Mesh-imposter type
  76395. */
  76396. static MeshImpostor: number;
  76397. /**
  76398. * Cylinder-Imposter type
  76399. */
  76400. static CylinderImpostor: number;
  76401. /**
  76402. * Particle-Imposter type
  76403. */
  76404. static ParticleImpostor: number;
  76405. /**
  76406. * Heightmap-Imposter type
  76407. */
  76408. static HeightmapImpostor: number;
  76409. /**
  76410. * ConvexHull-Impostor type (Ammo.js plugin only)
  76411. */
  76412. static ConvexHullImpostor: number;
  76413. /**
  76414. * Rope-Imposter type
  76415. */
  76416. static RopeImpostor: number;
  76417. /**
  76418. * Cloth-Imposter type
  76419. */
  76420. static ClothImpostor: number;
  76421. /**
  76422. * Softbody-Imposter type
  76423. */
  76424. static SoftbodyImpostor: number;
  76425. }
  76426. }
  76427. declare module BABYLON {
  76428. /**
  76429. * @hidden
  76430. **/
  76431. export class _CreationDataStorage {
  76432. closePath?: boolean;
  76433. closeArray?: boolean;
  76434. idx: number[];
  76435. dashSize: number;
  76436. gapSize: number;
  76437. path3D: Path3D;
  76438. pathArray: Vector3[][];
  76439. arc: number;
  76440. radius: number;
  76441. cap: number;
  76442. tessellation: number;
  76443. }
  76444. /**
  76445. * @hidden
  76446. **/
  76447. class _InstanceDataStorage {
  76448. visibleInstances: any;
  76449. batchCache: _InstancesBatch;
  76450. instancesBufferSize: number;
  76451. instancesBuffer: Nullable<Buffer>;
  76452. instancesData: Float32Array;
  76453. overridenInstanceCount: number;
  76454. isFrozen: boolean;
  76455. previousBatch: Nullable<_InstancesBatch>;
  76456. hardwareInstancedRendering: boolean;
  76457. sideOrientation: number;
  76458. }
  76459. /**
  76460. * @hidden
  76461. **/
  76462. export class _InstancesBatch {
  76463. mustReturn: boolean;
  76464. visibleInstances: Nullable<InstancedMesh[]>[];
  76465. renderSelf: boolean[];
  76466. hardwareInstancedRendering: boolean[];
  76467. }
  76468. /**
  76469. * Class used to represent renderable models
  76470. */
  76471. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  76472. /**
  76473. * Mesh side orientation : usually the external or front surface
  76474. */
  76475. static readonly FRONTSIDE: number;
  76476. /**
  76477. * Mesh side orientation : usually the internal or back surface
  76478. */
  76479. static readonly BACKSIDE: number;
  76480. /**
  76481. * Mesh side orientation : both internal and external or front and back surfaces
  76482. */
  76483. static readonly DOUBLESIDE: number;
  76484. /**
  76485. * Mesh side orientation : by default, `FRONTSIDE`
  76486. */
  76487. static readonly DEFAULTSIDE: number;
  76488. /**
  76489. * Mesh cap setting : no cap
  76490. */
  76491. static readonly NO_CAP: number;
  76492. /**
  76493. * Mesh cap setting : one cap at the beginning of the mesh
  76494. */
  76495. static readonly CAP_START: number;
  76496. /**
  76497. * Mesh cap setting : one cap at the end of the mesh
  76498. */
  76499. static readonly CAP_END: number;
  76500. /**
  76501. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  76502. */
  76503. static readonly CAP_ALL: number;
  76504. /**
  76505. * Mesh pattern setting : no flip or rotate
  76506. */
  76507. static readonly NO_FLIP: number;
  76508. /**
  76509. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  76510. */
  76511. static readonly FLIP_TILE: number;
  76512. /**
  76513. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  76514. */
  76515. static readonly ROTATE_TILE: number;
  76516. /**
  76517. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  76518. */
  76519. static readonly FLIP_ROW: number;
  76520. /**
  76521. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  76522. */
  76523. static readonly ROTATE_ROW: number;
  76524. /**
  76525. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  76526. */
  76527. static readonly FLIP_N_ROTATE_TILE: number;
  76528. /**
  76529. * Mesh pattern setting : rotate pattern and rotate
  76530. */
  76531. static readonly FLIP_N_ROTATE_ROW: number;
  76532. /**
  76533. * Mesh tile positioning : part tiles same on left/right or top/bottom
  76534. */
  76535. static readonly CENTER: number;
  76536. /**
  76537. * Mesh tile positioning : part tiles on left
  76538. */
  76539. static readonly LEFT: number;
  76540. /**
  76541. * Mesh tile positioning : part tiles on right
  76542. */
  76543. static readonly RIGHT: number;
  76544. /**
  76545. * Mesh tile positioning : part tiles on top
  76546. */
  76547. static readonly TOP: number;
  76548. /**
  76549. * Mesh tile positioning : part tiles on bottom
  76550. */
  76551. static readonly BOTTOM: number;
  76552. /**
  76553. * Gets the default side orientation.
  76554. * @param orientation the orientation to value to attempt to get
  76555. * @returns the default orientation
  76556. * @hidden
  76557. */
  76558. static _GetDefaultSideOrientation(orientation?: number): number;
  76559. private _internalMeshDataInfo;
  76560. /**
  76561. * An event triggered before rendering the mesh
  76562. */
  76563. readonly onBeforeRenderObservable: Observable<Mesh>;
  76564. /**
  76565. * An event triggered before binding the mesh
  76566. */
  76567. readonly onBeforeBindObservable: Observable<Mesh>;
  76568. /**
  76569. * An event triggered after rendering the mesh
  76570. */
  76571. readonly onAfterRenderObservable: Observable<Mesh>;
  76572. /**
  76573. * An event triggered before drawing the mesh
  76574. */
  76575. readonly onBeforeDrawObservable: Observable<Mesh>;
  76576. private _onBeforeDrawObserver;
  76577. /**
  76578. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  76579. */
  76580. onBeforeDraw: () => void;
  76581. /**
  76582. * Gets the delay loading state of the mesh (when delay loading is turned on)
  76583. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  76584. */
  76585. delayLoadState: number;
  76586. /**
  76587. * Gets the list of instances created from this mesh
  76588. * it is not supposed to be modified manually.
  76589. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  76590. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  76591. */
  76592. instances: InstancedMesh[];
  76593. /**
  76594. * Gets the file containing delay loading data for this mesh
  76595. */
  76596. delayLoadingFile: string;
  76597. /** @hidden */
  76598. _binaryInfo: any;
  76599. /**
  76600. * User defined function used to change how LOD level selection is done
  76601. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  76602. */
  76603. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  76604. /**
  76605. * Gets or sets the morph target manager
  76606. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  76607. */
  76608. morphTargetManager: Nullable<MorphTargetManager>;
  76609. /** @hidden */
  76610. _creationDataStorage: Nullable<_CreationDataStorage>;
  76611. /** @hidden */
  76612. _geometry: Nullable<Geometry>;
  76613. /** @hidden */
  76614. _delayInfo: Array<string>;
  76615. /** @hidden */
  76616. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  76617. /** @hidden */
  76618. _instanceDataStorage: _InstanceDataStorage;
  76619. private _effectiveMaterial;
  76620. /** @hidden */
  76621. _shouldGenerateFlatShading: boolean;
  76622. /** @hidden */
  76623. _originalBuilderSideOrientation: number;
  76624. /**
  76625. * Use this property to change the original side orientation defined at construction time
  76626. */
  76627. overrideMaterialSideOrientation: Nullable<number>;
  76628. /**
  76629. * Gets the source mesh (the one used to clone this one from)
  76630. */
  76631. readonly source: Nullable<Mesh>;
  76632. /**
  76633. * Gets or sets a boolean indicating that this mesh does not use index buffer
  76634. */
  76635. isUnIndexed: boolean;
  76636. /**
  76637. * @constructor
  76638. * @param name The value used by scene.getMeshByName() to do a lookup.
  76639. * @param scene The scene to add this mesh to.
  76640. * @param parent The parent of this mesh, if it has one
  76641. * @param source An optional Mesh from which geometry is shared, cloned.
  76642. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  76643. * When false, achieved by calling a clone(), also passing False.
  76644. * This will make creation of children, recursive.
  76645. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  76646. */
  76647. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  76648. /**
  76649. * Gets the class name
  76650. * @returns the string "Mesh".
  76651. */
  76652. getClassName(): string;
  76653. /** @hidden */
  76654. readonly _isMesh: boolean;
  76655. /**
  76656. * Returns a description of this mesh
  76657. * @param fullDetails define if full details about this mesh must be used
  76658. * @returns a descriptive string representing this mesh
  76659. */
  76660. toString(fullDetails?: boolean): string;
  76661. /** @hidden */
  76662. _unBindEffect(): void;
  76663. /**
  76664. * Gets a boolean indicating if this mesh has LOD
  76665. */
  76666. readonly hasLODLevels: boolean;
  76667. /**
  76668. * Gets the list of MeshLODLevel associated with the current mesh
  76669. * @returns an array of MeshLODLevel
  76670. */
  76671. getLODLevels(): MeshLODLevel[];
  76672. private _sortLODLevels;
  76673. /**
  76674. * Add a mesh as LOD level triggered at the given distance.
  76675. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  76676. * @param distance The distance from the center of the object to show this level
  76677. * @param mesh The mesh to be added as LOD level (can be null)
  76678. * @return This mesh (for chaining)
  76679. */
  76680. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  76681. /**
  76682. * Returns the LOD level mesh at the passed distance or null if not found.
  76683. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  76684. * @param distance The distance from the center of the object to show this level
  76685. * @returns a Mesh or `null`
  76686. */
  76687. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  76688. /**
  76689. * Remove a mesh from the LOD array
  76690. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  76691. * @param mesh defines the mesh to be removed
  76692. * @return This mesh (for chaining)
  76693. */
  76694. removeLODLevel(mesh: Mesh): Mesh;
  76695. /**
  76696. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  76697. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  76698. * @param camera defines the camera to use to compute distance
  76699. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  76700. * @return This mesh (for chaining)
  76701. */
  76702. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  76703. /**
  76704. * Gets the mesh internal Geometry object
  76705. */
  76706. readonly geometry: Nullable<Geometry>;
  76707. /**
  76708. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  76709. * @returns the total number of vertices
  76710. */
  76711. getTotalVertices(): number;
  76712. /**
  76713. * Returns the content of an associated vertex buffer
  76714. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  76715. * - VertexBuffer.PositionKind
  76716. * - VertexBuffer.UVKind
  76717. * - VertexBuffer.UV2Kind
  76718. * - VertexBuffer.UV3Kind
  76719. * - VertexBuffer.UV4Kind
  76720. * - VertexBuffer.UV5Kind
  76721. * - VertexBuffer.UV6Kind
  76722. * - VertexBuffer.ColorKind
  76723. * - VertexBuffer.MatricesIndicesKind
  76724. * - VertexBuffer.MatricesIndicesExtraKind
  76725. * - VertexBuffer.MatricesWeightsKind
  76726. * - VertexBuffer.MatricesWeightsExtraKind
  76727. * @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
  76728. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  76729. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  76730. */
  76731. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  76732. /**
  76733. * Returns the mesh VertexBuffer object from the requested `kind`
  76734. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  76735. * - VertexBuffer.PositionKind
  76736. * - VertexBuffer.NormalKind
  76737. * - VertexBuffer.UVKind
  76738. * - VertexBuffer.UV2Kind
  76739. * - VertexBuffer.UV3Kind
  76740. * - VertexBuffer.UV4Kind
  76741. * - VertexBuffer.UV5Kind
  76742. * - VertexBuffer.UV6Kind
  76743. * - VertexBuffer.ColorKind
  76744. * - VertexBuffer.MatricesIndicesKind
  76745. * - VertexBuffer.MatricesIndicesExtraKind
  76746. * - VertexBuffer.MatricesWeightsKind
  76747. * - VertexBuffer.MatricesWeightsExtraKind
  76748. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  76749. */
  76750. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  76751. /**
  76752. * Tests if a specific vertex buffer is associated with this mesh
  76753. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  76754. * - VertexBuffer.PositionKind
  76755. * - VertexBuffer.NormalKind
  76756. * - VertexBuffer.UVKind
  76757. * - VertexBuffer.UV2Kind
  76758. * - VertexBuffer.UV3Kind
  76759. * - VertexBuffer.UV4Kind
  76760. * - VertexBuffer.UV5Kind
  76761. * - VertexBuffer.UV6Kind
  76762. * - VertexBuffer.ColorKind
  76763. * - VertexBuffer.MatricesIndicesKind
  76764. * - VertexBuffer.MatricesIndicesExtraKind
  76765. * - VertexBuffer.MatricesWeightsKind
  76766. * - VertexBuffer.MatricesWeightsExtraKind
  76767. * @returns a boolean
  76768. */
  76769. isVerticesDataPresent(kind: string): boolean;
  76770. /**
  76771. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  76772. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  76773. * - VertexBuffer.PositionKind
  76774. * - VertexBuffer.UVKind
  76775. * - VertexBuffer.UV2Kind
  76776. * - VertexBuffer.UV3Kind
  76777. * - VertexBuffer.UV4Kind
  76778. * - VertexBuffer.UV5Kind
  76779. * - VertexBuffer.UV6Kind
  76780. * - VertexBuffer.ColorKind
  76781. * - VertexBuffer.MatricesIndicesKind
  76782. * - VertexBuffer.MatricesIndicesExtraKind
  76783. * - VertexBuffer.MatricesWeightsKind
  76784. * - VertexBuffer.MatricesWeightsExtraKind
  76785. * @returns a boolean
  76786. */
  76787. isVertexBufferUpdatable(kind: string): boolean;
  76788. /**
  76789. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  76790. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  76791. * - VertexBuffer.PositionKind
  76792. * - VertexBuffer.NormalKind
  76793. * - VertexBuffer.UVKind
  76794. * - VertexBuffer.UV2Kind
  76795. * - VertexBuffer.UV3Kind
  76796. * - VertexBuffer.UV4Kind
  76797. * - VertexBuffer.UV5Kind
  76798. * - VertexBuffer.UV6Kind
  76799. * - VertexBuffer.ColorKind
  76800. * - VertexBuffer.MatricesIndicesKind
  76801. * - VertexBuffer.MatricesIndicesExtraKind
  76802. * - VertexBuffer.MatricesWeightsKind
  76803. * - VertexBuffer.MatricesWeightsExtraKind
  76804. * @returns an array of strings
  76805. */
  76806. getVerticesDataKinds(): string[];
  76807. /**
  76808. * Returns a positive integer : the total number of indices in this mesh geometry.
  76809. * @returns the numner of indices or zero if the mesh has no geometry.
  76810. */
  76811. getTotalIndices(): number;
  76812. /**
  76813. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  76814. * @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.
  76815. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  76816. * @returns the indices array or an empty array if the mesh has no geometry
  76817. */
  76818. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  76819. readonly isBlocked: boolean;
  76820. /**
  76821. * Determine if the current mesh is ready to be rendered
  76822. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  76823. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  76824. * @returns true if all associated assets are ready (material, textures, shaders)
  76825. */
  76826. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  76827. /**
  76828. * 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.
  76829. */
  76830. readonly areNormalsFrozen: boolean;
  76831. /**
  76832. * 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.
  76833. * @returns the current mesh
  76834. */
  76835. freezeNormals(): Mesh;
  76836. /**
  76837. * 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
  76838. * @returns the current mesh
  76839. */
  76840. unfreezeNormals(): Mesh;
  76841. /**
  76842. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  76843. */
  76844. overridenInstanceCount: number;
  76845. /** @hidden */
  76846. _preActivate(): Mesh;
  76847. /** @hidden */
  76848. _preActivateForIntermediateRendering(renderId: number): Mesh;
  76849. /** @hidden */
  76850. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  76851. /**
  76852. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  76853. * This means the mesh underlying bounding box and sphere are recomputed.
  76854. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  76855. * @returns the current mesh
  76856. */
  76857. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  76858. /** @hidden */
  76859. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  76860. /**
  76861. * This function will subdivide the mesh into multiple submeshes
  76862. * @param count defines the expected number of submeshes
  76863. */
  76864. subdivide(count: number): void;
  76865. /**
  76866. * Copy a FloatArray into a specific associated vertex buffer
  76867. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  76868. * - VertexBuffer.PositionKind
  76869. * - VertexBuffer.UVKind
  76870. * - VertexBuffer.UV2Kind
  76871. * - VertexBuffer.UV3Kind
  76872. * - VertexBuffer.UV4Kind
  76873. * - VertexBuffer.UV5Kind
  76874. * - VertexBuffer.UV6Kind
  76875. * - VertexBuffer.ColorKind
  76876. * - VertexBuffer.MatricesIndicesKind
  76877. * - VertexBuffer.MatricesIndicesExtraKind
  76878. * - VertexBuffer.MatricesWeightsKind
  76879. * - VertexBuffer.MatricesWeightsExtraKind
  76880. * @param data defines the data source
  76881. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  76882. * @param stride defines the data stride size (can be null)
  76883. * @returns the current mesh
  76884. */
  76885. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  76886. /**
  76887. * Flags an associated vertex buffer as updatable
  76888. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  76889. * - VertexBuffer.PositionKind
  76890. * - VertexBuffer.UVKind
  76891. * - VertexBuffer.UV2Kind
  76892. * - VertexBuffer.UV3Kind
  76893. * - VertexBuffer.UV4Kind
  76894. * - VertexBuffer.UV5Kind
  76895. * - VertexBuffer.UV6Kind
  76896. * - VertexBuffer.ColorKind
  76897. * - VertexBuffer.MatricesIndicesKind
  76898. * - VertexBuffer.MatricesIndicesExtraKind
  76899. * - VertexBuffer.MatricesWeightsKind
  76900. * - VertexBuffer.MatricesWeightsExtraKind
  76901. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  76902. */
  76903. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  76904. /**
  76905. * Sets the mesh global Vertex Buffer
  76906. * @param buffer defines the buffer to use
  76907. * @returns the current mesh
  76908. */
  76909. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  76910. /**
  76911. * Update a specific associated vertex buffer
  76912. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  76913. * - VertexBuffer.PositionKind
  76914. * - VertexBuffer.UVKind
  76915. * - VertexBuffer.UV2Kind
  76916. * - VertexBuffer.UV3Kind
  76917. * - VertexBuffer.UV4Kind
  76918. * - VertexBuffer.UV5Kind
  76919. * - VertexBuffer.UV6Kind
  76920. * - VertexBuffer.ColorKind
  76921. * - VertexBuffer.MatricesIndicesKind
  76922. * - VertexBuffer.MatricesIndicesExtraKind
  76923. * - VertexBuffer.MatricesWeightsKind
  76924. * - VertexBuffer.MatricesWeightsExtraKind
  76925. * @param data defines the data source
  76926. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  76927. * @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)
  76928. * @returns the current mesh
  76929. */
  76930. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  76931. /**
  76932. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  76933. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  76934. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  76935. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  76936. * @returns the current mesh
  76937. */
  76938. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  76939. /**
  76940. * Creates a un-shared specific occurence of the geometry for the mesh.
  76941. * @returns the current mesh
  76942. */
  76943. makeGeometryUnique(): Mesh;
  76944. /**
  76945. * Set the index buffer of this mesh
  76946. * @param indices defines the source data
  76947. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  76948. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  76949. * @returns the current mesh
  76950. */
  76951. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  76952. /**
  76953. * Update the current index buffer
  76954. * @param indices defines the source data
  76955. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  76956. * @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)
  76957. * @returns the current mesh
  76958. */
  76959. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  76960. /**
  76961. * Invert the geometry to move from a right handed system to a left handed one.
  76962. * @returns the current mesh
  76963. */
  76964. toLeftHanded(): Mesh;
  76965. /** @hidden */
  76966. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  76967. /** @hidden */
  76968. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  76969. /**
  76970. * Registers for this mesh a javascript function called just before the rendering process
  76971. * @param func defines the function to call before rendering this mesh
  76972. * @returns the current mesh
  76973. */
  76974. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  76975. /**
  76976. * Disposes a previously registered javascript function called before the rendering
  76977. * @param func defines the function to remove
  76978. * @returns the current mesh
  76979. */
  76980. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  76981. /**
  76982. * Registers for this mesh a javascript function called just after the rendering is complete
  76983. * @param func defines the function to call after rendering this mesh
  76984. * @returns the current mesh
  76985. */
  76986. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  76987. /**
  76988. * Disposes a previously registered javascript function called after the rendering.
  76989. * @param func defines the function to remove
  76990. * @returns the current mesh
  76991. */
  76992. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  76993. /** @hidden */
  76994. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  76995. /** @hidden */
  76996. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  76997. /** @hidden */
  76998. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  76999. /** @hidden */
  77000. _freeze(): void;
  77001. /** @hidden */
  77002. _unFreeze(): void;
  77003. /**
  77004. * 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
  77005. * @param subMesh defines the subMesh to render
  77006. * @param enableAlphaMode defines if alpha mode can be changed
  77007. * @returns the current mesh
  77008. */
  77009. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  77010. private _onBeforeDraw;
  77011. /**
  77012. * Renormalize the mesh and patch it up if there are no weights
  77013. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  77014. * However in the case of zero weights then we set just a single influence to 1.
  77015. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  77016. */
  77017. cleanMatrixWeights(): void;
  77018. private normalizeSkinFourWeights;
  77019. private normalizeSkinWeightsAndExtra;
  77020. /**
  77021. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  77022. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  77023. * the user know there was an issue with importing the mesh
  77024. * @returns a validation object with skinned, valid and report string
  77025. */
  77026. validateSkinning(): {
  77027. skinned: boolean;
  77028. valid: boolean;
  77029. report: string;
  77030. };
  77031. /** @hidden */
  77032. _checkDelayState(): Mesh;
  77033. private _queueLoad;
  77034. /**
  77035. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  77036. * A mesh is in the frustum if its bounding box intersects the frustum
  77037. * @param frustumPlanes defines the frustum to test
  77038. * @returns true if the mesh is in the frustum planes
  77039. */
  77040. isInFrustum(frustumPlanes: Plane[]): boolean;
  77041. /**
  77042. * Sets the mesh material by the material or multiMaterial `id` property
  77043. * @param id is a string identifying the material or the multiMaterial
  77044. * @returns the current mesh
  77045. */
  77046. setMaterialByID(id: string): Mesh;
  77047. /**
  77048. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  77049. * @returns an array of IAnimatable
  77050. */
  77051. getAnimatables(): IAnimatable[];
  77052. /**
  77053. * Modifies the mesh geometry according to the passed transformation matrix.
  77054. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  77055. * The mesh normals are modified using the same transformation.
  77056. * Note that, under the hood, this method sets a new VertexBuffer each call.
  77057. * @param transform defines the transform matrix to use
  77058. * @see http://doc.babylonjs.com/resources/baking_transformations
  77059. * @returns the current mesh
  77060. */
  77061. bakeTransformIntoVertices(transform: Matrix): Mesh;
  77062. /**
  77063. * Modifies the mesh geometry according to its own current World Matrix.
  77064. * The mesh World Matrix is then reset.
  77065. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  77066. * Note that, under the hood, this method sets a new VertexBuffer each call.
  77067. * @see http://doc.babylonjs.com/resources/baking_transformations
  77068. * @returns the current mesh
  77069. */
  77070. bakeCurrentTransformIntoVertices(): Mesh;
  77071. /** @hidden */
  77072. readonly _positions: Nullable<Vector3[]>;
  77073. /** @hidden */
  77074. _resetPointsArrayCache(): Mesh;
  77075. /** @hidden */
  77076. _generatePointsArray(): boolean;
  77077. /**
  77078. * Returns a new Mesh object generated from the current mesh properties.
  77079. * This method must not get confused with createInstance()
  77080. * @param name is a string, the name given to the new mesh
  77081. * @param newParent can be any Node object (default `null`)
  77082. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  77083. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  77084. * @returns a new mesh
  77085. */
  77086. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  77087. /**
  77088. * Releases resources associated with this mesh.
  77089. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  77090. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  77091. */
  77092. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  77093. /**
  77094. * Modifies the mesh geometry according to a displacement map.
  77095. * 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.
  77096. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  77097. * @param url is a string, the URL from the image file is to be downloaded.
  77098. * @param minHeight is the lower limit of the displacement.
  77099. * @param maxHeight is the upper limit of the displacement.
  77100. * @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.
  77101. * @param uvOffset is an optional vector2 used to offset UV.
  77102. * @param uvScale is an optional vector2 used to scale UV.
  77103. * @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.
  77104. * @returns the Mesh.
  77105. */
  77106. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  77107. /**
  77108. * Modifies the mesh geometry according to a displacementMap buffer.
  77109. * 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.
  77110. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  77111. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  77112. * @param heightMapWidth is the width of the buffer image.
  77113. * @param heightMapHeight is the height of the buffer image.
  77114. * @param minHeight is the lower limit of the displacement.
  77115. * @param maxHeight is the upper limit of the displacement.
  77116. * @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.
  77117. * @param uvOffset is an optional vector2 used to offset UV.
  77118. * @param uvScale is an optional vector2 used to scale UV.
  77119. * @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.
  77120. * @returns the Mesh.
  77121. */
  77122. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  77123. /**
  77124. * Modify the mesh to get a flat shading rendering.
  77125. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  77126. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  77127. * @returns current mesh
  77128. */
  77129. convertToFlatShadedMesh(): Mesh;
  77130. /**
  77131. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  77132. * In other words, more vertices, no more indices and a single bigger VBO.
  77133. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  77134. * @returns current mesh
  77135. */
  77136. convertToUnIndexedMesh(): Mesh;
  77137. /**
  77138. * Inverses facet orientations.
  77139. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  77140. * @param flipNormals will also inverts the normals
  77141. * @returns current mesh
  77142. */
  77143. flipFaces(flipNormals?: boolean): Mesh;
  77144. /**
  77145. * Increase the number of facets and hence vertices in a mesh
  77146. * Vertex normals are interpolated from existing vertex normals
  77147. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  77148. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  77149. */
  77150. increaseVertices(numberPerEdge: number): void;
  77151. /**
  77152. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  77153. * This will undo any application of covertToFlatShadedMesh
  77154. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  77155. */
  77156. forceSharedVertices(): void;
  77157. /** @hidden */
  77158. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  77159. /** @hidden */
  77160. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  77161. /**
  77162. * Creates a new InstancedMesh object from the mesh model.
  77163. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  77164. * @param name defines the name of the new instance
  77165. * @returns a new InstancedMesh
  77166. */
  77167. createInstance(name: string): InstancedMesh;
  77168. /**
  77169. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  77170. * After this call, all the mesh instances have the same submeshes than the current mesh.
  77171. * @returns the current mesh
  77172. */
  77173. synchronizeInstances(): Mesh;
  77174. /**
  77175. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  77176. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  77177. * This should be used together with the simplification to avoid disappearing triangles.
  77178. * @param successCallback an optional success callback to be called after the optimization finished.
  77179. * @returns the current mesh
  77180. */
  77181. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  77182. /**
  77183. * Serialize current mesh
  77184. * @param serializationObject defines the object which will receive the serialization data
  77185. */
  77186. serialize(serializationObject: any): void;
  77187. /** @hidden */
  77188. _syncGeometryWithMorphTargetManager(): void;
  77189. /** @hidden */
  77190. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  77191. /**
  77192. * Returns a new Mesh object parsed from the source provided.
  77193. * @param parsedMesh is the source
  77194. * @param scene defines the hosting scene
  77195. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  77196. * @returns a new Mesh
  77197. */
  77198. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  77199. /**
  77200. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  77201. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  77202. * @param name defines the name of the mesh to create
  77203. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  77204. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  77205. * @param closePath creates a seam between the first and the last points of each path of the path array
  77206. * @param offset is taken in account only if the `pathArray` is containing a single path
  77207. * @param scene defines the hosting scene
  77208. * @param updatable defines if the mesh must be flagged as updatable
  77209. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77210. * @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)
  77211. * @returns a new Mesh
  77212. */
  77213. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  77214. /**
  77215. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  77216. * @param name defines the name of the mesh to create
  77217. * @param radius sets the radius size (float) of the polygon (default 0.5)
  77218. * @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
  77219. * @param scene defines the hosting scene
  77220. * @param updatable defines if the mesh must be flagged as updatable
  77221. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77222. * @returns a new Mesh
  77223. */
  77224. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  77225. /**
  77226. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  77227. * @param name defines the name of the mesh to create
  77228. * @param size sets the size (float) of each box side (default 1)
  77229. * @param scene defines the hosting scene
  77230. * @param updatable defines if the mesh must be flagged as updatable
  77231. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77232. * @returns a new Mesh
  77233. */
  77234. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  77235. /**
  77236. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  77237. * @param name defines the name of the mesh to create
  77238. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  77239. * @param diameter sets the diameter size (float) of the sphere (default 1)
  77240. * @param scene defines the hosting scene
  77241. * @param updatable defines if the mesh must be flagged as updatable
  77242. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77243. * @returns a new Mesh
  77244. */
  77245. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77246. /**
  77247. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  77248. * @param name defines the name of the mesh to create
  77249. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  77250. * @param diameter sets the diameter size (float) of the sphere (default 1)
  77251. * @param scene defines the hosting scene
  77252. * @returns a new Mesh
  77253. */
  77254. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  77255. /**
  77256. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  77257. * @param name defines the name of the mesh to create
  77258. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  77259. * @param diameterTop set the top cap diameter (floats, default 1)
  77260. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  77261. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  77262. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  77263. * @param scene defines the hosting scene
  77264. * @param updatable defines if the mesh must be flagged as updatable
  77265. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77266. * @returns a new Mesh
  77267. */
  77268. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  77269. /**
  77270. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  77271. * @param name defines the name of the mesh to create
  77272. * @param diameter sets the diameter size (float) of the torus (default 1)
  77273. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  77274. * @param tessellation sets the number of torus sides (postive integer, default 16)
  77275. * @param scene defines the hosting scene
  77276. * @param updatable defines if the mesh must be flagged as updatable
  77277. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77278. * @returns a new Mesh
  77279. */
  77280. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77281. /**
  77282. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  77283. * @param name defines the name of the mesh to create
  77284. * @param radius sets the global radius size (float) of the torus knot (default 2)
  77285. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  77286. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  77287. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  77288. * @param p the number of windings on X axis (positive integers, default 2)
  77289. * @param q the number of windings on Y axis (positive integers, default 3)
  77290. * @param scene defines the hosting scene
  77291. * @param updatable defines if the mesh must be flagged as updatable
  77292. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77293. * @returns a new Mesh
  77294. */
  77295. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77296. /**
  77297. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  77298. * @param name defines the name of the mesh to create
  77299. * @param points is an array successive Vector3
  77300. * @param scene defines the hosting scene
  77301. * @param updatable defines if the mesh must be flagged as updatable
  77302. * @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).
  77303. * @returns a new Mesh
  77304. */
  77305. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  77306. /**
  77307. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  77308. * @param name defines the name of the mesh to create
  77309. * @param points is an array successive Vector3
  77310. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  77311. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  77312. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  77313. * @param scene defines the hosting scene
  77314. * @param updatable defines if the mesh must be flagged as updatable
  77315. * @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)
  77316. * @returns a new Mesh
  77317. */
  77318. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  77319. /**
  77320. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  77321. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  77322. * 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.
  77323. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  77324. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  77325. * Remember you can only change the shape positions, not their number when updating a polygon.
  77326. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  77327. * @param name defines the name of the mesh to create
  77328. * @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
  77329. * @param scene defines the hosting scene
  77330. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  77331. * @param updatable defines if the mesh must be flagged as updatable
  77332. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77333. * @param earcutInjection can be used to inject your own earcut reference
  77334. * @returns a new Mesh
  77335. */
  77336. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  77337. /**
  77338. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  77339. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  77340. * @param name defines the name of the mesh to create
  77341. * @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
  77342. * @param depth defines the height of extrusion
  77343. * @param scene defines the hosting scene
  77344. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  77345. * @param updatable defines if the mesh must be flagged as updatable
  77346. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77347. * @param earcutInjection can be used to inject your own earcut reference
  77348. * @returns a new Mesh
  77349. */
  77350. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  77351. /**
  77352. * Creates an extruded shape mesh.
  77353. * 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
  77354. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  77355. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  77356. * @param name defines the name of the mesh to create
  77357. * @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
  77358. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  77359. * @param scale is the value to scale the shape
  77360. * @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
  77361. * @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
  77362. * @param scene defines the hosting scene
  77363. * @param updatable defines if the mesh must be flagged as updatable
  77364. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77365. * @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)
  77366. * @returns a new Mesh
  77367. */
  77368. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  77369. /**
  77370. * Creates an custom extruded shape mesh.
  77371. * The custom extrusion is a parametric shape.
  77372. * It has no predefined shape. Its final shape will depend on the input parameters.
  77373. * Please consider using the same method from the MeshBuilder class instead
  77374. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  77375. * @param name defines the name of the mesh to create
  77376. * @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
  77377. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  77378. * @param scaleFunction is a custom Javascript function called on each path point
  77379. * @param rotationFunction is a custom Javascript function called on each path point
  77380. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  77381. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  77382. * @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
  77383. * @param scene defines the hosting scene
  77384. * @param updatable defines if the mesh must be flagged as updatable
  77385. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77386. * @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)
  77387. * @returns a new Mesh
  77388. */
  77389. 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;
  77390. /**
  77391. * Creates lathe mesh.
  77392. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  77393. * Please consider using the same method from the MeshBuilder class instead
  77394. * @param name defines the name of the mesh to create
  77395. * @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
  77396. * @param radius is the radius value of the lathe
  77397. * @param tessellation is the side number of the lathe.
  77398. * @param scene defines the hosting scene
  77399. * @param updatable defines if the mesh must be flagged as updatable
  77400. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77401. * @returns a new Mesh
  77402. */
  77403. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77404. /**
  77405. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  77406. * @param name defines the name of the mesh to create
  77407. * @param size sets the size (float) of both sides of the plane at once (default 1)
  77408. * @param scene defines the hosting scene
  77409. * @param updatable defines if the mesh must be flagged as updatable
  77410. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77411. * @returns a new Mesh
  77412. */
  77413. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77414. /**
  77415. * Creates a ground mesh.
  77416. * Please consider using the same method from the MeshBuilder class instead
  77417. * @param name defines the name of the mesh to create
  77418. * @param width set the width of the ground
  77419. * @param height set the height of the ground
  77420. * @param subdivisions sets the number of subdivisions per side
  77421. * @param scene defines the hosting scene
  77422. * @param updatable defines if the mesh must be flagged as updatable
  77423. * @returns a new Mesh
  77424. */
  77425. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  77426. /**
  77427. * Creates a tiled ground mesh.
  77428. * Please consider using the same method from the MeshBuilder class instead
  77429. * @param name defines the name of the mesh to create
  77430. * @param xmin set the ground minimum X coordinate
  77431. * @param zmin set the ground minimum Y coordinate
  77432. * @param xmax set the ground maximum X coordinate
  77433. * @param zmax set the ground maximum Z coordinate
  77434. * @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
  77435. * @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
  77436. * @param scene defines the hosting scene
  77437. * @param updatable defines if the mesh must be flagged as updatable
  77438. * @returns a new Mesh
  77439. */
  77440. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  77441. w: number;
  77442. h: number;
  77443. }, precision: {
  77444. w: number;
  77445. h: number;
  77446. }, scene: Scene, updatable?: boolean): Mesh;
  77447. /**
  77448. * Creates a ground mesh from a height map.
  77449. * Please consider using the same method from the MeshBuilder class instead
  77450. * @see http://doc.babylonjs.com/babylon101/height_map
  77451. * @param name defines the name of the mesh to create
  77452. * @param url sets the URL of the height map image resource
  77453. * @param width set the ground width size
  77454. * @param height set the ground height size
  77455. * @param subdivisions sets the number of subdivision per side
  77456. * @param minHeight is the minimum altitude on the ground
  77457. * @param maxHeight is the maximum altitude on the ground
  77458. * @param scene defines the hosting scene
  77459. * @param updatable defines if the mesh must be flagged as updatable
  77460. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  77461. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  77462. * @returns a new Mesh
  77463. */
  77464. 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;
  77465. /**
  77466. * Creates a tube mesh.
  77467. * The tube is a parametric shape.
  77468. * It has no predefined shape. Its final shape will depend on the input parameters.
  77469. * Please consider using the same method from the MeshBuilder class instead
  77470. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  77471. * @param name defines the name of the mesh to create
  77472. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  77473. * @param radius sets the tube radius size
  77474. * @param tessellation is the number of sides on the tubular surface
  77475. * @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
  77476. * @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
  77477. * @param scene defines the hosting scene
  77478. * @param updatable defines if the mesh must be flagged as updatable
  77479. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77480. * @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)
  77481. * @returns a new Mesh
  77482. */
  77483. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  77484. (i: number, distance: number): number;
  77485. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  77486. /**
  77487. * Creates a polyhedron mesh.
  77488. * Please consider using the same method from the MeshBuilder class instead.
  77489. * * 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
  77490. * * The parameter `size` (positive float, default 1) sets the polygon size
  77491. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  77492. * * 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`
  77493. * * 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
  77494. * * 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)`)
  77495. * * 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
  77496. * * 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
  77497. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  77498. * * If you create a double-sided mesh, you can choose what parts of 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
  77499. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  77500. * @param name defines the name of the mesh to create
  77501. * @param options defines the options used to create the mesh
  77502. * @param scene defines the hosting scene
  77503. * @returns a new Mesh
  77504. */
  77505. static CreatePolyhedron(name: string, options: {
  77506. type?: number;
  77507. size?: number;
  77508. sizeX?: number;
  77509. sizeY?: number;
  77510. sizeZ?: number;
  77511. custom?: any;
  77512. faceUV?: Vector4[];
  77513. faceColors?: Color4[];
  77514. updatable?: boolean;
  77515. sideOrientation?: number;
  77516. }, scene: Scene): Mesh;
  77517. /**
  77518. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  77519. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  77520. * * 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`)
  77521. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  77522. * * 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
  77523. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  77524. * * If you create a double-sided mesh, you can choose what parts of 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
  77525. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  77526. * @param name defines the name of the mesh
  77527. * @param options defines the options used to create the mesh
  77528. * @param scene defines the hosting scene
  77529. * @returns a new Mesh
  77530. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  77531. */
  77532. static CreateIcoSphere(name: string, options: {
  77533. radius?: number;
  77534. flat?: boolean;
  77535. subdivisions?: number;
  77536. sideOrientation?: number;
  77537. updatable?: boolean;
  77538. }, scene: Scene): Mesh;
  77539. /**
  77540. * Creates a decal mesh.
  77541. * Please consider using the same method from the MeshBuilder class instead.
  77542. * A decal is a mesh usually applied as a model onto the surface of another mesh
  77543. * @param name defines the name of the mesh
  77544. * @param sourceMesh defines the mesh receiving the decal
  77545. * @param position sets the position of the decal in world coordinates
  77546. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  77547. * @param size sets the decal scaling
  77548. * @param angle sets the angle to rotate the decal
  77549. * @returns a new Mesh
  77550. */
  77551. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  77552. /**
  77553. * Prepare internal position array for software CPU skinning
  77554. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  77555. */
  77556. setPositionsForCPUSkinning(): Float32Array;
  77557. /**
  77558. * Prepare internal normal array for software CPU skinning
  77559. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  77560. */
  77561. setNormalsForCPUSkinning(): Float32Array;
  77562. /**
  77563. * Updates the vertex buffer by applying transformation from the bones
  77564. * @param skeleton defines the skeleton to apply to current mesh
  77565. * @returns the current mesh
  77566. */
  77567. applySkeleton(skeleton: Skeleton): Mesh;
  77568. /**
  77569. * 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
  77570. * @param meshes defines the list of meshes to scan
  77571. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  77572. */
  77573. static MinMax(meshes: AbstractMesh[]): {
  77574. min: Vector3;
  77575. max: Vector3;
  77576. };
  77577. /**
  77578. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  77579. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  77580. * @returns a vector3
  77581. */
  77582. static Center(meshesOrMinMaxVector: {
  77583. min: Vector3;
  77584. max: Vector3;
  77585. } | AbstractMesh[]): Vector3;
  77586. /**
  77587. * Merge the array of meshes into a single mesh for performance reasons.
  77588. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  77589. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  77590. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  77591. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  77592. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  77593. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  77594. * @returns a new mesh
  77595. */
  77596. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  77597. /** @hidden */
  77598. addInstance(instance: InstancedMesh): void;
  77599. /** @hidden */
  77600. removeInstance(instance: InstancedMesh): void;
  77601. }
  77602. }
  77603. declare module BABYLON {
  77604. /**
  77605. * Interface used to define Action
  77606. */
  77607. export interface IAction {
  77608. /**
  77609. * Trigger for the action
  77610. */
  77611. trigger: number;
  77612. /** Options of the trigger */
  77613. triggerOptions: any;
  77614. /**
  77615. * Gets the trigger parameters
  77616. * @returns the trigger parameters
  77617. */
  77618. getTriggerParameter(): any;
  77619. /**
  77620. * Internal only - executes current action event
  77621. * @hidden
  77622. */
  77623. _executeCurrent(evt?: ActionEvent): void;
  77624. /**
  77625. * Serialize placeholder for child classes
  77626. * @param parent of child
  77627. * @returns the serialized object
  77628. */
  77629. serialize(parent: any): any;
  77630. /**
  77631. * Internal only
  77632. * @hidden
  77633. */
  77634. _prepare(): void;
  77635. /**
  77636. * Internal only - manager for action
  77637. * @hidden
  77638. */
  77639. _actionManager: AbstractActionManager;
  77640. /**
  77641. * Adds action to chain of actions, may be a DoNothingAction
  77642. * @param action defines the next action to execute
  77643. * @returns The action passed in
  77644. * @see https://www.babylonjs-playground.com/#1T30HR#0
  77645. */
  77646. then(action: IAction): IAction;
  77647. }
  77648. /**
  77649. * The action to be carried out following a trigger
  77650. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  77651. */
  77652. export class Action implements IAction {
  77653. /** the trigger, with or without parameters, for the action */
  77654. triggerOptions: any;
  77655. /**
  77656. * Trigger for the action
  77657. */
  77658. trigger: number;
  77659. /**
  77660. * Internal only - manager for action
  77661. * @hidden
  77662. */
  77663. _actionManager: ActionManager;
  77664. private _nextActiveAction;
  77665. private _child;
  77666. private _condition?;
  77667. private _triggerParameter;
  77668. /**
  77669. * An event triggered prior to action being executed.
  77670. */
  77671. onBeforeExecuteObservable: Observable<Action>;
  77672. /**
  77673. * Creates a new Action
  77674. * @param triggerOptions the trigger, with or without parameters, for the action
  77675. * @param condition an optional determinant of action
  77676. */
  77677. constructor(
  77678. /** the trigger, with or without parameters, for the action */
  77679. triggerOptions: any, condition?: Condition);
  77680. /**
  77681. * Internal only
  77682. * @hidden
  77683. */
  77684. _prepare(): void;
  77685. /**
  77686. * Gets the trigger parameters
  77687. * @returns the trigger parameters
  77688. */
  77689. getTriggerParameter(): any;
  77690. /**
  77691. * Internal only - executes current action event
  77692. * @hidden
  77693. */
  77694. _executeCurrent(evt?: ActionEvent): void;
  77695. /**
  77696. * Execute placeholder for child classes
  77697. * @param evt optional action event
  77698. */
  77699. execute(evt?: ActionEvent): void;
  77700. /**
  77701. * Skips to next active action
  77702. */
  77703. skipToNextActiveAction(): void;
  77704. /**
  77705. * Adds action to chain of actions, may be a DoNothingAction
  77706. * @param action defines the next action to execute
  77707. * @returns The action passed in
  77708. * @see https://www.babylonjs-playground.com/#1T30HR#0
  77709. */
  77710. then(action: Action): Action;
  77711. /**
  77712. * Internal only
  77713. * @hidden
  77714. */
  77715. _getProperty(propertyPath: string): string;
  77716. /**
  77717. * Internal only
  77718. * @hidden
  77719. */
  77720. _getEffectiveTarget(target: any, propertyPath: string): any;
  77721. /**
  77722. * Serialize placeholder for child classes
  77723. * @param parent of child
  77724. * @returns the serialized object
  77725. */
  77726. serialize(parent: any): any;
  77727. /**
  77728. * Internal only called by serialize
  77729. * @hidden
  77730. */
  77731. protected _serialize(serializedAction: any, parent?: any): any;
  77732. /**
  77733. * Internal only
  77734. * @hidden
  77735. */
  77736. static _SerializeValueAsString: (value: any) => string;
  77737. /**
  77738. * Internal only
  77739. * @hidden
  77740. */
  77741. static _GetTargetProperty: (target: Scene | Node) => {
  77742. name: string;
  77743. targetType: string;
  77744. value: string;
  77745. };
  77746. }
  77747. }
  77748. declare module BABYLON {
  77749. /**
  77750. * A Condition applied to an Action
  77751. */
  77752. export class Condition {
  77753. /**
  77754. * Internal only - manager for action
  77755. * @hidden
  77756. */
  77757. _actionManager: ActionManager;
  77758. /**
  77759. * Internal only
  77760. * @hidden
  77761. */
  77762. _evaluationId: number;
  77763. /**
  77764. * Internal only
  77765. * @hidden
  77766. */
  77767. _currentResult: boolean;
  77768. /**
  77769. * Creates a new Condition
  77770. * @param actionManager the manager of the action the condition is applied to
  77771. */
  77772. constructor(actionManager: ActionManager);
  77773. /**
  77774. * Check if the current condition is valid
  77775. * @returns a boolean
  77776. */
  77777. isValid(): boolean;
  77778. /**
  77779. * Internal only
  77780. * @hidden
  77781. */
  77782. _getProperty(propertyPath: string): string;
  77783. /**
  77784. * Internal only
  77785. * @hidden
  77786. */
  77787. _getEffectiveTarget(target: any, propertyPath: string): any;
  77788. /**
  77789. * Serialize placeholder for child classes
  77790. * @returns the serialized object
  77791. */
  77792. serialize(): any;
  77793. /**
  77794. * Internal only
  77795. * @hidden
  77796. */
  77797. protected _serialize(serializedCondition: any): any;
  77798. }
  77799. /**
  77800. * Defines specific conditional operators as extensions of Condition
  77801. */
  77802. export class ValueCondition extends Condition {
  77803. /** path to specify the property of the target the conditional operator uses */
  77804. propertyPath: string;
  77805. /** the value compared by the conditional operator against the current value of the property */
  77806. value: any;
  77807. /** the conditional operator, default ValueCondition.IsEqual */
  77808. operator: number;
  77809. /**
  77810. * Internal only
  77811. * @hidden
  77812. */
  77813. private static _IsEqual;
  77814. /**
  77815. * Internal only
  77816. * @hidden
  77817. */
  77818. private static _IsDifferent;
  77819. /**
  77820. * Internal only
  77821. * @hidden
  77822. */
  77823. private static _IsGreater;
  77824. /**
  77825. * Internal only
  77826. * @hidden
  77827. */
  77828. private static _IsLesser;
  77829. /**
  77830. * returns the number for IsEqual
  77831. */
  77832. static readonly IsEqual: number;
  77833. /**
  77834. * Returns the number for IsDifferent
  77835. */
  77836. static readonly IsDifferent: number;
  77837. /**
  77838. * Returns the number for IsGreater
  77839. */
  77840. static readonly IsGreater: number;
  77841. /**
  77842. * Returns the number for IsLesser
  77843. */
  77844. static readonly IsLesser: number;
  77845. /**
  77846. * Internal only The action manager for the condition
  77847. * @hidden
  77848. */
  77849. _actionManager: ActionManager;
  77850. /**
  77851. * Internal only
  77852. * @hidden
  77853. */
  77854. private _target;
  77855. /**
  77856. * Internal only
  77857. * @hidden
  77858. */
  77859. private _effectiveTarget;
  77860. /**
  77861. * Internal only
  77862. * @hidden
  77863. */
  77864. private _property;
  77865. /**
  77866. * Creates a new ValueCondition
  77867. * @param actionManager manager for the action the condition applies to
  77868. * @param target for the action
  77869. * @param propertyPath path to specify the property of the target the conditional operator uses
  77870. * @param value the value compared by the conditional operator against the current value of the property
  77871. * @param operator the conditional operator, default ValueCondition.IsEqual
  77872. */
  77873. constructor(actionManager: ActionManager, target: any,
  77874. /** path to specify the property of the target the conditional operator uses */
  77875. propertyPath: string,
  77876. /** the value compared by the conditional operator against the current value of the property */
  77877. value: any,
  77878. /** the conditional operator, default ValueCondition.IsEqual */
  77879. operator?: number);
  77880. /**
  77881. * Compares the given value with the property value for the specified conditional operator
  77882. * @returns the result of the comparison
  77883. */
  77884. isValid(): boolean;
  77885. /**
  77886. * Serialize the ValueCondition into a JSON compatible object
  77887. * @returns serialization object
  77888. */
  77889. serialize(): any;
  77890. /**
  77891. * Gets the name of the conditional operator for the ValueCondition
  77892. * @param operator the conditional operator
  77893. * @returns the name
  77894. */
  77895. static GetOperatorName(operator: number): string;
  77896. }
  77897. /**
  77898. * Defines a predicate condition as an extension of Condition
  77899. */
  77900. export class PredicateCondition extends Condition {
  77901. /** defines the predicate function used to validate the condition */
  77902. predicate: () => boolean;
  77903. /**
  77904. * Internal only - manager for action
  77905. * @hidden
  77906. */
  77907. _actionManager: ActionManager;
  77908. /**
  77909. * Creates a new PredicateCondition
  77910. * @param actionManager manager for the action the condition applies to
  77911. * @param predicate defines the predicate function used to validate the condition
  77912. */
  77913. constructor(actionManager: ActionManager,
  77914. /** defines the predicate function used to validate the condition */
  77915. predicate: () => boolean);
  77916. /**
  77917. * @returns the validity of the predicate condition
  77918. */
  77919. isValid(): boolean;
  77920. }
  77921. /**
  77922. * Defines a state condition as an extension of Condition
  77923. */
  77924. export class StateCondition extends Condition {
  77925. /** Value to compare with target state */
  77926. value: string;
  77927. /**
  77928. * Internal only - manager for action
  77929. * @hidden
  77930. */
  77931. _actionManager: ActionManager;
  77932. /**
  77933. * Internal only
  77934. * @hidden
  77935. */
  77936. private _target;
  77937. /**
  77938. * Creates a new StateCondition
  77939. * @param actionManager manager for the action the condition applies to
  77940. * @param target of the condition
  77941. * @param value to compare with target state
  77942. */
  77943. constructor(actionManager: ActionManager, target: any,
  77944. /** Value to compare with target state */
  77945. value: string);
  77946. /**
  77947. * Gets a boolean indicating if the current condition is met
  77948. * @returns the validity of the state
  77949. */
  77950. isValid(): boolean;
  77951. /**
  77952. * Serialize the StateCondition into a JSON compatible object
  77953. * @returns serialization object
  77954. */
  77955. serialize(): any;
  77956. }
  77957. }
  77958. declare module BABYLON {
  77959. /**
  77960. * This defines an action responsible to toggle a boolean once triggered.
  77961. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77962. */
  77963. export class SwitchBooleanAction extends Action {
  77964. /**
  77965. * The path to the boolean property in the target object
  77966. */
  77967. propertyPath: string;
  77968. private _target;
  77969. private _effectiveTarget;
  77970. private _property;
  77971. /**
  77972. * Instantiate the action
  77973. * @param triggerOptions defines the trigger options
  77974. * @param target defines the object containing the boolean
  77975. * @param propertyPath defines the path to the boolean property in the target object
  77976. * @param condition defines the trigger related conditions
  77977. */
  77978. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  77979. /** @hidden */
  77980. _prepare(): void;
  77981. /**
  77982. * Execute the action toggle the boolean value.
  77983. */
  77984. execute(): void;
  77985. /**
  77986. * Serializes the actions and its related information.
  77987. * @param parent defines the object to serialize in
  77988. * @returns the serialized object
  77989. */
  77990. serialize(parent: any): any;
  77991. }
  77992. /**
  77993. * This defines an action responsible to set a the state field of the target
  77994. * to a desired value once triggered.
  77995. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77996. */
  77997. export class SetStateAction extends Action {
  77998. /**
  77999. * The value to store in the state field.
  78000. */
  78001. value: string;
  78002. private _target;
  78003. /**
  78004. * Instantiate the action
  78005. * @param triggerOptions defines the trigger options
  78006. * @param target defines the object containing the state property
  78007. * @param value defines the value to store in the state field
  78008. * @param condition defines the trigger related conditions
  78009. */
  78010. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  78011. /**
  78012. * Execute the action and store the value on the target state property.
  78013. */
  78014. execute(): void;
  78015. /**
  78016. * Serializes the actions and its related information.
  78017. * @param parent defines the object to serialize in
  78018. * @returns the serialized object
  78019. */
  78020. serialize(parent: any): any;
  78021. }
  78022. /**
  78023. * This defines an action responsible to set a property of the target
  78024. * to a desired value once triggered.
  78025. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78026. */
  78027. export class SetValueAction extends Action {
  78028. /**
  78029. * The path of the property to set in the target.
  78030. */
  78031. propertyPath: string;
  78032. /**
  78033. * The value to set in the property
  78034. */
  78035. value: any;
  78036. private _target;
  78037. private _effectiveTarget;
  78038. private _property;
  78039. /**
  78040. * Instantiate the action
  78041. * @param triggerOptions defines the trigger options
  78042. * @param target defines the object containing the property
  78043. * @param propertyPath defines the path of the property to set in the target
  78044. * @param value defines the value to set in the property
  78045. * @param condition defines the trigger related conditions
  78046. */
  78047. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  78048. /** @hidden */
  78049. _prepare(): void;
  78050. /**
  78051. * Execute the action and set the targetted property to the desired value.
  78052. */
  78053. execute(): void;
  78054. /**
  78055. * Serializes the actions and its related information.
  78056. * @param parent defines the object to serialize in
  78057. * @returns the serialized object
  78058. */
  78059. serialize(parent: any): any;
  78060. }
  78061. /**
  78062. * This defines an action responsible to increment the target value
  78063. * to a desired value once triggered.
  78064. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78065. */
  78066. export class IncrementValueAction extends Action {
  78067. /**
  78068. * The path of the property to increment in the target.
  78069. */
  78070. propertyPath: string;
  78071. /**
  78072. * The value we should increment the property by.
  78073. */
  78074. value: any;
  78075. private _target;
  78076. private _effectiveTarget;
  78077. private _property;
  78078. /**
  78079. * Instantiate the action
  78080. * @param triggerOptions defines the trigger options
  78081. * @param target defines the object containing the property
  78082. * @param propertyPath defines the path of the property to increment in the target
  78083. * @param value defines the value value we should increment the property by
  78084. * @param condition defines the trigger related conditions
  78085. */
  78086. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  78087. /** @hidden */
  78088. _prepare(): void;
  78089. /**
  78090. * Execute the action and increment the target of the value amount.
  78091. */
  78092. execute(): void;
  78093. /**
  78094. * Serializes the actions and its related information.
  78095. * @param parent defines the object to serialize in
  78096. * @returns the serialized object
  78097. */
  78098. serialize(parent: any): any;
  78099. }
  78100. /**
  78101. * This defines an action responsible to start an animation once triggered.
  78102. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78103. */
  78104. export class PlayAnimationAction extends Action {
  78105. /**
  78106. * Where the animation should start (animation frame)
  78107. */
  78108. from: number;
  78109. /**
  78110. * Where the animation should stop (animation frame)
  78111. */
  78112. to: number;
  78113. /**
  78114. * Define if the animation should loop or stop after the first play.
  78115. */
  78116. loop?: boolean;
  78117. private _target;
  78118. /**
  78119. * Instantiate the action
  78120. * @param triggerOptions defines the trigger options
  78121. * @param target defines the target animation or animation name
  78122. * @param from defines from where the animation should start (animation frame)
  78123. * @param end defines where the animation should stop (animation frame)
  78124. * @param loop defines if the animation should loop or stop after the first play
  78125. * @param condition defines the trigger related conditions
  78126. */
  78127. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  78128. /** @hidden */
  78129. _prepare(): void;
  78130. /**
  78131. * Execute the action and play the animation.
  78132. */
  78133. execute(): void;
  78134. /**
  78135. * Serializes the actions and its related information.
  78136. * @param parent defines the object to serialize in
  78137. * @returns the serialized object
  78138. */
  78139. serialize(parent: any): any;
  78140. }
  78141. /**
  78142. * This defines an action responsible to stop an animation once triggered.
  78143. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78144. */
  78145. export class StopAnimationAction extends Action {
  78146. private _target;
  78147. /**
  78148. * Instantiate the action
  78149. * @param triggerOptions defines the trigger options
  78150. * @param target defines the target animation or animation name
  78151. * @param condition defines the trigger related conditions
  78152. */
  78153. constructor(triggerOptions: any, target: any, condition?: Condition);
  78154. /** @hidden */
  78155. _prepare(): void;
  78156. /**
  78157. * Execute the action and stop the animation.
  78158. */
  78159. execute(): void;
  78160. /**
  78161. * Serializes the actions and its related information.
  78162. * @param parent defines the object to serialize in
  78163. * @returns the serialized object
  78164. */
  78165. serialize(parent: any): any;
  78166. }
  78167. /**
  78168. * This defines an action responsible that does nothing once triggered.
  78169. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78170. */
  78171. export class DoNothingAction extends Action {
  78172. /**
  78173. * Instantiate the action
  78174. * @param triggerOptions defines the trigger options
  78175. * @param condition defines the trigger related conditions
  78176. */
  78177. constructor(triggerOptions?: any, condition?: Condition);
  78178. /**
  78179. * Execute the action and do nothing.
  78180. */
  78181. execute(): void;
  78182. /**
  78183. * Serializes the actions and its related information.
  78184. * @param parent defines the object to serialize in
  78185. * @returns the serialized object
  78186. */
  78187. serialize(parent: any): any;
  78188. }
  78189. /**
  78190. * This defines an action responsible to trigger several actions once triggered.
  78191. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78192. */
  78193. export class CombineAction extends Action {
  78194. /**
  78195. * The list of aggregated animations to run.
  78196. */
  78197. children: Action[];
  78198. /**
  78199. * Instantiate the action
  78200. * @param triggerOptions defines the trigger options
  78201. * @param children defines the list of aggregated animations to run
  78202. * @param condition defines the trigger related conditions
  78203. */
  78204. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  78205. /** @hidden */
  78206. _prepare(): void;
  78207. /**
  78208. * Execute the action and executes all the aggregated actions.
  78209. */
  78210. execute(evt: ActionEvent): void;
  78211. /**
  78212. * Serializes the actions and its related information.
  78213. * @param parent defines the object to serialize in
  78214. * @returns the serialized object
  78215. */
  78216. serialize(parent: any): any;
  78217. }
  78218. /**
  78219. * This defines an action responsible to run code (external event) once triggered.
  78220. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78221. */
  78222. export class ExecuteCodeAction extends Action {
  78223. /**
  78224. * The callback function to run.
  78225. */
  78226. func: (evt: ActionEvent) => void;
  78227. /**
  78228. * Instantiate the action
  78229. * @param triggerOptions defines the trigger options
  78230. * @param func defines the callback function to run
  78231. * @param condition defines the trigger related conditions
  78232. */
  78233. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  78234. /**
  78235. * Execute the action and run the attached code.
  78236. */
  78237. execute(evt: ActionEvent): void;
  78238. }
  78239. /**
  78240. * This defines an action responsible to set the parent property of the target once triggered.
  78241. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78242. */
  78243. export class SetParentAction extends Action {
  78244. private _parent;
  78245. private _target;
  78246. /**
  78247. * Instantiate the action
  78248. * @param triggerOptions defines the trigger options
  78249. * @param target defines the target containing the parent property
  78250. * @param parent defines from where the animation should start (animation frame)
  78251. * @param condition defines the trigger related conditions
  78252. */
  78253. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  78254. /** @hidden */
  78255. _prepare(): void;
  78256. /**
  78257. * Execute the action and set the parent property.
  78258. */
  78259. execute(): void;
  78260. /**
  78261. * Serializes the actions and its related information.
  78262. * @param parent defines the object to serialize in
  78263. * @returns the serialized object
  78264. */
  78265. serialize(parent: any): any;
  78266. }
  78267. }
  78268. declare module BABYLON {
  78269. /**
  78270. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  78271. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  78272. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78273. */
  78274. export class ActionManager extends AbstractActionManager {
  78275. /**
  78276. * Nothing
  78277. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78278. */
  78279. static readonly NothingTrigger: number;
  78280. /**
  78281. * On pick
  78282. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78283. */
  78284. static readonly OnPickTrigger: number;
  78285. /**
  78286. * On left pick
  78287. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78288. */
  78289. static readonly OnLeftPickTrigger: number;
  78290. /**
  78291. * On right pick
  78292. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78293. */
  78294. static readonly OnRightPickTrigger: number;
  78295. /**
  78296. * On center pick
  78297. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78298. */
  78299. static readonly OnCenterPickTrigger: number;
  78300. /**
  78301. * On pick down
  78302. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78303. */
  78304. static readonly OnPickDownTrigger: number;
  78305. /**
  78306. * On double pick
  78307. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78308. */
  78309. static readonly OnDoublePickTrigger: number;
  78310. /**
  78311. * On pick up
  78312. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78313. */
  78314. static readonly OnPickUpTrigger: number;
  78315. /**
  78316. * On pick out.
  78317. * This trigger will only be raised if you also declared a OnPickDown
  78318. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78319. */
  78320. static readonly OnPickOutTrigger: number;
  78321. /**
  78322. * On long press
  78323. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78324. */
  78325. static readonly OnLongPressTrigger: number;
  78326. /**
  78327. * On pointer over
  78328. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78329. */
  78330. static readonly OnPointerOverTrigger: number;
  78331. /**
  78332. * On pointer out
  78333. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78334. */
  78335. static readonly OnPointerOutTrigger: number;
  78336. /**
  78337. * On every frame
  78338. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78339. */
  78340. static readonly OnEveryFrameTrigger: number;
  78341. /**
  78342. * On intersection enter
  78343. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78344. */
  78345. static readonly OnIntersectionEnterTrigger: number;
  78346. /**
  78347. * On intersection exit
  78348. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78349. */
  78350. static readonly OnIntersectionExitTrigger: number;
  78351. /**
  78352. * On key down
  78353. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78354. */
  78355. static readonly OnKeyDownTrigger: number;
  78356. /**
  78357. * On key up
  78358. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78359. */
  78360. static readonly OnKeyUpTrigger: number;
  78361. private _scene;
  78362. /**
  78363. * Creates a new action manager
  78364. * @param scene defines the hosting scene
  78365. */
  78366. constructor(scene: Scene);
  78367. /**
  78368. * Releases all associated resources
  78369. */
  78370. dispose(): void;
  78371. /**
  78372. * Gets hosting scene
  78373. * @returns the hosting scene
  78374. */
  78375. getScene(): Scene;
  78376. /**
  78377. * Does this action manager handles actions of any of the given triggers
  78378. * @param triggers defines the triggers to be tested
  78379. * @return a boolean indicating whether one (or more) of the triggers is handled
  78380. */
  78381. hasSpecificTriggers(triggers: number[]): boolean;
  78382. /**
  78383. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  78384. * speed.
  78385. * @param triggerA defines the trigger to be tested
  78386. * @param triggerB defines the trigger to be tested
  78387. * @return a boolean indicating whether one (or more) of the triggers is handled
  78388. */
  78389. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  78390. /**
  78391. * Does this action manager handles actions of a given trigger
  78392. * @param trigger defines the trigger to be tested
  78393. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  78394. * @return whether the trigger is handled
  78395. */
  78396. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  78397. /**
  78398. * Does this action manager has pointer triggers
  78399. */
  78400. readonly hasPointerTriggers: boolean;
  78401. /**
  78402. * Does this action manager has pick triggers
  78403. */
  78404. readonly hasPickTriggers: boolean;
  78405. /**
  78406. * Registers an action to this action manager
  78407. * @param action defines the action to be registered
  78408. * @return the action amended (prepared) after registration
  78409. */
  78410. registerAction(action: IAction): Nullable<IAction>;
  78411. /**
  78412. * Unregisters an action to this action manager
  78413. * @param action defines the action to be unregistered
  78414. * @return a boolean indicating whether the action has been unregistered
  78415. */
  78416. unregisterAction(action: IAction): Boolean;
  78417. /**
  78418. * Process a specific trigger
  78419. * @param trigger defines the trigger to process
  78420. * @param evt defines the event details to be processed
  78421. */
  78422. processTrigger(trigger: number, evt?: IActionEvent): void;
  78423. /** @hidden */
  78424. _getEffectiveTarget(target: any, propertyPath: string): any;
  78425. /** @hidden */
  78426. _getProperty(propertyPath: string): string;
  78427. /**
  78428. * Serialize this manager to a JSON object
  78429. * @param name defines the property name to store this manager
  78430. * @returns a JSON representation of this manager
  78431. */
  78432. serialize(name: string): any;
  78433. /**
  78434. * Creates a new ActionManager from a JSON data
  78435. * @param parsedActions defines the JSON data to read from
  78436. * @param object defines the hosting mesh
  78437. * @param scene defines the hosting scene
  78438. */
  78439. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  78440. /**
  78441. * Get a trigger name by index
  78442. * @param trigger defines the trigger index
  78443. * @returns a trigger name
  78444. */
  78445. static GetTriggerName(trigger: number): string;
  78446. }
  78447. }
  78448. declare module BABYLON {
  78449. /**
  78450. * Class representing a ray with position and direction
  78451. */
  78452. export class Ray {
  78453. /** origin point */
  78454. origin: Vector3;
  78455. /** direction */
  78456. direction: Vector3;
  78457. /** length of the ray */
  78458. length: number;
  78459. private static readonly TmpVector3;
  78460. private _tmpRay;
  78461. /**
  78462. * Creates a new ray
  78463. * @param origin origin point
  78464. * @param direction direction
  78465. * @param length length of the ray
  78466. */
  78467. constructor(
  78468. /** origin point */
  78469. origin: Vector3,
  78470. /** direction */
  78471. direction: Vector3,
  78472. /** length of the ray */
  78473. length?: number);
  78474. /**
  78475. * Checks if the ray intersects a box
  78476. * @param minimum bound of the box
  78477. * @param maximum bound of the box
  78478. * @param intersectionTreshold extra extend to be added to the box in all direction
  78479. * @returns if the box was hit
  78480. */
  78481. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  78482. /**
  78483. * Checks if the ray intersects a box
  78484. * @param box the bounding box to check
  78485. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  78486. * @returns if the box was hit
  78487. */
  78488. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  78489. /**
  78490. * If the ray hits a sphere
  78491. * @param sphere the bounding sphere to check
  78492. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  78493. * @returns true if it hits the sphere
  78494. */
  78495. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  78496. /**
  78497. * If the ray hits a triange
  78498. * @param vertex0 triangle vertex
  78499. * @param vertex1 triangle vertex
  78500. * @param vertex2 triangle vertex
  78501. * @returns intersection information if hit
  78502. */
  78503. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  78504. /**
  78505. * Checks if ray intersects a plane
  78506. * @param plane the plane to check
  78507. * @returns the distance away it was hit
  78508. */
  78509. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  78510. /**
  78511. * Checks if ray intersects a mesh
  78512. * @param mesh the mesh to check
  78513. * @param fastCheck if only the bounding box should checked
  78514. * @returns picking info of the intersecton
  78515. */
  78516. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  78517. /**
  78518. * Checks if ray intersects a mesh
  78519. * @param meshes the meshes to check
  78520. * @param fastCheck if only the bounding box should checked
  78521. * @param results array to store result in
  78522. * @returns Array of picking infos
  78523. */
  78524. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  78525. private _comparePickingInfo;
  78526. private static smallnum;
  78527. private static rayl;
  78528. /**
  78529. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  78530. * @param sega the first point of the segment to test the intersection against
  78531. * @param segb the second point of the segment to test the intersection against
  78532. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  78533. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  78534. */
  78535. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  78536. /**
  78537. * Update the ray from viewport position
  78538. * @param x position
  78539. * @param y y position
  78540. * @param viewportWidth viewport width
  78541. * @param viewportHeight viewport height
  78542. * @param world world matrix
  78543. * @param view view matrix
  78544. * @param projection projection matrix
  78545. * @returns this ray updated
  78546. */
  78547. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  78548. /**
  78549. * Creates a ray with origin and direction of 0,0,0
  78550. * @returns the new ray
  78551. */
  78552. static Zero(): Ray;
  78553. /**
  78554. * Creates a new ray from screen space and viewport
  78555. * @param x position
  78556. * @param y y position
  78557. * @param viewportWidth viewport width
  78558. * @param viewportHeight viewport height
  78559. * @param world world matrix
  78560. * @param view view matrix
  78561. * @param projection projection matrix
  78562. * @returns new ray
  78563. */
  78564. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  78565. /**
  78566. * 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
  78567. * transformed to the given world matrix.
  78568. * @param origin The origin point
  78569. * @param end The end point
  78570. * @param world a matrix to transform the ray to. Default is the identity matrix.
  78571. * @returns the new ray
  78572. */
  78573. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  78574. /**
  78575. * Transforms a ray by a matrix
  78576. * @param ray ray to transform
  78577. * @param matrix matrix to apply
  78578. * @returns the resulting new ray
  78579. */
  78580. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  78581. /**
  78582. * Transforms a ray by a matrix
  78583. * @param ray ray to transform
  78584. * @param matrix matrix to apply
  78585. * @param result ray to store result in
  78586. */
  78587. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  78588. /**
  78589. * Unproject a ray from screen space to object space
  78590. * @param sourceX defines the screen space x coordinate to use
  78591. * @param sourceY defines the screen space y coordinate to use
  78592. * @param viewportWidth defines the current width of the viewport
  78593. * @param viewportHeight defines the current height of the viewport
  78594. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  78595. * @param view defines the view matrix to use
  78596. * @param projection defines the projection matrix to use
  78597. */
  78598. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  78599. }
  78600. /**
  78601. * Type used to define predicate used to select faces when a mesh intersection is detected
  78602. */
  78603. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  78604. interface Scene {
  78605. /** @hidden */
  78606. _tempPickingRay: Nullable<Ray>;
  78607. /** @hidden */
  78608. _cachedRayForTransform: Ray;
  78609. /** @hidden */
  78610. _pickWithRayInverseMatrix: Matrix;
  78611. /** @hidden */
  78612. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  78613. /** @hidden */
  78614. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  78615. }
  78616. }
  78617. declare module BABYLON {
  78618. interface Scene {
  78619. /** @hidden */
  78620. _pointerOverSprite: Nullable<Sprite>;
  78621. /** @hidden */
  78622. _pickedDownSprite: Nullable<Sprite>;
  78623. /** @hidden */
  78624. _tempSpritePickingRay: Nullable<Ray>;
  78625. /**
  78626. * All of the sprite managers added to this scene
  78627. * @see http://doc.babylonjs.com/babylon101/sprites
  78628. */
  78629. spriteManagers: Array<ISpriteManager>;
  78630. /**
  78631. * An event triggered when sprites rendering is about to start
  78632. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  78633. */
  78634. onBeforeSpritesRenderingObservable: Observable<Scene>;
  78635. /**
  78636. * An event triggered when sprites rendering is done
  78637. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  78638. */
  78639. onAfterSpritesRenderingObservable: Observable<Scene>;
  78640. /** @hidden */
  78641. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  78642. /** Launch a ray to try to pick a sprite in the scene
  78643. * @param x position on screen
  78644. * @param y position on screen
  78645. * @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
  78646. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  78647. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  78648. * @returns a PickingInfo
  78649. */
  78650. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  78651. /** Use the given ray to pick a sprite in the scene
  78652. * @param ray The ray (in world space) to use to pick meshes
  78653. * @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
  78654. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  78655. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  78656. * @returns a PickingInfo
  78657. */
  78658. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  78659. /**
  78660. * Force the sprite under the pointer
  78661. * @param sprite defines the sprite to use
  78662. */
  78663. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  78664. /**
  78665. * Gets the sprite under the pointer
  78666. * @returns a Sprite or null if no sprite is under the pointer
  78667. */
  78668. getPointerOverSprite(): Nullable<Sprite>;
  78669. }
  78670. /**
  78671. * Defines the sprite scene component responsible to manage sprites
  78672. * in a given scene.
  78673. */
  78674. export class SpriteSceneComponent implements ISceneComponent {
  78675. /**
  78676. * The component name helpfull to identify the component in the list of scene components.
  78677. */
  78678. readonly name: string;
  78679. /**
  78680. * The scene the component belongs to.
  78681. */
  78682. scene: Scene;
  78683. /** @hidden */
  78684. private _spritePredicate;
  78685. /**
  78686. * Creates a new instance of the component for the given scene
  78687. * @param scene Defines the scene to register the component in
  78688. */
  78689. constructor(scene: Scene);
  78690. /**
  78691. * Registers the component in a given scene
  78692. */
  78693. register(): void;
  78694. /**
  78695. * Rebuilds the elements related to this component in case of
  78696. * context lost for instance.
  78697. */
  78698. rebuild(): void;
  78699. /**
  78700. * Disposes the component and the associated ressources.
  78701. */
  78702. dispose(): void;
  78703. private _pickSpriteButKeepRay;
  78704. private _pointerMove;
  78705. private _pointerDown;
  78706. private _pointerUp;
  78707. }
  78708. }
  78709. declare module BABYLON {
  78710. /** @hidden */
  78711. export var fogFragmentDeclaration: {
  78712. name: string;
  78713. shader: string;
  78714. };
  78715. }
  78716. declare module BABYLON {
  78717. /** @hidden */
  78718. export var fogFragment: {
  78719. name: string;
  78720. shader: string;
  78721. };
  78722. }
  78723. declare module BABYLON {
  78724. /** @hidden */
  78725. export var spritesPixelShader: {
  78726. name: string;
  78727. shader: string;
  78728. };
  78729. }
  78730. declare module BABYLON {
  78731. /** @hidden */
  78732. export var fogVertexDeclaration: {
  78733. name: string;
  78734. shader: string;
  78735. };
  78736. }
  78737. declare module BABYLON {
  78738. /** @hidden */
  78739. export var spritesVertexShader: {
  78740. name: string;
  78741. shader: string;
  78742. };
  78743. }
  78744. declare module BABYLON {
  78745. /**
  78746. * Defines the minimum interface to fullfil in order to be a sprite manager.
  78747. */
  78748. export interface ISpriteManager extends IDisposable {
  78749. /**
  78750. * Restricts the camera to viewing objects with the same layerMask.
  78751. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  78752. */
  78753. layerMask: number;
  78754. /**
  78755. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  78756. */
  78757. isPickable: boolean;
  78758. /**
  78759. * Specifies the rendering group id for this mesh (0 by default)
  78760. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  78761. */
  78762. renderingGroupId: number;
  78763. /**
  78764. * Defines the list of sprites managed by the manager.
  78765. */
  78766. sprites: Array<Sprite>;
  78767. /**
  78768. * Tests the intersection of a sprite with a specific ray.
  78769. * @param ray The ray we are sending to test the collision
  78770. * @param camera The camera space we are sending rays in
  78771. * @param predicate A predicate allowing excluding sprites from the list of object to test
  78772. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  78773. * @returns picking info or null.
  78774. */
  78775. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  78776. /**
  78777. * Renders the list of sprites on screen.
  78778. */
  78779. render(): void;
  78780. }
  78781. /**
  78782. * Class used to manage multiple sprites on the same spritesheet
  78783. * @see http://doc.babylonjs.com/babylon101/sprites
  78784. */
  78785. export class SpriteManager implements ISpriteManager {
  78786. /** defines the manager's name */
  78787. name: string;
  78788. /** Gets the list of sprites */
  78789. sprites: Sprite[];
  78790. /** Gets or sets the rendering group id (0 by default) */
  78791. renderingGroupId: number;
  78792. /** Gets or sets camera layer mask */
  78793. layerMask: number;
  78794. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  78795. fogEnabled: boolean;
  78796. /** Gets or sets a boolean indicating if the sprites are pickable */
  78797. isPickable: boolean;
  78798. /** Defines the default width of a cell in the spritesheet */
  78799. cellWidth: number;
  78800. /** Defines the default height of a cell in the spritesheet */
  78801. cellHeight: number;
  78802. /**
  78803. * An event triggered when the manager is disposed.
  78804. */
  78805. onDisposeObservable: Observable<SpriteManager>;
  78806. private _onDisposeObserver;
  78807. /**
  78808. * Callback called when the manager is disposed
  78809. */
  78810. onDispose: () => void;
  78811. private _capacity;
  78812. private _spriteTexture;
  78813. private _epsilon;
  78814. private _scene;
  78815. private _vertexData;
  78816. private _buffer;
  78817. private _vertexBuffers;
  78818. private _indexBuffer;
  78819. private _effectBase;
  78820. private _effectFog;
  78821. /**
  78822. * Gets or sets the spritesheet texture
  78823. */
  78824. texture: Texture;
  78825. /**
  78826. * Creates a new sprite manager
  78827. * @param name defines the manager's name
  78828. * @param imgUrl defines the sprite sheet url
  78829. * @param capacity defines the maximum allowed number of sprites
  78830. * @param cellSize defines the size of a sprite cell
  78831. * @param scene defines the hosting scene
  78832. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  78833. * @param samplingMode defines the smapling mode to use with spritesheet
  78834. */
  78835. constructor(
  78836. /** defines the manager's name */
  78837. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  78838. private _appendSpriteVertex;
  78839. /**
  78840. * Intersects the sprites with a ray
  78841. * @param ray defines the ray to intersect with
  78842. * @param camera defines the current active camera
  78843. * @param predicate defines a predicate used to select candidate sprites
  78844. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  78845. * @returns null if no hit or a PickingInfo
  78846. */
  78847. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  78848. /**
  78849. * Render all child sprites
  78850. */
  78851. render(): void;
  78852. /**
  78853. * Release associated resources
  78854. */
  78855. dispose(): void;
  78856. }
  78857. }
  78858. declare module BABYLON {
  78859. /**
  78860. * Class used to represent a sprite
  78861. * @see http://doc.babylonjs.com/babylon101/sprites
  78862. */
  78863. export class Sprite {
  78864. /** defines the name */
  78865. name: string;
  78866. /** Gets or sets the current world position */
  78867. position: Vector3;
  78868. /** Gets or sets the main color */
  78869. color: Color4;
  78870. /** Gets or sets the width */
  78871. width: number;
  78872. /** Gets or sets the height */
  78873. height: number;
  78874. /** Gets or sets rotation angle */
  78875. angle: number;
  78876. /** Gets or sets the cell index in the sprite sheet */
  78877. cellIndex: number;
  78878. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  78879. invertU: number;
  78880. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  78881. invertV: number;
  78882. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  78883. disposeWhenFinishedAnimating: boolean;
  78884. /** Gets the list of attached animations */
  78885. animations: Animation[];
  78886. /** Gets or sets a boolean indicating if the sprite can be picked */
  78887. isPickable: boolean;
  78888. /**
  78889. * Gets or sets the associated action manager
  78890. */
  78891. actionManager: Nullable<ActionManager>;
  78892. private _animationStarted;
  78893. private _loopAnimation;
  78894. private _fromIndex;
  78895. private _toIndex;
  78896. private _delay;
  78897. private _direction;
  78898. private _manager;
  78899. private _time;
  78900. private _onAnimationEnd;
  78901. /**
  78902. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  78903. */
  78904. isVisible: boolean;
  78905. /**
  78906. * Gets or sets the sprite size
  78907. */
  78908. size: number;
  78909. /**
  78910. * Creates a new Sprite
  78911. * @param name defines the name
  78912. * @param manager defines the manager
  78913. */
  78914. constructor(
  78915. /** defines the name */
  78916. name: string, manager: ISpriteManager);
  78917. /**
  78918. * Starts an animation
  78919. * @param from defines the initial key
  78920. * @param to defines the end key
  78921. * @param loop defines if the animation must loop
  78922. * @param delay defines the start delay (in ms)
  78923. * @param onAnimationEnd defines a callback to call when animation ends
  78924. */
  78925. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  78926. /** Stops current animation (if any) */
  78927. stopAnimation(): void;
  78928. /** @hidden */
  78929. _animate(deltaTime: number): void;
  78930. /** Release associated resources */
  78931. dispose(): void;
  78932. }
  78933. }
  78934. declare module BABYLON {
  78935. /**
  78936. * Information about the result of picking within a scene
  78937. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  78938. */
  78939. export class PickingInfo {
  78940. /** @hidden */
  78941. _pickingUnavailable: boolean;
  78942. /**
  78943. * If the pick collided with an object
  78944. */
  78945. hit: boolean;
  78946. /**
  78947. * Distance away where the pick collided
  78948. */
  78949. distance: number;
  78950. /**
  78951. * The location of pick collision
  78952. */
  78953. pickedPoint: Nullable<Vector3>;
  78954. /**
  78955. * The mesh corresponding the the pick collision
  78956. */
  78957. pickedMesh: Nullable<AbstractMesh>;
  78958. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  78959. bu: number;
  78960. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  78961. bv: number;
  78962. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  78963. faceId: number;
  78964. /** Id of the the submesh that was picked */
  78965. subMeshId: number;
  78966. /** If a sprite was picked, this will be the sprite the pick collided with */
  78967. pickedSprite: Nullable<Sprite>;
  78968. /**
  78969. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  78970. */
  78971. originMesh: Nullable<AbstractMesh>;
  78972. /**
  78973. * The ray that was used to perform the picking.
  78974. */
  78975. ray: Nullable<Ray>;
  78976. /**
  78977. * Gets the normal correspodning to the face the pick collided with
  78978. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  78979. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  78980. * @returns The normal correspodning to the face the pick collided with
  78981. */
  78982. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  78983. /**
  78984. * Gets the texture coordinates of where the pick occured
  78985. * @returns the vector containing the coordnates of the texture
  78986. */
  78987. getTextureCoordinates(): Nullable<Vector2>;
  78988. }
  78989. }
  78990. declare module BABYLON {
  78991. /**
  78992. * Gather the list of pointer event types as constants.
  78993. */
  78994. export class PointerEventTypes {
  78995. /**
  78996. * 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.
  78997. */
  78998. static readonly POINTERDOWN: number;
  78999. /**
  79000. * The pointerup event is fired when a pointer is no longer active.
  79001. */
  79002. static readonly POINTERUP: number;
  79003. /**
  79004. * The pointermove event is fired when a pointer changes coordinates.
  79005. */
  79006. static readonly POINTERMOVE: number;
  79007. /**
  79008. * The pointerwheel event is fired when a mouse wheel has been rotated.
  79009. */
  79010. static readonly POINTERWHEEL: number;
  79011. /**
  79012. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  79013. */
  79014. static readonly POINTERPICK: number;
  79015. /**
  79016. * The pointertap event is fired when a the object has been touched and released without drag.
  79017. */
  79018. static readonly POINTERTAP: number;
  79019. /**
  79020. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  79021. */
  79022. static readonly POINTERDOUBLETAP: number;
  79023. }
  79024. /**
  79025. * Base class of pointer info types.
  79026. */
  79027. export class PointerInfoBase {
  79028. /**
  79029. * Defines the type of event (PointerEventTypes)
  79030. */
  79031. type: number;
  79032. /**
  79033. * Defines the related dom event
  79034. */
  79035. event: PointerEvent | MouseWheelEvent;
  79036. /**
  79037. * Instantiates the base class of pointers info.
  79038. * @param type Defines the type of event (PointerEventTypes)
  79039. * @param event Defines the related dom event
  79040. */
  79041. constructor(
  79042. /**
  79043. * Defines the type of event (PointerEventTypes)
  79044. */
  79045. type: number,
  79046. /**
  79047. * Defines the related dom event
  79048. */
  79049. event: PointerEvent | MouseWheelEvent);
  79050. }
  79051. /**
  79052. * This class is used to store pointer related info for the onPrePointerObservable event.
  79053. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  79054. */
  79055. export class PointerInfoPre extends PointerInfoBase {
  79056. /**
  79057. * Ray from a pointer if availible (eg. 6dof controller)
  79058. */
  79059. ray: Nullable<Ray>;
  79060. /**
  79061. * Defines the local position of the pointer on the canvas.
  79062. */
  79063. localPosition: Vector2;
  79064. /**
  79065. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  79066. */
  79067. skipOnPointerObservable: boolean;
  79068. /**
  79069. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  79070. * @param type Defines the type of event (PointerEventTypes)
  79071. * @param event Defines the related dom event
  79072. * @param localX Defines the local x coordinates of the pointer when the event occured
  79073. * @param localY Defines the local y coordinates of the pointer when the event occured
  79074. */
  79075. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  79076. }
  79077. /**
  79078. * This type contains all the data related to a pointer event in Babylon.js.
  79079. * 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.
  79080. */
  79081. export class PointerInfo extends PointerInfoBase {
  79082. /**
  79083. * Defines the picking info associated to the info (if any)\
  79084. */
  79085. pickInfo: Nullable<PickingInfo>;
  79086. /**
  79087. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  79088. * @param type Defines the type of event (PointerEventTypes)
  79089. * @param event Defines the related dom event
  79090. * @param pickInfo Defines the picking info associated to the info (if any)\
  79091. */
  79092. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  79093. /**
  79094. * Defines the picking info associated to the info (if any)\
  79095. */
  79096. pickInfo: Nullable<PickingInfo>);
  79097. }
  79098. /**
  79099. * Data relating to a touch event on the screen.
  79100. */
  79101. export interface PointerTouch {
  79102. /**
  79103. * X coordinate of touch.
  79104. */
  79105. x: number;
  79106. /**
  79107. * Y coordinate of touch.
  79108. */
  79109. y: number;
  79110. /**
  79111. * Id of touch. Unique for each finger.
  79112. */
  79113. pointerId: number;
  79114. /**
  79115. * Event type passed from DOM.
  79116. */
  79117. type: any;
  79118. }
  79119. }
  79120. declare module BABYLON {
  79121. /**
  79122. * Manage the mouse inputs to control the movement of a free camera.
  79123. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79124. */
  79125. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  79126. /**
  79127. * Define if touch is enabled in the mouse input
  79128. */
  79129. touchEnabled: boolean;
  79130. /**
  79131. * Defines the camera the input is attached to.
  79132. */
  79133. camera: FreeCamera;
  79134. /**
  79135. * Defines the buttons associated with the input to handle camera move.
  79136. */
  79137. buttons: number[];
  79138. /**
  79139. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  79140. */
  79141. angularSensibility: number;
  79142. private _pointerInput;
  79143. private _onMouseMove;
  79144. private _observer;
  79145. private previousPosition;
  79146. /**
  79147. * Observable for when a pointer move event occurs containing the move offset
  79148. */
  79149. onPointerMovedObservable: Observable<{
  79150. offsetX: number;
  79151. offsetY: number;
  79152. }>;
  79153. /**
  79154. * @hidden
  79155. * If the camera should be rotated automatically based on pointer movement
  79156. */
  79157. _allowCameraRotation: boolean;
  79158. /**
  79159. * Manage the mouse inputs to control the movement of a free camera.
  79160. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79161. * @param touchEnabled Defines if touch is enabled or not
  79162. */
  79163. constructor(
  79164. /**
  79165. * Define if touch is enabled in the mouse input
  79166. */
  79167. touchEnabled?: boolean);
  79168. /**
  79169. * Attach the input controls to a specific dom element to get the input from.
  79170. * @param element Defines the element the controls should be listened from
  79171. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79172. */
  79173. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79174. /**
  79175. * Called on JS contextmenu event.
  79176. * Override this method to provide functionality.
  79177. */
  79178. protected onContextMenu(evt: PointerEvent): void;
  79179. /**
  79180. * Detach the current controls from the specified dom element.
  79181. * @param element Defines the element to stop listening the inputs from
  79182. */
  79183. detachControl(element: Nullable<HTMLElement>): void;
  79184. /**
  79185. * Gets the class name of the current intput.
  79186. * @returns the class name
  79187. */
  79188. getClassName(): string;
  79189. /**
  79190. * Get the friendly name associated with the input class.
  79191. * @returns the input friendly name
  79192. */
  79193. getSimpleName(): string;
  79194. }
  79195. }
  79196. declare module BABYLON {
  79197. /**
  79198. * Manage the touch inputs to control the movement of a free camera.
  79199. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79200. */
  79201. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  79202. /**
  79203. * Defines the camera the input is attached to.
  79204. */
  79205. camera: FreeCamera;
  79206. /**
  79207. * Defines the touch sensibility for rotation.
  79208. * The higher the faster.
  79209. */
  79210. touchAngularSensibility: number;
  79211. /**
  79212. * Defines the touch sensibility for move.
  79213. * The higher the faster.
  79214. */
  79215. touchMoveSensibility: number;
  79216. private _offsetX;
  79217. private _offsetY;
  79218. private _pointerPressed;
  79219. private _pointerInput;
  79220. private _observer;
  79221. private _onLostFocus;
  79222. /**
  79223. * Attach the input controls to a specific dom element to get the input from.
  79224. * @param element Defines the element the controls should be listened from
  79225. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79226. */
  79227. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79228. /**
  79229. * Detach the current controls from the specified dom element.
  79230. * @param element Defines the element to stop listening the inputs from
  79231. */
  79232. detachControl(element: Nullable<HTMLElement>): void;
  79233. /**
  79234. * Update the current camera state depending on the inputs that have been used this frame.
  79235. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  79236. */
  79237. checkInputs(): void;
  79238. /**
  79239. * Gets the class name of the current intput.
  79240. * @returns the class name
  79241. */
  79242. getClassName(): string;
  79243. /**
  79244. * Get the friendly name associated with the input class.
  79245. * @returns the input friendly name
  79246. */
  79247. getSimpleName(): string;
  79248. }
  79249. }
  79250. declare module BABYLON {
  79251. /**
  79252. * Default Inputs manager for the FreeCamera.
  79253. * It groups all the default supported inputs for ease of use.
  79254. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79255. */
  79256. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  79257. /**
  79258. * @hidden
  79259. */
  79260. _mouseInput: Nullable<FreeCameraMouseInput>;
  79261. /**
  79262. * Instantiates a new FreeCameraInputsManager.
  79263. * @param camera Defines the camera the inputs belong to
  79264. */
  79265. constructor(camera: FreeCamera);
  79266. /**
  79267. * Add keyboard input support to the input manager.
  79268. * @returns the current input manager
  79269. */
  79270. addKeyboard(): FreeCameraInputsManager;
  79271. /**
  79272. * Add mouse input support to the input manager.
  79273. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  79274. * @returns the current input manager
  79275. */
  79276. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  79277. /**
  79278. * Removes the mouse input support from the manager
  79279. * @returns the current input manager
  79280. */
  79281. removeMouse(): FreeCameraInputsManager;
  79282. /**
  79283. * Add touch input support to the input manager.
  79284. * @returns the current input manager
  79285. */
  79286. addTouch(): FreeCameraInputsManager;
  79287. /**
  79288. * Remove all attached input methods from a camera
  79289. */
  79290. clear(): void;
  79291. }
  79292. }
  79293. declare module BABYLON {
  79294. /**
  79295. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  79296. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  79297. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  79298. */
  79299. export class FreeCamera extends TargetCamera {
  79300. /**
  79301. * Define the collision ellipsoid of the camera.
  79302. * This is helpful to simulate a camera body like the player body around the camera
  79303. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  79304. */
  79305. ellipsoid: Vector3;
  79306. /**
  79307. * Define an offset for the position of the ellipsoid around the camera.
  79308. * This can be helpful to determine the center of the body near the gravity center of the body
  79309. * instead of its head.
  79310. */
  79311. ellipsoidOffset: Vector3;
  79312. /**
  79313. * Enable or disable collisions of the camera with the rest of the scene objects.
  79314. */
  79315. checkCollisions: boolean;
  79316. /**
  79317. * Enable or disable gravity on the camera.
  79318. */
  79319. applyGravity: boolean;
  79320. /**
  79321. * Define the input manager associated to the camera.
  79322. */
  79323. inputs: FreeCameraInputsManager;
  79324. /**
  79325. * Gets the input sensibility for a mouse input. (default is 2000.0)
  79326. * Higher values reduce sensitivity.
  79327. */
  79328. /**
  79329. * Sets the input sensibility for a mouse input. (default is 2000.0)
  79330. * Higher values reduce sensitivity.
  79331. */
  79332. angularSensibility: number;
  79333. /**
  79334. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  79335. */
  79336. keysUp: number[];
  79337. /**
  79338. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  79339. */
  79340. keysDown: number[];
  79341. /**
  79342. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  79343. */
  79344. keysLeft: number[];
  79345. /**
  79346. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  79347. */
  79348. keysRight: number[];
  79349. /**
  79350. * Event raised when the camera collide with a mesh in the scene.
  79351. */
  79352. onCollide: (collidedMesh: AbstractMesh) => void;
  79353. private _collider;
  79354. private _needMoveForGravity;
  79355. private _oldPosition;
  79356. private _diffPosition;
  79357. private _newPosition;
  79358. /** @hidden */
  79359. _localDirection: Vector3;
  79360. /** @hidden */
  79361. _transformedDirection: Vector3;
  79362. /**
  79363. * Instantiates a Free Camera.
  79364. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  79365. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  79366. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  79367. * @param name Define the name of the camera in the scene
  79368. * @param position Define the start position of the camera in the scene
  79369. * @param scene Define the scene the camera belongs to
  79370. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  79371. */
  79372. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  79373. /**
  79374. * Attached controls to the current camera.
  79375. * @param element Defines the element the controls should be listened from
  79376. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79377. */
  79378. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79379. /**
  79380. * Detach the current controls from the camera.
  79381. * The camera will stop reacting to inputs.
  79382. * @param element Defines the element to stop listening the inputs from
  79383. */
  79384. detachControl(element: HTMLElement): void;
  79385. private _collisionMask;
  79386. /**
  79387. * Define a collision mask to limit the list of object the camera can collide with
  79388. */
  79389. collisionMask: number;
  79390. /** @hidden */
  79391. _collideWithWorld(displacement: Vector3): void;
  79392. private _onCollisionPositionChange;
  79393. /** @hidden */
  79394. _checkInputs(): void;
  79395. /** @hidden */
  79396. _decideIfNeedsToMove(): boolean;
  79397. /** @hidden */
  79398. _updatePosition(): void;
  79399. /**
  79400. * Destroy the camera and release the current resources hold by it.
  79401. */
  79402. dispose(): void;
  79403. /**
  79404. * Gets the current object class name.
  79405. * @return the class name
  79406. */
  79407. getClassName(): string;
  79408. }
  79409. }
  79410. declare module BABYLON {
  79411. /**
  79412. * Represents a gamepad control stick position
  79413. */
  79414. export class StickValues {
  79415. /**
  79416. * The x component of the control stick
  79417. */
  79418. x: number;
  79419. /**
  79420. * The y component of the control stick
  79421. */
  79422. y: number;
  79423. /**
  79424. * Initializes the gamepad x and y control stick values
  79425. * @param x The x component of the gamepad control stick value
  79426. * @param y The y component of the gamepad control stick value
  79427. */
  79428. constructor(
  79429. /**
  79430. * The x component of the control stick
  79431. */
  79432. x: number,
  79433. /**
  79434. * The y component of the control stick
  79435. */
  79436. y: number);
  79437. }
  79438. /**
  79439. * An interface which manages callbacks for gamepad button changes
  79440. */
  79441. export interface GamepadButtonChanges {
  79442. /**
  79443. * Called when a gamepad has been changed
  79444. */
  79445. changed: boolean;
  79446. /**
  79447. * Called when a gamepad press event has been triggered
  79448. */
  79449. pressChanged: boolean;
  79450. /**
  79451. * Called when a touch event has been triggered
  79452. */
  79453. touchChanged: boolean;
  79454. /**
  79455. * Called when a value has changed
  79456. */
  79457. valueChanged: boolean;
  79458. }
  79459. /**
  79460. * Represents a gamepad
  79461. */
  79462. export class Gamepad {
  79463. /**
  79464. * The id of the gamepad
  79465. */
  79466. id: string;
  79467. /**
  79468. * The index of the gamepad
  79469. */
  79470. index: number;
  79471. /**
  79472. * The browser gamepad
  79473. */
  79474. browserGamepad: any;
  79475. /**
  79476. * Specifies what type of gamepad this represents
  79477. */
  79478. type: number;
  79479. private _leftStick;
  79480. private _rightStick;
  79481. /** @hidden */
  79482. _isConnected: boolean;
  79483. private _leftStickAxisX;
  79484. private _leftStickAxisY;
  79485. private _rightStickAxisX;
  79486. private _rightStickAxisY;
  79487. /**
  79488. * Triggered when the left control stick has been changed
  79489. */
  79490. private _onleftstickchanged;
  79491. /**
  79492. * Triggered when the right control stick has been changed
  79493. */
  79494. private _onrightstickchanged;
  79495. /**
  79496. * Represents a gamepad controller
  79497. */
  79498. static GAMEPAD: number;
  79499. /**
  79500. * Represents a generic controller
  79501. */
  79502. static GENERIC: number;
  79503. /**
  79504. * Represents an XBox controller
  79505. */
  79506. static XBOX: number;
  79507. /**
  79508. * Represents a pose-enabled controller
  79509. */
  79510. static POSE_ENABLED: number;
  79511. /**
  79512. * Specifies whether the left control stick should be Y-inverted
  79513. */
  79514. protected _invertLeftStickY: boolean;
  79515. /**
  79516. * Specifies if the gamepad has been connected
  79517. */
  79518. readonly isConnected: boolean;
  79519. /**
  79520. * Initializes the gamepad
  79521. * @param id The id of the gamepad
  79522. * @param index The index of the gamepad
  79523. * @param browserGamepad The browser gamepad
  79524. * @param leftStickX The x component of the left joystick
  79525. * @param leftStickY The y component of the left joystick
  79526. * @param rightStickX The x component of the right joystick
  79527. * @param rightStickY The y component of the right joystick
  79528. */
  79529. constructor(
  79530. /**
  79531. * The id of the gamepad
  79532. */
  79533. id: string,
  79534. /**
  79535. * The index of the gamepad
  79536. */
  79537. index: number,
  79538. /**
  79539. * The browser gamepad
  79540. */
  79541. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  79542. /**
  79543. * Callback triggered when the left joystick has changed
  79544. * @param callback
  79545. */
  79546. onleftstickchanged(callback: (values: StickValues) => void): void;
  79547. /**
  79548. * Callback triggered when the right joystick has changed
  79549. * @param callback
  79550. */
  79551. onrightstickchanged(callback: (values: StickValues) => void): void;
  79552. /**
  79553. * Gets the left joystick
  79554. */
  79555. /**
  79556. * Sets the left joystick values
  79557. */
  79558. leftStick: StickValues;
  79559. /**
  79560. * Gets the right joystick
  79561. */
  79562. /**
  79563. * Sets the right joystick value
  79564. */
  79565. rightStick: StickValues;
  79566. /**
  79567. * Updates the gamepad joystick positions
  79568. */
  79569. update(): void;
  79570. /**
  79571. * Disposes the gamepad
  79572. */
  79573. dispose(): void;
  79574. }
  79575. /**
  79576. * Represents a generic gamepad
  79577. */
  79578. export class GenericPad extends Gamepad {
  79579. private _buttons;
  79580. private _onbuttondown;
  79581. private _onbuttonup;
  79582. /**
  79583. * Observable triggered when a button has been pressed
  79584. */
  79585. onButtonDownObservable: Observable<number>;
  79586. /**
  79587. * Observable triggered when a button has been released
  79588. */
  79589. onButtonUpObservable: Observable<number>;
  79590. /**
  79591. * Callback triggered when a button has been pressed
  79592. * @param callback Called when a button has been pressed
  79593. */
  79594. onbuttondown(callback: (buttonPressed: number) => void): void;
  79595. /**
  79596. * Callback triggered when a button has been released
  79597. * @param callback Called when a button has been released
  79598. */
  79599. onbuttonup(callback: (buttonReleased: number) => void): void;
  79600. /**
  79601. * Initializes the generic gamepad
  79602. * @param id The id of the generic gamepad
  79603. * @param index The index of the generic gamepad
  79604. * @param browserGamepad The browser gamepad
  79605. */
  79606. constructor(id: string, index: number, browserGamepad: any);
  79607. private _setButtonValue;
  79608. /**
  79609. * Updates the generic gamepad
  79610. */
  79611. update(): void;
  79612. /**
  79613. * Disposes the generic gamepad
  79614. */
  79615. dispose(): void;
  79616. }
  79617. }
  79618. declare module BABYLON {
  79619. /**
  79620. * Defines the types of pose enabled controllers that are supported
  79621. */
  79622. export enum PoseEnabledControllerType {
  79623. /**
  79624. * HTC Vive
  79625. */
  79626. VIVE = 0,
  79627. /**
  79628. * Oculus Rift
  79629. */
  79630. OCULUS = 1,
  79631. /**
  79632. * Windows mixed reality
  79633. */
  79634. WINDOWS = 2,
  79635. /**
  79636. * Samsung gear VR
  79637. */
  79638. GEAR_VR = 3,
  79639. /**
  79640. * Google Daydream
  79641. */
  79642. DAYDREAM = 4,
  79643. /**
  79644. * Generic
  79645. */
  79646. GENERIC = 5
  79647. }
  79648. /**
  79649. * Defines the MutableGamepadButton interface for the state of a gamepad button
  79650. */
  79651. export interface MutableGamepadButton {
  79652. /**
  79653. * Value of the button/trigger
  79654. */
  79655. value: number;
  79656. /**
  79657. * If the button/trigger is currently touched
  79658. */
  79659. touched: boolean;
  79660. /**
  79661. * If the button/trigger is currently pressed
  79662. */
  79663. pressed: boolean;
  79664. }
  79665. /**
  79666. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  79667. * @hidden
  79668. */
  79669. export interface ExtendedGamepadButton extends GamepadButton {
  79670. /**
  79671. * If the button/trigger is currently pressed
  79672. */
  79673. readonly pressed: boolean;
  79674. /**
  79675. * If the button/trigger is currently touched
  79676. */
  79677. readonly touched: boolean;
  79678. /**
  79679. * Value of the button/trigger
  79680. */
  79681. readonly value: number;
  79682. }
  79683. /** @hidden */
  79684. export interface _GamePadFactory {
  79685. /**
  79686. * Returns wether or not the current gamepad can be created for this type of controller.
  79687. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  79688. * @returns true if it can be created, otherwise false
  79689. */
  79690. canCreate(gamepadInfo: any): boolean;
  79691. /**
  79692. * Creates a new instance of the Gamepad.
  79693. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  79694. * @returns the new gamepad instance
  79695. */
  79696. create(gamepadInfo: any): Gamepad;
  79697. }
  79698. /**
  79699. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  79700. */
  79701. export class PoseEnabledControllerHelper {
  79702. /** @hidden */
  79703. static _ControllerFactories: _GamePadFactory[];
  79704. /** @hidden */
  79705. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  79706. /**
  79707. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  79708. * @param vrGamepad the gamepad to initialized
  79709. * @returns a vr controller of the type the gamepad identified as
  79710. */
  79711. static InitiateController(vrGamepad: any): Gamepad;
  79712. }
  79713. /**
  79714. * Defines the PoseEnabledController object that contains state of a vr capable controller
  79715. */
  79716. export class PoseEnabledController extends Gamepad implements PoseControlled {
  79717. private _deviceRoomPosition;
  79718. private _deviceRoomRotationQuaternion;
  79719. /**
  79720. * The device position in babylon space
  79721. */
  79722. devicePosition: Vector3;
  79723. /**
  79724. * The device rotation in babylon space
  79725. */
  79726. deviceRotationQuaternion: Quaternion;
  79727. /**
  79728. * The scale factor of the device in babylon space
  79729. */
  79730. deviceScaleFactor: number;
  79731. /**
  79732. * (Likely devicePosition should be used instead) The device position in its room space
  79733. */
  79734. position: Vector3;
  79735. /**
  79736. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  79737. */
  79738. rotationQuaternion: Quaternion;
  79739. /**
  79740. * The type of controller (Eg. Windows mixed reality)
  79741. */
  79742. controllerType: PoseEnabledControllerType;
  79743. protected _calculatedPosition: Vector3;
  79744. private _calculatedRotation;
  79745. /**
  79746. * The raw pose from the device
  79747. */
  79748. rawPose: DevicePose;
  79749. private _trackPosition;
  79750. private _maxRotationDistFromHeadset;
  79751. private _draggedRoomRotation;
  79752. /**
  79753. * @hidden
  79754. */
  79755. _disableTrackPosition(fixedPosition: Vector3): void;
  79756. /**
  79757. * Internal, the mesh attached to the controller
  79758. * @hidden
  79759. */
  79760. _mesh: Nullable<AbstractMesh>;
  79761. private _poseControlledCamera;
  79762. private _leftHandSystemQuaternion;
  79763. /**
  79764. * Internal, matrix used to convert room space to babylon space
  79765. * @hidden
  79766. */
  79767. _deviceToWorld: Matrix;
  79768. /**
  79769. * Node to be used when casting a ray from the controller
  79770. * @hidden
  79771. */
  79772. _pointingPoseNode: Nullable<TransformNode>;
  79773. /**
  79774. * Name of the child mesh that can be used to cast a ray from the controller
  79775. */
  79776. static readonly POINTING_POSE: string;
  79777. /**
  79778. * Creates a new PoseEnabledController from a gamepad
  79779. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  79780. */
  79781. constructor(browserGamepad: any);
  79782. private _workingMatrix;
  79783. /**
  79784. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  79785. */
  79786. update(): void;
  79787. /**
  79788. * Updates only the pose device and mesh without doing any button event checking
  79789. */
  79790. protected _updatePoseAndMesh(): void;
  79791. /**
  79792. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  79793. * @param poseData raw pose fromthe device
  79794. */
  79795. updateFromDevice(poseData: DevicePose): void;
  79796. /**
  79797. * @hidden
  79798. */
  79799. _meshAttachedObservable: Observable<AbstractMesh>;
  79800. /**
  79801. * Attaches a mesh to the controller
  79802. * @param mesh the mesh to be attached
  79803. */
  79804. attachToMesh(mesh: AbstractMesh): void;
  79805. /**
  79806. * Attaches the controllers mesh to a camera
  79807. * @param camera the camera the mesh should be attached to
  79808. */
  79809. attachToPoseControlledCamera(camera: TargetCamera): void;
  79810. /**
  79811. * Disposes of the controller
  79812. */
  79813. dispose(): void;
  79814. /**
  79815. * The mesh that is attached to the controller
  79816. */
  79817. readonly mesh: Nullable<AbstractMesh>;
  79818. /**
  79819. * Gets the ray of the controller in the direction the controller is pointing
  79820. * @param length the length the resulting ray should be
  79821. * @returns a ray in the direction the controller is pointing
  79822. */
  79823. getForwardRay(length?: number): Ray;
  79824. }
  79825. }
  79826. declare module BABYLON {
  79827. /**
  79828. * Defines the WebVRController object that represents controllers tracked in 3D space
  79829. */
  79830. export abstract class WebVRController extends PoseEnabledController {
  79831. /**
  79832. * Internal, the default controller model for the controller
  79833. */
  79834. protected _defaultModel: AbstractMesh;
  79835. /**
  79836. * Fired when the trigger state has changed
  79837. */
  79838. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  79839. /**
  79840. * Fired when the main button state has changed
  79841. */
  79842. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  79843. /**
  79844. * Fired when the secondary button state has changed
  79845. */
  79846. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  79847. /**
  79848. * Fired when the pad state has changed
  79849. */
  79850. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  79851. /**
  79852. * Fired when controllers stick values have changed
  79853. */
  79854. onPadValuesChangedObservable: Observable<StickValues>;
  79855. /**
  79856. * Array of button availible on the controller
  79857. */
  79858. protected _buttons: Array<MutableGamepadButton>;
  79859. private _onButtonStateChange;
  79860. /**
  79861. * Fired when a controller button's state has changed
  79862. * @param callback the callback containing the button that was modified
  79863. */
  79864. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  79865. /**
  79866. * X and Y axis corresponding to the controllers joystick
  79867. */
  79868. pad: StickValues;
  79869. /**
  79870. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  79871. */
  79872. hand: string;
  79873. /**
  79874. * The default controller model for the controller
  79875. */
  79876. readonly defaultModel: AbstractMesh;
  79877. /**
  79878. * Creates a new WebVRController from a gamepad
  79879. * @param vrGamepad the gamepad that the WebVRController should be created from
  79880. */
  79881. constructor(vrGamepad: any);
  79882. /**
  79883. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  79884. */
  79885. update(): void;
  79886. /**
  79887. * Function to be called when a button is modified
  79888. */
  79889. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  79890. /**
  79891. * Loads a mesh and attaches it to the controller
  79892. * @param scene the scene the mesh should be added to
  79893. * @param meshLoaded callback for when the mesh has been loaded
  79894. */
  79895. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  79896. private _setButtonValue;
  79897. private _changes;
  79898. private _checkChanges;
  79899. /**
  79900. * Disposes of th webVRCOntroller
  79901. */
  79902. dispose(): void;
  79903. }
  79904. }
  79905. declare module BABYLON {
  79906. /**
  79907. * The HemisphericLight simulates the ambient environment light,
  79908. * so the passed direction is the light reflection direction, not the incoming direction.
  79909. */
  79910. export class HemisphericLight extends Light {
  79911. /**
  79912. * The groundColor is the light in the opposite direction to the one specified during creation.
  79913. * 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.
  79914. */
  79915. groundColor: Color3;
  79916. /**
  79917. * The light reflection direction, not the incoming direction.
  79918. */
  79919. direction: Vector3;
  79920. /**
  79921. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  79922. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  79923. * The HemisphericLight can't cast shadows.
  79924. * Documentation : https://doc.babylonjs.com/babylon101/lights
  79925. * @param name The friendly name of the light
  79926. * @param direction The direction of the light reflection
  79927. * @param scene The scene the light belongs to
  79928. */
  79929. constructor(name: string, direction: Vector3, scene: Scene);
  79930. protected _buildUniformLayout(): void;
  79931. /**
  79932. * Returns the string "HemisphericLight".
  79933. * @return The class name
  79934. */
  79935. getClassName(): string;
  79936. /**
  79937. * Sets the HemisphericLight direction towards the passed target (Vector3).
  79938. * Returns the updated direction.
  79939. * @param target The target the direction should point to
  79940. * @return The computed direction
  79941. */
  79942. setDirectionToTarget(target: Vector3): Vector3;
  79943. /**
  79944. * Returns the shadow generator associated to the light.
  79945. * @returns Always null for hemispheric lights because it does not support shadows.
  79946. */
  79947. getShadowGenerator(): Nullable<IShadowGenerator>;
  79948. /**
  79949. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  79950. * @param effect The effect to update
  79951. * @param lightIndex The index of the light in the effect to update
  79952. * @returns The hemispheric light
  79953. */
  79954. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  79955. /**
  79956. * Computes the world matrix of the node
  79957. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  79958. * @param useWasUpdatedFlag defines a reserved property
  79959. * @returns the world matrix
  79960. */
  79961. computeWorldMatrix(): Matrix;
  79962. /**
  79963. * Returns the integer 3.
  79964. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  79965. */
  79966. getTypeID(): number;
  79967. /**
  79968. * Prepares the list of defines specific to the light type.
  79969. * @param defines the list of defines
  79970. * @param lightIndex defines the index of the light for the effect
  79971. */
  79972. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  79973. }
  79974. }
  79975. declare module BABYLON {
  79976. /** @hidden */
  79977. export var vrMultiviewToSingleviewPixelShader: {
  79978. name: string;
  79979. shader: string;
  79980. };
  79981. }
  79982. declare module BABYLON {
  79983. /**
  79984. * Renders to multiple views with a single draw call
  79985. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  79986. */
  79987. export class MultiviewRenderTarget extends RenderTargetTexture {
  79988. /**
  79989. * Creates a multiview render target
  79990. * @param scene scene used with the render target
  79991. * @param size the size of the render target (used for each view)
  79992. */
  79993. constructor(scene: Scene, size?: number | {
  79994. width: number;
  79995. height: number;
  79996. } | {
  79997. ratio: number;
  79998. });
  79999. /**
  80000. * @hidden
  80001. * @param faceIndex the face index, if its a cube texture
  80002. */
  80003. _bindFrameBuffer(faceIndex?: number): void;
  80004. /**
  80005. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  80006. * @returns the view count
  80007. */
  80008. getViewCount(): number;
  80009. }
  80010. }
  80011. declare module BABYLON {
  80012. interface Engine {
  80013. /**
  80014. * Creates a new multiview render target
  80015. * @param width defines the width of the texture
  80016. * @param height defines the height of the texture
  80017. * @returns the created multiview texture
  80018. */
  80019. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  80020. /**
  80021. * Binds a multiview framebuffer to be drawn to
  80022. * @param multiviewTexture texture to bind
  80023. */
  80024. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  80025. }
  80026. interface Camera {
  80027. /**
  80028. * @hidden
  80029. * 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)
  80030. */
  80031. _useMultiviewToSingleView: boolean;
  80032. /**
  80033. * @hidden
  80034. * 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)
  80035. */
  80036. _multiviewTexture: Nullable<RenderTargetTexture>;
  80037. /**
  80038. * @hidden
  80039. * ensures the multiview texture of the camera exists and has the specified width/height
  80040. * @param width height to set on the multiview texture
  80041. * @param height width to set on the multiview texture
  80042. */
  80043. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  80044. }
  80045. interface Scene {
  80046. /** @hidden */
  80047. _transformMatrixR: Matrix;
  80048. /** @hidden */
  80049. _multiviewSceneUbo: Nullable<UniformBuffer>;
  80050. /** @hidden */
  80051. _createMultiviewUbo(): void;
  80052. /** @hidden */
  80053. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  80054. /** @hidden */
  80055. _renderMultiviewToSingleView(camera: Camera): void;
  80056. }
  80057. }
  80058. declare module BABYLON {
  80059. /**
  80060. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  80061. * This will not be used for webXR as it supports displaying texture arrays directly
  80062. */
  80063. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  80064. /**
  80065. * Initializes a VRMultiviewToSingleview
  80066. * @param name name of the post process
  80067. * @param camera camera to be applied to
  80068. * @param scaleFactor scaling factor to the size of the output texture
  80069. */
  80070. constructor(name: string, camera: Camera, scaleFactor: number);
  80071. }
  80072. }
  80073. declare module BABYLON {
  80074. interface Engine {
  80075. /** @hidden */
  80076. _vrDisplay: any;
  80077. /** @hidden */
  80078. _vrSupported: boolean;
  80079. /** @hidden */
  80080. _oldSize: Size;
  80081. /** @hidden */
  80082. _oldHardwareScaleFactor: number;
  80083. /** @hidden */
  80084. _vrExclusivePointerMode: boolean;
  80085. /** @hidden */
  80086. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  80087. /** @hidden */
  80088. _onVRDisplayPointerRestricted: () => void;
  80089. /** @hidden */
  80090. _onVRDisplayPointerUnrestricted: () => void;
  80091. /** @hidden */
  80092. _onVrDisplayConnect: Nullable<(display: any) => void>;
  80093. /** @hidden */
  80094. _onVrDisplayDisconnect: Nullable<() => void>;
  80095. /** @hidden */
  80096. _onVrDisplayPresentChange: Nullable<() => void>;
  80097. /**
  80098. * Observable signaled when VR display mode changes
  80099. */
  80100. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  80101. /**
  80102. * Observable signaled when VR request present is complete
  80103. */
  80104. onVRRequestPresentComplete: Observable<boolean>;
  80105. /**
  80106. * Observable signaled when VR request present starts
  80107. */
  80108. onVRRequestPresentStart: Observable<Engine>;
  80109. /**
  80110. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  80111. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  80112. */
  80113. isInVRExclusivePointerMode: boolean;
  80114. /**
  80115. * Gets a boolean indicating if a webVR device was detected
  80116. * @returns true if a webVR device was detected
  80117. */
  80118. isVRDevicePresent(): boolean;
  80119. /**
  80120. * Gets the current webVR device
  80121. * @returns the current webVR device (or null)
  80122. */
  80123. getVRDevice(): any;
  80124. /**
  80125. * Initializes a webVR display and starts listening to display change events
  80126. * The onVRDisplayChangedObservable will be notified upon these changes
  80127. * @returns A promise containing a VRDisplay and if vr is supported
  80128. */
  80129. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  80130. /** @hidden */
  80131. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  80132. /**
  80133. * Call this function to switch to webVR mode
  80134. * Will do nothing if webVR is not supported or if there is no webVR device
  80135. * @see http://doc.babylonjs.com/how_to/webvr_camera
  80136. */
  80137. enableVR(): void;
  80138. /** @hidden */
  80139. _onVRFullScreenTriggered(): void;
  80140. }
  80141. }
  80142. declare module BABYLON {
  80143. /**
  80144. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  80145. * IMPORTANT!! The data is right-hand data.
  80146. * @export
  80147. * @interface DevicePose
  80148. */
  80149. export interface DevicePose {
  80150. /**
  80151. * The position of the device, values in array are [x,y,z].
  80152. */
  80153. readonly position: Nullable<Float32Array>;
  80154. /**
  80155. * The linearVelocity of the device, values in array are [x,y,z].
  80156. */
  80157. readonly linearVelocity: Nullable<Float32Array>;
  80158. /**
  80159. * The linearAcceleration of the device, values in array are [x,y,z].
  80160. */
  80161. readonly linearAcceleration: Nullable<Float32Array>;
  80162. /**
  80163. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  80164. */
  80165. readonly orientation: Nullable<Float32Array>;
  80166. /**
  80167. * The angularVelocity of the device, values in array are [x,y,z].
  80168. */
  80169. readonly angularVelocity: Nullable<Float32Array>;
  80170. /**
  80171. * The angularAcceleration of the device, values in array are [x,y,z].
  80172. */
  80173. readonly angularAcceleration: Nullable<Float32Array>;
  80174. }
  80175. /**
  80176. * Interface representing a pose controlled object in Babylon.
  80177. * A pose controlled object has both regular pose values as well as pose values
  80178. * from an external device such as a VR head mounted display
  80179. */
  80180. export interface PoseControlled {
  80181. /**
  80182. * The position of the object in babylon space.
  80183. */
  80184. position: Vector3;
  80185. /**
  80186. * The rotation quaternion of the object in babylon space.
  80187. */
  80188. rotationQuaternion: Quaternion;
  80189. /**
  80190. * The position of the device in babylon space.
  80191. */
  80192. devicePosition?: Vector3;
  80193. /**
  80194. * The rotation quaternion of the device in babylon space.
  80195. */
  80196. deviceRotationQuaternion: Quaternion;
  80197. /**
  80198. * The raw pose coming from the device.
  80199. */
  80200. rawPose: Nullable<DevicePose>;
  80201. /**
  80202. * The scale of the device to be used when translating from device space to babylon space.
  80203. */
  80204. deviceScaleFactor: number;
  80205. /**
  80206. * Updates the poseControlled values based on the input device pose.
  80207. * @param poseData the pose data to update the object with
  80208. */
  80209. updateFromDevice(poseData: DevicePose): void;
  80210. }
  80211. /**
  80212. * Set of options to customize the webVRCamera
  80213. */
  80214. export interface WebVROptions {
  80215. /**
  80216. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  80217. */
  80218. trackPosition?: boolean;
  80219. /**
  80220. * Sets the scale of the vrDevice in babylon space. (default: 1)
  80221. */
  80222. positionScale?: number;
  80223. /**
  80224. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  80225. */
  80226. displayName?: string;
  80227. /**
  80228. * Should the native controller meshes be initialized. (default: true)
  80229. */
  80230. controllerMeshes?: boolean;
  80231. /**
  80232. * Creating a default HemiLight only on controllers. (default: true)
  80233. */
  80234. defaultLightingOnControllers?: boolean;
  80235. /**
  80236. * If you don't want to use the default VR button of the helper. (default: false)
  80237. */
  80238. useCustomVRButton?: boolean;
  80239. /**
  80240. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  80241. */
  80242. customVRButton?: HTMLButtonElement;
  80243. /**
  80244. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  80245. */
  80246. rayLength?: number;
  80247. /**
  80248. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  80249. */
  80250. defaultHeight?: number;
  80251. /**
  80252. * If multiview should be used if availible (default: false)
  80253. */
  80254. useMultiview?: boolean;
  80255. }
  80256. /**
  80257. * This represents a WebVR camera.
  80258. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  80259. * @example http://doc.babylonjs.com/how_to/webvr_camera
  80260. */
  80261. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  80262. private webVROptions;
  80263. /**
  80264. * @hidden
  80265. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  80266. */
  80267. _vrDevice: any;
  80268. /**
  80269. * The rawPose of the vrDevice.
  80270. */
  80271. rawPose: Nullable<DevicePose>;
  80272. private _onVREnabled;
  80273. private _specsVersion;
  80274. private _attached;
  80275. private _frameData;
  80276. protected _descendants: Array<Node>;
  80277. private _deviceRoomPosition;
  80278. /** @hidden */
  80279. _deviceRoomRotationQuaternion: Quaternion;
  80280. private _standingMatrix;
  80281. /**
  80282. * Represents device position in babylon space.
  80283. */
  80284. devicePosition: Vector3;
  80285. /**
  80286. * Represents device rotation in babylon space.
  80287. */
  80288. deviceRotationQuaternion: Quaternion;
  80289. /**
  80290. * The scale of the device to be used when translating from device space to babylon space.
  80291. */
  80292. deviceScaleFactor: number;
  80293. private _deviceToWorld;
  80294. private _worldToDevice;
  80295. /**
  80296. * References to the webVR controllers for the vrDevice.
  80297. */
  80298. controllers: Array<WebVRController>;
  80299. /**
  80300. * Emits an event when a controller is attached.
  80301. */
  80302. onControllersAttachedObservable: Observable<WebVRController[]>;
  80303. /**
  80304. * Emits an event when a controller's mesh has been loaded;
  80305. */
  80306. onControllerMeshLoadedObservable: Observable<WebVRController>;
  80307. /**
  80308. * Emits an event when the HMD's pose has been updated.
  80309. */
  80310. onPoseUpdatedFromDeviceObservable: Observable<any>;
  80311. private _poseSet;
  80312. /**
  80313. * If the rig cameras be used as parent instead of this camera.
  80314. */
  80315. rigParenting: boolean;
  80316. private _lightOnControllers;
  80317. private _defaultHeight?;
  80318. /**
  80319. * Instantiates a WebVRFreeCamera.
  80320. * @param name The name of the WebVRFreeCamera
  80321. * @param position The starting anchor position for the camera
  80322. * @param scene The scene the camera belongs to
  80323. * @param webVROptions a set of customizable options for the webVRCamera
  80324. */
  80325. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  80326. /**
  80327. * Gets the device distance from the ground in meters.
  80328. * @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.
  80329. */
  80330. deviceDistanceToRoomGround(): number;
  80331. /**
  80332. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  80333. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  80334. */
  80335. useStandingMatrix(callback?: (bool: boolean) => void): void;
  80336. /**
  80337. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  80338. * @returns A promise with a boolean set to if the standing matrix is supported.
  80339. */
  80340. useStandingMatrixAsync(): Promise<boolean>;
  80341. /**
  80342. * Disposes the camera
  80343. */
  80344. dispose(): void;
  80345. /**
  80346. * Gets a vrController by name.
  80347. * @param name The name of the controller to retreive
  80348. * @returns the controller matching the name specified or null if not found
  80349. */
  80350. getControllerByName(name: string): Nullable<WebVRController>;
  80351. private _leftController;
  80352. /**
  80353. * The controller corresponding to the users left hand.
  80354. */
  80355. readonly leftController: Nullable<WebVRController>;
  80356. private _rightController;
  80357. /**
  80358. * The controller corresponding to the users right hand.
  80359. */
  80360. readonly rightController: Nullable<WebVRController>;
  80361. /**
  80362. * Casts a ray forward from the vrCamera's gaze.
  80363. * @param length Length of the ray (default: 100)
  80364. * @returns the ray corresponding to the gaze
  80365. */
  80366. getForwardRay(length?: number): Ray;
  80367. /**
  80368. * @hidden
  80369. * Updates the camera based on device's frame data
  80370. */
  80371. _checkInputs(): void;
  80372. /**
  80373. * Updates the poseControlled values based on the input device pose.
  80374. * @param poseData Pose coming from the device
  80375. */
  80376. updateFromDevice(poseData: DevicePose): void;
  80377. private _htmlElementAttached;
  80378. private _detachIfAttached;
  80379. /**
  80380. * WebVR's attach control will start broadcasting frames to the device.
  80381. * Note that in certain browsers (chrome for example) this function must be called
  80382. * within a user-interaction callback. Example:
  80383. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  80384. *
  80385. * @param element html element to attach the vrDevice to
  80386. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  80387. */
  80388. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  80389. /**
  80390. * Detaches the camera from the html element and disables VR
  80391. *
  80392. * @param element html element to detach from
  80393. */
  80394. detachControl(element: HTMLElement): void;
  80395. /**
  80396. * @returns the name of this class
  80397. */
  80398. getClassName(): string;
  80399. /**
  80400. * Calls resetPose on the vrDisplay
  80401. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  80402. */
  80403. resetToCurrentRotation(): void;
  80404. /**
  80405. * @hidden
  80406. * Updates the rig cameras (left and right eye)
  80407. */
  80408. _updateRigCameras(): void;
  80409. private _workingVector;
  80410. private _oneVector;
  80411. private _workingMatrix;
  80412. private updateCacheCalled;
  80413. private _correctPositionIfNotTrackPosition;
  80414. /**
  80415. * @hidden
  80416. * Updates the cached values of the camera
  80417. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  80418. */
  80419. _updateCache(ignoreParentClass?: boolean): void;
  80420. /**
  80421. * @hidden
  80422. * Get current device position in babylon world
  80423. */
  80424. _computeDevicePosition(): void;
  80425. /**
  80426. * Updates the current device position and rotation in the babylon world
  80427. */
  80428. update(): void;
  80429. /**
  80430. * @hidden
  80431. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  80432. * @returns an identity matrix
  80433. */
  80434. _getViewMatrix(): Matrix;
  80435. private _tmpMatrix;
  80436. /**
  80437. * This function is called by the two RIG cameras.
  80438. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  80439. * @hidden
  80440. */
  80441. _getWebVRViewMatrix(): Matrix;
  80442. /** @hidden */
  80443. _getWebVRProjectionMatrix(): Matrix;
  80444. private _onGamepadConnectedObserver;
  80445. private _onGamepadDisconnectedObserver;
  80446. private _updateCacheWhenTrackingDisabledObserver;
  80447. /**
  80448. * Initializes the controllers and their meshes
  80449. */
  80450. initControllers(): void;
  80451. }
  80452. }
  80453. declare module BABYLON {
  80454. /**
  80455. * Size options for a post process
  80456. */
  80457. export type PostProcessOptions = {
  80458. width: number;
  80459. height: number;
  80460. };
  80461. /**
  80462. * PostProcess can be used to apply a shader to a texture after it has been rendered
  80463. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  80464. */
  80465. export class PostProcess {
  80466. /** Name of the PostProcess. */
  80467. name: string;
  80468. /**
  80469. * Gets or sets the unique id of the post process
  80470. */
  80471. uniqueId: number;
  80472. /**
  80473. * Width of the texture to apply the post process on
  80474. */
  80475. width: number;
  80476. /**
  80477. * Height of the texture to apply the post process on
  80478. */
  80479. height: number;
  80480. /**
  80481. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  80482. * @hidden
  80483. */
  80484. _outputTexture: Nullable<InternalTexture>;
  80485. /**
  80486. * Sampling mode used by the shader
  80487. * See https://doc.babylonjs.com/classes/3.1/texture
  80488. */
  80489. renderTargetSamplingMode: number;
  80490. /**
  80491. * Clear color to use when screen clearing
  80492. */
  80493. clearColor: Color4;
  80494. /**
  80495. * If the buffer needs to be cleared before applying the post process. (default: true)
  80496. * Should be set to false if shader will overwrite all previous pixels.
  80497. */
  80498. autoClear: boolean;
  80499. /**
  80500. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  80501. */
  80502. alphaMode: number;
  80503. /**
  80504. * Sets the setAlphaBlendConstants of the babylon engine
  80505. */
  80506. alphaConstants: Color4;
  80507. /**
  80508. * Animations to be used for the post processing
  80509. */
  80510. animations: Animation[];
  80511. /**
  80512. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  80513. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  80514. */
  80515. enablePixelPerfectMode: boolean;
  80516. /**
  80517. * Force the postprocess to be applied without taking in account viewport
  80518. */
  80519. forceFullscreenViewport: boolean;
  80520. /**
  80521. * List of inspectable custom properties (used by the Inspector)
  80522. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  80523. */
  80524. inspectableCustomProperties: IInspectable[];
  80525. /**
  80526. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  80527. *
  80528. * | Value | Type | Description |
  80529. * | ----- | ----------------------------------- | ----------- |
  80530. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  80531. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  80532. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  80533. *
  80534. */
  80535. scaleMode: number;
  80536. /**
  80537. * Force textures to be a power of two (default: false)
  80538. */
  80539. alwaysForcePOT: boolean;
  80540. private _samples;
  80541. /**
  80542. * Number of sample textures (default: 1)
  80543. */
  80544. samples: number;
  80545. /**
  80546. * Modify the scale of the post process to be the same as the viewport (default: false)
  80547. */
  80548. adaptScaleToCurrentViewport: boolean;
  80549. private _camera;
  80550. private _scene;
  80551. private _engine;
  80552. private _options;
  80553. private _reusable;
  80554. private _textureType;
  80555. /**
  80556. * Smart array of input and output textures for the post process.
  80557. * @hidden
  80558. */
  80559. _textures: SmartArray<InternalTexture>;
  80560. /**
  80561. * The index in _textures that corresponds to the output texture.
  80562. * @hidden
  80563. */
  80564. _currentRenderTextureInd: number;
  80565. private _effect;
  80566. private _samplers;
  80567. private _fragmentUrl;
  80568. private _vertexUrl;
  80569. private _parameters;
  80570. private _scaleRatio;
  80571. protected _indexParameters: any;
  80572. private _shareOutputWithPostProcess;
  80573. private _texelSize;
  80574. private _forcedOutputTexture;
  80575. /**
  80576. * Returns the fragment url or shader name used in the post process.
  80577. * @returns the fragment url or name in the shader store.
  80578. */
  80579. getEffectName(): string;
  80580. /**
  80581. * An event triggered when the postprocess is activated.
  80582. */
  80583. onActivateObservable: Observable<Camera>;
  80584. private _onActivateObserver;
  80585. /**
  80586. * A function that is added to the onActivateObservable
  80587. */
  80588. onActivate: Nullable<(camera: Camera) => void>;
  80589. /**
  80590. * An event triggered when the postprocess changes its size.
  80591. */
  80592. onSizeChangedObservable: Observable<PostProcess>;
  80593. private _onSizeChangedObserver;
  80594. /**
  80595. * A function that is added to the onSizeChangedObservable
  80596. */
  80597. onSizeChanged: (postProcess: PostProcess) => void;
  80598. /**
  80599. * An event triggered when the postprocess applies its effect.
  80600. */
  80601. onApplyObservable: Observable<Effect>;
  80602. private _onApplyObserver;
  80603. /**
  80604. * A function that is added to the onApplyObservable
  80605. */
  80606. onApply: (effect: Effect) => void;
  80607. /**
  80608. * An event triggered before rendering the postprocess
  80609. */
  80610. onBeforeRenderObservable: Observable<Effect>;
  80611. private _onBeforeRenderObserver;
  80612. /**
  80613. * A function that is added to the onBeforeRenderObservable
  80614. */
  80615. onBeforeRender: (effect: Effect) => void;
  80616. /**
  80617. * An event triggered after rendering the postprocess
  80618. */
  80619. onAfterRenderObservable: Observable<Effect>;
  80620. private _onAfterRenderObserver;
  80621. /**
  80622. * A function that is added to the onAfterRenderObservable
  80623. */
  80624. onAfterRender: (efect: Effect) => void;
  80625. /**
  80626. * 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
  80627. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  80628. */
  80629. inputTexture: InternalTexture;
  80630. /**
  80631. * Gets the camera which post process is applied to.
  80632. * @returns The camera the post process is applied to.
  80633. */
  80634. getCamera(): Camera;
  80635. /**
  80636. * Gets the texel size of the postprocess.
  80637. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  80638. */
  80639. readonly texelSize: Vector2;
  80640. /**
  80641. * Creates a new instance PostProcess
  80642. * @param name The name of the PostProcess.
  80643. * @param fragmentUrl The url of the fragment shader to be used.
  80644. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  80645. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  80646. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  80647. * @param camera The camera to apply the render pass to.
  80648. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  80649. * @param engine The engine which the post process will be applied. (default: current engine)
  80650. * @param reusable If the post process can be reused on the same frame. (default: false)
  80651. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  80652. * @param textureType Type of textures used when performing the post process. (default: 0)
  80653. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  80654. * @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
  80655. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  80656. */
  80657. constructor(
  80658. /** Name of the PostProcess. */
  80659. 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);
  80660. /**
  80661. * Gets a string idenfifying the name of the class
  80662. * @returns "PostProcess" string
  80663. */
  80664. getClassName(): string;
  80665. /**
  80666. * Gets the engine which this post process belongs to.
  80667. * @returns The engine the post process was enabled with.
  80668. */
  80669. getEngine(): Engine;
  80670. /**
  80671. * The effect that is created when initializing the post process.
  80672. * @returns The created effect corresponding the the postprocess.
  80673. */
  80674. getEffect(): Effect;
  80675. /**
  80676. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  80677. * @param postProcess The post process to share the output with.
  80678. * @returns This post process.
  80679. */
  80680. shareOutputWith(postProcess: PostProcess): PostProcess;
  80681. /**
  80682. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  80683. * This should be called if the post process that shares output with this post process is disabled/disposed.
  80684. */
  80685. useOwnOutput(): void;
  80686. /**
  80687. * Updates the effect with the current post process compile time values and recompiles the shader.
  80688. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  80689. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  80690. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  80691. * @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
  80692. * @param onCompiled Called when the shader has been compiled.
  80693. * @param onError Called if there is an error when compiling a shader.
  80694. */
  80695. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  80696. /**
  80697. * The post process is reusable if it can be used multiple times within one frame.
  80698. * @returns If the post process is reusable
  80699. */
  80700. isReusable(): boolean;
  80701. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  80702. markTextureDirty(): void;
  80703. /**
  80704. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  80705. * 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.
  80706. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  80707. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  80708. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  80709. * @returns The target texture that was bound to be written to.
  80710. */
  80711. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  80712. /**
  80713. * If the post process is supported.
  80714. */
  80715. readonly isSupported: boolean;
  80716. /**
  80717. * The aspect ratio of the output texture.
  80718. */
  80719. readonly aspectRatio: number;
  80720. /**
  80721. * Get a value indicating if the post-process is ready to be used
  80722. * @returns true if the post-process is ready (shader is compiled)
  80723. */
  80724. isReady(): boolean;
  80725. /**
  80726. * Binds all textures and uniforms to the shader, this will be run on every pass.
  80727. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  80728. */
  80729. apply(): Nullable<Effect>;
  80730. private _disposeTextures;
  80731. /**
  80732. * Disposes the post process.
  80733. * @param camera The camera to dispose the post process on.
  80734. */
  80735. dispose(camera?: Camera): void;
  80736. }
  80737. }
  80738. declare module BABYLON {
  80739. /** @hidden */
  80740. export var kernelBlurVaryingDeclaration: {
  80741. name: string;
  80742. shader: string;
  80743. };
  80744. }
  80745. declare module BABYLON {
  80746. /** @hidden */
  80747. export var kernelBlurFragment: {
  80748. name: string;
  80749. shader: string;
  80750. };
  80751. }
  80752. declare module BABYLON {
  80753. /** @hidden */
  80754. export var kernelBlurFragment2: {
  80755. name: string;
  80756. shader: string;
  80757. };
  80758. }
  80759. declare module BABYLON {
  80760. /** @hidden */
  80761. export var kernelBlurPixelShader: {
  80762. name: string;
  80763. shader: string;
  80764. };
  80765. }
  80766. declare module BABYLON {
  80767. /** @hidden */
  80768. export var kernelBlurVertex: {
  80769. name: string;
  80770. shader: string;
  80771. };
  80772. }
  80773. declare module BABYLON {
  80774. /** @hidden */
  80775. export var kernelBlurVertexShader: {
  80776. name: string;
  80777. shader: string;
  80778. };
  80779. }
  80780. declare module BABYLON {
  80781. /**
  80782. * The Blur Post Process which blurs an image based on a kernel and direction.
  80783. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  80784. */
  80785. export class BlurPostProcess extends PostProcess {
  80786. /** The direction in which to blur the image. */
  80787. direction: Vector2;
  80788. private blockCompilation;
  80789. protected _kernel: number;
  80790. protected _idealKernel: number;
  80791. protected _packedFloat: boolean;
  80792. private _staticDefines;
  80793. /**
  80794. * Sets the length in pixels of the blur sample region
  80795. */
  80796. /**
  80797. * Gets the length in pixels of the blur sample region
  80798. */
  80799. kernel: number;
  80800. /**
  80801. * Sets wether or not the blur needs to unpack/repack floats
  80802. */
  80803. /**
  80804. * Gets wether or not the blur is unpacking/repacking floats
  80805. */
  80806. packedFloat: boolean;
  80807. /**
  80808. * Creates a new instance BlurPostProcess
  80809. * @param name The name of the effect.
  80810. * @param direction The direction in which to blur the image.
  80811. * @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.
  80812. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  80813. * @param camera The camera to apply the render pass to.
  80814. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  80815. * @param engine The engine which the post process will be applied. (default: current engine)
  80816. * @param reusable If the post process can be reused on the same frame. (default: false)
  80817. * @param textureType Type of textures used when performing the post process. (default: 0)
  80818. * @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)
  80819. */
  80820. constructor(name: string,
  80821. /** The direction in which to blur the image. */
  80822. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  80823. /**
  80824. * Updates the effect with the current post process compile time values and recompiles the shader.
  80825. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  80826. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  80827. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  80828. * @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
  80829. * @param onCompiled Called when the shader has been compiled.
  80830. * @param onError Called if there is an error when compiling a shader.
  80831. */
  80832. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  80833. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  80834. /**
  80835. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  80836. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  80837. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  80838. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  80839. * The gaps between physical kernels are compensated for in the weighting of the samples
  80840. * @param idealKernel Ideal blur kernel.
  80841. * @return Nearest best kernel.
  80842. */
  80843. protected _nearestBestKernel(idealKernel: number): number;
  80844. /**
  80845. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  80846. * @param x The point on the Gaussian distribution to sample.
  80847. * @return the value of the Gaussian function at x.
  80848. */
  80849. protected _gaussianWeight(x: number): number;
  80850. /**
  80851. * Generates a string that can be used as a floating point number in GLSL.
  80852. * @param x Value to print.
  80853. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  80854. * @return GLSL float string.
  80855. */
  80856. protected _glslFloat(x: number, decimalFigures?: number): string;
  80857. }
  80858. }
  80859. declare module BABYLON {
  80860. /**
  80861. * Mirror texture can be used to simulate the view from a mirror in a scene.
  80862. * It will dynamically be rendered every frame to adapt to the camera point of view.
  80863. * You can then easily use it as a reflectionTexture on a flat surface.
  80864. * In case the surface is not a plane, please consider relying on reflection probes.
  80865. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  80866. */
  80867. export class MirrorTexture extends RenderTargetTexture {
  80868. private scene;
  80869. /**
  80870. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  80871. * 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.
  80872. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  80873. */
  80874. mirrorPlane: Plane;
  80875. /**
  80876. * Define the blur ratio used to blur the reflection if needed.
  80877. */
  80878. blurRatio: number;
  80879. /**
  80880. * Define the adaptive blur kernel used to blur the reflection if needed.
  80881. * This will autocompute the closest best match for the `blurKernel`
  80882. */
  80883. adaptiveBlurKernel: number;
  80884. /**
  80885. * Define the blur kernel used to blur the reflection if needed.
  80886. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  80887. */
  80888. blurKernel: number;
  80889. /**
  80890. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  80891. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  80892. */
  80893. blurKernelX: number;
  80894. /**
  80895. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  80896. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  80897. */
  80898. blurKernelY: number;
  80899. private _autoComputeBlurKernel;
  80900. protected _onRatioRescale(): void;
  80901. private _updateGammaSpace;
  80902. private _imageProcessingConfigChangeObserver;
  80903. private _transformMatrix;
  80904. private _mirrorMatrix;
  80905. private _savedViewMatrix;
  80906. private _blurX;
  80907. private _blurY;
  80908. private _adaptiveBlurKernel;
  80909. private _blurKernelX;
  80910. private _blurKernelY;
  80911. private _blurRatio;
  80912. /**
  80913. * Instantiates a Mirror Texture.
  80914. * Mirror texture can be used to simulate the view from a mirror in a scene.
  80915. * It will dynamically be rendered every frame to adapt to the camera point of view.
  80916. * You can then easily use it as a reflectionTexture on a flat surface.
  80917. * In case the surface is not a plane, please consider relying on reflection probes.
  80918. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  80919. * @param name
  80920. * @param size
  80921. * @param scene
  80922. * @param generateMipMaps
  80923. * @param type
  80924. * @param samplingMode
  80925. * @param generateDepthBuffer
  80926. */
  80927. constructor(name: string, size: number | {
  80928. width: number;
  80929. height: number;
  80930. } | {
  80931. ratio: number;
  80932. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  80933. private _preparePostProcesses;
  80934. /**
  80935. * Clone the mirror texture.
  80936. * @returns the cloned texture
  80937. */
  80938. clone(): MirrorTexture;
  80939. /**
  80940. * Serialize the texture to a JSON representation you could use in Parse later on
  80941. * @returns the serialized JSON representation
  80942. */
  80943. serialize(): any;
  80944. /**
  80945. * Dispose the texture and release its associated resources.
  80946. */
  80947. dispose(): void;
  80948. }
  80949. }
  80950. declare module BABYLON {
  80951. /**
  80952. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  80953. * @see http://doc.babylonjs.com/babylon101/materials#texture
  80954. */
  80955. export class Texture extends BaseTexture {
  80956. /** @hidden */
  80957. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  80958. /** @hidden */
  80959. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  80960. /** @hidden */
  80961. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  80962. /** nearest is mag = nearest and min = nearest and mip = linear */
  80963. static readonly NEAREST_SAMPLINGMODE: number;
  80964. /** nearest is mag = nearest and min = nearest and mip = linear */
  80965. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  80966. /** Bilinear is mag = linear and min = linear and mip = nearest */
  80967. static readonly BILINEAR_SAMPLINGMODE: number;
  80968. /** Bilinear is mag = linear and min = linear and mip = nearest */
  80969. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  80970. /** Trilinear is mag = linear and min = linear and mip = linear */
  80971. static readonly TRILINEAR_SAMPLINGMODE: number;
  80972. /** Trilinear is mag = linear and min = linear and mip = linear */
  80973. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  80974. /** mag = nearest and min = nearest and mip = nearest */
  80975. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  80976. /** mag = nearest and min = linear and mip = nearest */
  80977. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  80978. /** mag = nearest and min = linear and mip = linear */
  80979. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  80980. /** mag = nearest and min = linear and mip = none */
  80981. static readonly NEAREST_LINEAR: number;
  80982. /** mag = nearest and min = nearest and mip = none */
  80983. static readonly NEAREST_NEAREST: number;
  80984. /** mag = linear and min = nearest and mip = nearest */
  80985. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  80986. /** mag = linear and min = nearest and mip = linear */
  80987. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  80988. /** mag = linear and min = linear and mip = none */
  80989. static readonly LINEAR_LINEAR: number;
  80990. /** mag = linear and min = nearest and mip = none */
  80991. static readonly LINEAR_NEAREST: number;
  80992. /** Explicit coordinates mode */
  80993. static readonly EXPLICIT_MODE: number;
  80994. /** Spherical coordinates mode */
  80995. static readonly SPHERICAL_MODE: number;
  80996. /** Planar coordinates mode */
  80997. static readonly PLANAR_MODE: number;
  80998. /** Cubic coordinates mode */
  80999. static readonly CUBIC_MODE: number;
  81000. /** Projection coordinates mode */
  81001. static readonly PROJECTION_MODE: number;
  81002. /** Inverse Cubic coordinates mode */
  81003. static readonly SKYBOX_MODE: number;
  81004. /** Inverse Cubic coordinates mode */
  81005. static readonly INVCUBIC_MODE: number;
  81006. /** Equirectangular coordinates mode */
  81007. static readonly EQUIRECTANGULAR_MODE: number;
  81008. /** Equirectangular Fixed coordinates mode */
  81009. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  81010. /** Equirectangular Fixed Mirrored coordinates mode */
  81011. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  81012. /** Texture is not repeating outside of 0..1 UVs */
  81013. static readonly CLAMP_ADDRESSMODE: number;
  81014. /** Texture is repeating outside of 0..1 UVs */
  81015. static readonly WRAP_ADDRESSMODE: number;
  81016. /** Texture is repeating and mirrored */
  81017. static readonly MIRROR_ADDRESSMODE: number;
  81018. /**
  81019. * 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
  81020. */
  81021. static UseSerializedUrlIfAny: boolean;
  81022. /**
  81023. * Define the url of the texture.
  81024. */
  81025. url: Nullable<string>;
  81026. /**
  81027. * Define an offset on the texture to offset the u coordinates of the UVs
  81028. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  81029. */
  81030. uOffset: number;
  81031. /**
  81032. * Define an offset on the texture to offset the v coordinates of the UVs
  81033. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  81034. */
  81035. vOffset: number;
  81036. /**
  81037. * Define an offset on the texture to scale the u coordinates of the UVs
  81038. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  81039. */
  81040. uScale: number;
  81041. /**
  81042. * Define an offset on the texture to scale the v coordinates of the UVs
  81043. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  81044. */
  81045. vScale: number;
  81046. /**
  81047. * Define an offset on the texture to rotate around the u coordinates of the UVs
  81048. * @see http://doc.babylonjs.com/how_to/more_materials
  81049. */
  81050. uAng: number;
  81051. /**
  81052. * Define an offset on the texture to rotate around the v coordinates of the UVs
  81053. * @see http://doc.babylonjs.com/how_to/more_materials
  81054. */
  81055. vAng: number;
  81056. /**
  81057. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  81058. * @see http://doc.babylonjs.com/how_to/more_materials
  81059. */
  81060. wAng: number;
  81061. /**
  81062. * Defines the center of rotation (U)
  81063. */
  81064. uRotationCenter: number;
  81065. /**
  81066. * Defines the center of rotation (V)
  81067. */
  81068. vRotationCenter: number;
  81069. /**
  81070. * Defines the center of rotation (W)
  81071. */
  81072. wRotationCenter: number;
  81073. /**
  81074. * Are mip maps generated for this texture or not.
  81075. */
  81076. readonly noMipmap: boolean;
  81077. /**
  81078. * List of inspectable custom properties (used by the Inspector)
  81079. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  81080. */
  81081. inspectableCustomProperties: Nullable<IInspectable[]>;
  81082. private _noMipmap;
  81083. /** @hidden */
  81084. _invertY: boolean;
  81085. private _rowGenerationMatrix;
  81086. private _cachedTextureMatrix;
  81087. private _projectionModeMatrix;
  81088. private _t0;
  81089. private _t1;
  81090. private _t2;
  81091. private _cachedUOffset;
  81092. private _cachedVOffset;
  81093. private _cachedUScale;
  81094. private _cachedVScale;
  81095. private _cachedUAng;
  81096. private _cachedVAng;
  81097. private _cachedWAng;
  81098. private _cachedProjectionMatrixId;
  81099. private _cachedCoordinatesMode;
  81100. /** @hidden */
  81101. protected _initialSamplingMode: number;
  81102. /** @hidden */
  81103. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  81104. private _deleteBuffer;
  81105. protected _format: Nullable<number>;
  81106. private _delayedOnLoad;
  81107. private _delayedOnError;
  81108. /**
  81109. * Observable triggered once the texture has been loaded.
  81110. */
  81111. onLoadObservable: Observable<Texture>;
  81112. protected _isBlocking: boolean;
  81113. /**
  81114. * Is the texture preventing material to render while loading.
  81115. * If false, a default texture will be used instead of the loading one during the preparation step.
  81116. */
  81117. isBlocking: boolean;
  81118. /**
  81119. * Get the current sampling mode associated with the texture.
  81120. */
  81121. readonly samplingMode: number;
  81122. /**
  81123. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  81124. */
  81125. readonly invertY: boolean;
  81126. /**
  81127. * Instantiates a new texture.
  81128. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  81129. * @see http://doc.babylonjs.com/babylon101/materials#texture
  81130. * @param url define the url of the picture to load as a texture
  81131. * @param scene define the scene the texture will belong to
  81132. * @param noMipmap define if the texture will require mip maps or not
  81133. * @param invertY define if the texture needs to be inverted on the y axis during loading
  81134. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  81135. * @param onLoad define a callback triggered when the texture has been loaded
  81136. * @param onError define a callback triggered when an error occurred during the loading session
  81137. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  81138. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  81139. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  81140. */
  81141. 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);
  81142. /**
  81143. * Update the url (and optional buffer) of this texture if url was null during construction.
  81144. * @param url the url of the texture
  81145. * @param buffer the buffer of the texture (defaults to null)
  81146. * @param onLoad callback called when the texture is loaded (defaults to null)
  81147. */
  81148. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  81149. /**
  81150. * Finish the loading sequence of a texture flagged as delayed load.
  81151. * @hidden
  81152. */
  81153. delayLoad(): void;
  81154. private _prepareRowForTextureGeneration;
  81155. /**
  81156. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  81157. * @returns the transform matrix of the texture.
  81158. */
  81159. getTextureMatrix(): Matrix;
  81160. /**
  81161. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  81162. * @returns The reflection texture transform
  81163. */
  81164. getReflectionTextureMatrix(): Matrix;
  81165. /**
  81166. * Clones the texture.
  81167. * @returns the cloned texture
  81168. */
  81169. clone(): Texture;
  81170. /**
  81171. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  81172. * @returns The JSON representation of the texture
  81173. */
  81174. serialize(): any;
  81175. /**
  81176. * Get the current class name of the texture useful for serialization or dynamic coding.
  81177. * @returns "Texture"
  81178. */
  81179. getClassName(): string;
  81180. /**
  81181. * Dispose the texture and release its associated resources.
  81182. */
  81183. dispose(): void;
  81184. /**
  81185. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  81186. * @param parsedTexture Define the JSON representation of the texture
  81187. * @param scene Define the scene the parsed texture should be instantiated in
  81188. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  81189. * @returns The parsed texture if successful
  81190. */
  81191. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  81192. /**
  81193. * Creates a texture from its base 64 representation.
  81194. * @param data Define the base64 payload without the data: prefix
  81195. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  81196. * @param scene Define the scene the texture should belong to
  81197. * @param noMipmap Forces the texture to not create mip map information if true
  81198. * @param invertY define if the texture needs to be inverted on the y axis during loading
  81199. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  81200. * @param onLoad define a callback triggered when the texture has been loaded
  81201. * @param onError define a callback triggered when an error occurred during the loading session
  81202. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  81203. * @returns the created texture
  81204. */
  81205. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  81206. /**
  81207. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  81208. * @param data Define the base64 payload without the data: prefix
  81209. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  81210. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  81211. * @param scene Define the scene the texture should belong to
  81212. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  81213. * @param noMipmap Forces the texture to not create mip map information if true
  81214. * @param invertY define if the texture needs to be inverted on the y axis during loading
  81215. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  81216. * @param onLoad define a callback triggered when the texture has been loaded
  81217. * @param onError define a callback triggered when an error occurred during the loading session
  81218. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  81219. * @returns the created texture
  81220. */
  81221. 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;
  81222. }
  81223. }
  81224. declare module BABYLON {
  81225. /**
  81226. * PostProcessManager is used to manage one or more post processes or post process pipelines
  81227. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  81228. */
  81229. export class PostProcessManager {
  81230. private _scene;
  81231. private _indexBuffer;
  81232. private _vertexBuffers;
  81233. /**
  81234. * Creates a new instance PostProcess
  81235. * @param scene The scene that the post process is associated with.
  81236. */
  81237. constructor(scene: Scene);
  81238. private _prepareBuffers;
  81239. private _buildIndexBuffer;
  81240. /**
  81241. * Rebuilds the vertex buffers of the manager.
  81242. * @hidden
  81243. */
  81244. _rebuild(): void;
  81245. /**
  81246. * Prepares a frame to be run through a post process.
  81247. * @param sourceTexture The input texture to the post procesess. (default: null)
  81248. * @param postProcesses An array of post processes to be run. (default: null)
  81249. * @returns True if the post processes were able to be run.
  81250. * @hidden
  81251. */
  81252. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  81253. /**
  81254. * Manually render a set of post processes to a texture.
  81255. * @param postProcesses An array of post processes to be run.
  81256. * @param targetTexture The target texture to render to.
  81257. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  81258. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  81259. * @param lodLevel defines which lod of the texture to render to
  81260. */
  81261. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  81262. /**
  81263. * Finalize the result of the output of the postprocesses.
  81264. * @param doNotPresent If true the result will not be displayed to the screen.
  81265. * @param targetTexture The target texture to render to.
  81266. * @param faceIndex The index of the face to bind the target texture to.
  81267. * @param postProcesses The array of post processes to render.
  81268. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  81269. * @hidden
  81270. */
  81271. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  81272. /**
  81273. * Disposes of the post process manager.
  81274. */
  81275. dispose(): void;
  81276. }
  81277. }
  81278. declare module BABYLON {
  81279. interface AbstractScene {
  81280. /**
  81281. * The list of procedural textures added to the scene
  81282. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  81283. */
  81284. proceduralTextures: Array<ProceduralTexture>;
  81285. }
  81286. /**
  81287. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  81288. * in a given scene.
  81289. */
  81290. export class ProceduralTextureSceneComponent implements ISceneComponent {
  81291. /**
  81292. * The component name helpfull to identify the component in the list of scene components.
  81293. */
  81294. readonly name: string;
  81295. /**
  81296. * The scene the component belongs to.
  81297. */
  81298. scene: Scene;
  81299. /**
  81300. * Creates a new instance of the component for the given scene
  81301. * @param scene Defines the scene to register the component in
  81302. */
  81303. constructor(scene: Scene);
  81304. /**
  81305. * Registers the component in a given scene
  81306. */
  81307. register(): void;
  81308. /**
  81309. * Rebuilds the elements related to this component in case of
  81310. * context lost for instance.
  81311. */
  81312. rebuild(): void;
  81313. /**
  81314. * Disposes the component and the associated ressources.
  81315. */
  81316. dispose(): void;
  81317. private _beforeClear;
  81318. }
  81319. }
  81320. declare module BABYLON {
  81321. interface Engine {
  81322. /**
  81323. * Creates a new render target cube texture
  81324. * @param size defines the size of the texture
  81325. * @param options defines the options used to create the texture
  81326. * @returns a new render target cube texture stored in an InternalTexture
  81327. */
  81328. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  81329. }
  81330. }
  81331. declare module BABYLON {
  81332. /** @hidden */
  81333. export var proceduralVertexShader: {
  81334. name: string;
  81335. shader: string;
  81336. };
  81337. }
  81338. declare module BABYLON {
  81339. /**
  81340. * 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.
  81341. * This is the base class of any Procedural texture and contains most of the shareable code.
  81342. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  81343. */
  81344. export class ProceduralTexture extends Texture {
  81345. isCube: boolean;
  81346. /**
  81347. * Define if the texture is enabled or not (disabled texture will not render)
  81348. */
  81349. isEnabled: boolean;
  81350. /**
  81351. * Define if the texture must be cleared before rendering (default is true)
  81352. */
  81353. autoClear: boolean;
  81354. /**
  81355. * Callback called when the texture is generated
  81356. */
  81357. onGenerated: () => void;
  81358. /**
  81359. * Event raised when the texture is generated
  81360. */
  81361. onGeneratedObservable: Observable<ProceduralTexture>;
  81362. /** @hidden */
  81363. _generateMipMaps: boolean;
  81364. /** @hidden **/
  81365. _effect: Effect;
  81366. /** @hidden */
  81367. _textures: {
  81368. [key: string]: Texture;
  81369. };
  81370. private _size;
  81371. private _currentRefreshId;
  81372. private _refreshRate;
  81373. private _vertexBuffers;
  81374. private _indexBuffer;
  81375. private _uniforms;
  81376. private _samplers;
  81377. private _fragment;
  81378. private _floats;
  81379. private _ints;
  81380. private _floatsArrays;
  81381. private _colors3;
  81382. private _colors4;
  81383. private _vectors2;
  81384. private _vectors3;
  81385. private _matrices;
  81386. private _fallbackTexture;
  81387. private _fallbackTextureUsed;
  81388. private _engine;
  81389. private _cachedDefines;
  81390. private _contentUpdateId;
  81391. private _contentData;
  81392. /**
  81393. * Instantiates a new procedural texture.
  81394. * 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.
  81395. * This is the base class of any Procedural texture and contains most of the shareable code.
  81396. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  81397. * @param name Define the name of the texture
  81398. * @param size Define the size of the texture to create
  81399. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  81400. * @param scene Define the scene the texture belongs to
  81401. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  81402. * @param generateMipMaps Define if the texture should creates mip maps or not
  81403. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  81404. */
  81405. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  81406. /**
  81407. * The effect that is created when initializing the post process.
  81408. * @returns The created effect corresponding the the postprocess.
  81409. */
  81410. getEffect(): Effect;
  81411. /**
  81412. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  81413. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  81414. */
  81415. getContent(): Nullable<ArrayBufferView>;
  81416. private _createIndexBuffer;
  81417. /** @hidden */
  81418. _rebuild(): void;
  81419. /**
  81420. * Resets the texture in order to recreate its associated resources.
  81421. * This can be called in case of context loss
  81422. */
  81423. reset(): void;
  81424. protected _getDefines(): string;
  81425. /**
  81426. * Is the texture ready to be used ? (rendered at least once)
  81427. * @returns true if ready, otherwise, false.
  81428. */
  81429. isReady(): boolean;
  81430. /**
  81431. * Resets the refresh counter of the texture and start bak from scratch.
  81432. * Could be useful to regenerate the texture if it is setup to render only once.
  81433. */
  81434. resetRefreshCounter(): void;
  81435. /**
  81436. * Set the fragment shader to use in order to render the texture.
  81437. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  81438. */
  81439. setFragment(fragment: any): void;
  81440. /**
  81441. * Define the refresh rate of the texture or the rendering frequency.
  81442. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  81443. */
  81444. refreshRate: number;
  81445. /** @hidden */
  81446. _shouldRender(): boolean;
  81447. /**
  81448. * Get the size the texture is rendering at.
  81449. * @returns the size (texture is always squared)
  81450. */
  81451. getRenderSize(): number;
  81452. /**
  81453. * Resize the texture to new value.
  81454. * @param size Define the new size the texture should have
  81455. * @param generateMipMaps Define whether the new texture should create mip maps
  81456. */
  81457. resize(size: number, generateMipMaps: boolean): void;
  81458. private _checkUniform;
  81459. /**
  81460. * Set a texture in the shader program used to render.
  81461. * @param name Define the name of the uniform samplers as defined in the shader
  81462. * @param texture Define the texture to bind to this sampler
  81463. * @return the texture itself allowing "fluent" like uniform updates
  81464. */
  81465. setTexture(name: string, texture: Texture): ProceduralTexture;
  81466. /**
  81467. * Set a float in the shader.
  81468. * @param name Define the name of the uniform as defined in the shader
  81469. * @param value Define the value to give to the uniform
  81470. * @return the texture itself allowing "fluent" like uniform updates
  81471. */
  81472. setFloat(name: string, value: number): ProceduralTexture;
  81473. /**
  81474. * Set a int in the shader.
  81475. * @param name Define the name of the uniform as defined in the shader
  81476. * @param value Define the value to give to the uniform
  81477. * @return the texture itself allowing "fluent" like uniform updates
  81478. */
  81479. setInt(name: string, value: number): ProceduralTexture;
  81480. /**
  81481. * Set an array of floats in the shader.
  81482. * @param name Define the name of the uniform as defined in the shader
  81483. * @param value Define the value to give to the uniform
  81484. * @return the texture itself allowing "fluent" like uniform updates
  81485. */
  81486. setFloats(name: string, value: number[]): ProceduralTexture;
  81487. /**
  81488. * Set a vec3 in the shader from a Color3.
  81489. * @param name Define the name of the uniform as defined in the shader
  81490. * @param value Define the value to give to the uniform
  81491. * @return the texture itself allowing "fluent" like uniform updates
  81492. */
  81493. setColor3(name: string, value: Color3): ProceduralTexture;
  81494. /**
  81495. * Set a vec4 in the shader from a Color4.
  81496. * @param name Define the name of the uniform as defined in the shader
  81497. * @param value Define the value to give to the uniform
  81498. * @return the texture itself allowing "fluent" like uniform updates
  81499. */
  81500. setColor4(name: string, value: Color4): ProceduralTexture;
  81501. /**
  81502. * Set a vec2 in the shader from a Vector2.
  81503. * @param name Define the name of the uniform as defined in the shader
  81504. * @param value Define the value to give to the uniform
  81505. * @return the texture itself allowing "fluent" like uniform updates
  81506. */
  81507. setVector2(name: string, value: Vector2): ProceduralTexture;
  81508. /**
  81509. * Set a vec3 in the shader from a Vector3.
  81510. * @param name Define the name of the uniform as defined in the shader
  81511. * @param value Define the value to give to the uniform
  81512. * @return the texture itself allowing "fluent" like uniform updates
  81513. */
  81514. setVector3(name: string, value: Vector3): ProceduralTexture;
  81515. /**
  81516. * Set a mat4 in the shader from a MAtrix.
  81517. * @param name Define the name of the uniform as defined in the shader
  81518. * @param value Define the value to give to the uniform
  81519. * @return the texture itself allowing "fluent" like uniform updates
  81520. */
  81521. setMatrix(name: string, value: Matrix): ProceduralTexture;
  81522. /**
  81523. * Render the texture to its associated render target.
  81524. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  81525. */
  81526. render(useCameraPostProcess?: boolean): void;
  81527. /**
  81528. * Clone the texture.
  81529. * @returns the cloned texture
  81530. */
  81531. clone(): ProceduralTexture;
  81532. /**
  81533. * Dispose the texture and release its asoociated resources.
  81534. */
  81535. dispose(): void;
  81536. }
  81537. }
  81538. declare module BABYLON {
  81539. /**
  81540. * This represents the base class for particle system in Babylon.
  81541. * 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.
  81542. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  81543. * @example https://doc.babylonjs.com/babylon101/particles
  81544. */
  81545. export class BaseParticleSystem {
  81546. /**
  81547. * Source color is added to the destination color without alpha affecting the result
  81548. */
  81549. static BLENDMODE_ONEONE: number;
  81550. /**
  81551. * Blend current color and particle color using particle’s alpha
  81552. */
  81553. static BLENDMODE_STANDARD: number;
  81554. /**
  81555. * Add current color and particle color multiplied by particle’s alpha
  81556. */
  81557. static BLENDMODE_ADD: number;
  81558. /**
  81559. * Multiply current color with particle color
  81560. */
  81561. static BLENDMODE_MULTIPLY: number;
  81562. /**
  81563. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  81564. */
  81565. static BLENDMODE_MULTIPLYADD: number;
  81566. /**
  81567. * List of animations used by the particle system.
  81568. */
  81569. animations: Animation[];
  81570. /**
  81571. * The id of the Particle system.
  81572. */
  81573. id: string;
  81574. /**
  81575. * The friendly name of the Particle system.
  81576. */
  81577. name: string;
  81578. /**
  81579. * The rendering group used by the Particle system to chose when to render.
  81580. */
  81581. renderingGroupId: number;
  81582. /**
  81583. * The emitter represents the Mesh or position we are attaching the particle system to.
  81584. */
  81585. emitter: Nullable<AbstractMesh | Vector3>;
  81586. /**
  81587. * The maximum number of particles to emit per frame
  81588. */
  81589. emitRate: number;
  81590. /**
  81591. * If you want to launch only a few particles at once, that can be done, as well.
  81592. */
  81593. manualEmitCount: number;
  81594. /**
  81595. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  81596. */
  81597. updateSpeed: number;
  81598. /**
  81599. * The amount of time the particle system is running (depends of the overall update speed).
  81600. */
  81601. targetStopDuration: number;
  81602. /**
  81603. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  81604. */
  81605. disposeOnStop: boolean;
  81606. /**
  81607. * Minimum power of emitting particles.
  81608. */
  81609. minEmitPower: number;
  81610. /**
  81611. * Maximum power of emitting particles.
  81612. */
  81613. maxEmitPower: number;
  81614. /**
  81615. * Minimum life time of emitting particles.
  81616. */
  81617. minLifeTime: number;
  81618. /**
  81619. * Maximum life time of emitting particles.
  81620. */
  81621. maxLifeTime: number;
  81622. /**
  81623. * Minimum Size of emitting particles.
  81624. */
  81625. minSize: number;
  81626. /**
  81627. * Maximum Size of emitting particles.
  81628. */
  81629. maxSize: number;
  81630. /**
  81631. * Minimum scale of emitting particles on X axis.
  81632. */
  81633. minScaleX: number;
  81634. /**
  81635. * Maximum scale of emitting particles on X axis.
  81636. */
  81637. maxScaleX: number;
  81638. /**
  81639. * Minimum scale of emitting particles on Y axis.
  81640. */
  81641. minScaleY: number;
  81642. /**
  81643. * Maximum scale of emitting particles on Y axis.
  81644. */
  81645. maxScaleY: number;
  81646. /**
  81647. * Gets or sets the minimal initial rotation in radians.
  81648. */
  81649. minInitialRotation: number;
  81650. /**
  81651. * Gets or sets the maximal initial rotation in radians.
  81652. */
  81653. maxInitialRotation: number;
  81654. /**
  81655. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  81656. */
  81657. minAngularSpeed: number;
  81658. /**
  81659. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  81660. */
  81661. maxAngularSpeed: number;
  81662. /**
  81663. * The texture used to render each particle. (this can be a spritesheet)
  81664. */
  81665. particleTexture: Nullable<Texture>;
  81666. /**
  81667. * The layer mask we are rendering the particles through.
  81668. */
  81669. layerMask: number;
  81670. /**
  81671. * This can help using your own shader to render the particle system.
  81672. * The according effect will be created
  81673. */
  81674. customShader: any;
  81675. /**
  81676. * By default particle system starts as soon as they are created. This prevents the
  81677. * automatic start to happen and let you decide when to start emitting particles.
  81678. */
  81679. preventAutoStart: boolean;
  81680. private _noiseTexture;
  81681. /**
  81682. * Gets or sets a texture used to add random noise to particle positions
  81683. */
  81684. noiseTexture: Nullable<ProceduralTexture>;
  81685. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  81686. noiseStrength: Vector3;
  81687. /**
  81688. * Callback triggered when the particle animation is ending.
  81689. */
  81690. onAnimationEnd: Nullable<() => void>;
  81691. /**
  81692. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  81693. */
  81694. blendMode: number;
  81695. /**
  81696. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  81697. * to override the particles.
  81698. */
  81699. forceDepthWrite: boolean;
  81700. /** 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 */
  81701. preWarmCycles: number;
  81702. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  81703. preWarmStepOffset: number;
  81704. /**
  81705. * 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)
  81706. */
  81707. spriteCellChangeSpeed: number;
  81708. /**
  81709. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  81710. */
  81711. startSpriteCellID: number;
  81712. /**
  81713. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  81714. */
  81715. endSpriteCellID: number;
  81716. /**
  81717. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  81718. */
  81719. spriteCellWidth: number;
  81720. /**
  81721. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  81722. */
  81723. spriteCellHeight: number;
  81724. /**
  81725. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  81726. */
  81727. spriteRandomStartCell: boolean;
  81728. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  81729. translationPivot: Vector2;
  81730. /** @hidden */
  81731. protected _isAnimationSheetEnabled: boolean;
  81732. /**
  81733. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  81734. */
  81735. beginAnimationOnStart: boolean;
  81736. /**
  81737. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  81738. */
  81739. beginAnimationFrom: number;
  81740. /**
  81741. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  81742. */
  81743. beginAnimationTo: number;
  81744. /**
  81745. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  81746. */
  81747. beginAnimationLoop: boolean;
  81748. /**
  81749. * Gets or sets a world offset applied to all particles
  81750. */
  81751. worldOffset: Vector3;
  81752. /**
  81753. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  81754. */
  81755. isAnimationSheetEnabled: boolean;
  81756. /**
  81757. * Get hosting scene
  81758. * @returns the scene
  81759. */
  81760. getScene(): Scene;
  81761. /**
  81762. * You can use gravity if you want to give an orientation to your particles.
  81763. */
  81764. gravity: Vector3;
  81765. protected _colorGradients: Nullable<Array<ColorGradient>>;
  81766. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  81767. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  81768. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  81769. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  81770. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  81771. protected _dragGradients: Nullable<Array<FactorGradient>>;
  81772. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  81773. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  81774. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  81775. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  81776. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  81777. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  81778. /**
  81779. * Defines the delay in milliseconds before starting the system (0 by default)
  81780. */
  81781. startDelay: number;
  81782. /**
  81783. * Gets the current list of drag gradients.
  81784. * You must use addDragGradient and removeDragGradient to udpate this list
  81785. * @returns the list of drag gradients
  81786. */
  81787. getDragGradients(): Nullable<Array<FactorGradient>>;
  81788. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  81789. limitVelocityDamping: number;
  81790. /**
  81791. * Gets the current list of limit velocity gradients.
  81792. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  81793. * @returns the list of limit velocity gradients
  81794. */
  81795. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  81796. /**
  81797. * Gets the current list of color gradients.
  81798. * You must use addColorGradient and removeColorGradient to udpate this list
  81799. * @returns the list of color gradients
  81800. */
  81801. getColorGradients(): Nullable<Array<ColorGradient>>;
  81802. /**
  81803. * Gets the current list of size gradients.
  81804. * You must use addSizeGradient and removeSizeGradient to udpate this list
  81805. * @returns the list of size gradients
  81806. */
  81807. getSizeGradients(): Nullable<Array<FactorGradient>>;
  81808. /**
  81809. * Gets the current list of color remap gradients.
  81810. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  81811. * @returns the list of color remap gradients
  81812. */
  81813. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  81814. /**
  81815. * Gets the current list of alpha remap gradients.
  81816. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  81817. * @returns the list of alpha remap gradients
  81818. */
  81819. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  81820. /**
  81821. * Gets the current list of life time gradients.
  81822. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  81823. * @returns the list of life time gradients
  81824. */
  81825. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  81826. /**
  81827. * Gets the current list of angular speed gradients.
  81828. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  81829. * @returns the list of angular speed gradients
  81830. */
  81831. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  81832. /**
  81833. * Gets the current list of velocity gradients.
  81834. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  81835. * @returns the list of velocity gradients
  81836. */
  81837. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  81838. /**
  81839. * Gets the current list of start size gradients.
  81840. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  81841. * @returns the list of start size gradients
  81842. */
  81843. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  81844. /**
  81845. * Gets the current list of emit rate gradients.
  81846. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  81847. * @returns the list of emit rate gradients
  81848. */
  81849. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  81850. /**
  81851. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  81852. * This only works when particleEmitterTyps is a BoxParticleEmitter
  81853. */
  81854. direction1: Vector3;
  81855. /**
  81856. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  81857. * This only works when particleEmitterTyps is a BoxParticleEmitter
  81858. */
  81859. direction2: Vector3;
  81860. /**
  81861. * 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.
  81862. * This only works when particleEmitterTyps is a BoxParticleEmitter
  81863. */
  81864. minEmitBox: Vector3;
  81865. /**
  81866. * 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.
  81867. * This only works when particleEmitterTyps is a BoxParticleEmitter
  81868. */
  81869. maxEmitBox: Vector3;
  81870. /**
  81871. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  81872. */
  81873. color1: Color4;
  81874. /**
  81875. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  81876. */
  81877. color2: Color4;
  81878. /**
  81879. * Color the particle will have at the end of its lifetime
  81880. */
  81881. colorDead: Color4;
  81882. /**
  81883. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  81884. */
  81885. textureMask: Color4;
  81886. /**
  81887. * The particle emitter type defines the emitter used by the particle system.
  81888. * It can be for example box, sphere, or cone...
  81889. */
  81890. particleEmitterType: IParticleEmitterType;
  81891. /** @hidden */
  81892. _isSubEmitter: boolean;
  81893. /**
  81894. * Gets or sets the billboard mode to use when isBillboardBased = true.
  81895. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  81896. */
  81897. billboardMode: number;
  81898. protected _isBillboardBased: boolean;
  81899. /**
  81900. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  81901. */
  81902. isBillboardBased: boolean;
  81903. /**
  81904. * The scene the particle system belongs to.
  81905. */
  81906. protected _scene: Scene;
  81907. /**
  81908. * Local cache of defines for image processing.
  81909. */
  81910. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  81911. /**
  81912. * Default configuration related to image processing available in the standard Material.
  81913. */
  81914. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  81915. /**
  81916. * Gets the image processing configuration used either in this material.
  81917. */
  81918. /**
  81919. * Sets the Default image processing configuration used either in the this material.
  81920. *
  81921. * If sets to null, the scene one is in use.
  81922. */
  81923. imageProcessingConfiguration: ImageProcessingConfiguration;
  81924. /**
  81925. * Attaches a new image processing configuration to the Standard Material.
  81926. * @param configuration
  81927. */
  81928. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  81929. /** @hidden */
  81930. protected _reset(): void;
  81931. /** @hidden */
  81932. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  81933. /**
  81934. * Instantiates a particle system.
  81935. * 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.
  81936. * @param name The name of the particle system
  81937. */
  81938. constructor(name: string);
  81939. /**
  81940. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  81941. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  81942. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  81943. * @returns the emitter
  81944. */
  81945. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  81946. /**
  81947. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  81948. * @param radius The radius of the hemisphere to emit from
  81949. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  81950. * @returns the emitter
  81951. */
  81952. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  81953. /**
  81954. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  81955. * @param radius The radius of the sphere to emit from
  81956. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  81957. * @returns the emitter
  81958. */
  81959. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  81960. /**
  81961. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  81962. * @param radius The radius of the sphere to emit from
  81963. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  81964. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  81965. * @returns the emitter
  81966. */
  81967. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  81968. /**
  81969. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  81970. * @param radius The radius of the emission cylinder
  81971. * @param height The height of the emission cylinder
  81972. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  81973. * @param directionRandomizer How much to randomize the particle direction [0-1]
  81974. * @returns the emitter
  81975. */
  81976. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  81977. /**
  81978. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  81979. * @param radius The radius of the cylinder to emit from
  81980. * @param height The height of the emission cylinder
  81981. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  81982. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  81983. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  81984. * @returns the emitter
  81985. */
  81986. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  81987. /**
  81988. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  81989. * @param radius The radius of the cone to emit from
  81990. * @param angle The base angle of the cone
  81991. * @returns the emitter
  81992. */
  81993. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  81994. /**
  81995. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  81996. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  81997. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  81998. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  81999. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  82000. * @returns the emitter
  82001. */
  82002. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  82003. }
  82004. }
  82005. declare module BABYLON {
  82006. /**
  82007. * Type of sub emitter
  82008. */
  82009. export enum SubEmitterType {
  82010. /**
  82011. * Attached to the particle over it's lifetime
  82012. */
  82013. ATTACHED = 0,
  82014. /**
  82015. * Created when the particle dies
  82016. */
  82017. END = 1
  82018. }
  82019. /**
  82020. * Sub emitter class used to emit particles from an existing particle
  82021. */
  82022. export class SubEmitter {
  82023. /**
  82024. * the particle system to be used by the sub emitter
  82025. */
  82026. particleSystem: ParticleSystem;
  82027. /**
  82028. * Type of the submitter (Default: END)
  82029. */
  82030. type: SubEmitterType;
  82031. /**
  82032. * 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)
  82033. * Note: This only is supported when using an emitter of type Mesh
  82034. */
  82035. inheritDirection: boolean;
  82036. /**
  82037. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  82038. */
  82039. inheritedVelocityAmount: number;
  82040. /**
  82041. * Creates a sub emitter
  82042. * @param particleSystem the particle system to be used by the sub emitter
  82043. */
  82044. constructor(
  82045. /**
  82046. * the particle system to be used by the sub emitter
  82047. */
  82048. particleSystem: ParticleSystem);
  82049. /**
  82050. * Clones the sub emitter
  82051. * @returns the cloned sub emitter
  82052. */
  82053. clone(): SubEmitter;
  82054. /**
  82055. * Serialize current object to a JSON object
  82056. * @returns the serialized object
  82057. */
  82058. serialize(): any;
  82059. /** @hidden */
  82060. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  82061. /**
  82062. * Creates a new SubEmitter from a serialized JSON version
  82063. * @param serializationObject defines the JSON object to read from
  82064. * @param scene defines the hosting scene
  82065. * @param rootUrl defines the rootUrl for data loading
  82066. * @returns a new SubEmitter
  82067. */
  82068. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  82069. /** Release associated resources */
  82070. dispose(): void;
  82071. }
  82072. }
  82073. declare module BABYLON {
  82074. /** @hidden */
  82075. export var imageProcessingDeclaration: {
  82076. name: string;
  82077. shader: string;
  82078. };
  82079. }
  82080. declare module BABYLON {
  82081. /** @hidden */
  82082. export var imageProcessingFunctions: {
  82083. name: string;
  82084. shader: string;
  82085. };
  82086. }
  82087. declare module BABYLON {
  82088. /** @hidden */
  82089. export var particlesPixelShader: {
  82090. name: string;
  82091. shader: string;
  82092. };
  82093. }
  82094. declare module BABYLON {
  82095. /** @hidden */
  82096. export var particlesVertexShader: {
  82097. name: string;
  82098. shader: string;
  82099. };
  82100. }
  82101. declare module BABYLON {
  82102. /**
  82103. * This represents a particle system in Babylon.
  82104. * 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.
  82105. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  82106. * @example https://doc.babylonjs.com/babylon101/particles
  82107. */
  82108. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  82109. /**
  82110. * Billboard mode will only apply to Y axis
  82111. */
  82112. static readonly BILLBOARDMODE_Y: number;
  82113. /**
  82114. * Billboard mode will apply to all axes
  82115. */
  82116. static readonly BILLBOARDMODE_ALL: number;
  82117. /**
  82118. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  82119. */
  82120. static readonly BILLBOARDMODE_STRETCHED: number;
  82121. /**
  82122. * This function can be defined to provide custom update for active particles.
  82123. * This function will be called instead of regular update (age, position, color, etc.).
  82124. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  82125. */
  82126. updateFunction: (particles: Particle[]) => void;
  82127. private _emitterWorldMatrix;
  82128. /**
  82129. * This function can be defined to specify initial direction for every new particle.
  82130. * It by default use the emitterType defined function
  82131. */
  82132. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  82133. /**
  82134. * This function can be defined to specify initial position for every new particle.
  82135. * It by default use the emitterType defined function
  82136. */
  82137. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  82138. /**
  82139. * @hidden
  82140. */
  82141. _inheritedVelocityOffset: Vector3;
  82142. /**
  82143. * An event triggered when the system is disposed
  82144. */
  82145. onDisposeObservable: Observable<ParticleSystem>;
  82146. private _onDisposeObserver;
  82147. /**
  82148. * Sets a callback that will be triggered when the system is disposed
  82149. */
  82150. onDispose: () => void;
  82151. private _particles;
  82152. private _epsilon;
  82153. private _capacity;
  82154. private _stockParticles;
  82155. private _newPartsExcess;
  82156. private _vertexData;
  82157. private _vertexBuffer;
  82158. private _vertexBuffers;
  82159. private _spriteBuffer;
  82160. private _indexBuffer;
  82161. private _effect;
  82162. private _customEffect;
  82163. private _cachedDefines;
  82164. private _scaledColorStep;
  82165. private _colorDiff;
  82166. private _scaledDirection;
  82167. private _scaledGravity;
  82168. private _currentRenderId;
  82169. private _alive;
  82170. private _useInstancing;
  82171. private _started;
  82172. private _stopped;
  82173. private _actualFrame;
  82174. private _scaledUpdateSpeed;
  82175. private _vertexBufferSize;
  82176. /** @hidden */
  82177. _currentEmitRateGradient: Nullable<FactorGradient>;
  82178. /** @hidden */
  82179. _currentEmitRate1: number;
  82180. /** @hidden */
  82181. _currentEmitRate2: number;
  82182. /** @hidden */
  82183. _currentStartSizeGradient: Nullable<FactorGradient>;
  82184. /** @hidden */
  82185. _currentStartSize1: number;
  82186. /** @hidden */
  82187. _currentStartSize2: number;
  82188. private readonly _rawTextureWidth;
  82189. private _rampGradientsTexture;
  82190. private _useRampGradients;
  82191. /** Gets or sets a boolean indicating that ramp gradients must be used
  82192. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  82193. */
  82194. useRampGradients: boolean;
  82195. /**
  82196. * 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.
  82197. * 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: [])
  82198. */
  82199. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  82200. private _subEmitters;
  82201. /**
  82202. * @hidden
  82203. * If the particle systems emitter should be disposed when the particle system is disposed
  82204. */
  82205. _disposeEmitterOnDispose: boolean;
  82206. /**
  82207. * The current active Sub-systems, this property is used by the root particle system only.
  82208. */
  82209. activeSubSystems: Array<ParticleSystem>;
  82210. private _rootParticleSystem;
  82211. /**
  82212. * Gets the current list of active particles
  82213. */
  82214. readonly particles: Particle[];
  82215. /**
  82216. * Returns the string "ParticleSystem"
  82217. * @returns a string containing the class name
  82218. */
  82219. getClassName(): string;
  82220. /**
  82221. * Instantiates a particle system.
  82222. * 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.
  82223. * @param name The name of the particle system
  82224. * @param capacity The max number of particles alive at the same time
  82225. * @param scene The scene the particle system belongs to
  82226. * @param customEffect a custom effect used to change the way particles are rendered by default
  82227. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  82228. * @param epsilon Offset used to render the particles
  82229. */
  82230. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  82231. private _addFactorGradient;
  82232. private _removeFactorGradient;
  82233. /**
  82234. * Adds a new life time gradient
  82235. * @param gradient defines the gradient to use (between 0 and 1)
  82236. * @param factor defines the life time factor to affect to the specified gradient
  82237. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82238. * @returns the current particle system
  82239. */
  82240. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82241. /**
  82242. * Remove a specific life time gradient
  82243. * @param gradient defines the gradient to remove
  82244. * @returns the current particle system
  82245. */
  82246. removeLifeTimeGradient(gradient: number): IParticleSystem;
  82247. /**
  82248. * Adds a new size gradient
  82249. * @param gradient defines the gradient to use (between 0 and 1)
  82250. * @param factor defines the size factor to affect to the specified gradient
  82251. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82252. * @returns the current particle system
  82253. */
  82254. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82255. /**
  82256. * Remove a specific size gradient
  82257. * @param gradient defines the gradient to remove
  82258. * @returns the current particle system
  82259. */
  82260. removeSizeGradient(gradient: number): IParticleSystem;
  82261. /**
  82262. * Adds a new color remap gradient
  82263. * @param gradient defines the gradient to use (between 0 and 1)
  82264. * @param min defines the color remap minimal range
  82265. * @param max defines the color remap maximal range
  82266. * @returns the current particle system
  82267. */
  82268. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  82269. /**
  82270. * Remove a specific color remap gradient
  82271. * @param gradient defines the gradient to remove
  82272. * @returns the current particle system
  82273. */
  82274. removeColorRemapGradient(gradient: number): IParticleSystem;
  82275. /**
  82276. * Adds a new alpha remap gradient
  82277. * @param gradient defines the gradient to use (between 0 and 1)
  82278. * @param min defines the alpha remap minimal range
  82279. * @param max defines the alpha remap maximal range
  82280. * @returns the current particle system
  82281. */
  82282. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  82283. /**
  82284. * Remove a specific alpha remap gradient
  82285. * @param gradient defines the gradient to remove
  82286. * @returns the current particle system
  82287. */
  82288. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  82289. /**
  82290. * Adds a new angular speed gradient
  82291. * @param gradient defines the gradient to use (between 0 and 1)
  82292. * @param factor defines the angular speed to affect to the specified gradient
  82293. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82294. * @returns the current particle system
  82295. */
  82296. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82297. /**
  82298. * Remove a specific angular speed gradient
  82299. * @param gradient defines the gradient to remove
  82300. * @returns the current particle system
  82301. */
  82302. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  82303. /**
  82304. * Adds a new velocity gradient
  82305. * @param gradient defines the gradient to use (between 0 and 1)
  82306. * @param factor defines the velocity to affect to the specified gradient
  82307. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82308. * @returns the current particle system
  82309. */
  82310. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82311. /**
  82312. * Remove a specific velocity gradient
  82313. * @param gradient defines the gradient to remove
  82314. * @returns the current particle system
  82315. */
  82316. removeVelocityGradient(gradient: number): IParticleSystem;
  82317. /**
  82318. * Adds a new limit velocity gradient
  82319. * @param gradient defines the gradient to use (between 0 and 1)
  82320. * @param factor defines the limit velocity value to affect to the specified gradient
  82321. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82322. * @returns the current particle system
  82323. */
  82324. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82325. /**
  82326. * Remove a specific limit velocity gradient
  82327. * @param gradient defines the gradient to remove
  82328. * @returns the current particle system
  82329. */
  82330. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  82331. /**
  82332. * Adds a new drag gradient
  82333. * @param gradient defines the gradient to use (between 0 and 1)
  82334. * @param factor defines the drag value to affect to the specified gradient
  82335. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82336. * @returns the current particle system
  82337. */
  82338. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82339. /**
  82340. * Remove a specific drag gradient
  82341. * @param gradient defines the gradient to remove
  82342. * @returns the current particle system
  82343. */
  82344. removeDragGradient(gradient: number): IParticleSystem;
  82345. /**
  82346. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  82347. * @param gradient defines the gradient to use (between 0 and 1)
  82348. * @param factor defines the emit rate value to affect to the specified gradient
  82349. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82350. * @returns the current particle system
  82351. */
  82352. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82353. /**
  82354. * Remove a specific emit rate gradient
  82355. * @param gradient defines the gradient to remove
  82356. * @returns the current particle system
  82357. */
  82358. removeEmitRateGradient(gradient: number): IParticleSystem;
  82359. /**
  82360. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  82361. * @param gradient defines the gradient to use (between 0 and 1)
  82362. * @param factor defines the start size value to affect to the specified gradient
  82363. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82364. * @returns the current particle system
  82365. */
  82366. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82367. /**
  82368. * Remove a specific start size gradient
  82369. * @param gradient defines the gradient to remove
  82370. * @returns the current particle system
  82371. */
  82372. removeStartSizeGradient(gradient: number): IParticleSystem;
  82373. private _createRampGradientTexture;
  82374. /**
  82375. * Gets the current list of ramp gradients.
  82376. * You must use addRampGradient and removeRampGradient to udpate this list
  82377. * @returns the list of ramp gradients
  82378. */
  82379. getRampGradients(): Nullable<Array<Color3Gradient>>;
  82380. /**
  82381. * Adds a new ramp gradient used to remap particle colors
  82382. * @param gradient defines the gradient to use (between 0 and 1)
  82383. * @param color defines the color to affect to the specified gradient
  82384. * @returns the current particle system
  82385. */
  82386. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  82387. /**
  82388. * Remove a specific ramp gradient
  82389. * @param gradient defines the gradient to remove
  82390. * @returns the current particle system
  82391. */
  82392. removeRampGradient(gradient: number): ParticleSystem;
  82393. /**
  82394. * Adds a new color gradient
  82395. * @param gradient defines the gradient to use (between 0 and 1)
  82396. * @param color1 defines the color to affect to the specified gradient
  82397. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  82398. * @returns this particle system
  82399. */
  82400. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  82401. /**
  82402. * Remove a specific color gradient
  82403. * @param gradient defines the gradient to remove
  82404. * @returns this particle system
  82405. */
  82406. removeColorGradient(gradient: number): IParticleSystem;
  82407. private _fetchR;
  82408. protected _reset(): void;
  82409. private _resetEffect;
  82410. private _createVertexBuffers;
  82411. private _createIndexBuffer;
  82412. /**
  82413. * Gets the maximum number of particles active at the same time.
  82414. * @returns The max number of active particles.
  82415. */
  82416. getCapacity(): number;
  82417. /**
  82418. * Gets whether there are still active particles in the system.
  82419. * @returns True if it is alive, otherwise false.
  82420. */
  82421. isAlive(): boolean;
  82422. /**
  82423. * Gets if the system has been started. (Note: this will still be true after stop is called)
  82424. * @returns True if it has been started, otherwise false.
  82425. */
  82426. isStarted(): boolean;
  82427. private _prepareSubEmitterInternalArray;
  82428. /**
  82429. * Starts the particle system and begins to emit
  82430. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  82431. */
  82432. start(delay?: number): void;
  82433. /**
  82434. * Stops the particle system.
  82435. * @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.
  82436. */
  82437. stop(stopSubEmitters?: boolean): void;
  82438. /**
  82439. * Remove all active particles
  82440. */
  82441. reset(): void;
  82442. /**
  82443. * @hidden (for internal use only)
  82444. */
  82445. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  82446. /**
  82447. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  82448. * Its lifetime will start back at 0.
  82449. */
  82450. recycleParticle: (particle: Particle) => void;
  82451. private _stopSubEmitters;
  82452. private _createParticle;
  82453. private _removeFromRoot;
  82454. private _emitFromParticle;
  82455. private _update;
  82456. /** @hidden */
  82457. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  82458. /** @hidden */
  82459. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  82460. /** @hidden */
  82461. private _getEffect;
  82462. /**
  82463. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  82464. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  82465. */
  82466. animate(preWarmOnly?: boolean): void;
  82467. private _appendParticleVertices;
  82468. /**
  82469. * Rebuilds the particle system.
  82470. */
  82471. rebuild(): void;
  82472. /**
  82473. * Is this system ready to be used/rendered
  82474. * @return true if the system is ready
  82475. */
  82476. isReady(): boolean;
  82477. private _render;
  82478. /**
  82479. * Renders the particle system in its current state.
  82480. * @returns the current number of particles
  82481. */
  82482. render(): number;
  82483. /**
  82484. * Disposes the particle system and free the associated resources
  82485. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  82486. */
  82487. dispose(disposeTexture?: boolean): void;
  82488. /**
  82489. * Clones the particle system.
  82490. * @param name The name of the cloned object
  82491. * @param newEmitter The new emitter to use
  82492. * @returns the cloned particle system
  82493. */
  82494. clone(name: string, newEmitter: any): ParticleSystem;
  82495. /**
  82496. * Serializes the particle system to a JSON object.
  82497. * @returns the JSON object
  82498. */
  82499. serialize(): any;
  82500. /** @hidden */
  82501. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  82502. /** @hidden */
  82503. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  82504. /**
  82505. * Parses a JSON object to create a particle system.
  82506. * @param parsedParticleSystem The JSON object to parse
  82507. * @param scene The scene to create the particle system in
  82508. * @param rootUrl The root url to use to load external dependencies like texture
  82509. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  82510. * @returns the Parsed particle system
  82511. */
  82512. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  82513. }
  82514. }
  82515. declare module BABYLON {
  82516. /**
  82517. * A particle represents one of the element emitted by a particle system.
  82518. * This is mainly define by its coordinates, direction, velocity and age.
  82519. */
  82520. export class Particle {
  82521. /**
  82522. * The particle system the particle belongs to.
  82523. */
  82524. particleSystem: ParticleSystem;
  82525. private static _Count;
  82526. /**
  82527. * Unique ID of the particle
  82528. */
  82529. id: number;
  82530. /**
  82531. * The world position of the particle in the scene.
  82532. */
  82533. position: Vector3;
  82534. /**
  82535. * The world direction of the particle in the scene.
  82536. */
  82537. direction: Vector3;
  82538. /**
  82539. * The color of the particle.
  82540. */
  82541. color: Color4;
  82542. /**
  82543. * The color change of the particle per step.
  82544. */
  82545. colorStep: Color4;
  82546. /**
  82547. * Defines how long will the life of the particle be.
  82548. */
  82549. lifeTime: number;
  82550. /**
  82551. * The current age of the particle.
  82552. */
  82553. age: number;
  82554. /**
  82555. * The current size of the particle.
  82556. */
  82557. size: number;
  82558. /**
  82559. * The current scale of the particle.
  82560. */
  82561. scale: Vector2;
  82562. /**
  82563. * The current angle of the particle.
  82564. */
  82565. angle: number;
  82566. /**
  82567. * Defines how fast is the angle changing.
  82568. */
  82569. angularSpeed: number;
  82570. /**
  82571. * Defines the cell index used by the particle to be rendered from a sprite.
  82572. */
  82573. cellIndex: number;
  82574. /**
  82575. * The information required to support color remapping
  82576. */
  82577. remapData: Vector4;
  82578. /** @hidden */
  82579. _randomCellOffset?: number;
  82580. /** @hidden */
  82581. _initialDirection: Nullable<Vector3>;
  82582. /** @hidden */
  82583. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  82584. /** @hidden */
  82585. _initialStartSpriteCellID: number;
  82586. /** @hidden */
  82587. _initialEndSpriteCellID: number;
  82588. /** @hidden */
  82589. _currentColorGradient: Nullable<ColorGradient>;
  82590. /** @hidden */
  82591. _currentColor1: Color4;
  82592. /** @hidden */
  82593. _currentColor2: Color4;
  82594. /** @hidden */
  82595. _currentSizeGradient: Nullable<FactorGradient>;
  82596. /** @hidden */
  82597. _currentSize1: number;
  82598. /** @hidden */
  82599. _currentSize2: number;
  82600. /** @hidden */
  82601. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  82602. /** @hidden */
  82603. _currentAngularSpeed1: number;
  82604. /** @hidden */
  82605. _currentAngularSpeed2: number;
  82606. /** @hidden */
  82607. _currentVelocityGradient: Nullable<FactorGradient>;
  82608. /** @hidden */
  82609. _currentVelocity1: number;
  82610. /** @hidden */
  82611. _currentVelocity2: number;
  82612. /** @hidden */
  82613. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  82614. /** @hidden */
  82615. _currentLimitVelocity1: number;
  82616. /** @hidden */
  82617. _currentLimitVelocity2: number;
  82618. /** @hidden */
  82619. _currentDragGradient: Nullable<FactorGradient>;
  82620. /** @hidden */
  82621. _currentDrag1: number;
  82622. /** @hidden */
  82623. _currentDrag2: number;
  82624. /** @hidden */
  82625. _randomNoiseCoordinates1: Vector3;
  82626. /** @hidden */
  82627. _randomNoiseCoordinates2: Vector3;
  82628. /**
  82629. * Creates a new instance Particle
  82630. * @param particleSystem the particle system the particle belongs to
  82631. */
  82632. constructor(
  82633. /**
  82634. * The particle system the particle belongs to.
  82635. */
  82636. particleSystem: ParticleSystem);
  82637. private updateCellInfoFromSystem;
  82638. /**
  82639. * Defines how the sprite cell index is updated for the particle
  82640. */
  82641. updateCellIndex(): void;
  82642. /** @hidden */
  82643. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  82644. /** @hidden */
  82645. _inheritParticleInfoToSubEmitters(): void;
  82646. /** @hidden */
  82647. _reset(): void;
  82648. /**
  82649. * Copy the properties of particle to another one.
  82650. * @param other the particle to copy the information to.
  82651. */
  82652. copyTo(other: Particle): void;
  82653. }
  82654. }
  82655. declare module BABYLON {
  82656. /**
  82657. * Particle emitter represents a volume emitting particles.
  82658. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  82659. */
  82660. export interface IParticleEmitterType {
  82661. /**
  82662. * Called by the particle System when the direction is computed for the created particle.
  82663. * @param worldMatrix is the world matrix of the particle system
  82664. * @param directionToUpdate is the direction vector to update with the result
  82665. * @param particle is the particle we are computed the direction for
  82666. */
  82667. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82668. /**
  82669. * Called by the particle System when the position is computed for the created particle.
  82670. * @param worldMatrix is the world matrix of the particle system
  82671. * @param positionToUpdate is the position vector to update with the result
  82672. * @param particle is the particle we are computed the position for
  82673. */
  82674. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  82675. /**
  82676. * Clones the current emitter and returns a copy of it
  82677. * @returns the new emitter
  82678. */
  82679. clone(): IParticleEmitterType;
  82680. /**
  82681. * Called by the GPUParticleSystem to setup the update shader
  82682. * @param effect defines the update shader
  82683. */
  82684. applyToShader(effect: Effect): void;
  82685. /**
  82686. * Returns a string to use to update the GPU particles update shader
  82687. * @returns the effect defines string
  82688. */
  82689. getEffectDefines(): string;
  82690. /**
  82691. * Returns a string representing the class name
  82692. * @returns a string containing the class name
  82693. */
  82694. getClassName(): string;
  82695. /**
  82696. * Serializes the particle system to a JSON object.
  82697. * @returns the JSON object
  82698. */
  82699. serialize(): any;
  82700. /**
  82701. * Parse properties from a JSON object
  82702. * @param serializationObject defines the JSON object
  82703. */
  82704. parse(serializationObject: any): void;
  82705. }
  82706. }
  82707. declare module BABYLON {
  82708. /**
  82709. * Particle emitter emitting particles from the inside of a box.
  82710. * It emits the particles randomly between 2 given directions.
  82711. */
  82712. export class BoxParticleEmitter implements IParticleEmitterType {
  82713. /**
  82714. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  82715. */
  82716. direction1: Vector3;
  82717. /**
  82718. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  82719. */
  82720. direction2: Vector3;
  82721. /**
  82722. * 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.
  82723. */
  82724. minEmitBox: Vector3;
  82725. /**
  82726. * 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.
  82727. */
  82728. maxEmitBox: Vector3;
  82729. /**
  82730. * Creates a new instance BoxParticleEmitter
  82731. */
  82732. constructor();
  82733. /**
  82734. * Called by the particle System when the direction is computed for the created particle.
  82735. * @param worldMatrix is the world matrix of the particle system
  82736. * @param directionToUpdate is the direction vector to update with the result
  82737. * @param particle is the particle we are computed the direction for
  82738. */
  82739. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82740. /**
  82741. * Called by the particle System when the position is computed for the created particle.
  82742. * @param worldMatrix is the world matrix of the particle system
  82743. * @param positionToUpdate is the position vector to update with the result
  82744. * @param particle is the particle we are computed the position for
  82745. */
  82746. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  82747. /**
  82748. * Clones the current emitter and returns a copy of it
  82749. * @returns the new emitter
  82750. */
  82751. clone(): BoxParticleEmitter;
  82752. /**
  82753. * Called by the GPUParticleSystem to setup the update shader
  82754. * @param effect defines the update shader
  82755. */
  82756. applyToShader(effect: Effect): void;
  82757. /**
  82758. * Returns a string to use to update the GPU particles update shader
  82759. * @returns a string containng the defines string
  82760. */
  82761. getEffectDefines(): string;
  82762. /**
  82763. * Returns the string "BoxParticleEmitter"
  82764. * @returns a string containing the class name
  82765. */
  82766. getClassName(): string;
  82767. /**
  82768. * Serializes the particle system to a JSON object.
  82769. * @returns the JSON object
  82770. */
  82771. serialize(): any;
  82772. /**
  82773. * Parse properties from a JSON object
  82774. * @param serializationObject defines the JSON object
  82775. */
  82776. parse(serializationObject: any): void;
  82777. }
  82778. }
  82779. declare module BABYLON {
  82780. /**
  82781. * Particle emitter emitting particles from the inside of a cone.
  82782. * It emits the particles alongside the cone volume from the base to the particle.
  82783. * The emission direction might be randomized.
  82784. */
  82785. export class ConeParticleEmitter implements IParticleEmitterType {
  82786. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  82787. directionRandomizer: number;
  82788. private _radius;
  82789. private _angle;
  82790. private _height;
  82791. /**
  82792. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  82793. */
  82794. radiusRange: number;
  82795. /**
  82796. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  82797. */
  82798. heightRange: number;
  82799. /**
  82800. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  82801. */
  82802. emitFromSpawnPointOnly: boolean;
  82803. /**
  82804. * Gets or sets the radius of the emission cone
  82805. */
  82806. radius: number;
  82807. /**
  82808. * Gets or sets the angle of the emission cone
  82809. */
  82810. angle: number;
  82811. private _buildHeight;
  82812. /**
  82813. * Creates a new instance ConeParticleEmitter
  82814. * @param radius the radius of the emission cone (1 by default)
  82815. * @param angle the cone base angle (PI by default)
  82816. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  82817. */
  82818. constructor(radius?: number, angle?: number,
  82819. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  82820. directionRandomizer?: number);
  82821. /**
  82822. * Called by the particle System when the direction is computed for the created particle.
  82823. * @param worldMatrix is the world matrix of the particle system
  82824. * @param directionToUpdate is the direction vector to update with the result
  82825. * @param particle is the particle we are computed the direction for
  82826. */
  82827. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82828. /**
  82829. * Called by the particle System when the position is computed for the created particle.
  82830. * @param worldMatrix is the world matrix of the particle system
  82831. * @param positionToUpdate is the position vector to update with the result
  82832. * @param particle is the particle we are computed the position for
  82833. */
  82834. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  82835. /**
  82836. * Clones the current emitter and returns a copy of it
  82837. * @returns the new emitter
  82838. */
  82839. clone(): ConeParticleEmitter;
  82840. /**
  82841. * Called by the GPUParticleSystem to setup the update shader
  82842. * @param effect defines the update shader
  82843. */
  82844. applyToShader(effect: Effect): void;
  82845. /**
  82846. * Returns a string to use to update the GPU particles update shader
  82847. * @returns a string containng the defines string
  82848. */
  82849. getEffectDefines(): string;
  82850. /**
  82851. * Returns the string "ConeParticleEmitter"
  82852. * @returns a string containing the class name
  82853. */
  82854. getClassName(): string;
  82855. /**
  82856. * Serializes the particle system to a JSON object.
  82857. * @returns the JSON object
  82858. */
  82859. serialize(): any;
  82860. /**
  82861. * Parse properties from a JSON object
  82862. * @param serializationObject defines the JSON object
  82863. */
  82864. parse(serializationObject: any): void;
  82865. }
  82866. }
  82867. declare module BABYLON {
  82868. /**
  82869. * Particle emitter emitting particles from the inside of a cylinder.
  82870. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  82871. */
  82872. export class CylinderParticleEmitter implements IParticleEmitterType {
  82873. /**
  82874. * The radius of the emission cylinder.
  82875. */
  82876. radius: number;
  82877. /**
  82878. * The height of the emission cylinder.
  82879. */
  82880. height: number;
  82881. /**
  82882. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  82883. */
  82884. radiusRange: number;
  82885. /**
  82886. * How much to randomize the particle direction [0-1].
  82887. */
  82888. directionRandomizer: number;
  82889. /**
  82890. * Creates a new instance CylinderParticleEmitter
  82891. * @param radius the radius of the emission cylinder (1 by default)
  82892. * @param height the height of the emission cylinder (1 by default)
  82893. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  82894. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  82895. */
  82896. constructor(
  82897. /**
  82898. * The radius of the emission cylinder.
  82899. */
  82900. radius?: number,
  82901. /**
  82902. * The height of the emission cylinder.
  82903. */
  82904. height?: number,
  82905. /**
  82906. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  82907. */
  82908. radiusRange?: number,
  82909. /**
  82910. * How much to randomize the particle direction [0-1].
  82911. */
  82912. directionRandomizer?: number);
  82913. /**
  82914. * Called by the particle System when the direction is computed for the created particle.
  82915. * @param worldMatrix is the world matrix of the particle system
  82916. * @param directionToUpdate is the direction vector to update with the result
  82917. * @param particle is the particle we are computed the direction for
  82918. */
  82919. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82920. /**
  82921. * Called by the particle System when the position is computed for the created particle.
  82922. * @param worldMatrix is the world matrix of the particle system
  82923. * @param positionToUpdate is the position vector to update with the result
  82924. * @param particle is the particle we are computed the position for
  82925. */
  82926. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  82927. /**
  82928. * Clones the current emitter and returns a copy of it
  82929. * @returns the new emitter
  82930. */
  82931. clone(): CylinderParticleEmitter;
  82932. /**
  82933. * Called by the GPUParticleSystem to setup the update shader
  82934. * @param effect defines the update shader
  82935. */
  82936. applyToShader(effect: Effect): void;
  82937. /**
  82938. * Returns a string to use to update the GPU particles update shader
  82939. * @returns a string containng the defines string
  82940. */
  82941. getEffectDefines(): string;
  82942. /**
  82943. * Returns the string "CylinderParticleEmitter"
  82944. * @returns a string containing the class name
  82945. */
  82946. getClassName(): string;
  82947. /**
  82948. * Serializes the particle system to a JSON object.
  82949. * @returns the JSON object
  82950. */
  82951. serialize(): any;
  82952. /**
  82953. * Parse properties from a JSON object
  82954. * @param serializationObject defines the JSON object
  82955. */
  82956. parse(serializationObject: any): void;
  82957. }
  82958. /**
  82959. * Particle emitter emitting particles from the inside of a cylinder.
  82960. * It emits the particles randomly between two vectors.
  82961. */
  82962. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  82963. /**
  82964. * The min limit of the emission direction.
  82965. */
  82966. direction1: Vector3;
  82967. /**
  82968. * The max limit of the emission direction.
  82969. */
  82970. direction2: Vector3;
  82971. /**
  82972. * Creates a new instance CylinderDirectedParticleEmitter
  82973. * @param radius the radius of the emission cylinder (1 by default)
  82974. * @param height the height of the emission cylinder (1 by default)
  82975. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  82976. * @param direction1 the min limit of the emission direction (up vector by default)
  82977. * @param direction2 the max limit of the emission direction (up vector by default)
  82978. */
  82979. constructor(radius?: number, height?: number, radiusRange?: number,
  82980. /**
  82981. * The min limit of the emission direction.
  82982. */
  82983. direction1?: Vector3,
  82984. /**
  82985. * The max limit of the emission direction.
  82986. */
  82987. direction2?: Vector3);
  82988. /**
  82989. * Called by the particle System when the direction is computed for the created particle.
  82990. * @param worldMatrix is the world matrix of the particle system
  82991. * @param directionToUpdate is the direction vector to update with the result
  82992. * @param particle is the particle we are computed the direction for
  82993. */
  82994. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82995. /**
  82996. * Clones the current emitter and returns a copy of it
  82997. * @returns the new emitter
  82998. */
  82999. clone(): CylinderDirectedParticleEmitter;
  83000. /**
  83001. * Called by the GPUParticleSystem to setup the update shader
  83002. * @param effect defines the update shader
  83003. */
  83004. applyToShader(effect: Effect): void;
  83005. /**
  83006. * Returns a string to use to update the GPU particles update shader
  83007. * @returns a string containng the defines string
  83008. */
  83009. getEffectDefines(): string;
  83010. /**
  83011. * Returns the string "CylinderDirectedParticleEmitter"
  83012. * @returns a string containing the class name
  83013. */
  83014. getClassName(): string;
  83015. /**
  83016. * Serializes the particle system to a JSON object.
  83017. * @returns the JSON object
  83018. */
  83019. serialize(): any;
  83020. /**
  83021. * Parse properties from a JSON object
  83022. * @param serializationObject defines the JSON object
  83023. */
  83024. parse(serializationObject: any): void;
  83025. }
  83026. }
  83027. declare module BABYLON {
  83028. /**
  83029. * Particle emitter emitting particles from the inside of a hemisphere.
  83030. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  83031. */
  83032. export class HemisphericParticleEmitter implements IParticleEmitterType {
  83033. /**
  83034. * The radius of the emission hemisphere.
  83035. */
  83036. radius: number;
  83037. /**
  83038. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83039. */
  83040. radiusRange: number;
  83041. /**
  83042. * How much to randomize the particle direction [0-1].
  83043. */
  83044. directionRandomizer: number;
  83045. /**
  83046. * Creates a new instance HemisphericParticleEmitter
  83047. * @param radius the radius of the emission hemisphere (1 by default)
  83048. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83049. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  83050. */
  83051. constructor(
  83052. /**
  83053. * The radius of the emission hemisphere.
  83054. */
  83055. radius?: number,
  83056. /**
  83057. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83058. */
  83059. radiusRange?: number,
  83060. /**
  83061. * How much to randomize the particle direction [0-1].
  83062. */
  83063. directionRandomizer?: number);
  83064. /**
  83065. * Called by the particle System when the direction is computed for the created particle.
  83066. * @param worldMatrix is the world matrix of the particle system
  83067. * @param directionToUpdate is the direction vector to update with the result
  83068. * @param particle is the particle we are computed the direction for
  83069. */
  83070. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83071. /**
  83072. * Called by the particle System when the position is computed for the created particle.
  83073. * @param worldMatrix is the world matrix of the particle system
  83074. * @param positionToUpdate is the position vector to update with the result
  83075. * @param particle is the particle we are computed the position for
  83076. */
  83077. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83078. /**
  83079. * Clones the current emitter and returns a copy of it
  83080. * @returns the new emitter
  83081. */
  83082. clone(): HemisphericParticleEmitter;
  83083. /**
  83084. * Called by the GPUParticleSystem to setup the update shader
  83085. * @param effect defines the update shader
  83086. */
  83087. applyToShader(effect: Effect): void;
  83088. /**
  83089. * Returns a string to use to update the GPU particles update shader
  83090. * @returns a string containng the defines string
  83091. */
  83092. getEffectDefines(): string;
  83093. /**
  83094. * Returns the string "HemisphericParticleEmitter"
  83095. * @returns a string containing the class name
  83096. */
  83097. getClassName(): string;
  83098. /**
  83099. * Serializes the particle system to a JSON object.
  83100. * @returns the JSON object
  83101. */
  83102. serialize(): any;
  83103. /**
  83104. * Parse properties from a JSON object
  83105. * @param serializationObject defines the JSON object
  83106. */
  83107. parse(serializationObject: any): void;
  83108. }
  83109. }
  83110. declare module BABYLON {
  83111. /**
  83112. * Particle emitter emitting particles from a point.
  83113. * It emits the particles randomly between 2 given directions.
  83114. */
  83115. export class PointParticleEmitter implements IParticleEmitterType {
  83116. /**
  83117. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83118. */
  83119. direction1: Vector3;
  83120. /**
  83121. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83122. */
  83123. direction2: Vector3;
  83124. /**
  83125. * Creates a new instance PointParticleEmitter
  83126. */
  83127. constructor();
  83128. /**
  83129. * Called by the particle System when the direction is computed for the created particle.
  83130. * @param worldMatrix is the world matrix of the particle system
  83131. * @param directionToUpdate is the direction vector to update with the result
  83132. * @param particle is the particle we are computed the direction for
  83133. */
  83134. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83135. /**
  83136. * Called by the particle System when the position is computed for the created particle.
  83137. * @param worldMatrix is the world matrix of the particle system
  83138. * @param positionToUpdate is the position vector to update with the result
  83139. * @param particle is the particle we are computed the position for
  83140. */
  83141. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83142. /**
  83143. * Clones the current emitter and returns a copy of it
  83144. * @returns the new emitter
  83145. */
  83146. clone(): PointParticleEmitter;
  83147. /**
  83148. * Called by the GPUParticleSystem to setup the update shader
  83149. * @param effect defines the update shader
  83150. */
  83151. applyToShader(effect: Effect): void;
  83152. /**
  83153. * Returns a string to use to update the GPU particles update shader
  83154. * @returns a string containng the defines string
  83155. */
  83156. getEffectDefines(): string;
  83157. /**
  83158. * Returns the string "PointParticleEmitter"
  83159. * @returns a string containing the class name
  83160. */
  83161. getClassName(): string;
  83162. /**
  83163. * Serializes the particle system to a JSON object.
  83164. * @returns the JSON object
  83165. */
  83166. serialize(): any;
  83167. /**
  83168. * Parse properties from a JSON object
  83169. * @param serializationObject defines the JSON object
  83170. */
  83171. parse(serializationObject: any): void;
  83172. }
  83173. }
  83174. declare module BABYLON {
  83175. /**
  83176. * Particle emitter emitting particles from the inside of a sphere.
  83177. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  83178. */
  83179. export class SphereParticleEmitter implements IParticleEmitterType {
  83180. /**
  83181. * The radius of the emission sphere.
  83182. */
  83183. radius: number;
  83184. /**
  83185. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83186. */
  83187. radiusRange: number;
  83188. /**
  83189. * How much to randomize the particle direction [0-1].
  83190. */
  83191. directionRandomizer: number;
  83192. /**
  83193. * Creates a new instance SphereParticleEmitter
  83194. * @param radius the radius of the emission sphere (1 by default)
  83195. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83196. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  83197. */
  83198. constructor(
  83199. /**
  83200. * The radius of the emission sphere.
  83201. */
  83202. radius?: number,
  83203. /**
  83204. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83205. */
  83206. radiusRange?: number,
  83207. /**
  83208. * How much to randomize the particle direction [0-1].
  83209. */
  83210. directionRandomizer?: number);
  83211. /**
  83212. * Called by the particle System when the direction is computed for the created particle.
  83213. * @param worldMatrix is the world matrix of the particle system
  83214. * @param directionToUpdate is the direction vector to update with the result
  83215. * @param particle is the particle we are computed the direction for
  83216. */
  83217. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83218. /**
  83219. * Called by the particle System when the position is computed for the created particle.
  83220. * @param worldMatrix is the world matrix of the particle system
  83221. * @param positionToUpdate is the position vector to update with the result
  83222. * @param particle is the particle we are computed the position for
  83223. */
  83224. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83225. /**
  83226. * Clones the current emitter and returns a copy of it
  83227. * @returns the new emitter
  83228. */
  83229. clone(): SphereParticleEmitter;
  83230. /**
  83231. * Called by the GPUParticleSystem to setup the update shader
  83232. * @param effect defines the update shader
  83233. */
  83234. applyToShader(effect: Effect): void;
  83235. /**
  83236. * Returns a string to use to update the GPU particles update shader
  83237. * @returns a string containng the defines string
  83238. */
  83239. getEffectDefines(): string;
  83240. /**
  83241. * Returns the string "SphereParticleEmitter"
  83242. * @returns a string containing the class name
  83243. */
  83244. getClassName(): string;
  83245. /**
  83246. * Serializes the particle system to a JSON object.
  83247. * @returns the JSON object
  83248. */
  83249. serialize(): any;
  83250. /**
  83251. * Parse properties from a JSON object
  83252. * @param serializationObject defines the JSON object
  83253. */
  83254. parse(serializationObject: any): void;
  83255. }
  83256. /**
  83257. * Particle emitter emitting particles from the inside of a sphere.
  83258. * It emits the particles randomly between two vectors.
  83259. */
  83260. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  83261. /**
  83262. * The min limit of the emission direction.
  83263. */
  83264. direction1: Vector3;
  83265. /**
  83266. * The max limit of the emission direction.
  83267. */
  83268. direction2: Vector3;
  83269. /**
  83270. * Creates a new instance SphereDirectedParticleEmitter
  83271. * @param radius the radius of the emission sphere (1 by default)
  83272. * @param direction1 the min limit of the emission direction (up vector by default)
  83273. * @param direction2 the max limit of the emission direction (up vector by default)
  83274. */
  83275. constructor(radius?: number,
  83276. /**
  83277. * The min limit of the emission direction.
  83278. */
  83279. direction1?: Vector3,
  83280. /**
  83281. * The max limit of the emission direction.
  83282. */
  83283. direction2?: Vector3);
  83284. /**
  83285. * Called by the particle System when the direction is computed for the created particle.
  83286. * @param worldMatrix is the world matrix of the particle system
  83287. * @param directionToUpdate is the direction vector to update with the result
  83288. * @param particle is the particle we are computed the direction for
  83289. */
  83290. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83291. /**
  83292. * Clones the current emitter and returns a copy of it
  83293. * @returns the new emitter
  83294. */
  83295. clone(): SphereDirectedParticleEmitter;
  83296. /**
  83297. * Called by the GPUParticleSystem to setup the update shader
  83298. * @param effect defines the update shader
  83299. */
  83300. applyToShader(effect: Effect): void;
  83301. /**
  83302. * Returns a string to use to update the GPU particles update shader
  83303. * @returns a string containng the defines string
  83304. */
  83305. getEffectDefines(): string;
  83306. /**
  83307. * Returns the string "SphereDirectedParticleEmitter"
  83308. * @returns a string containing the class name
  83309. */
  83310. getClassName(): string;
  83311. /**
  83312. * Serializes the particle system to a JSON object.
  83313. * @returns the JSON object
  83314. */
  83315. serialize(): any;
  83316. /**
  83317. * Parse properties from a JSON object
  83318. * @param serializationObject defines the JSON object
  83319. */
  83320. parse(serializationObject: any): void;
  83321. }
  83322. }
  83323. declare module BABYLON {
  83324. /**
  83325. * Interface representing a particle system in Babylon.js.
  83326. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  83327. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  83328. */
  83329. export interface IParticleSystem {
  83330. /**
  83331. * List of animations used by the particle system.
  83332. */
  83333. animations: Animation[];
  83334. /**
  83335. * The id of the Particle system.
  83336. */
  83337. id: string;
  83338. /**
  83339. * The name of the Particle system.
  83340. */
  83341. name: string;
  83342. /**
  83343. * The emitter represents the Mesh or position we are attaching the particle system to.
  83344. */
  83345. emitter: Nullable<AbstractMesh | Vector3>;
  83346. /**
  83347. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  83348. */
  83349. isBillboardBased: boolean;
  83350. /**
  83351. * The rendering group used by the Particle system to chose when to render.
  83352. */
  83353. renderingGroupId: number;
  83354. /**
  83355. * The layer mask we are rendering the particles through.
  83356. */
  83357. layerMask: number;
  83358. /**
  83359. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  83360. */
  83361. updateSpeed: number;
  83362. /**
  83363. * The amount of time the particle system is running (depends of the overall update speed).
  83364. */
  83365. targetStopDuration: number;
  83366. /**
  83367. * The texture used to render each particle. (this can be a spritesheet)
  83368. */
  83369. particleTexture: Nullable<Texture>;
  83370. /**
  83371. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  83372. */
  83373. blendMode: number;
  83374. /**
  83375. * Minimum life time of emitting particles.
  83376. */
  83377. minLifeTime: number;
  83378. /**
  83379. * Maximum life time of emitting particles.
  83380. */
  83381. maxLifeTime: number;
  83382. /**
  83383. * Minimum Size of emitting particles.
  83384. */
  83385. minSize: number;
  83386. /**
  83387. * Maximum Size of emitting particles.
  83388. */
  83389. maxSize: number;
  83390. /**
  83391. * Minimum scale of emitting particles on X axis.
  83392. */
  83393. minScaleX: number;
  83394. /**
  83395. * Maximum scale of emitting particles on X axis.
  83396. */
  83397. maxScaleX: number;
  83398. /**
  83399. * Minimum scale of emitting particles on Y axis.
  83400. */
  83401. minScaleY: number;
  83402. /**
  83403. * Maximum scale of emitting particles on Y axis.
  83404. */
  83405. maxScaleY: number;
  83406. /**
  83407. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  83408. */
  83409. color1: Color4;
  83410. /**
  83411. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  83412. */
  83413. color2: Color4;
  83414. /**
  83415. * Color the particle will have at the end of its lifetime.
  83416. */
  83417. colorDead: Color4;
  83418. /**
  83419. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  83420. */
  83421. emitRate: number;
  83422. /**
  83423. * You can use gravity if you want to give an orientation to your particles.
  83424. */
  83425. gravity: Vector3;
  83426. /**
  83427. * Minimum power of emitting particles.
  83428. */
  83429. minEmitPower: number;
  83430. /**
  83431. * Maximum power of emitting particles.
  83432. */
  83433. maxEmitPower: number;
  83434. /**
  83435. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  83436. */
  83437. minAngularSpeed: number;
  83438. /**
  83439. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  83440. */
  83441. maxAngularSpeed: number;
  83442. /**
  83443. * Gets or sets the minimal initial rotation in radians.
  83444. */
  83445. minInitialRotation: number;
  83446. /**
  83447. * Gets or sets the maximal initial rotation in radians.
  83448. */
  83449. maxInitialRotation: number;
  83450. /**
  83451. * The particle emitter type defines the emitter used by the particle system.
  83452. * It can be for example box, sphere, or cone...
  83453. */
  83454. particleEmitterType: Nullable<IParticleEmitterType>;
  83455. /**
  83456. * Defines the delay in milliseconds before starting the system (0 by default)
  83457. */
  83458. startDelay: number;
  83459. /**
  83460. * 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
  83461. */
  83462. preWarmCycles: number;
  83463. /**
  83464. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  83465. */
  83466. preWarmStepOffset: number;
  83467. /**
  83468. * 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)
  83469. */
  83470. spriteCellChangeSpeed: number;
  83471. /**
  83472. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  83473. */
  83474. startSpriteCellID: number;
  83475. /**
  83476. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  83477. */
  83478. endSpriteCellID: number;
  83479. /**
  83480. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  83481. */
  83482. spriteCellWidth: number;
  83483. /**
  83484. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  83485. */
  83486. spriteCellHeight: number;
  83487. /**
  83488. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  83489. */
  83490. spriteRandomStartCell: boolean;
  83491. /**
  83492. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  83493. */
  83494. isAnimationSheetEnabled: boolean;
  83495. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  83496. translationPivot: Vector2;
  83497. /**
  83498. * Gets or sets a texture used to add random noise to particle positions
  83499. */
  83500. noiseTexture: Nullable<BaseTexture>;
  83501. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  83502. noiseStrength: Vector3;
  83503. /**
  83504. * Gets or sets the billboard mode to use when isBillboardBased = true.
  83505. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  83506. */
  83507. billboardMode: number;
  83508. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  83509. limitVelocityDamping: number;
  83510. /**
  83511. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  83512. */
  83513. beginAnimationOnStart: boolean;
  83514. /**
  83515. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  83516. */
  83517. beginAnimationFrom: number;
  83518. /**
  83519. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  83520. */
  83521. beginAnimationTo: number;
  83522. /**
  83523. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  83524. */
  83525. beginAnimationLoop: boolean;
  83526. /**
  83527. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  83528. */
  83529. disposeOnStop: boolean;
  83530. /**
  83531. * Gets the maximum number of particles active at the same time.
  83532. * @returns The max number of active particles.
  83533. */
  83534. getCapacity(): number;
  83535. /**
  83536. * Gets if the system has been started. (Note: this will still be true after stop is called)
  83537. * @returns True if it has been started, otherwise false.
  83538. */
  83539. isStarted(): boolean;
  83540. /**
  83541. * Animates the particle system for this frame.
  83542. */
  83543. animate(): void;
  83544. /**
  83545. * Renders the particle system in its current state.
  83546. * @returns the current number of particles
  83547. */
  83548. render(): number;
  83549. /**
  83550. * Dispose the particle system and frees its associated resources.
  83551. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  83552. */
  83553. dispose(disposeTexture?: boolean): void;
  83554. /**
  83555. * Clones the particle system.
  83556. * @param name The name of the cloned object
  83557. * @param newEmitter The new emitter to use
  83558. * @returns the cloned particle system
  83559. */
  83560. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  83561. /**
  83562. * Serializes the particle system to a JSON object.
  83563. * @returns the JSON object
  83564. */
  83565. serialize(): any;
  83566. /**
  83567. * Rebuild the particle system
  83568. */
  83569. rebuild(): void;
  83570. /**
  83571. * Starts the particle system and begins to emit
  83572. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  83573. */
  83574. start(delay?: number): void;
  83575. /**
  83576. * Stops the particle system.
  83577. */
  83578. stop(): void;
  83579. /**
  83580. * Remove all active particles
  83581. */
  83582. reset(): void;
  83583. /**
  83584. * Is this system ready to be used/rendered
  83585. * @return true if the system is ready
  83586. */
  83587. isReady(): boolean;
  83588. /**
  83589. * Adds a new color gradient
  83590. * @param gradient defines the gradient to use (between 0 and 1)
  83591. * @param color1 defines the color to affect to the specified gradient
  83592. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  83593. * @returns the current particle system
  83594. */
  83595. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  83596. /**
  83597. * Remove a specific color gradient
  83598. * @param gradient defines the gradient to remove
  83599. * @returns the current particle system
  83600. */
  83601. removeColorGradient(gradient: number): IParticleSystem;
  83602. /**
  83603. * Adds a new size gradient
  83604. * @param gradient defines the gradient to use (between 0 and 1)
  83605. * @param factor defines the size factor to affect to the specified gradient
  83606. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83607. * @returns the current particle system
  83608. */
  83609. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83610. /**
  83611. * Remove a specific size gradient
  83612. * @param gradient defines the gradient to remove
  83613. * @returns the current particle system
  83614. */
  83615. removeSizeGradient(gradient: number): IParticleSystem;
  83616. /**
  83617. * Gets the current list of color gradients.
  83618. * You must use addColorGradient and removeColorGradient to udpate this list
  83619. * @returns the list of color gradients
  83620. */
  83621. getColorGradients(): Nullable<Array<ColorGradient>>;
  83622. /**
  83623. * Gets the current list of size gradients.
  83624. * You must use addSizeGradient and removeSizeGradient to udpate this list
  83625. * @returns the list of size gradients
  83626. */
  83627. getSizeGradients(): Nullable<Array<FactorGradient>>;
  83628. /**
  83629. * Gets the current list of angular speed gradients.
  83630. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  83631. * @returns the list of angular speed gradients
  83632. */
  83633. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  83634. /**
  83635. * Adds a new angular speed gradient
  83636. * @param gradient defines the gradient to use (between 0 and 1)
  83637. * @param factor defines the angular speed to affect to the specified gradient
  83638. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83639. * @returns the current particle system
  83640. */
  83641. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83642. /**
  83643. * Remove a specific angular speed gradient
  83644. * @param gradient defines the gradient to remove
  83645. * @returns the current particle system
  83646. */
  83647. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  83648. /**
  83649. * Gets the current list of velocity gradients.
  83650. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  83651. * @returns the list of velocity gradients
  83652. */
  83653. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  83654. /**
  83655. * Adds a new velocity gradient
  83656. * @param gradient defines the gradient to use (between 0 and 1)
  83657. * @param factor defines the velocity to affect to the specified gradient
  83658. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83659. * @returns the current particle system
  83660. */
  83661. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83662. /**
  83663. * Remove a specific velocity gradient
  83664. * @param gradient defines the gradient to remove
  83665. * @returns the current particle system
  83666. */
  83667. removeVelocityGradient(gradient: number): IParticleSystem;
  83668. /**
  83669. * Gets the current list of limit velocity gradients.
  83670. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  83671. * @returns the list of limit velocity gradients
  83672. */
  83673. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  83674. /**
  83675. * Adds a new limit velocity gradient
  83676. * @param gradient defines the gradient to use (between 0 and 1)
  83677. * @param factor defines the limit velocity to affect to the specified gradient
  83678. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83679. * @returns the current particle system
  83680. */
  83681. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83682. /**
  83683. * Remove a specific limit velocity gradient
  83684. * @param gradient defines the gradient to remove
  83685. * @returns the current particle system
  83686. */
  83687. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  83688. /**
  83689. * Adds a new drag gradient
  83690. * @param gradient defines the gradient to use (between 0 and 1)
  83691. * @param factor defines the drag to affect to the specified gradient
  83692. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83693. * @returns the current particle system
  83694. */
  83695. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83696. /**
  83697. * Remove a specific drag gradient
  83698. * @param gradient defines the gradient to remove
  83699. * @returns the current particle system
  83700. */
  83701. removeDragGradient(gradient: number): IParticleSystem;
  83702. /**
  83703. * Gets the current list of drag gradients.
  83704. * You must use addDragGradient and removeDragGradient to udpate this list
  83705. * @returns the list of drag gradients
  83706. */
  83707. getDragGradients(): Nullable<Array<FactorGradient>>;
  83708. /**
  83709. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  83710. * @param gradient defines the gradient to use (between 0 and 1)
  83711. * @param factor defines the emit rate to affect to the specified gradient
  83712. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83713. * @returns the current particle system
  83714. */
  83715. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83716. /**
  83717. * Remove a specific emit rate gradient
  83718. * @param gradient defines the gradient to remove
  83719. * @returns the current particle system
  83720. */
  83721. removeEmitRateGradient(gradient: number): IParticleSystem;
  83722. /**
  83723. * Gets the current list of emit rate gradients.
  83724. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  83725. * @returns the list of emit rate gradients
  83726. */
  83727. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  83728. /**
  83729. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  83730. * @param gradient defines the gradient to use (between 0 and 1)
  83731. * @param factor defines the start size to affect to the specified gradient
  83732. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83733. * @returns the current particle system
  83734. */
  83735. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83736. /**
  83737. * Remove a specific start size gradient
  83738. * @param gradient defines the gradient to remove
  83739. * @returns the current particle system
  83740. */
  83741. removeStartSizeGradient(gradient: number): IParticleSystem;
  83742. /**
  83743. * Gets the current list of start size gradients.
  83744. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  83745. * @returns the list of start size gradients
  83746. */
  83747. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  83748. /**
  83749. * Adds a new life time gradient
  83750. * @param gradient defines the gradient to use (between 0 and 1)
  83751. * @param factor defines the life time factor to affect to the specified gradient
  83752. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83753. * @returns the current particle system
  83754. */
  83755. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83756. /**
  83757. * Remove a specific life time gradient
  83758. * @param gradient defines the gradient to remove
  83759. * @returns the current particle system
  83760. */
  83761. removeLifeTimeGradient(gradient: number): IParticleSystem;
  83762. /**
  83763. * Gets the current list of life time gradients.
  83764. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  83765. * @returns the list of life time gradients
  83766. */
  83767. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  83768. /**
  83769. * Gets the current list of color gradients.
  83770. * You must use addColorGradient and removeColorGradient to udpate this list
  83771. * @returns the list of color gradients
  83772. */
  83773. getColorGradients(): Nullable<Array<ColorGradient>>;
  83774. /**
  83775. * Adds a new ramp gradient used to remap particle colors
  83776. * @param gradient defines the gradient to use (between 0 and 1)
  83777. * @param color defines the color to affect to the specified gradient
  83778. * @returns the current particle system
  83779. */
  83780. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  83781. /**
  83782. * Gets the current list of ramp gradients.
  83783. * You must use addRampGradient and removeRampGradient to udpate this list
  83784. * @returns the list of ramp gradients
  83785. */
  83786. getRampGradients(): Nullable<Array<Color3Gradient>>;
  83787. /** Gets or sets a boolean indicating that ramp gradients must be used
  83788. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  83789. */
  83790. useRampGradients: boolean;
  83791. /**
  83792. * Adds a new color remap gradient
  83793. * @param gradient defines the gradient to use (between 0 and 1)
  83794. * @param min defines the color remap minimal range
  83795. * @param max defines the color remap maximal range
  83796. * @returns the current particle system
  83797. */
  83798. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  83799. /**
  83800. * Gets the current list of color remap gradients.
  83801. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  83802. * @returns the list of color remap gradients
  83803. */
  83804. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  83805. /**
  83806. * Adds a new alpha remap gradient
  83807. * @param gradient defines the gradient to use (between 0 and 1)
  83808. * @param min defines the alpha remap minimal range
  83809. * @param max defines the alpha remap maximal range
  83810. * @returns the current particle system
  83811. */
  83812. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  83813. /**
  83814. * Gets the current list of alpha remap gradients.
  83815. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  83816. * @returns the list of alpha remap gradients
  83817. */
  83818. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  83819. /**
  83820. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  83821. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  83822. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  83823. * @returns the emitter
  83824. */
  83825. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  83826. /**
  83827. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  83828. * @param radius The radius of the hemisphere to emit from
  83829. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  83830. * @returns the emitter
  83831. */
  83832. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  83833. /**
  83834. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  83835. * @param radius The radius of the sphere to emit from
  83836. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  83837. * @returns the emitter
  83838. */
  83839. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  83840. /**
  83841. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  83842. * @param radius The radius of the sphere to emit from
  83843. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  83844. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  83845. * @returns the emitter
  83846. */
  83847. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  83848. /**
  83849. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  83850. * @param radius The radius of the emission cylinder
  83851. * @param height The height of the emission cylinder
  83852. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  83853. * @param directionRandomizer How much to randomize the particle direction [0-1]
  83854. * @returns the emitter
  83855. */
  83856. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  83857. /**
  83858. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  83859. * @param radius The radius of the cylinder to emit from
  83860. * @param height The height of the emission cylinder
  83861. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83862. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  83863. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  83864. * @returns the emitter
  83865. */
  83866. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  83867. /**
  83868. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  83869. * @param radius The radius of the cone to emit from
  83870. * @param angle The base angle of the cone
  83871. * @returns the emitter
  83872. */
  83873. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  83874. /**
  83875. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  83876. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  83877. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  83878. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  83879. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  83880. * @returns the emitter
  83881. */
  83882. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  83883. /**
  83884. * Get hosting scene
  83885. * @returns the scene
  83886. */
  83887. getScene(): Scene;
  83888. }
  83889. }
  83890. declare module BABYLON {
  83891. /** @hidden */
  83892. export var linePixelShader: {
  83893. name: string;
  83894. shader: string;
  83895. };
  83896. }
  83897. declare module BABYLON {
  83898. /** @hidden */
  83899. export var lineVertexShader: {
  83900. name: string;
  83901. shader: string;
  83902. };
  83903. }
  83904. declare module BABYLON {
  83905. interface AbstractMesh {
  83906. /**
  83907. * Gets the edgesRenderer associated with the mesh
  83908. */
  83909. edgesRenderer: Nullable<EdgesRenderer>;
  83910. }
  83911. interface LinesMesh {
  83912. /**
  83913. * Enables the edge rendering mode on the mesh.
  83914. * This mode makes the mesh edges visible
  83915. * @param epsilon defines the maximal distance between two angles to detect a face
  83916. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  83917. * @returns the currentAbstractMesh
  83918. * @see https://www.babylonjs-playground.com/#19O9TU#0
  83919. */
  83920. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  83921. }
  83922. interface InstancedLinesMesh {
  83923. /**
  83924. * Enables the edge rendering mode on the mesh.
  83925. * This mode makes the mesh edges visible
  83926. * @param epsilon defines the maximal distance between two angles to detect a face
  83927. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  83928. * @returns the current InstancedLinesMesh
  83929. * @see https://www.babylonjs-playground.com/#19O9TU#0
  83930. */
  83931. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  83932. }
  83933. /**
  83934. * Defines the minimum contract an Edges renderer should follow.
  83935. */
  83936. export interface IEdgesRenderer extends IDisposable {
  83937. /**
  83938. * Gets or sets a boolean indicating if the edgesRenderer is active
  83939. */
  83940. isEnabled: boolean;
  83941. /**
  83942. * Renders the edges of the attached mesh,
  83943. */
  83944. render(): void;
  83945. /**
  83946. * Checks wether or not the edges renderer is ready to render.
  83947. * @return true if ready, otherwise false.
  83948. */
  83949. isReady(): boolean;
  83950. }
  83951. /**
  83952. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  83953. */
  83954. export class EdgesRenderer implements IEdgesRenderer {
  83955. /**
  83956. * Define the size of the edges with an orthographic camera
  83957. */
  83958. edgesWidthScalerForOrthographic: number;
  83959. /**
  83960. * Define the size of the edges with a perspective camera
  83961. */
  83962. edgesWidthScalerForPerspective: number;
  83963. protected _source: AbstractMesh;
  83964. protected _linesPositions: number[];
  83965. protected _linesNormals: number[];
  83966. protected _linesIndices: number[];
  83967. protected _epsilon: number;
  83968. protected _indicesCount: number;
  83969. protected _lineShader: ShaderMaterial;
  83970. protected _ib: DataBuffer;
  83971. protected _buffers: {
  83972. [key: string]: Nullable<VertexBuffer>;
  83973. };
  83974. protected _checkVerticesInsteadOfIndices: boolean;
  83975. private _meshRebuildObserver;
  83976. private _meshDisposeObserver;
  83977. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  83978. isEnabled: boolean;
  83979. /**
  83980. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  83981. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  83982. * @param source Mesh used to create edges
  83983. * @param epsilon sum of angles in adjacency to check for edge
  83984. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  83985. * @param generateEdgesLines - should generate Lines or only prepare resources.
  83986. */
  83987. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  83988. protected _prepareRessources(): void;
  83989. /** @hidden */
  83990. _rebuild(): void;
  83991. /**
  83992. * Releases the required resources for the edges renderer
  83993. */
  83994. dispose(): void;
  83995. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  83996. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  83997. /**
  83998. * Checks if the pair of p0 and p1 is en edge
  83999. * @param faceIndex
  84000. * @param edge
  84001. * @param faceNormals
  84002. * @param p0
  84003. * @param p1
  84004. * @private
  84005. */
  84006. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  84007. /**
  84008. * push line into the position, normal and index buffer
  84009. * @protected
  84010. */
  84011. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  84012. /**
  84013. * Generates lines edges from adjacencjes
  84014. * @private
  84015. */
  84016. _generateEdgesLines(): void;
  84017. /**
  84018. * Checks wether or not the edges renderer is ready to render.
  84019. * @return true if ready, otherwise false.
  84020. */
  84021. isReady(): boolean;
  84022. /**
  84023. * Renders the edges of the attached mesh,
  84024. */
  84025. render(): void;
  84026. }
  84027. /**
  84028. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  84029. */
  84030. export class LineEdgesRenderer extends EdgesRenderer {
  84031. /**
  84032. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  84033. * @param source LineMesh used to generate edges
  84034. * @param epsilon not important (specified angle for edge detection)
  84035. * @param checkVerticesInsteadOfIndices not important for LineMesh
  84036. */
  84037. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  84038. /**
  84039. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  84040. */
  84041. _generateEdgesLines(): void;
  84042. }
  84043. }
  84044. declare module BABYLON {
  84045. /**
  84046. * This represents the object necessary to create a rendering group.
  84047. * This is exclusively used and created by the rendering manager.
  84048. * To modify the behavior, you use the available helpers in your scene or meshes.
  84049. * @hidden
  84050. */
  84051. export class RenderingGroup {
  84052. index: number;
  84053. private static _zeroVector;
  84054. private _scene;
  84055. private _opaqueSubMeshes;
  84056. private _transparentSubMeshes;
  84057. private _alphaTestSubMeshes;
  84058. private _depthOnlySubMeshes;
  84059. private _particleSystems;
  84060. private _spriteManagers;
  84061. private _opaqueSortCompareFn;
  84062. private _alphaTestSortCompareFn;
  84063. private _transparentSortCompareFn;
  84064. private _renderOpaque;
  84065. private _renderAlphaTest;
  84066. private _renderTransparent;
  84067. /** @hidden */
  84068. _edgesRenderers: SmartArray<IEdgesRenderer>;
  84069. onBeforeTransparentRendering: () => void;
  84070. /**
  84071. * Set the opaque sort comparison function.
  84072. * If null the sub meshes will be render in the order they were created
  84073. */
  84074. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  84075. /**
  84076. * Set the alpha test sort comparison function.
  84077. * If null the sub meshes will be render in the order they were created
  84078. */
  84079. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  84080. /**
  84081. * Set the transparent sort comparison function.
  84082. * If null the sub meshes will be render in the order they were created
  84083. */
  84084. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  84085. /**
  84086. * Creates a new rendering group.
  84087. * @param index The rendering group index
  84088. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  84089. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  84090. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  84091. */
  84092. 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>);
  84093. /**
  84094. * Render all the sub meshes contained in the group.
  84095. * @param customRenderFunction Used to override the default render behaviour of the group.
  84096. * @returns true if rendered some submeshes.
  84097. */
  84098. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  84099. /**
  84100. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  84101. * @param subMeshes The submeshes to render
  84102. */
  84103. private renderOpaqueSorted;
  84104. /**
  84105. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  84106. * @param subMeshes The submeshes to render
  84107. */
  84108. private renderAlphaTestSorted;
  84109. /**
  84110. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  84111. * @param subMeshes The submeshes to render
  84112. */
  84113. private renderTransparentSorted;
  84114. /**
  84115. * Renders the submeshes in a specified order.
  84116. * @param subMeshes The submeshes to sort before render
  84117. * @param sortCompareFn The comparison function use to sort
  84118. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  84119. * @param transparent Specifies to activate blending if true
  84120. */
  84121. private static renderSorted;
  84122. /**
  84123. * Renders the submeshes in the order they were dispatched (no sort applied).
  84124. * @param subMeshes The submeshes to render
  84125. */
  84126. private static renderUnsorted;
  84127. /**
  84128. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  84129. * are rendered back to front if in the same alpha index.
  84130. *
  84131. * @param a The first submesh
  84132. * @param b The second submesh
  84133. * @returns The result of the comparison
  84134. */
  84135. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  84136. /**
  84137. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  84138. * are rendered back to front.
  84139. *
  84140. * @param a The first submesh
  84141. * @param b The second submesh
  84142. * @returns The result of the comparison
  84143. */
  84144. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  84145. /**
  84146. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  84147. * are rendered front to back (prevent overdraw).
  84148. *
  84149. * @param a The first submesh
  84150. * @param b The second submesh
  84151. * @returns The result of the comparison
  84152. */
  84153. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  84154. /**
  84155. * Resets the different lists of submeshes to prepare a new frame.
  84156. */
  84157. prepare(): void;
  84158. dispose(): void;
  84159. /**
  84160. * Inserts the submesh in its correct queue depending on its material.
  84161. * @param subMesh The submesh to dispatch
  84162. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  84163. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  84164. */
  84165. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  84166. dispatchSprites(spriteManager: ISpriteManager): void;
  84167. dispatchParticles(particleSystem: IParticleSystem): void;
  84168. private _renderParticles;
  84169. private _renderSprites;
  84170. }
  84171. }
  84172. declare module BABYLON {
  84173. /**
  84174. * Interface describing the different options available in the rendering manager
  84175. * regarding Auto Clear between groups.
  84176. */
  84177. export interface IRenderingManagerAutoClearSetup {
  84178. /**
  84179. * Defines whether or not autoclear is enable.
  84180. */
  84181. autoClear: boolean;
  84182. /**
  84183. * Defines whether or not to autoclear the depth buffer.
  84184. */
  84185. depth: boolean;
  84186. /**
  84187. * Defines whether or not to autoclear the stencil buffer.
  84188. */
  84189. stencil: boolean;
  84190. }
  84191. /**
  84192. * This class is used by the onRenderingGroupObservable
  84193. */
  84194. export class RenderingGroupInfo {
  84195. /**
  84196. * The Scene that being rendered
  84197. */
  84198. scene: Scene;
  84199. /**
  84200. * The camera currently used for the rendering pass
  84201. */
  84202. camera: Nullable<Camera>;
  84203. /**
  84204. * The ID of the renderingGroup being processed
  84205. */
  84206. renderingGroupId: number;
  84207. }
  84208. /**
  84209. * This is the manager responsible of all the rendering for meshes sprites and particles.
  84210. * It is enable to manage the different groups as well as the different necessary sort functions.
  84211. * This should not be used directly aside of the few static configurations
  84212. */
  84213. export class RenderingManager {
  84214. /**
  84215. * The max id used for rendering groups (not included)
  84216. */
  84217. static MAX_RENDERINGGROUPS: number;
  84218. /**
  84219. * The min id used for rendering groups (included)
  84220. */
  84221. static MIN_RENDERINGGROUPS: number;
  84222. /**
  84223. * Used to globally prevent autoclearing scenes.
  84224. */
  84225. static AUTOCLEAR: boolean;
  84226. /**
  84227. * @hidden
  84228. */
  84229. _useSceneAutoClearSetup: boolean;
  84230. private _scene;
  84231. private _renderingGroups;
  84232. private _depthStencilBufferAlreadyCleaned;
  84233. private _autoClearDepthStencil;
  84234. private _customOpaqueSortCompareFn;
  84235. private _customAlphaTestSortCompareFn;
  84236. private _customTransparentSortCompareFn;
  84237. private _renderingGroupInfo;
  84238. /**
  84239. * Instantiates a new rendering group for a particular scene
  84240. * @param scene Defines the scene the groups belongs to
  84241. */
  84242. constructor(scene: Scene);
  84243. private _clearDepthStencilBuffer;
  84244. /**
  84245. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  84246. * @hidden
  84247. */
  84248. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  84249. /**
  84250. * Resets the different information of the group to prepare a new frame
  84251. * @hidden
  84252. */
  84253. reset(): void;
  84254. /**
  84255. * Dispose and release the group and its associated resources.
  84256. * @hidden
  84257. */
  84258. dispose(): void;
  84259. /**
  84260. * Clear the info related to rendering groups preventing retention points during dispose.
  84261. */
  84262. freeRenderingGroups(): void;
  84263. private _prepareRenderingGroup;
  84264. /**
  84265. * Add a sprite manager to the rendering manager in order to render it this frame.
  84266. * @param spriteManager Define the sprite manager to render
  84267. */
  84268. dispatchSprites(spriteManager: ISpriteManager): void;
  84269. /**
  84270. * Add a particle system to the rendering manager in order to render it this frame.
  84271. * @param particleSystem Define the particle system to render
  84272. */
  84273. dispatchParticles(particleSystem: IParticleSystem): void;
  84274. /**
  84275. * Add a submesh to the manager in order to render it this frame
  84276. * @param subMesh The submesh to dispatch
  84277. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  84278. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  84279. */
  84280. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  84281. /**
  84282. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  84283. * This allowed control for front to back rendering or reversly depending of the special needs.
  84284. *
  84285. * @param renderingGroupId The rendering group id corresponding to its index
  84286. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  84287. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  84288. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  84289. */
  84290. 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;
  84291. /**
  84292. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  84293. *
  84294. * @param renderingGroupId The rendering group id corresponding to its index
  84295. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  84296. * @param depth Automatically clears depth between groups if true and autoClear is true.
  84297. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  84298. */
  84299. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  84300. /**
  84301. * Gets the current auto clear configuration for one rendering group of the rendering
  84302. * manager.
  84303. * @param index the rendering group index to get the information for
  84304. * @returns The auto clear setup for the requested rendering group
  84305. */
  84306. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  84307. }
  84308. }
  84309. declare module BABYLON {
  84310. /**
  84311. * This Helps creating a texture that will be created from a camera in your scene.
  84312. * It is basically a dynamic texture that could be used to create special effects for instance.
  84313. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  84314. */
  84315. export class RenderTargetTexture extends Texture {
  84316. isCube: boolean;
  84317. /**
  84318. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  84319. */
  84320. static readonly REFRESHRATE_RENDER_ONCE: number;
  84321. /**
  84322. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  84323. */
  84324. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  84325. /**
  84326. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  84327. * the central point of your effect and can save a lot of performances.
  84328. */
  84329. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  84330. /**
  84331. * Use this predicate to dynamically define the list of mesh you want to render.
  84332. * If set, the renderList property will be overwritten.
  84333. */
  84334. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  84335. private _renderList;
  84336. /**
  84337. * Use this list to define the list of mesh you want to render.
  84338. */
  84339. renderList: Nullable<Array<AbstractMesh>>;
  84340. private _hookArray;
  84341. /**
  84342. * Define if particles should be rendered in your texture.
  84343. */
  84344. renderParticles: boolean;
  84345. /**
  84346. * Define if sprites should be rendered in your texture.
  84347. */
  84348. renderSprites: boolean;
  84349. /**
  84350. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  84351. */
  84352. coordinatesMode: number;
  84353. /**
  84354. * Define the camera used to render the texture.
  84355. */
  84356. activeCamera: Nullable<Camera>;
  84357. /**
  84358. * Override the render function of the texture with your own one.
  84359. */
  84360. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  84361. /**
  84362. * Define if camera post processes should be use while rendering the texture.
  84363. */
  84364. useCameraPostProcesses: boolean;
  84365. /**
  84366. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  84367. */
  84368. ignoreCameraViewport: boolean;
  84369. private _postProcessManager;
  84370. private _postProcesses;
  84371. private _resizeObserver;
  84372. /**
  84373. * An event triggered when the texture is unbind.
  84374. */
  84375. onBeforeBindObservable: Observable<RenderTargetTexture>;
  84376. /**
  84377. * An event triggered when the texture is unbind.
  84378. */
  84379. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  84380. private _onAfterUnbindObserver;
  84381. /**
  84382. * Set a after unbind callback in the texture.
  84383. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  84384. */
  84385. onAfterUnbind: () => void;
  84386. /**
  84387. * An event triggered before rendering the texture
  84388. */
  84389. onBeforeRenderObservable: Observable<number>;
  84390. private _onBeforeRenderObserver;
  84391. /**
  84392. * Set a before render callback in the texture.
  84393. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  84394. */
  84395. onBeforeRender: (faceIndex: number) => void;
  84396. /**
  84397. * An event triggered after rendering the texture
  84398. */
  84399. onAfterRenderObservable: Observable<number>;
  84400. private _onAfterRenderObserver;
  84401. /**
  84402. * Set a after render callback in the texture.
  84403. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  84404. */
  84405. onAfterRender: (faceIndex: number) => void;
  84406. /**
  84407. * An event triggered after the texture clear
  84408. */
  84409. onClearObservable: Observable<Engine>;
  84410. private _onClearObserver;
  84411. /**
  84412. * Set a clear callback in the texture.
  84413. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  84414. */
  84415. onClear: (Engine: Engine) => void;
  84416. /**
  84417. * Define the clear color of the Render Target if it should be different from the scene.
  84418. */
  84419. clearColor: Color4;
  84420. protected _size: number | {
  84421. width: number;
  84422. height: number;
  84423. };
  84424. protected _initialSizeParameter: number | {
  84425. width: number;
  84426. height: number;
  84427. } | {
  84428. ratio: number;
  84429. };
  84430. protected _sizeRatio: Nullable<number>;
  84431. /** @hidden */
  84432. _generateMipMaps: boolean;
  84433. protected _renderingManager: RenderingManager;
  84434. /** @hidden */
  84435. _waitingRenderList: string[];
  84436. protected _doNotChangeAspectRatio: boolean;
  84437. protected _currentRefreshId: number;
  84438. protected _refreshRate: number;
  84439. protected _textureMatrix: Matrix;
  84440. protected _samples: number;
  84441. protected _renderTargetOptions: RenderTargetCreationOptions;
  84442. /**
  84443. * Gets render target creation options that were used.
  84444. */
  84445. readonly renderTargetOptions: RenderTargetCreationOptions;
  84446. protected _engine: Engine;
  84447. protected _onRatioRescale(): void;
  84448. /**
  84449. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  84450. * It must define where the camera used to render the texture is set
  84451. */
  84452. boundingBoxPosition: Vector3;
  84453. private _boundingBoxSize;
  84454. /**
  84455. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  84456. * When defined, the cubemap will switch to local mode
  84457. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  84458. * @example https://www.babylonjs-playground.com/#RNASML
  84459. */
  84460. boundingBoxSize: Vector3;
  84461. /**
  84462. * In case the RTT has been created with a depth texture, get the associated
  84463. * depth texture.
  84464. * Otherwise, return null.
  84465. */
  84466. depthStencilTexture: Nullable<InternalTexture>;
  84467. /**
  84468. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  84469. * or used a shadow, depth texture...
  84470. * @param name The friendly name of the texture
  84471. * @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)
  84472. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  84473. * @param generateMipMaps True if mip maps need to be generated after render.
  84474. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  84475. * @param type The type of the buffer in the RTT (int, half float, float...)
  84476. * @param isCube True if a cube texture needs to be created
  84477. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  84478. * @param generateDepthBuffer True to generate a depth buffer
  84479. * @param generateStencilBuffer True to generate a stencil buffer
  84480. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  84481. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  84482. * @param delayAllocation if the texture allocation should be delayed (default: false)
  84483. */
  84484. constructor(name: string, size: number | {
  84485. width: number;
  84486. height: number;
  84487. } | {
  84488. ratio: number;
  84489. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  84490. /**
  84491. * Creates a depth stencil texture.
  84492. * This is only available in WebGL 2 or with the depth texture extension available.
  84493. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  84494. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  84495. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  84496. */
  84497. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  84498. private _processSizeParameter;
  84499. /**
  84500. * Define the number of samples to use in case of MSAA.
  84501. * It defaults to one meaning no MSAA has been enabled.
  84502. */
  84503. samples: number;
  84504. /**
  84505. * Resets the refresh counter of the texture and start bak from scratch.
  84506. * Could be useful to regenerate the texture if it is setup to render only once.
  84507. */
  84508. resetRefreshCounter(): void;
  84509. /**
  84510. * Define the refresh rate of the texture or the rendering frequency.
  84511. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  84512. */
  84513. refreshRate: number;
  84514. /**
  84515. * Adds a post process to the render target rendering passes.
  84516. * @param postProcess define the post process to add
  84517. */
  84518. addPostProcess(postProcess: PostProcess): void;
  84519. /**
  84520. * Clear all the post processes attached to the render target
  84521. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  84522. */
  84523. clearPostProcesses(dispose?: boolean): void;
  84524. /**
  84525. * Remove one of the post process from the list of attached post processes to the texture
  84526. * @param postProcess define the post process to remove from the list
  84527. */
  84528. removePostProcess(postProcess: PostProcess): void;
  84529. /** @hidden */
  84530. _shouldRender(): boolean;
  84531. /**
  84532. * Gets the actual render size of the texture.
  84533. * @returns the width of the render size
  84534. */
  84535. getRenderSize(): number;
  84536. /**
  84537. * Gets the actual render width of the texture.
  84538. * @returns the width of the render size
  84539. */
  84540. getRenderWidth(): number;
  84541. /**
  84542. * Gets the actual render height of the texture.
  84543. * @returns the height of the render size
  84544. */
  84545. getRenderHeight(): number;
  84546. /**
  84547. * Get if the texture can be rescaled or not.
  84548. */
  84549. readonly canRescale: boolean;
  84550. /**
  84551. * Resize the texture using a ratio.
  84552. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  84553. */
  84554. scale(ratio: number): void;
  84555. /**
  84556. * Get the texture reflection matrix used to rotate/transform the reflection.
  84557. * @returns the reflection matrix
  84558. */
  84559. getReflectionTextureMatrix(): Matrix;
  84560. /**
  84561. * Resize the texture to a new desired size.
  84562. * Be carrefull as it will recreate all the data in the new texture.
  84563. * @param size Define the new size. It can be:
  84564. * - a number for squared texture,
  84565. * - an object containing { width: number, height: number }
  84566. * - or an object containing a ratio { ratio: number }
  84567. */
  84568. resize(size: number | {
  84569. width: number;
  84570. height: number;
  84571. } | {
  84572. ratio: number;
  84573. }): void;
  84574. /**
  84575. * Renders all the objects from the render list into the texture.
  84576. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  84577. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  84578. */
  84579. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  84580. private _bestReflectionRenderTargetDimension;
  84581. /**
  84582. * @hidden
  84583. * @param faceIndex face index to bind to if this is a cubetexture
  84584. */
  84585. _bindFrameBuffer(faceIndex?: number): void;
  84586. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  84587. private renderToTarget;
  84588. /**
  84589. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  84590. * This allowed control for front to back rendering or reversly depending of the special needs.
  84591. *
  84592. * @param renderingGroupId The rendering group id corresponding to its index
  84593. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  84594. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  84595. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  84596. */
  84597. 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;
  84598. /**
  84599. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  84600. *
  84601. * @param renderingGroupId The rendering group id corresponding to its index
  84602. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  84603. */
  84604. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  84605. /**
  84606. * Clones the texture.
  84607. * @returns the cloned texture
  84608. */
  84609. clone(): RenderTargetTexture;
  84610. /**
  84611. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  84612. * @returns The JSON representation of the texture
  84613. */
  84614. serialize(): any;
  84615. /**
  84616. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  84617. */
  84618. disposeFramebufferObjects(): void;
  84619. /**
  84620. * Dispose the texture and release its associated resources.
  84621. */
  84622. dispose(): void;
  84623. /** @hidden */
  84624. _rebuild(): void;
  84625. /**
  84626. * Clear the info related to rendering groups preventing retention point in material dispose.
  84627. */
  84628. freeRenderingGroups(): void;
  84629. /**
  84630. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  84631. * @returns the view count
  84632. */
  84633. getViewCount(): number;
  84634. }
  84635. }
  84636. declare module BABYLON {
  84637. /**
  84638. * Base class for the main features of a material in Babylon.js
  84639. */
  84640. export class Material implements IAnimatable {
  84641. /**
  84642. * Returns the triangle fill mode
  84643. */
  84644. static readonly TriangleFillMode: number;
  84645. /**
  84646. * Returns the wireframe mode
  84647. */
  84648. static readonly WireFrameFillMode: number;
  84649. /**
  84650. * Returns the point fill mode
  84651. */
  84652. static readonly PointFillMode: number;
  84653. /**
  84654. * Returns the point list draw mode
  84655. */
  84656. static readonly PointListDrawMode: number;
  84657. /**
  84658. * Returns the line list draw mode
  84659. */
  84660. static readonly LineListDrawMode: number;
  84661. /**
  84662. * Returns the line loop draw mode
  84663. */
  84664. static readonly LineLoopDrawMode: number;
  84665. /**
  84666. * Returns the line strip draw mode
  84667. */
  84668. static readonly LineStripDrawMode: number;
  84669. /**
  84670. * Returns the triangle strip draw mode
  84671. */
  84672. static readonly TriangleStripDrawMode: number;
  84673. /**
  84674. * Returns the triangle fan draw mode
  84675. */
  84676. static readonly TriangleFanDrawMode: number;
  84677. /**
  84678. * Stores the clock-wise side orientation
  84679. */
  84680. static readonly ClockWiseSideOrientation: number;
  84681. /**
  84682. * Stores the counter clock-wise side orientation
  84683. */
  84684. static readonly CounterClockWiseSideOrientation: number;
  84685. /**
  84686. * The dirty texture flag value
  84687. */
  84688. static readonly TextureDirtyFlag: number;
  84689. /**
  84690. * The dirty light flag value
  84691. */
  84692. static readonly LightDirtyFlag: number;
  84693. /**
  84694. * The dirty fresnel flag value
  84695. */
  84696. static readonly FresnelDirtyFlag: number;
  84697. /**
  84698. * The dirty attribute flag value
  84699. */
  84700. static readonly AttributesDirtyFlag: number;
  84701. /**
  84702. * The dirty misc flag value
  84703. */
  84704. static readonly MiscDirtyFlag: number;
  84705. /**
  84706. * The all dirty flag value
  84707. */
  84708. static readonly AllDirtyFlag: number;
  84709. /**
  84710. * The ID of the material
  84711. */
  84712. id: string;
  84713. /**
  84714. * Gets or sets the unique id of the material
  84715. */
  84716. uniqueId: number;
  84717. /**
  84718. * The name of the material
  84719. */
  84720. name: string;
  84721. /**
  84722. * Gets or sets user defined metadata
  84723. */
  84724. metadata: any;
  84725. /**
  84726. * For internal use only. Please do not use.
  84727. */
  84728. reservedDataStore: any;
  84729. /**
  84730. * Specifies if the ready state should be checked on each call
  84731. */
  84732. checkReadyOnEveryCall: boolean;
  84733. /**
  84734. * Specifies if the ready state should be checked once
  84735. */
  84736. checkReadyOnlyOnce: boolean;
  84737. /**
  84738. * The state of the material
  84739. */
  84740. state: string;
  84741. /**
  84742. * The alpha value of the material
  84743. */
  84744. protected _alpha: number;
  84745. /**
  84746. * List of inspectable custom properties (used by the Inspector)
  84747. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  84748. */
  84749. inspectableCustomProperties: IInspectable[];
  84750. /**
  84751. * Sets the alpha value of the material
  84752. */
  84753. /**
  84754. * Gets the alpha value of the material
  84755. */
  84756. alpha: number;
  84757. /**
  84758. * Specifies if back face culling is enabled
  84759. */
  84760. protected _backFaceCulling: boolean;
  84761. /**
  84762. * Sets the back-face culling state
  84763. */
  84764. /**
  84765. * Gets the back-face culling state
  84766. */
  84767. backFaceCulling: boolean;
  84768. /**
  84769. * Stores the value for side orientation
  84770. */
  84771. sideOrientation: number;
  84772. /**
  84773. * Callback triggered when the material is compiled
  84774. */
  84775. onCompiled: Nullable<(effect: Effect) => void>;
  84776. /**
  84777. * Callback triggered when an error occurs
  84778. */
  84779. onError: Nullable<(effect: Effect, errors: string) => void>;
  84780. /**
  84781. * Callback triggered to get the render target textures
  84782. */
  84783. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  84784. /**
  84785. * Gets a boolean indicating that current material needs to register RTT
  84786. */
  84787. readonly hasRenderTargetTextures: boolean;
  84788. /**
  84789. * Specifies if the material should be serialized
  84790. */
  84791. doNotSerialize: boolean;
  84792. /**
  84793. * @hidden
  84794. */
  84795. _storeEffectOnSubMeshes: boolean;
  84796. /**
  84797. * Stores the animations for the material
  84798. */
  84799. animations: Nullable<Array<Animation>>;
  84800. /**
  84801. * An event triggered when the material is disposed
  84802. */
  84803. onDisposeObservable: Observable<Material>;
  84804. /**
  84805. * An observer which watches for dispose events
  84806. */
  84807. private _onDisposeObserver;
  84808. private _onUnBindObservable;
  84809. /**
  84810. * Called during a dispose event
  84811. */
  84812. onDispose: () => void;
  84813. private _onBindObservable;
  84814. /**
  84815. * An event triggered when the material is bound
  84816. */
  84817. readonly onBindObservable: Observable<AbstractMesh>;
  84818. /**
  84819. * An observer which watches for bind events
  84820. */
  84821. private _onBindObserver;
  84822. /**
  84823. * Called during a bind event
  84824. */
  84825. onBind: (Mesh: AbstractMesh) => void;
  84826. /**
  84827. * An event triggered when the material is unbound
  84828. */
  84829. readonly onUnBindObservable: Observable<Material>;
  84830. /**
  84831. * Stores the value of the alpha mode
  84832. */
  84833. private _alphaMode;
  84834. /**
  84835. * Sets the value of the alpha mode.
  84836. *
  84837. * | Value | Type | Description |
  84838. * | --- | --- | --- |
  84839. * | 0 | ALPHA_DISABLE | |
  84840. * | 1 | ALPHA_ADD | |
  84841. * | 2 | ALPHA_COMBINE | |
  84842. * | 3 | ALPHA_SUBTRACT | |
  84843. * | 4 | ALPHA_MULTIPLY | |
  84844. * | 5 | ALPHA_MAXIMIZED | |
  84845. * | 6 | ALPHA_ONEONE | |
  84846. * | 7 | ALPHA_PREMULTIPLIED | |
  84847. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  84848. * | 9 | ALPHA_INTERPOLATE | |
  84849. * | 10 | ALPHA_SCREENMODE | |
  84850. *
  84851. */
  84852. /**
  84853. * Gets the value of the alpha mode
  84854. */
  84855. alphaMode: number;
  84856. /**
  84857. * Stores the state of the need depth pre-pass value
  84858. */
  84859. private _needDepthPrePass;
  84860. /**
  84861. * Sets the need depth pre-pass value
  84862. */
  84863. /**
  84864. * Gets the depth pre-pass value
  84865. */
  84866. needDepthPrePass: boolean;
  84867. /**
  84868. * Specifies if depth writing should be disabled
  84869. */
  84870. disableDepthWrite: boolean;
  84871. /**
  84872. * Specifies if depth writing should be forced
  84873. */
  84874. forceDepthWrite: boolean;
  84875. /**
  84876. * Specifies if there should be a separate pass for culling
  84877. */
  84878. separateCullingPass: boolean;
  84879. /**
  84880. * Stores the state specifing if fog should be enabled
  84881. */
  84882. private _fogEnabled;
  84883. /**
  84884. * Sets the state for enabling fog
  84885. */
  84886. /**
  84887. * Gets the value of the fog enabled state
  84888. */
  84889. fogEnabled: boolean;
  84890. /**
  84891. * Stores the size of points
  84892. */
  84893. pointSize: number;
  84894. /**
  84895. * Stores the z offset value
  84896. */
  84897. zOffset: number;
  84898. /**
  84899. * Gets a value specifying if wireframe mode is enabled
  84900. */
  84901. /**
  84902. * Sets the state of wireframe mode
  84903. */
  84904. wireframe: boolean;
  84905. /**
  84906. * Gets the value specifying if point clouds are enabled
  84907. */
  84908. /**
  84909. * Sets the state of point cloud mode
  84910. */
  84911. pointsCloud: boolean;
  84912. /**
  84913. * Gets the material fill mode
  84914. */
  84915. /**
  84916. * Sets the material fill mode
  84917. */
  84918. fillMode: number;
  84919. /**
  84920. * @hidden
  84921. * Stores the effects for the material
  84922. */
  84923. _effect: Nullable<Effect>;
  84924. /**
  84925. * @hidden
  84926. * Specifies if the material was previously ready
  84927. */
  84928. _wasPreviouslyReady: boolean;
  84929. /**
  84930. * Specifies if uniform buffers should be used
  84931. */
  84932. private _useUBO;
  84933. /**
  84934. * Stores a reference to the scene
  84935. */
  84936. private _scene;
  84937. /**
  84938. * Stores the fill mode state
  84939. */
  84940. private _fillMode;
  84941. /**
  84942. * Specifies if the depth write state should be cached
  84943. */
  84944. private _cachedDepthWriteState;
  84945. /**
  84946. * Stores the uniform buffer
  84947. */
  84948. protected _uniformBuffer: UniformBuffer;
  84949. /** @hidden */
  84950. _indexInSceneMaterialArray: number;
  84951. /** @hidden */
  84952. meshMap: Nullable<{
  84953. [id: string]: AbstractMesh | undefined;
  84954. }>;
  84955. /**
  84956. * Creates a material instance
  84957. * @param name defines the name of the material
  84958. * @param scene defines the scene to reference
  84959. * @param doNotAdd specifies if the material should be added to the scene
  84960. */
  84961. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  84962. /**
  84963. * Returns a string representation of the current material
  84964. * @param fullDetails defines a boolean indicating which levels of logging is desired
  84965. * @returns a string with material information
  84966. */
  84967. toString(fullDetails?: boolean): string;
  84968. /**
  84969. * Gets the class name of the material
  84970. * @returns a string with the class name of the material
  84971. */
  84972. getClassName(): string;
  84973. /**
  84974. * Specifies if updates for the material been locked
  84975. */
  84976. readonly isFrozen: boolean;
  84977. /**
  84978. * Locks updates for the material
  84979. */
  84980. freeze(): void;
  84981. /**
  84982. * Unlocks updates for the material
  84983. */
  84984. unfreeze(): void;
  84985. /**
  84986. * Specifies if the material is ready to be used
  84987. * @param mesh defines the mesh to check
  84988. * @param useInstances specifies if instances should be used
  84989. * @returns a boolean indicating if the material is ready to be used
  84990. */
  84991. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  84992. /**
  84993. * Specifies that the submesh is ready to be used
  84994. * @param mesh defines the mesh to check
  84995. * @param subMesh defines which submesh to check
  84996. * @param useInstances specifies that instances should be used
  84997. * @returns a boolean indicating that the submesh is ready or not
  84998. */
  84999. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  85000. /**
  85001. * Returns the material effect
  85002. * @returns the effect associated with the material
  85003. */
  85004. getEffect(): Nullable<Effect>;
  85005. /**
  85006. * Returns the current scene
  85007. * @returns a Scene
  85008. */
  85009. getScene(): Scene;
  85010. /**
  85011. * Specifies if the material will require alpha blending
  85012. * @returns a boolean specifying if alpha blending is needed
  85013. */
  85014. needAlphaBlending(): boolean;
  85015. /**
  85016. * Specifies if the mesh will require alpha blending
  85017. * @param mesh defines the mesh to check
  85018. * @returns a boolean specifying if alpha blending is needed for the mesh
  85019. */
  85020. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  85021. /**
  85022. * Specifies if this material should be rendered in alpha test mode
  85023. * @returns a boolean specifying if an alpha test is needed.
  85024. */
  85025. needAlphaTesting(): boolean;
  85026. /**
  85027. * Gets the texture used for the alpha test
  85028. * @returns the texture to use for alpha testing
  85029. */
  85030. getAlphaTestTexture(): Nullable<BaseTexture>;
  85031. /**
  85032. * Marks the material to indicate that it needs to be re-calculated
  85033. */
  85034. markDirty(): void;
  85035. /** @hidden */
  85036. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  85037. /**
  85038. * Binds the material to the mesh
  85039. * @param world defines the world transformation matrix
  85040. * @param mesh defines the mesh to bind the material to
  85041. */
  85042. bind(world: Matrix, mesh?: Mesh): void;
  85043. /**
  85044. * Binds the submesh to the material
  85045. * @param world defines the world transformation matrix
  85046. * @param mesh defines the mesh containing the submesh
  85047. * @param subMesh defines the submesh to bind the material to
  85048. */
  85049. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  85050. /**
  85051. * Binds the world matrix to the material
  85052. * @param world defines the world transformation matrix
  85053. */
  85054. bindOnlyWorldMatrix(world: Matrix): void;
  85055. /**
  85056. * Binds the scene's uniform buffer to the effect.
  85057. * @param effect defines the effect to bind to the scene uniform buffer
  85058. * @param sceneUbo defines the uniform buffer storing scene data
  85059. */
  85060. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  85061. /**
  85062. * Binds the view matrix to the effect
  85063. * @param effect defines the effect to bind the view matrix to
  85064. */
  85065. bindView(effect: Effect): void;
  85066. /**
  85067. * Binds the view projection matrix to the effect
  85068. * @param effect defines the effect to bind the view projection matrix to
  85069. */
  85070. bindViewProjection(effect: Effect): void;
  85071. /**
  85072. * Specifies if material alpha testing should be turned on for the mesh
  85073. * @param mesh defines the mesh to check
  85074. */
  85075. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  85076. /**
  85077. * Processes to execute after binding the material to a mesh
  85078. * @param mesh defines the rendered mesh
  85079. */
  85080. protected _afterBind(mesh?: Mesh): void;
  85081. /**
  85082. * Unbinds the material from the mesh
  85083. */
  85084. unbind(): void;
  85085. /**
  85086. * Gets the active textures from the material
  85087. * @returns an array of textures
  85088. */
  85089. getActiveTextures(): BaseTexture[];
  85090. /**
  85091. * Specifies if the material uses a texture
  85092. * @param texture defines the texture to check against the material
  85093. * @returns a boolean specifying if the material uses the texture
  85094. */
  85095. hasTexture(texture: BaseTexture): boolean;
  85096. /**
  85097. * Makes a duplicate of the material, and gives it a new name
  85098. * @param name defines the new name for the duplicated material
  85099. * @returns the cloned material
  85100. */
  85101. clone(name: string): Nullable<Material>;
  85102. /**
  85103. * Gets the meshes bound to the material
  85104. * @returns an array of meshes bound to the material
  85105. */
  85106. getBindedMeshes(): AbstractMesh[];
  85107. /**
  85108. * Force shader compilation
  85109. * @param mesh defines the mesh associated with this material
  85110. * @param onCompiled defines a function to execute once the material is compiled
  85111. * @param options defines the options to configure the compilation
  85112. */
  85113. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  85114. clipPlane: boolean;
  85115. }>): void;
  85116. /**
  85117. * Force shader compilation
  85118. * @param mesh defines the mesh that will use this material
  85119. * @param options defines additional options for compiling the shaders
  85120. * @returns a promise that resolves when the compilation completes
  85121. */
  85122. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  85123. clipPlane: boolean;
  85124. }>): Promise<void>;
  85125. private static readonly _AllDirtyCallBack;
  85126. private static readonly _ImageProcessingDirtyCallBack;
  85127. private static readonly _TextureDirtyCallBack;
  85128. private static readonly _FresnelDirtyCallBack;
  85129. private static readonly _MiscDirtyCallBack;
  85130. private static readonly _LightsDirtyCallBack;
  85131. private static readonly _AttributeDirtyCallBack;
  85132. private static _FresnelAndMiscDirtyCallBack;
  85133. private static _TextureAndMiscDirtyCallBack;
  85134. private static readonly _DirtyCallbackArray;
  85135. private static readonly _RunDirtyCallBacks;
  85136. /**
  85137. * Marks a define in the material to indicate that it needs to be re-computed
  85138. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  85139. */
  85140. markAsDirty(flag: number): void;
  85141. /**
  85142. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  85143. * @param func defines a function which checks material defines against the submeshes
  85144. */
  85145. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  85146. /**
  85147. * Indicates that we need to re-calculated for all submeshes
  85148. */
  85149. protected _markAllSubMeshesAsAllDirty(): void;
  85150. /**
  85151. * Indicates that image processing needs to be re-calculated for all submeshes
  85152. */
  85153. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  85154. /**
  85155. * Indicates that textures need to be re-calculated for all submeshes
  85156. */
  85157. protected _markAllSubMeshesAsTexturesDirty(): void;
  85158. /**
  85159. * Indicates that fresnel needs to be re-calculated for all submeshes
  85160. */
  85161. protected _markAllSubMeshesAsFresnelDirty(): void;
  85162. /**
  85163. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  85164. */
  85165. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  85166. /**
  85167. * Indicates that lights need to be re-calculated for all submeshes
  85168. */
  85169. protected _markAllSubMeshesAsLightsDirty(): void;
  85170. /**
  85171. * Indicates that attributes need to be re-calculated for all submeshes
  85172. */
  85173. protected _markAllSubMeshesAsAttributesDirty(): void;
  85174. /**
  85175. * Indicates that misc needs to be re-calculated for all submeshes
  85176. */
  85177. protected _markAllSubMeshesAsMiscDirty(): void;
  85178. /**
  85179. * Indicates that textures and misc need to be re-calculated for all submeshes
  85180. */
  85181. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  85182. /**
  85183. * Disposes the material
  85184. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  85185. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  85186. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  85187. */
  85188. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  85189. /** @hidden */
  85190. private releaseVertexArrayObject;
  85191. /**
  85192. * Serializes this material
  85193. * @returns the serialized material object
  85194. */
  85195. serialize(): any;
  85196. /**
  85197. * Creates a material from parsed material data
  85198. * @param parsedMaterial defines parsed material data
  85199. * @param scene defines the hosting scene
  85200. * @param rootUrl defines the root URL to use to load textures
  85201. * @returns a new material
  85202. */
  85203. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  85204. }
  85205. }
  85206. declare module BABYLON {
  85207. /**
  85208. * Base class for submeshes
  85209. */
  85210. export class BaseSubMesh {
  85211. /** @hidden */
  85212. _materialDefines: Nullable<MaterialDefines>;
  85213. /** @hidden */
  85214. _materialEffect: Nullable<Effect>;
  85215. /**
  85216. * Gets associated effect
  85217. */
  85218. readonly effect: Nullable<Effect>;
  85219. /**
  85220. * Sets associated effect (effect used to render this submesh)
  85221. * @param effect defines the effect to associate with
  85222. * @param defines defines the set of defines used to compile this effect
  85223. */
  85224. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  85225. }
  85226. /**
  85227. * Defines a subdivision inside a mesh
  85228. */
  85229. export class SubMesh extends BaseSubMesh implements ICullable {
  85230. /** the material index to use */
  85231. materialIndex: number;
  85232. /** vertex index start */
  85233. verticesStart: number;
  85234. /** vertices count */
  85235. verticesCount: number;
  85236. /** index start */
  85237. indexStart: number;
  85238. /** indices count */
  85239. indexCount: number;
  85240. /** @hidden */
  85241. _linesIndexCount: number;
  85242. private _mesh;
  85243. private _renderingMesh;
  85244. private _boundingInfo;
  85245. private _linesIndexBuffer;
  85246. /** @hidden */
  85247. _lastColliderWorldVertices: Nullable<Vector3[]>;
  85248. /** @hidden */
  85249. _trianglePlanes: Plane[];
  85250. /** @hidden */
  85251. _lastColliderTransformMatrix: Nullable<Matrix>;
  85252. /** @hidden */
  85253. _renderId: number;
  85254. /** @hidden */
  85255. _alphaIndex: number;
  85256. /** @hidden */
  85257. _distanceToCamera: number;
  85258. /** @hidden */
  85259. _id: number;
  85260. private _currentMaterial;
  85261. /**
  85262. * Add a new submesh to a mesh
  85263. * @param materialIndex defines the material index to use
  85264. * @param verticesStart defines vertex index start
  85265. * @param verticesCount defines vertices count
  85266. * @param indexStart defines index start
  85267. * @param indexCount defines indices count
  85268. * @param mesh defines the parent mesh
  85269. * @param renderingMesh defines an optional rendering mesh
  85270. * @param createBoundingBox defines if bounding box should be created for this submesh
  85271. * @returns the new submesh
  85272. */
  85273. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  85274. /**
  85275. * Creates a new submesh
  85276. * @param materialIndex defines the material index to use
  85277. * @param verticesStart defines vertex index start
  85278. * @param verticesCount defines vertices count
  85279. * @param indexStart defines index start
  85280. * @param indexCount defines indices count
  85281. * @param mesh defines the parent mesh
  85282. * @param renderingMesh defines an optional rendering mesh
  85283. * @param createBoundingBox defines if bounding box should be created for this submesh
  85284. */
  85285. constructor(
  85286. /** the material index to use */
  85287. materialIndex: number,
  85288. /** vertex index start */
  85289. verticesStart: number,
  85290. /** vertices count */
  85291. verticesCount: number,
  85292. /** index start */
  85293. indexStart: number,
  85294. /** indices count */
  85295. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  85296. /**
  85297. * Returns true if this submesh covers the entire parent mesh
  85298. * @ignorenaming
  85299. */
  85300. readonly IsGlobal: boolean;
  85301. /**
  85302. * Returns the submesh BoudingInfo object
  85303. * @returns current bounding info (or mesh's one if the submesh is global)
  85304. */
  85305. getBoundingInfo(): BoundingInfo;
  85306. /**
  85307. * Sets the submesh BoundingInfo
  85308. * @param boundingInfo defines the new bounding info to use
  85309. * @returns the SubMesh
  85310. */
  85311. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  85312. /**
  85313. * Returns the mesh of the current submesh
  85314. * @return the parent mesh
  85315. */
  85316. getMesh(): AbstractMesh;
  85317. /**
  85318. * Returns the rendering mesh of the submesh
  85319. * @returns the rendering mesh (could be different from parent mesh)
  85320. */
  85321. getRenderingMesh(): Mesh;
  85322. /**
  85323. * Returns the submesh material
  85324. * @returns null or the current material
  85325. */
  85326. getMaterial(): Nullable<Material>;
  85327. /**
  85328. * Sets a new updated BoundingInfo object to the submesh
  85329. * @param data defines an optional position array to use to determine the bounding info
  85330. * @returns the SubMesh
  85331. */
  85332. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  85333. /** @hidden */
  85334. _checkCollision(collider: Collider): boolean;
  85335. /**
  85336. * Updates the submesh BoundingInfo
  85337. * @param world defines the world matrix to use to update the bounding info
  85338. * @returns the submesh
  85339. */
  85340. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  85341. /**
  85342. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  85343. * @param frustumPlanes defines the frustum planes
  85344. * @returns true if the submesh is intersecting with the frustum
  85345. */
  85346. isInFrustum(frustumPlanes: Plane[]): boolean;
  85347. /**
  85348. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  85349. * @param frustumPlanes defines the frustum planes
  85350. * @returns true if the submesh is inside the frustum
  85351. */
  85352. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  85353. /**
  85354. * Renders the submesh
  85355. * @param enableAlphaMode defines if alpha needs to be used
  85356. * @returns the submesh
  85357. */
  85358. render(enableAlphaMode: boolean): SubMesh;
  85359. /**
  85360. * @hidden
  85361. */
  85362. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  85363. /**
  85364. * Checks if the submesh intersects with a ray
  85365. * @param ray defines the ray to test
  85366. * @returns true is the passed ray intersects the submesh bounding box
  85367. */
  85368. canIntersects(ray: Ray): boolean;
  85369. /**
  85370. * Intersects current submesh with a ray
  85371. * @param ray defines the ray to test
  85372. * @param positions defines mesh's positions array
  85373. * @param indices defines mesh's indices array
  85374. * @param fastCheck defines if only bounding info should be used
  85375. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  85376. * @returns intersection info or null if no intersection
  85377. */
  85378. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  85379. /** @hidden */
  85380. private _intersectLines;
  85381. /** @hidden */
  85382. private _intersectUnIndexedLines;
  85383. /** @hidden */
  85384. private _intersectTriangles;
  85385. /** @hidden */
  85386. private _intersectUnIndexedTriangles;
  85387. /** @hidden */
  85388. _rebuild(): void;
  85389. /**
  85390. * Creates a new submesh from the passed mesh
  85391. * @param newMesh defines the new hosting mesh
  85392. * @param newRenderingMesh defines an optional rendering mesh
  85393. * @returns the new submesh
  85394. */
  85395. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  85396. /**
  85397. * Release associated resources
  85398. */
  85399. dispose(): void;
  85400. /**
  85401. * Gets the class name
  85402. * @returns the string "SubMesh".
  85403. */
  85404. getClassName(): string;
  85405. /**
  85406. * Creates a new submesh from indices data
  85407. * @param materialIndex the index of the main mesh material
  85408. * @param startIndex the index where to start the copy in the mesh indices array
  85409. * @param indexCount the number of indices to copy then from the startIndex
  85410. * @param mesh the main mesh to create the submesh from
  85411. * @param renderingMesh the optional rendering mesh
  85412. * @returns a new submesh
  85413. */
  85414. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  85415. }
  85416. }
  85417. declare module BABYLON {
  85418. /**
  85419. * Class used to store geometry data (vertex buffers + index buffer)
  85420. */
  85421. export class Geometry implements IGetSetVerticesData {
  85422. /**
  85423. * Gets or sets the ID of the geometry
  85424. */
  85425. id: string;
  85426. /**
  85427. * Gets or sets the unique ID of the geometry
  85428. */
  85429. uniqueId: number;
  85430. /**
  85431. * Gets the delay loading state of the geometry (none by default which means not delayed)
  85432. */
  85433. delayLoadState: number;
  85434. /**
  85435. * Gets the file containing the data to load when running in delay load state
  85436. */
  85437. delayLoadingFile: Nullable<string>;
  85438. /**
  85439. * Callback called when the geometry is updated
  85440. */
  85441. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  85442. private _scene;
  85443. private _engine;
  85444. private _meshes;
  85445. private _totalVertices;
  85446. /** @hidden */
  85447. _indices: IndicesArray;
  85448. /** @hidden */
  85449. _vertexBuffers: {
  85450. [key: string]: VertexBuffer;
  85451. };
  85452. private _isDisposed;
  85453. private _extend;
  85454. private _boundingBias;
  85455. /** @hidden */
  85456. _delayInfo: Array<string>;
  85457. private _indexBuffer;
  85458. private _indexBufferIsUpdatable;
  85459. /** @hidden */
  85460. _boundingInfo: Nullable<BoundingInfo>;
  85461. /** @hidden */
  85462. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  85463. /** @hidden */
  85464. _softwareSkinningFrameId: number;
  85465. private _vertexArrayObjects;
  85466. private _updatable;
  85467. /** @hidden */
  85468. _positions: Nullable<Vector3[]>;
  85469. /**
  85470. * 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
  85471. */
  85472. /**
  85473. * 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
  85474. */
  85475. boundingBias: Vector2;
  85476. /**
  85477. * Static function used to attach a new empty geometry to a mesh
  85478. * @param mesh defines the mesh to attach the geometry to
  85479. * @returns the new Geometry
  85480. */
  85481. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  85482. /**
  85483. * Creates a new geometry
  85484. * @param id defines the unique ID
  85485. * @param scene defines the hosting scene
  85486. * @param vertexData defines the VertexData used to get geometry data
  85487. * @param updatable defines if geometry must be updatable (false by default)
  85488. * @param mesh defines the mesh that will be associated with the geometry
  85489. */
  85490. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  85491. /**
  85492. * Gets the current extend of the geometry
  85493. */
  85494. readonly extend: {
  85495. minimum: Vector3;
  85496. maximum: Vector3;
  85497. };
  85498. /**
  85499. * Gets the hosting scene
  85500. * @returns the hosting Scene
  85501. */
  85502. getScene(): Scene;
  85503. /**
  85504. * Gets the hosting engine
  85505. * @returns the hosting Engine
  85506. */
  85507. getEngine(): Engine;
  85508. /**
  85509. * Defines if the geometry is ready to use
  85510. * @returns true if the geometry is ready to be used
  85511. */
  85512. isReady(): boolean;
  85513. /**
  85514. * Gets a value indicating that the geometry should not be serialized
  85515. */
  85516. readonly doNotSerialize: boolean;
  85517. /** @hidden */
  85518. _rebuild(): void;
  85519. /**
  85520. * Affects all geometry data in one call
  85521. * @param vertexData defines the geometry data
  85522. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  85523. */
  85524. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  85525. /**
  85526. * Set specific vertex data
  85527. * @param kind defines the data kind (Position, normal, etc...)
  85528. * @param data defines the vertex data to use
  85529. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  85530. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  85531. */
  85532. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  85533. /**
  85534. * Removes a specific vertex data
  85535. * @param kind defines the data kind (Position, normal, etc...)
  85536. */
  85537. removeVerticesData(kind: string): void;
  85538. /**
  85539. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  85540. * @param buffer defines the vertex buffer to use
  85541. * @param totalVertices defines the total number of vertices for position kind (could be null)
  85542. */
  85543. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  85544. /**
  85545. * Update a specific vertex buffer
  85546. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  85547. * It will do nothing if the buffer is not updatable
  85548. * @param kind defines the data kind (Position, normal, etc...)
  85549. * @param data defines the data to use
  85550. * @param offset defines the offset in the target buffer where to store the data
  85551. * @param useBytes set to true if the offset is in bytes
  85552. */
  85553. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  85554. /**
  85555. * Update a specific vertex buffer
  85556. * This function will create a new buffer if the current one is not updatable
  85557. * @param kind defines the data kind (Position, normal, etc...)
  85558. * @param data defines the data to use
  85559. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  85560. */
  85561. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  85562. private _updateBoundingInfo;
  85563. /** @hidden */
  85564. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  85565. /**
  85566. * Gets total number of vertices
  85567. * @returns the total number of vertices
  85568. */
  85569. getTotalVertices(): number;
  85570. /**
  85571. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  85572. * @param kind defines the data kind (Position, normal, etc...)
  85573. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  85574. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  85575. * @returns a float array containing vertex data
  85576. */
  85577. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  85578. /**
  85579. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  85580. * @param kind defines the data kind (Position, normal, etc...)
  85581. * @returns true if the vertex buffer with the specified kind is updatable
  85582. */
  85583. isVertexBufferUpdatable(kind: string): boolean;
  85584. /**
  85585. * Gets a specific vertex buffer
  85586. * @param kind defines the data kind (Position, normal, etc...)
  85587. * @returns a VertexBuffer
  85588. */
  85589. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  85590. /**
  85591. * Returns all vertex buffers
  85592. * @return an object holding all vertex buffers indexed by kind
  85593. */
  85594. getVertexBuffers(): Nullable<{
  85595. [key: string]: VertexBuffer;
  85596. }>;
  85597. /**
  85598. * Gets a boolean indicating if specific vertex buffer is present
  85599. * @param kind defines the data kind (Position, normal, etc...)
  85600. * @returns true if data is present
  85601. */
  85602. isVerticesDataPresent(kind: string): boolean;
  85603. /**
  85604. * Gets a list of all attached data kinds (Position, normal, etc...)
  85605. * @returns a list of string containing all kinds
  85606. */
  85607. getVerticesDataKinds(): string[];
  85608. /**
  85609. * Update index buffer
  85610. * @param indices defines the indices to store in the index buffer
  85611. * @param offset defines the offset in the target buffer where to store the data
  85612. * @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)
  85613. */
  85614. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  85615. /**
  85616. * Creates a new index buffer
  85617. * @param indices defines the indices to store in the index buffer
  85618. * @param totalVertices defines the total number of vertices (could be null)
  85619. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  85620. */
  85621. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  85622. /**
  85623. * Return the total number of indices
  85624. * @returns the total number of indices
  85625. */
  85626. getTotalIndices(): number;
  85627. /**
  85628. * Gets the index buffer array
  85629. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  85630. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  85631. * @returns the index buffer array
  85632. */
  85633. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  85634. /**
  85635. * Gets the index buffer
  85636. * @return the index buffer
  85637. */
  85638. getIndexBuffer(): Nullable<DataBuffer>;
  85639. /** @hidden */
  85640. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  85641. /**
  85642. * Release the associated resources for a specific mesh
  85643. * @param mesh defines the source mesh
  85644. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  85645. */
  85646. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  85647. /**
  85648. * Apply current geometry to a given mesh
  85649. * @param mesh defines the mesh to apply geometry to
  85650. */
  85651. applyToMesh(mesh: Mesh): void;
  85652. private _updateExtend;
  85653. private _applyToMesh;
  85654. private notifyUpdate;
  85655. /**
  85656. * Load the geometry if it was flagged as delay loaded
  85657. * @param scene defines the hosting scene
  85658. * @param onLoaded defines a callback called when the geometry is loaded
  85659. */
  85660. load(scene: Scene, onLoaded?: () => void): void;
  85661. private _queueLoad;
  85662. /**
  85663. * Invert the geometry to move from a right handed system to a left handed one.
  85664. */
  85665. toLeftHanded(): void;
  85666. /** @hidden */
  85667. _resetPointsArrayCache(): void;
  85668. /** @hidden */
  85669. _generatePointsArray(): boolean;
  85670. /**
  85671. * Gets a value indicating if the geometry is disposed
  85672. * @returns true if the geometry was disposed
  85673. */
  85674. isDisposed(): boolean;
  85675. private _disposeVertexArrayObjects;
  85676. /**
  85677. * Free all associated resources
  85678. */
  85679. dispose(): void;
  85680. /**
  85681. * Clone the current geometry into a new geometry
  85682. * @param id defines the unique ID of the new geometry
  85683. * @returns a new geometry object
  85684. */
  85685. copy(id: string): Geometry;
  85686. /**
  85687. * Serialize the current geometry info (and not the vertices data) into a JSON object
  85688. * @return a JSON representation of the current geometry data (without the vertices data)
  85689. */
  85690. serialize(): any;
  85691. private toNumberArray;
  85692. /**
  85693. * Serialize all vertices data into a JSON oject
  85694. * @returns a JSON representation of the current geometry data
  85695. */
  85696. serializeVerticeData(): any;
  85697. /**
  85698. * Extracts a clone of a mesh geometry
  85699. * @param mesh defines the source mesh
  85700. * @param id defines the unique ID of the new geometry object
  85701. * @returns the new geometry object
  85702. */
  85703. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  85704. /**
  85705. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  85706. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  85707. * Be aware Math.random() could cause collisions, but:
  85708. * "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"
  85709. * @returns a string containing a new GUID
  85710. */
  85711. static RandomId(): string;
  85712. /** @hidden */
  85713. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  85714. private static _CleanMatricesWeights;
  85715. /**
  85716. * Create a new geometry from persisted data (Using .babylon file format)
  85717. * @param parsedVertexData defines the persisted data
  85718. * @param scene defines the hosting scene
  85719. * @param rootUrl defines the root url to use to load assets (like delayed data)
  85720. * @returns the new geometry object
  85721. */
  85722. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  85723. }
  85724. }
  85725. declare module BABYLON {
  85726. /**
  85727. * Define an interface for all classes that will get and set the data on vertices
  85728. */
  85729. export interface IGetSetVerticesData {
  85730. /**
  85731. * Gets a boolean indicating if specific vertex data is present
  85732. * @param kind defines the vertex data kind to use
  85733. * @returns true is data kind is present
  85734. */
  85735. isVerticesDataPresent(kind: string): boolean;
  85736. /**
  85737. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  85738. * @param kind defines the data kind (Position, normal, etc...)
  85739. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  85740. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  85741. * @returns a float array containing vertex data
  85742. */
  85743. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  85744. /**
  85745. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  85746. * @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.
  85747. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  85748. * @returns the indices array or an empty array if the mesh has no geometry
  85749. */
  85750. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  85751. /**
  85752. * Set specific vertex data
  85753. * @param kind defines the data kind (Position, normal, etc...)
  85754. * @param data defines the vertex data to use
  85755. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  85756. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  85757. */
  85758. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  85759. /**
  85760. * Update a specific associated vertex buffer
  85761. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  85762. * - VertexBuffer.PositionKind
  85763. * - VertexBuffer.UVKind
  85764. * - VertexBuffer.UV2Kind
  85765. * - VertexBuffer.UV3Kind
  85766. * - VertexBuffer.UV4Kind
  85767. * - VertexBuffer.UV5Kind
  85768. * - VertexBuffer.UV6Kind
  85769. * - VertexBuffer.ColorKind
  85770. * - VertexBuffer.MatricesIndicesKind
  85771. * - VertexBuffer.MatricesIndicesExtraKind
  85772. * - VertexBuffer.MatricesWeightsKind
  85773. * - VertexBuffer.MatricesWeightsExtraKind
  85774. * @param data defines the data source
  85775. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  85776. * @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)
  85777. */
  85778. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  85779. /**
  85780. * Creates a new index buffer
  85781. * @param indices defines the indices to store in the index buffer
  85782. * @param totalVertices defines the total number of vertices (could be null)
  85783. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  85784. */
  85785. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  85786. }
  85787. /**
  85788. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  85789. */
  85790. export class VertexData {
  85791. /**
  85792. * Mesh side orientation : usually the external or front surface
  85793. */
  85794. static readonly FRONTSIDE: number;
  85795. /**
  85796. * Mesh side orientation : usually the internal or back surface
  85797. */
  85798. static readonly BACKSIDE: number;
  85799. /**
  85800. * Mesh side orientation : both internal and external or front and back surfaces
  85801. */
  85802. static readonly DOUBLESIDE: number;
  85803. /**
  85804. * Mesh side orientation : by default, `FRONTSIDE`
  85805. */
  85806. static readonly DEFAULTSIDE: number;
  85807. /**
  85808. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  85809. */
  85810. positions: Nullable<FloatArray>;
  85811. /**
  85812. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  85813. */
  85814. normals: Nullable<FloatArray>;
  85815. /**
  85816. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  85817. */
  85818. tangents: Nullable<FloatArray>;
  85819. /**
  85820. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85821. */
  85822. uvs: Nullable<FloatArray>;
  85823. /**
  85824. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85825. */
  85826. uvs2: Nullable<FloatArray>;
  85827. /**
  85828. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85829. */
  85830. uvs3: Nullable<FloatArray>;
  85831. /**
  85832. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85833. */
  85834. uvs4: Nullable<FloatArray>;
  85835. /**
  85836. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85837. */
  85838. uvs5: Nullable<FloatArray>;
  85839. /**
  85840. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85841. */
  85842. uvs6: Nullable<FloatArray>;
  85843. /**
  85844. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  85845. */
  85846. colors: Nullable<FloatArray>;
  85847. /**
  85848. * 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).
  85849. */
  85850. matricesIndices: Nullable<FloatArray>;
  85851. /**
  85852. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  85853. */
  85854. matricesWeights: Nullable<FloatArray>;
  85855. /**
  85856. * An array extending the number of possible indices
  85857. */
  85858. matricesIndicesExtra: Nullable<FloatArray>;
  85859. /**
  85860. * An array extending the number of possible weights when the number of indices is extended
  85861. */
  85862. matricesWeightsExtra: Nullable<FloatArray>;
  85863. /**
  85864. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  85865. */
  85866. indices: Nullable<IndicesArray>;
  85867. /**
  85868. * Uses the passed data array to set the set the values for the specified kind of data
  85869. * @param data a linear array of floating numbers
  85870. * @param kind the type of data that is being set, eg positions, colors etc
  85871. */
  85872. set(data: FloatArray, kind: string): void;
  85873. /**
  85874. * Associates the vertexData to the passed Mesh.
  85875. * Sets it as updatable or not (default `false`)
  85876. * @param mesh the mesh the vertexData is applied to
  85877. * @param updatable when used and having the value true allows new data to update the vertexData
  85878. * @returns the VertexData
  85879. */
  85880. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  85881. /**
  85882. * Associates the vertexData to the passed Geometry.
  85883. * Sets it as updatable or not (default `false`)
  85884. * @param geometry the geometry the vertexData is applied to
  85885. * @param updatable when used and having the value true allows new data to update the vertexData
  85886. * @returns VertexData
  85887. */
  85888. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  85889. /**
  85890. * Updates the associated mesh
  85891. * @param mesh the mesh to be updated
  85892. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  85893. * @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
  85894. * @returns VertexData
  85895. */
  85896. updateMesh(mesh: Mesh): VertexData;
  85897. /**
  85898. * Updates the associated geometry
  85899. * @param geometry the geometry to be updated
  85900. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  85901. * @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
  85902. * @returns VertexData.
  85903. */
  85904. updateGeometry(geometry: Geometry): VertexData;
  85905. private _applyTo;
  85906. private _update;
  85907. /**
  85908. * Transforms each position and each normal of the vertexData according to the passed Matrix
  85909. * @param matrix the transforming matrix
  85910. * @returns the VertexData
  85911. */
  85912. transform(matrix: Matrix): VertexData;
  85913. /**
  85914. * Merges the passed VertexData into the current one
  85915. * @param other the VertexData to be merged into the current one
  85916. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  85917. * @returns the modified VertexData
  85918. */
  85919. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  85920. private _mergeElement;
  85921. private _validate;
  85922. /**
  85923. * Serializes the VertexData
  85924. * @returns a serialized object
  85925. */
  85926. serialize(): any;
  85927. /**
  85928. * Extracts the vertexData from a mesh
  85929. * @param mesh the mesh from which to extract the VertexData
  85930. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  85931. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  85932. * @returns the object VertexData associated to the passed mesh
  85933. */
  85934. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  85935. /**
  85936. * Extracts the vertexData from the geometry
  85937. * @param geometry the geometry from which to extract the VertexData
  85938. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  85939. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  85940. * @returns the object VertexData associated to the passed mesh
  85941. */
  85942. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  85943. private static _ExtractFrom;
  85944. /**
  85945. * Creates the VertexData for a Ribbon
  85946. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  85947. * * pathArray array of paths, each of which an array of successive Vector3
  85948. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  85949. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  85950. * * 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
  85951. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85952. * * 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)
  85953. * * 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)
  85954. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  85955. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  85956. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  85957. * @returns the VertexData of the ribbon
  85958. */
  85959. static CreateRibbon(options: {
  85960. pathArray: Vector3[][];
  85961. closeArray?: boolean;
  85962. closePath?: boolean;
  85963. offset?: number;
  85964. sideOrientation?: number;
  85965. frontUVs?: Vector4;
  85966. backUVs?: Vector4;
  85967. invertUV?: boolean;
  85968. uvs?: Vector2[];
  85969. colors?: Color4[];
  85970. }): VertexData;
  85971. /**
  85972. * Creates the VertexData for a box
  85973. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85974. * * size sets the width, height and depth of the box to the value of size, optional default 1
  85975. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  85976. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  85977. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  85978. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  85979. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  85980. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85981. * * 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)
  85982. * * 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)
  85983. * @returns the VertexData of the box
  85984. */
  85985. static CreateBox(options: {
  85986. size?: number;
  85987. width?: number;
  85988. height?: number;
  85989. depth?: number;
  85990. faceUV?: Vector4[];
  85991. faceColors?: Color4[];
  85992. sideOrientation?: number;
  85993. frontUVs?: Vector4;
  85994. backUVs?: Vector4;
  85995. }): VertexData;
  85996. /**
  85997. * Creates the VertexData for a tiled box
  85998. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85999. * * faceTiles sets the pattern, tile size and number of tiles for a face
  86000. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  86001. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  86002. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86003. * @returns the VertexData of the box
  86004. */
  86005. static CreateTiledBox(options: {
  86006. pattern?: number;
  86007. width?: number;
  86008. height?: number;
  86009. depth?: number;
  86010. tileSize?: number;
  86011. tileWidth?: number;
  86012. tileHeight?: number;
  86013. alignHorizontal?: number;
  86014. alignVertical?: number;
  86015. faceUV?: Vector4[];
  86016. faceColors?: Color4[];
  86017. sideOrientation?: number;
  86018. }): VertexData;
  86019. /**
  86020. * Creates the VertexData for a tiled plane
  86021. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86022. * * pattern a limited pattern arrangement depending on the number
  86023. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  86024. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  86025. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  86026. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86027. * * 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)
  86028. * * 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)
  86029. * @returns the VertexData of the tiled plane
  86030. */
  86031. static CreateTiledPlane(options: {
  86032. pattern?: number;
  86033. tileSize?: number;
  86034. tileWidth?: number;
  86035. tileHeight?: number;
  86036. size?: number;
  86037. width?: number;
  86038. height?: number;
  86039. alignHorizontal?: number;
  86040. alignVertical?: number;
  86041. sideOrientation?: number;
  86042. frontUVs?: Vector4;
  86043. backUVs?: Vector4;
  86044. }): VertexData;
  86045. /**
  86046. * Creates the VertexData for an ellipsoid, defaults to a sphere
  86047. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86048. * * segments sets the number of horizontal strips optional, default 32
  86049. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  86050. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  86051. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  86052. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  86053. * * 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
  86054. * * 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
  86055. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86056. * * 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)
  86057. * * 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)
  86058. * @returns the VertexData of the ellipsoid
  86059. */
  86060. static CreateSphere(options: {
  86061. segments?: number;
  86062. diameter?: number;
  86063. diameterX?: number;
  86064. diameterY?: number;
  86065. diameterZ?: number;
  86066. arc?: number;
  86067. slice?: number;
  86068. sideOrientation?: number;
  86069. frontUVs?: Vector4;
  86070. backUVs?: Vector4;
  86071. }): VertexData;
  86072. /**
  86073. * Creates the VertexData for a cylinder, cone or prism
  86074. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86075. * * height sets the height (y direction) of the cylinder, optional, default 2
  86076. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  86077. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  86078. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  86079. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  86080. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  86081. * * 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
  86082. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  86083. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  86084. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  86085. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  86086. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86087. * * 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)
  86088. * * 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)
  86089. * @returns the VertexData of the cylinder, cone or prism
  86090. */
  86091. static CreateCylinder(options: {
  86092. height?: number;
  86093. diameterTop?: number;
  86094. diameterBottom?: number;
  86095. diameter?: number;
  86096. tessellation?: number;
  86097. subdivisions?: number;
  86098. arc?: number;
  86099. faceColors?: Color4[];
  86100. faceUV?: Vector4[];
  86101. hasRings?: boolean;
  86102. enclose?: boolean;
  86103. sideOrientation?: number;
  86104. frontUVs?: Vector4;
  86105. backUVs?: Vector4;
  86106. }): VertexData;
  86107. /**
  86108. * Creates the VertexData for a torus
  86109. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86110. * * diameter the diameter of the torus, optional default 1
  86111. * * thickness the diameter of the tube forming the torus, optional default 0.5
  86112. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  86113. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86114. * * 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)
  86115. * * 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)
  86116. * @returns the VertexData of the torus
  86117. */
  86118. static CreateTorus(options: {
  86119. diameter?: number;
  86120. thickness?: number;
  86121. tessellation?: number;
  86122. sideOrientation?: number;
  86123. frontUVs?: Vector4;
  86124. backUVs?: Vector4;
  86125. }): VertexData;
  86126. /**
  86127. * Creates the VertexData of the LineSystem
  86128. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  86129. * - lines an array of lines, each line being an array of successive Vector3
  86130. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  86131. * @returns the VertexData of the LineSystem
  86132. */
  86133. static CreateLineSystem(options: {
  86134. lines: Vector3[][];
  86135. colors?: Nullable<Color4[][]>;
  86136. }): VertexData;
  86137. /**
  86138. * Create the VertexData for a DashedLines
  86139. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  86140. * - points an array successive Vector3
  86141. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  86142. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  86143. * - dashNb the intended total number of dashes, optional, default 200
  86144. * @returns the VertexData for the DashedLines
  86145. */
  86146. static CreateDashedLines(options: {
  86147. points: Vector3[];
  86148. dashSize?: number;
  86149. gapSize?: number;
  86150. dashNb?: number;
  86151. }): VertexData;
  86152. /**
  86153. * Creates the VertexData for a Ground
  86154. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  86155. * - width the width (x direction) of the ground, optional, default 1
  86156. * - height the height (z direction) of the ground, optional, default 1
  86157. * - subdivisions the number of subdivisions per side, optional, default 1
  86158. * @returns the VertexData of the Ground
  86159. */
  86160. static CreateGround(options: {
  86161. width?: number;
  86162. height?: number;
  86163. subdivisions?: number;
  86164. subdivisionsX?: number;
  86165. subdivisionsY?: number;
  86166. }): VertexData;
  86167. /**
  86168. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  86169. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  86170. * * xmin the ground minimum X coordinate, optional, default -1
  86171. * * zmin the ground minimum Z coordinate, optional, default -1
  86172. * * xmax the ground maximum X coordinate, optional, default 1
  86173. * * zmax the ground maximum Z coordinate, optional, default 1
  86174. * * 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}
  86175. * * 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}
  86176. * @returns the VertexData of the TiledGround
  86177. */
  86178. static CreateTiledGround(options: {
  86179. xmin: number;
  86180. zmin: number;
  86181. xmax: number;
  86182. zmax: number;
  86183. subdivisions?: {
  86184. w: number;
  86185. h: number;
  86186. };
  86187. precision?: {
  86188. w: number;
  86189. h: number;
  86190. };
  86191. }): VertexData;
  86192. /**
  86193. * Creates the VertexData of the Ground designed from a heightmap
  86194. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  86195. * * width the width (x direction) of the ground
  86196. * * height the height (z direction) of the ground
  86197. * * subdivisions the number of subdivisions per side
  86198. * * minHeight the minimum altitude on the ground, optional, default 0
  86199. * * maxHeight the maximum altitude on the ground, optional default 1
  86200. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  86201. * * buffer the array holding the image color data
  86202. * * bufferWidth the width of image
  86203. * * bufferHeight the height of image
  86204. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  86205. * @returns the VertexData of the Ground designed from a heightmap
  86206. */
  86207. static CreateGroundFromHeightMap(options: {
  86208. width: number;
  86209. height: number;
  86210. subdivisions: number;
  86211. minHeight: number;
  86212. maxHeight: number;
  86213. colorFilter: Color3;
  86214. buffer: Uint8Array;
  86215. bufferWidth: number;
  86216. bufferHeight: number;
  86217. alphaFilter: number;
  86218. }): VertexData;
  86219. /**
  86220. * Creates the VertexData for a Plane
  86221. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  86222. * * size sets the width and height of the plane to the value of size, optional default 1
  86223. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  86224. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  86225. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86226. * * 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)
  86227. * * 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)
  86228. * @returns the VertexData of the box
  86229. */
  86230. static CreatePlane(options: {
  86231. size?: number;
  86232. width?: number;
  86233. height?: number;
  86234. sideOrientation?: number;
  86235. frontUVs?: Vector4;
  86236. backUVs?: Vector4;
  86237. }): VertexData;
  86238. /**
  86239. * Creates the VertexData of the Disc or regular Polygon
  86240. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  86241. * * radius the radius of the disc, optional default 0.5
  86242. * * tessellation the number of polygon sides, optional, default 64
  86243. * * 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
  86244. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86245. * * 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)
  86246. * * 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)
  86247. * @returns the VertexData of the box
  86248. */
  86249. static CreateDisc(options: {
  86250. radius?: number;
  86251. tessellation?: number;
  86252. arc?: number;
  86253. sideOrientation?: number;
  86254. frontUVs?: Vector4;
  86255. backUVs?: Vector4;
  86256. }): VertexData;
  86257. /**
  86258. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  86259. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  86260. * @param polygon a mesh built from polygonTriangulation.build()
  86261. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86262. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  86263. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  86264. * @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)
  86265. * @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)
  86266. * @returns the VertexData of the Polygon
  86267. */
  86268. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  86269. /**
  86270. * Creates the VertexData of the IcoSphere
  86271. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  86272. * * radius the radius of the IcoSphere, optional default 1
  86273. * * radiusX allows stretching in the x direction, optional, default radius
  86274. * * radiusY allows stretching in the y direction, optional, default radius
  86275. * * radiusZ allows stretching in the z direction, optional, default radius
  86276. * * flat when true creates a flat shaded mesh, optional, default true
  86277. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  86278. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86279. * * 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)
  86280. * * 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)
  86281. * @returns the VertexData of the IcoSphere
  86282. */
  86283. static CreateIcoSphere(options: {
  86284. radius?: number;
  86285. radiusX?: number;
  86286. radiusY?: number;
  86287. radiusZ?: number;
  86288. flat?: boolean;
  86289. subdivisions?: number;
  86290. sideOrientation?: number;
  86291. frontUVs?: Vector4;
  86292. backUVs?: Vector4;
  86293. }): VertexData;
  86294. /**
  86295. * Creates the VertexData for a Polyhedron
  86296. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  86297. * * type provided types are:
  86298. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  86299. * * 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)
  86300. * * size the size of the IcoSphere, optional default 1
  86301. * * sizeX allows stretching in the x direction, optional, default size
  86302. * * sizeY allows stretching in the y direction, optional, default size
  86303. * * sizeZ allows stretching in the z direction, optional, default size
  86304. * * 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
  86305. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  86306. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  86307. * * flat when true creates a flat shaded mesh, optional, default true
  86308. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  86309. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86310. * * 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)
  86311. * * 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)
  86312. * @returns the VertexData of the Polyhedron
  86313. */
  86314. static CreatePolyhedron(options: {
  86315. type?: number;
  86316. size?: number;
  86317. sizeX?: number;
  86318. sizeY?: number;
  86319. sizeZ?: number;
  86320. custom?: any;
  86321. faceUV?: Vector4[];
  86322. faceColors?: Color4[];
  86323. flat?: boolean;
  86324. sideOrientation?: number;
  86325. frontUVs?: Vector4;
  86326. backUVs?: Vector4;
  86327. }): VertexData;
  86328. /**
  86329. * Creates the VertexData for a TorusKnot
  86330. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  86331. * * radius the radius of the torus knot, optional, default 2
  86332. * * tube the thickness of the tube, optional, default 0.5
  86333. * * radialSegments the number of sides on each tube segments, optional, default 32
  86334. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  86335. * * p the number of windings around the z axis, optional, default 2
  86336. * * q the number of windings around the x axis, optional, default 3
  86337. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86338. * * 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)
  86339. * * 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)
  86340. * @returns the VertexData of the Torus Knot
  86341. */
  86342. static CreateTorusKnot(options: {
  86343. radius?: number;
  86344. tube?: number;
  86345. radialSegments?: number;
  86346. tubularSegments?: number;
  86347. p?: number;
  86348. q?: number;
  86349. sideOrientation?: number;
  86350. frontUVs?: Vector4;
  86351. backUVs?: Vector4;
  86352. }): VertexData;
  86353. /**
  86354. * Compute normals for given positions and indices
  86355. * @param positions an array of vertex positions, [...., x, y, z, ......]
  86356. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  86357. * @param normals an array of vertex normals, [...., x, y, z, ......]
  86358. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  86359. * * facetNormals : optional array of facet normals (vector3)
  86360. * * facetPositions : optional array of facet positions (vector3)
  86361. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  86362. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  86363. * * bInfo : optional bounding info, required for facetPartitioning computation
  86364. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  86365. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  86366. * * useRightHandedSystem: optional boolean to for right handed system computation
  86367. * * depthSort : optional boolean to enable the facet depth sort computation
  86368. * * distanceTo : optional Vector3 to compute the facet depth from this location
  86369. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  86370. */
  86371. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  86372. facetNormals?: any;
  86373. facetPositions?: any;
  86374. facetPartitioning?: any;
  86375. ratio?: number;
  86376. bInfo?: any;
  86377. bbSize?: Vector3;
  86378. subDiv?: any;
  86379. useRightHandedSystem?: boolean;
  86380. depthSort?: boolean;
  86381. distanceTo?: Vector3;
  86382. depthSortedFacets?: any;
  86383. }): void;
  86384. /** @hidden */
  86385. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  86386. /**
  86387. * Applies VertexData created from the imported parameters to the geometry
  86388. * @param parsedVertexData the parsed data from an imported file
  86389. * @param geometry the geometry to apply the VertexData to
  86390. */
  86391. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  86392. }
  86393. }
  86394. declare module BABYLON {
  86395. /**
  86396. * Class containing static functions to help procedurally build meshes
  86397. */
  86398. export class DiscBuilder {
  86399. /**
  86400. * Creates a plane polygonal mesh. By default, this is a disc
  86401. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  86402. * * 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
  86403. * * 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
  86404. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  86405. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  86406. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  86407. * @param name defines the name of the mesh
  86408. * @param options defines the options used to create the mesh
  86409. * @param scene defines the hosting scene
  86410. * @returns the plane polygonal mesh
  86411. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  86412. */
  86413. static CreateDisc(name: string, options: {
  86414. radius?: number;
  86415. tessellation?: number;
  86416. arc?: number;
  86417. updatable?: boolean;
  86418. sideOrientation?: number;
  86419. frontUVs?: Vector4;
  86420. backUVs?: Vector4;
  86421. }, scene?: Nullable<Scene>): Mesh;
  86422. }
  86423. }
  86424. declare module BABYLON {
  86425. /**
  86426. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  86427. *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.
  86428. * The SPS is also a particle system. It provides some methods to manage the particles.
  86429. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  86430. *
  86431. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  86432. */
  86433. export class SolidParticleSystem implements IDisposable {
  86434. /**
  86435. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  86436. * Example : var p = SPS.particles[i];
  86437. */
  86438. particles: SolidParticle[];
  86439. /**
  86440. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  86441. */
  86442. nbParticles: number;
  86443. /**
  86444. * If the particles must ever face the camera (default false). Useful for planar particles.
  86445. */
  86446. billboard: boolean;
  86447. /**
  86448. * Recompute normals when adding a shape
  86449. */
  86450. recomputeNormals: boolean;
  86451. /**
  86452. * This a counter ofr your own usage. It's not set by any SPS functions.
  86453. */
  86454. counter: number;
  86455. /**
  86456. * The SPS name. This name is also given to the underlying mesh.
  86457. */
  86458. name: string;
  86459. /**
  86460. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  86461. */
  86462. mesh: Mesh;
  86463. /**
  86464. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  86465. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  86466. */
  86467. vars: any;
  86468. /**
  86469. * This array is populated when the SPS is set as 'pickable'.
  86470. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  86471. * Each element of this array is an object `{idx: int, faceId: int}`.
  86472. * `idx` is the picked particle index in the `SPS.particles` array
  86473. * `faceId` is the picked face index counted within this particle.
  86474. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  86475. */
  86476. pickedParticles: {
  86477. idx: number;
  86478. faceId: number;
  86479. }[];
  86480. /**
  86481. * This array is populated when `enableDepthSort` is set to true.
  86482. * Each element of this array is an instance of the class DepthSortedParticle.
  86483. */
  86484. depthSortedParticles: DepthSortedParticle[];
  86485. /**
  86486. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  86487. * @hidden
  86488. */
  86489. _bSphereOnly: boolean;
  86490. /**
  86491. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  86492. * @hidden
  86493. */
  86494. _bSphereRadiusFactor: number;
  86495. private _scene;
  86496. private _positions;
  86497. private _indices;
  86498. private _normals;
  86499. private _colors;
  86500. private _uvs;
  86501. private _indices32;
  86502. private _positions32;
  86503. private _normals32;
  86504. private _fixedNormal32;
  86505. private _colors32;
  86506. private _uvs32;
  86507. private _index;
  86508. private _updatable;
  86509. private _pickable;
  86510. private _isVisibilityBoxLocked;
  86511. private _alwaysVisible;
  86512. private _depthSort;
  86513. private _shapeCounter;
  86514. private _copy;
  86515. private _color;
  86516. private _computeParticleColor;
  86517. private _computeParticleTexture;
  86518. private _computeParticleRotation;
  86519. private _computeParticleVertex;
  86520. private _computeBoundingBox;
  86521. private _depthSortParticles;
  86522. private _camera;
  86523. private _mustUnrotateFixedNormals;
  86524. private _particlesIntersect;
  86525. private _needs32Bits;
  86526. /**
  86527. * Creates a SPS (Solid Particle System) object.
  86528. * @param name (String) is the SPS name, this will be the underlying mesh name.
  86529. * @param scene (Scene) is the scene in which the SPS is added.
  86530. * @param options defines the options of the sps e.g.
  86531. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  86532. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  86533. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  86534. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  86535. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  86536. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  86537. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  86538. */
  86539. constructor(name: string, scene: Scene, options?: {
  86540. updatable?: boolean;
  86541. isPickable?: boolean;
  86542. enableDepthSort?: boolean;
  86543. particleIntersection?: boolean;
  86544. boundingSphereOnly?: boolean;
  86545. bSphereRadiusFactor?: number;
  86546. });
  86547. /**
  86548. * Builds the SPS underlying mesh. Returns a standard Mesh.
  86549. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  86550. * @returns the created mesh
  86551. */
  86552. buildMesh(): Mesh;
  86553. /**
  86554. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  86555. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  86556. * Thus the particles generated from `digest()` have their property `position` set yet.
  86557. * @param mesh ( Mesh ) is the mesh to be digested
  86558. * @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
  86559. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  86560. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  86561. * @returns the current SPS
  86562. */
  86563. digest(mesh: Mesh, options?: {
  86564. facetNb?: number;
  86565. number?: number;
  86566. delta?: number;
  86567. }): SolidParticleSystem;
  86568. private _unrotateFixedNormals;
  86569. private _resetCopy;
  86570. private _meshBuilder;
  86571. private _posToShape;
  86572. private _uvsToShapeUV;
  86573. private _addParticle;
  86574. /**
  86575. * Adds some particles to the SPS from the model shape. Returns the shape id.
  86576. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  86577. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  86578. * @param nb (positive integer) the number of particles to be created from this model
  86579. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  86580. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  86581. * @returns the number of shapes in the system
  86582. */
  86583. addShape(mesh: Mesh, nb: number, options?: {
  86584. positionFunction?: any;
  86585. vertexFunction?: any;
  86586. }): number;
  86587. private _rebuildParticle;
  86588. /**
  86589. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  86590. * @returns the SPS.
  86591. */
  86592. rebuildMesh(): SolidParticleSystem;
  86593. /**
  86594. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  86595. * This method calls `updateParticle()` for each particle of the SPS.
  86596. * For an animated SPS, it is usually called within the render loop.
  86597. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  86598. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  86599. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  86600. * @returns the SPS.
  86601. */
  86602. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  86603. /**
  86604. * Disposes the SPS.
  86605. */
  86606. dispose(): void;
  86607. /**
  86608. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  86609. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  86610. * @returns the SPS.
  86611. */
  86612. refreshVisibleSize(): SolidParticleSystem;
  86613. /**
  86614. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  86615. * @param size the size (float) of the visibility box
  86616. * note : this doesn't lock the SPS mesh bounding box.
  86617. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  86618. */
  86619. setVisibilityBox(size: number): void;
  86620. /**
  86621. * Gets whether the SPS as always visible or not
  86622. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  86623. */
  86624. /**
  86625. * Sets the SPS as always visible or not
  86626. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  86627. */
  86628. isAlwaysVisible: boolean;
  86629. /**
  86630. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  86631. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  86632. */
  86633. /**
  86634. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  86635. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  86636. */
  86637. isVisibilityBoxLocked: boolean;
  86638. /**
  86639. * Tells to `setParticles()` to compute the particle rotations or not.
  86640. * Default value : true. The SPS is faster when it's set to false.
  86641. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  86642. */
  86643. /**
  86644. * Gets if `setParticles()` computes the particle rotations or not.
  86645. * Default value : true. The SPS is faster when it's set to false.
  86646. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  86647. */
  86648. computeParticleRotation: boolean;
  86649. /**
  86650. * Tells to `setParticles()` to compute the particle colors or not.
  86651. * Default value : true. The SPS is faster when it's set to false.
  86652. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  86653. */
  86654. /**
  86655. * Gets if `setParticles()` computes the particle colors or not.
  86656. * Default value : true. The SPS is faster when it's set to false.
  86657. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  86658. */
  86659. computeParticleColor: boolean;
  86660. /**
  86661. * Gets if `setParticles()` computes the particle textures or not.
  86662. * Default value : true. The SPS is faster when it's set to false.
  86663. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  86664. */
  86665. computeParticleTexture: boolean;
  86666. /**
  86667. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  86668. * Default value : false. The SPS is faster when it's set to false.
  86669. * Note : the particle custom vertex positions aren't stored values.
  86670. */
  86671. /**
  86672. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  86673. * Default value : false. The SPS is faster when it's set to false.
  86674. * Note : the particle custom vertex positions aren't stored values.
  86675. */
  86676. computeParticleVertex: boolean;
  86677. /**
  86678. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  86679. */
  86680. /**
  86681. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  86682. */
  86683. computeBoundingBox: boolean;
  86684. /**
  86685. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  86686. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  86687. * Default : `true`
  86688. */
  86689. /**
  86690. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  86691. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  86692. * Default : `true`
  86693. */
  86694. depthSortParticles: boolean;
  86695. /**
  86696. * This function does nothing. It may be overwritten to set all the particle first values.
  86697. * The SPS doesn't call this function, you may have to call it by your own.
  86698. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  86699. */
  86700. initParticles(): void;
  86701. /**
  86702. * This function does nothing. It may be overwritten to recycle a particle.
  86703. * The SPS doesn't call this function, you may have to call it by your own.
  86704. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  86705. * @param particle The particle to recycle
  86706. * @returns the recycled particle
  86707. */
  86708. recycleParticle(particle: SolidParticle): SolidParticle;
  86709. /**
  86710. * Updates a particle : this function should be overwritten by the user.
  86711. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  86712. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  86713. * @example : just set a particle position or velocity and recycle conditions
  86714. * @param particle The particle to update
  86715. * @returns the updated particle
  86716. */
  86717. updateParticle(particle: SolidParticle): SolidParticle;
  86718. /**
  86719. * Updates a vertex of a particle : it can be overwritten by the user.
  86720. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  86721. * @param particle the current particle
  86722. * @param vertex the current index of the current particle
  86723. * @param pt the index of the current vertex in the particle shape
  86724. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  86725. * @example : just set a vertex particle position
  86726. * @returns the updated vertex
  86727. */
  86728. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  86729. /**
  86730. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  86731. * This does nothing and may be overwritten by the user.
  86732. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  86733. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  86734. * @param update the boolean update value actually passed to setParticles()
  86735. */
  86736. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  86737. /**
  86738. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  86739. * This will be passed three parameters.
  86740. * This does nothing and may be overwritten by the user.
  86741. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  86742. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  86743. * @param update the boolean update value actually passed to setParticles()
  86744. */
  86745. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  86746. }
  86747. }
  86748. declare module BABYLON {
  86749. /**
  86750. * Represents one particle of a solid particle system.
  86751. */
  86752. export class SolidParticle {
  86753. /**
  86754. * particle global index
  86755. */
  86756. idx: number;
  86757. /**
  86758. * The color of the particle
  86759. */
  86760. color: Nullable<Color4>;
  86761. /**
  86762. * The world space position of the particle.
  86763. */
  86764. position: Vector3;
  86765. /**
  86766. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  86767. */
  86768. rotation: Vector3;
  86769. /**
  86770. * The world space rotation quaternion of the particle.
  86771. */
  86772. rotationQuaternion: Nullable<Quaternion>;
  86773. /**
  86774. * The scaling of the particle.
  86775. */
  86776. scaling: Vector3;
  86777. /**
  86778. * The uvs of the particle.
  86779. */
  86780. uvs: Vector4;
  86781. /**
  86782. * The current speed of the particle.
  86783. */
  86784. velocity: Vector3;
  86785. /**
  86786. * The pivot point in the particle local space.
  86787. */
  86788. pivot: Vector3;
  86789. /**
  86790. * Must the particle be translated from its pivot point in its local space ?
  86791. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  86792. * Default : false
  86793. */
  86794. translateFromPivot: boolean;
  86795. /**
  86796. * Is the particle active or not ?
  86797. */
  86798. alive: boolean;
  86799. /**
  86800. * Is the particle visible or not ?
  86801. */
  86802. isVisible: boolean;
  86803. /**
  86804. * Index of this particle in the global "positions" array (Internal use)
  86805. * @hidden
  86806. */
  86807. _pos: number;
  86808. /**
  86809. * @hidden Index of this particle in the global "indices" array (Internal use)
  86810. */
  86811. _ind: number;
  86812. /**
  86813. * @hidden ModelShape of this particle (Internal use)
  86814. */
  86815. _model: ModelShape;
  86816. /**
  86817. * ModelShape id of this particle
  86818. */
  86819. shapeId: number;
  86820. /**
  86821. * Index of the particle in its shape id (Internal use)
  86822. */
  86823. idxInShape: number;
  86824. /**
  86825. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  86826. */
  86827. _modelBoundingInfo: BoundingInfo;
  86828. /**
  86829. * @hidden Particle BoundingInfo object (Internal use)
  86830. */
  86831. _boundingInfo: BoundingInfo;
  86832. /**
  86833. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  86834. */
  86835. _sps: SolidParticleSystem;
  86836. /**
  86837. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  86838. */
  86839. _stillInvisible: boolean;
  86840. /**
  86841. * @hidden Last computed particle rotation matrix
  86842. */
  86843. _rotationMatrix: number[];
  86844. /**
  86845. * Parent particle Id, if any.
  86846. * Default null.
  86847. */
  86848. parentId: Nullable<number>;
  86849. /**
  86850. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  86851. * The possible values are :
  86852. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  86853. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  86854. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  86855. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  86856. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  86857. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  86858. * */
  86859. cullingStrategy: number;
  86860. /**
  86861. * @hidden Internal global position in the SPS.
  86862. */
  86863. _globalPosition: Vector3;
  86864. /**
  86865. * Creates a Solid Particle object.
  86866. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  86867. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  86868. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  86869. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  86870. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  86871. * @param shapeId (integer) is the model shape identifier in the SPS.
  86872. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  86873. * @param sps defines the sps it is associated to
  86874. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  86875. */
  86876. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  86877. /**
  86878. * Legacy support, changed scale to scaling
  86879. */
  86880. /**
  86881. * Legacy support, changed scale to scaling
  86882. */
  86883. scale: Vector3;
  86884. /**
  86885. * Legacy support, changed quaternion to rotationQuaternion
  86886. */
  86887. /**
  86888. * Legacy support, changed quaternion to rotationQuaternion
  86889. */
  86890. quaternion: Nullable<Quaternion>;
  86891. /**
  86892. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  86893. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  86894. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  86895. * @returns true if it intersects
  86896. */
  86897. intersectsMesh(target: Mesh | SolidParticle): boolean;
  86898. /**
  86899. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  86900. * A particle is in the frustum if its bounding box intersects the frustum
  86901. * @param frustumPlanes defines the frustum to test
  86902. * @returns true if the particle is in the frustum planes
  86903. */
  86904. isInFrustum(frustumPlanes: Plane[]): boolean;
  86905. /**
  86906. * get the rotation matrix of the particle
  86907. * @hidden
  86908. */
  86909. getRotationMatrix(m: Matrix): void;
  86910. }
  86911. /**
  86912. * Represents the shape of the model used by one particle of a solid particle system.
  86913. * SPS internal tool, don't use it manually.
  86914. */
  86915. export class ModelShape {
  86916. /**
  86917. * The shape id
  86918. * @hidden
  86919. */
  86920. shapeID: number;
  86921. /**
  86922. * flat array of model positions (internal use)
  86923. * @hidden
  86924. */
  86925. _shape: Vector3[];
  86926. /**
  86927. * flat array of model UVs (internal use)
  86928. * @hidden
  86929. */
  86930. _shapeUV: number[];
  86931. /**
  86932. * length of the shape in the model indices array (internal use)
  86933. * @hidden
  86934. */
  86935. _indicesLength: number;
  86936. /**
  86937. * Custom position function (internal use)
  86938. * @hidden
  86939. */
  86940. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  86941. /**
  86942. * Custom vertex function (internal use)
  86943. * @hidden
  86944. */
  86945. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  86946. /**
  86947. * 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.
  86948. * SPS internal tool, don't use it manually.
  86949. * @hidden
  86950. */
  86951. 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>);
  86952. }
  86953. /**
  86954. * Represents a Depth Sorted Particle in the solid particle system.
  86955. */
  86956. export class DepthSortedParticle {
  86957. /**
  86958. * Index of the particle in the "indices" array
  86959. */
  86960. ind: number;
  86961. /**
  86962. * Length of the particle shape in the "indices" array
  86963. */
  86964. indicesLength: number;
  86965. /**
  86966. * Squared distance from the particle to the camera
  86967. */
  86968. sqDistance: number;
  86969. }
  86970. }
  86971. declare module BABYLON {
  86972. /**
  86973. * @hidden
  86974. */
  86975. export class _MeshCollisionData {
  86976. _checkCollisions: boolean;
  86977. _collisionMask: number;
  86978. _collisionGroup: number;
  86979. _collider: Nullable<Collider>;
  86980. _oldPositionForCollisions: Vector3;
  86981. _diffPositionForCollisions: Vector3;
  86982. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  86983. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  86984. }
  86985. }
  86986. declare module BABYLON {
  86987. /** @hidden */
  86988. class _FacetDataStorage {
  86989. facetPositions: Vector3[];
  86990. facetNormals: Vector3[];
  86991. facetPartitioning: number[][];
  86992. facetNb: number;
  86993. partitioningSubdivisions: number;
  86994. partitioningBBoxRatio: number;
  86995. facetDataEnabled: boolean;
  86996. facetParameters: any;
  86997. bbSize: Vector3;
  86998. subDiv: {
  86999. max: number;
  87000. X: number;
  87001. Y: number;
  87002. Z: number;
  87003. };
  87004. facetDepthSort: boolean;
  87005. facetDepthSortEnabled: boolean;
  87006. depthSortedIndices: IndicesArray;
  87007. depthSortedFacets: {
  87008. ind: number;
  87009. sqDistance: number;
  87010. }[];
  87011. facetDepthSortFunction: (f1: {
  87012. ind: number;
  87013. sqDistance: number;
  87014. }, f2: {
  87015. ind: number;
  87016. sqDistance: number;
  87017. }) => number;
  87018. facetDepthSortFrom: Vector3;
  87019. facetDepthSortOrigin: Vector3;
  87020. invertedMatrix: Matrix;
  87021. }
  87022. /**
  87023. * @hidden
  87024. **/
  87025. class _InternalAbstractMeshDataInfo {
  87026. _hasVertexAlpha: boolean;
  87027. _useVertexColors: boolean;
  87028. _numBoneInfluencers: number;
  87029. _applyFog: boolean;
  87030. _receiveShadows: boolean;
  87031. _facetData: _FacetDataStorage;
  87032. _visibility: number;
  87033. _skeleton: Nullable<Skeleton>;
  87034. _layerMask: number;
  87035. _computeBonesUsingShaders: boolean;
  87036. _isActive: boolean;
  87037. _onlyForInstances: boolean;
  87038. _isActiveIntermediate: boolean;
  87039. _onlyForInstancesIntermediate: boolean;
  87040. }
  87041. /**
  87042. * Class used to store all common mesh properties
  87043. */
  87044. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  87045. /** No occlusion */
  87046. static OCCLUSION_TYPE_NONE: number;
  87047. /** Occlusion set to optimisitic */
  87048. static OCCLUSION_TYPE_OPTIMISTIC: number;
  87049. /** Occlusion set to strict */
  87050. static OCCLUSION_TYPE_STRICT: number;
  87051. /** Use an accurante occlusion algorithm */
  87052. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  87053. /** Use a conservative occlusion algorithm */
  87054. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  87055. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  87056. * Test order :
  87057. * Is the bounding sphere outside the frustum ?
  87058. * If not, are the bounding box vertices outside the frustum ?
  87059. * It not, then the cullable object is in the frustum.
  87060. */
  87061. static readonly CULLINGSTRATEGY_STANDARD: number;
  87062. /** Culling strategy : Bounding Sphere Only.
  87063. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  87064. * It's also less accurate than the standard because some not visible objects can still be selected.
  87065. * Test : is the bounding sphere outside the frustum ?
  87066. * If not, then the cullable object is in the frustum.
  87067. */
  87068. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  87069. /** Culling strategy : Optimistic Inclusion.
  87070. * This in an inclusion test first, then the standard exclusion test.
  87071. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  87072. * 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.
  87073. * Anyway, it's as accurate as the standard strategy.
  87074. * Test :
  87075. * Is the cullable object bounding sphere center in the frustum ?
  87076. * If not, apply the default culling strategy.
  87077. */
  87078. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  87079. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  87080. * This in an inclusion test first, then the bounding sphere only exclusion test.
  87081. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  87082. * 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.
  87083. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  87084. * Test :
  87085. * Is the cullable object bounding sphere center in the frustum ?
  87086. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  87087. */
  87088. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  87089. /**
  87090. * No billboard
  87091. */
  87092. static readonly BILLBOARDMODE_NONE: number;
  87093. /** Billboard on X axis */
  87094. static readonly BILLBOARDMODE_X: number;
  87095. /** Billboard on Y axis */
  87096. static readonly BILLBOARDMODE_Y: number;
  87097. /** Billboard on Z axis */
  87098. static readonly BILLBOARDMODE_Z: number;
  87099. /** Billboard on all axes */
  87100. static readonly BILLBOARDMODE_ALL: number;
  87101. /** @hidden */
  87102. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  87103. /**
  87104. * The culling strategy to use to check whether the mesh must be rendered or not.
  87105. * This value can be changed at any time and will be used on the next render mesh selection.
  87106. * The possible values are :
  87107. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  87108. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  87109. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  87110. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  87111. * Please read each static variable documentation to get details about the culling process.
  87112. * */
  87113. cullingStrategy: number;
  87114. /**
  87115. * Gets the number of facets in the mesh
  87116. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  87117. */
  87118. readonly facetNb: number;
  87119. /**
  87120. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  87121. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  87122. */
  87123. partitioningSubdivisions: number;
  87124. /**
  87125. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  87126. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  87127. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  87128. */
  87129. partitioningBBoxRatio: number;
  87130. /**
  87131. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  87132. * Works only for updatable meshes.
  87133. * Doesn't work with multi-materials
  87134. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  87135. */
  87136. mustDepthSortFacets: boolean;
  87137. /**
  87138. * The location (Vector3) where the facet depth sort must be computed from.
  87139. * By default, the active camera position.
  87140. * Used only when facet depth sort is enabled
  87141. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  87142. */
  87143. facetDepthSortFrom: Vector3;
  87144. /**
  87145. * gets a boolean indicating if facetData is enabled
  87146. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  87147. */
  87148. readonly isFacetDataEnabled: boolean;
  87149. /** @hidden */
  87150. _updateNonUniformScalingState(value: boolean): boolean;
  87151. /**
  87152. * An event triggered when this mesh collides with another one
  87153. */
  87154. onCollideObservable: Observable<AbstractMesh>;
  87155. /** Set a function to call when this mesh collides with another one */
  87156. onCollide: () => void;
  87157. /**
  87158. * An event triggered when the collision's position changes
  87159. */
  87160. onCollisionPositionChangeObservable: Observable<Vector3>;
  87161. /** Set a function to call when the collision's position changes */
  87162. onCollisionPositionChange: () => void;
  87163. /**
  87164. * An event triggered when material is changed
  87165. */
  87166. onMaterialChangedObservable: Observable<AbstractMesh>;
  87167. /**
  87168. * Gets or sets the orientation for POV movement & rotation
  87169. */
  87170. definedFacingForward: boolean;
  87171. /** @hidden */
  87172. _occlusionQuery: Nullable<WebGLQuery>;
  87173. /** @hidden */
  87174. _renderingGroup: Nullable<RenderingGroup>;
  87175. /**
  87176. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  87177. */
  87178. /**
  87179. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  87180. */
  87181. visibility: number;
  87182. /** Gets or sets the alpha index used to sort transparent meshes
  87183. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  87184. */
  87185. alphaIndex: number;
  87186. /**
  87187. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  87188. */
  87189. isVisible: boolean;
  87190. /**
  87191. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  87192. */
  87193. isPickable: boolean;
  87194. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  87195. showSubMeshesBoundingBox: boolean;
  87196. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  87197. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  87198. */
  87199. isBlocker: boolean;
  87200. /**
  87201. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  87202. */
  87203. enablePointerMoveEvents: boolean;
  87204. /**
  87205. * Specifies the rendering group id for this mesh (0 by default)
  87206. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  87207. */
  87208. renderingGroupId: number;
  87209. private _material;
  87210. /** Gets or sets current material */
  87211. material: Nullable<Material>;
  87212. /**
  87213. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  87214. * @see http://doc.babylonjs.com/babylon101/shadows
  87215. */
  87216. receiveShadows: boolean;
  87217. /** Defines color to use when rendering outline */
  87218. outlineColor: Color3;
  87219. /** Define width to use when rendering outline */
  87220. outlineWidth: number;
  87221. /** Defines color to use when rendering overlay */
  87222. overlayColor: Color3;
  87223. /** Defines alpha to use when rendering overlay */
  87224. overlayAlpha: number;
  87225. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  87226. hasVertexAlpha: boolean;
  87227. /** 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) */
  87228. useVertexColors: boolean;
  87229. /**
  87230. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  87231. */
  87232. computeBonesUsingShaders: boolean;
  87233. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  87234. numBoneInfluencers: number;
  87235. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  87236. applyFog: boolean;
  87237. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  87238. useOctreeForRenderingSelection: boolean;
  87239. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  87240. useOctreeForPicking: boolean;
  87241. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  87242. useOctreeForCollisions: boolean;
  87243. /**
  87244. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  87245. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  87246. */
  87247. layerMask: number;
  87248. /**
  87249. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  87250. */
  87251. alwaysSelectAsActiveMesh: boolean;
  87252. /**
  87253. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  87254. */
  87255. doNotSyncBoundingInfo: boolean;
  87256. /**
  87257. * Gets or sets the current action manager
  87258. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87259. */
  87260. actionManager: Nullable<AbstractActionManager>;
  87261. private _meshCollisionData;
  87262. /**
  87263. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  87264. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  87265. */
  87266. ellipsoid: Vector3;
  87267. /**
  87268. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  87269. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  87270. */
  87271. ellipsoidOffset: Vector3;
  87272. /**
  87273. * Gets or sets a collision mask used to mask collisions (default is -1).
  87274. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  87275. */
  87276. collisionMask: number;
  87277. /**
  87278. * Gets or sets the current collision group mask (-1 by default).
  87279. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  87280. */
  87281. collisionGroup: number;
  87282. /**
  87283. * Defines edge width used when edgesRenderer is enabled
  87284. * @see https://www.babylonjs-playground.com/#10OJSG#13
  87285. */
  87286. edgesWidth: number;
  87287. /**
  87288. * Defines edge color used when edgesRenderer is enabled
  87289. * @see https://www.babylonjs-playground.com/#10OJSG#13
  87290. */
  87291. edgesColor: Color4;
  87292. /** @hidden */
  87293. _edgesRenderer: Nullable<IEdgesRenderer>;
  87294. /** @hidden */
  87295. _masterMesh: Nullable<AbstractMesh>;
  87296. /** @hidden */
  87297. _boundingInfo: Nullable<BoundingInfo>;
  87298. /** @hidden */
  87299. _renderId: number;
  87300. /**
  87301. * Gets or sets the list of subMeshes
  87302. * @see http://doc.babylonjs.com/how_to/multi_materials
  87303. */
  87304. subMeshes: SubMesh[];
  87305. /** @hidden */
  87306. _intersectionsInProgress: AbstractMesh[];
  87307. /** @hidden */
  87308. _unIndexed: boolean;
  87309. /** @hidden */
  87310. _lightSources: Light[];
  87311. /** Gets the list of lights affecting that mesh */
  87312. readonly lightSources: Light[];
  87313. /** @hidden */
  87314. readonly _positions: Nullable<Vector3[]>;
  87315. /** @hidden */
  87316. _waitingData: {
  87317. lods: Nullable<any>;
  87318. actions: Nullable<any>;
  87319. freezeWorldMatrix: Nullable<boolean>;
  87320. };
  87321. /** @hidden */
  87322. _bonesTransformMatrices: Nullable<Float32Array>;
  87323. /**
  87324. * Gets or sets a skeleton to apply skining transformations
  87325. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  87326. */
  87327. skeleton: Nullable<Skeleton>;
  87328. /**
  87329. * An event triggered when the mesh is rebuilt.
  87330. */
  87331. onRebuildObservable: Observable<AbstractMesh>;
  87332. /**
  87333. * Creates a new AbstractMesh
  87334. * @param name defines the name of the mesh
  87335. * @param scene defines the hosting scene
  87336. */
  87337. constructor(name: string, scene?: Nullable<Scene>);
  87338. /**
  87339. * Returns the string "AbstractMesh"
  87340. * @returns "AbstractMesh"
  87341. */
  87342. getClassName(): string;
  87343. /**
  87344. * Gets a string representation of the current mesh
  87345. * @param fullDetails defines a boolean indicating if full details must be included
  87346. * @returns a string representation of the current mesh
  87347. */
  87348. toString(fullDetails?: boolean): string;
  87349. /**
  87350. * @hidden
  87351. */
  87352. protected _getEffectiveParent(): Nullable<Node>;
  87353. /** @hidden */
  87354. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  87355. /** @hidden */
  87356. _rebuild(): void;
  87357. /** @hidden */
  87358. _resyncLightSources(): void;
  87359. /** @hidden */
  87360. _resyncLighSource(light: Light): void;
  87361. /** @hidden */
  87362. _unBindEffect(): void;
  87363. /** @hidden */
  87364. _removeLightSource(light: Light): void;
  87365. private _markSubMeshesAsDirty;
  87366. /** @hidden */
  87367. _markSubMeshesAsLightDirty(): void;
  87368. /** @hidden */
  87369. _markSubMeshesAsAttributesDirty(): void;
  87370. /** @hidden */
  87371. _markSubMeshesAsMiscDirty(): void;
  87372. /**
  87373. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  87374. */
  87375. scaling: Vector3;
  87376. /**
  87377. * Returns true if the mesh is blocked. Implemented by child classes
  87378. */
  87379. readonly isBlocked: boolean;
  87380. /**
  87381. * Returns the mesh itself by default. Implemented by child classes
  87382. * @param camera defines the camera to use to pick the right LOD level
  87383. * @returns the currentAbstractMesh
  87384. */
  87385. getLOD(camera: Camera): Nullable<AbstractMesh>;
  87386. /**
  87387. * Returns 0 by default. Implemented by child classes
  87388. * @returns an integer
  87389. */
  87390. getTotalVertices(): number;
  87391. /**
  87392. * Returns a positive integer : the total number of indices in this mesh geometry.
  87393. * @returns the numner of indices or zero if the mesh has no geometry.
  87394. */
  87395. getTotalIndices(): number;
  87396. /**
  87397. * Returns null by default. Implemented by child classes
  87398. * @returns null
  87399. */
  87400. getIndices(): Nullable<IndicesArray>;
  87401. /**
  87402. * Returns the array of the requested vertex data kind. Implemented by child classes
  87403. * @param kind defines the vertex data kind to use
  87404. * @returns null
  87405. */
  87406. getVerticesData(kind: string): Nullable<FloatArray>;
  87407. /**
  87408. * Sets the vertex data of the mesh geometry for the requested `kind`.
  87409. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  87410. * Note that a new underlying VertexBuffer object is created each call.
  87411. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  87412. * @param kind defines vertex data kind:
  87413. * * VertexBuffer.PositionKind
  87414. * * VertexBuffer.UVKind
  87415. * * VertexBuffer.UV2Kind
  87416. * * VertexBuffer.UV3Kind
  87417. * * VertexBuffer.UV4Kind
  87418. * * VertexBuffer.UV5Kind
  87419. * * VertexBuffer.UV6Kind
  87420. * * VertexBuffer.ColorKind
  87421. * * VertexBuffer.MatricesIndicesKind
  87422. * * VertexBuffer.MatricesIndicesExtraKind
  87423. * * VertexBuffer.MatricesWeightsKind
  87424. * * VertexBuffer.MatricesWeightsExtraKind
  87425. * @param data defines the data source
  87426. * @param updatable defines if the data must be flagged as updatable (or static)
  87427. * @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
  87428. * @returns the current mesh
  87429. */
  87430. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  87431. /**
  87432. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  87433. * If the mesh has no geometry, it is simply returned as it is.
  87434. * @param kind defines vertex data kind:
  87435. * * VertexBuffer.PositionKind
  87436. * * VertexBuffer.UVKind
  87437. * * VertexBuffer.UV2Kind
  87438. * * VertexBuffer.UV3Kind
  87439. * * VertexBuffer.UV4Kind
  87440. * * VertexBuffer.UV5Kind
  87441. * * VertexBuffer.UV6Kind
  87442. * * VertexBuffer.ColorKind
  87443. * * VertexBuffer.MatricesIndicesKind
  87444. * * VertexBuffer.MatricesIndicesExtraKind
  87445. * * VertexBuffer.MatricesWeightsKind
  87446. * * VertexBuffer.MatricesWeightsExtraKind
  87447. * @param data defines the data source
  87448. * @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
  87449. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  87450. * @returns the current mesh
  87451. */
  87452. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  87453. /**
  87454. * Sets the mesh indices,
  87455. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  87456. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  87457. * @param totalVertices Defines the total number of vertices
  87458. * @returns the current mesh
  87459. */
  87460. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  87461. /**
  87462. * Gets a boolean indicating if specific vertex data is present
  87463. * @param kind defines the vertex data kind to use
  87464. * @returns true is data kind is present
  87465. */
  87466. isVerticesDataPresent(kind: string): boolean;
  87467. /**
  87468. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  87469. * @returns a BoundingInfo
  87470. */
  87471. getBoundingInfo(): BoundingInfo;
  87472. /**
  87473. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  87474. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  87475. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  87476. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  87477. * @returns the current mesh
  87478. */
  87479. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  87480. /**
  87481. * Overwrite the current bounding info
  87482. * @param boundingInfo defines the new bounding info
  87483. * @returns the current mesh
  87484. */
  87485. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  87486. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  87487. readonly useBones: boolean;
  87488. /** @hidden */
  87489. _preActivate(): void;
  87490. /** @hidden */
  87491. _preActivateForIntermediateRendering(renderId: number): void;
  87492. /** @hidden */
  87493. _activate(renderId: number, intermediateRendering: boolean): boolean;
  87494. /** @hidden */
  87495. _postActivate(): void;
  87496. /** @hidden */
  87497. _freeze(): void;
  87498. /** @hidden */
  87499. _unFreeze(): void;
  87500. /**
  87501. * Gets the current world matrix
  87502. * @returns a Matrix
  87503. */
  87504. getWorldMatrix(): Matrix;
  87505. /** @hidden */
  87506. _getWorldMatrixDeterminant(): number;
  87507. /**
  87508. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  87509. */
  87510. readonly isAnInstance: boolean;
  87511. /**
  87512. * Perform relative position change from the point of view of behind the front of the mesh.
  87513. * This is performed taking into account the meshes current rotation, so you do not have to care.
  87514. * Supports definition of mesh facing forward or backward
  87515. * @param amountRight defines the distance on the right axis
  87516. * @param amountUp defines the distance on the up axis
  87517. * @param amountForward defines the distance on the forward axis
  87518. * @returns the current mesh
  87519. */
  87520. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  87521. /**
  87522. * Calculate relative position change from the point of view of behind the front of the mesh.
  87523. * This is performed taking into account the meshes current rotation, so you do not have to care.
  87524. * Supports definition of mesh facing forward or backward
  87525. * @param amountRight defines the distance on the right axis
  87526. * @param amountUp defines the distance on the up axis
  87527. * @param amountForward defines the distance on the forward axis
  87528. * @returns the new displacement vector
  87529. */
  87530. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  87531. /**
  87532. * Perform relative rotation change from the point of view of behind the front of the mesh.
  87533. * Supports definition of mesh facing forward or backward
  87534. * @param flipBack defines the flip
  87535. * @param twirlClockwise defines the twirl
  87536. * @param tiltRight defines the tilt
  87537. * @returns the current mesh
  87538. */
  87539. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  87540. /**
  87541. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  87542. * Supports definition of mesh facing forward or backward.
  87543. * @param flipBack defines the flip
  87544. * @param twirlClockwise defines the twirl
  87545. * @param tiltRight defines the tilt
  87546. * @returns the new rotation vector
  87547. */
  87548. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  87549. /**
  87550. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  87551. * This means the mesh underlying bounding box and sphere are recomputed.
  87552. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  87553. * @returns the current mesh
  87554. */
  87555. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  87556. /** @hidden */
  87557. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  87558. /** @hidden */
  87559. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  87560. /** @hidden */
  87561. _updateBoundingInfo(): AbstractMesh;
  87562. /** @hidden */
  87563. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  87564. /** @hidden */
  87565. protected _afterComputeWorldMatrix(): void;
  87566. /** @hidden */
  87567. readonly _effectiveMesh: AbstractMesh;
  87568. /**
  87569. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  87570. * A mesh is in the frustum if its bounding box intersects the frustum
  87571. * @param frustumPlanes defines the frustum to test
  87572. * @returns true if the mesh is in the frustum planes
  87573. */
  87574. isInFrustum(frustumPlanes: Plane[]): boolean;
  87575. /**
  87576. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  87577. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  87578. * @param frustumPlanes defines the frustum to test
  87579. * @returns true if the mesh is completely in the frustum planes
  87580. */
  87581. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  87582. /**
  87583. * True if the mesh intersects another mesh or a SolidParticle object
  87584. * @param mesh defines a target mesh or SolidParticle to test
  87585. * @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)
  87586. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  87587. * @returns true if there is an intersection
  87588. */
  87589. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  87590. /**
  87591. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  87592. * @param point defines the point to test
  87593. * @returns true if there is an intersection
  87594. */
  87595. intersectsPoint(point: Vector3): boolean;
  87596. /**
  87597. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  87598. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  87599. */
  87600. checkCollisions: boolean;
  87601. /**
  87602. * Gets Collider object used to compute collisions (not physics)
  87603. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  87604. */
  87605. readonly collider: Nullable<Collider>;
  87606. /**
  87607. * Move the mesh using collision engine
  87608. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  87609. * @param displacement defines the requested displacement vector
  87610. * @returns the current mesh
  87611. */
  87612. moveWithCollisions(displacement: Vector3): AbstractMesh;
  87613. private _onCollisionPositionChange;
  87614. /** @hidden */
  87615. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  87616. /** @hidden */
  87617. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  87618. /** @hidden */
  87619. _checkCollision(collider: Collider): AbstractMesh;
  87620. /** @hidden */
  87621. _generatePointsArray(): boolean;
  87622. /**
  87623. * Checks if the passed Ray intersects with the mesh
  87624. * @param ray defines the ray to use
  87625. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  87626. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  87627. * @returns the picking info
  87628. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  87629. */
  87630. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  87631. /**
  87632. * Clones the current mesh
  87633. * @param name defines the mesh name
  87634. * @param newParent defines the new mesh parent
  87635. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  87636. * @returns the new mesh
  87637. */
  87638. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  87639. /**
  87640. * Disposes all the submeshes of the current meshnp
  87641. * @returns the current mesh
  87642. */
  87643. releaseSubMeshes(): AbstractMesh;
  87644. /**
  87645. * Releases resources associated with this abstract mesh.
  87646. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  87647. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  87648. */
  87649. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  87650. /**
  87651. * Adds the passed mesh as a child to the current mesh
  87652. * @param mesh defines the child mesh
  87653. * @returns the current mesh
  87654. */
  87655. addChild(mesh: AbstractMesh): AbstractMesh;
  87656. /**
  87657. * Removes the passed mesh from the current mesh children list
  87658. * @param mesh defines the child mesh
  87659. * @returns the current mesh
  87660. */
  87661. removeChild(mesh: AbstractMesh): AbstractMesh;
  87662. /** @hidden */
  87663. private _initFacetData;
  87664. /**
  87665. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  87666. * This method can be called within the render loop.
  87667. * 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
  87668. * @returns the current mesh
  87669. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87670. */
  87671. updateFacetData(): AbstractMesh;
  87672. /**
  87673. * Returns the facetLocalNormals array.
  87674. * The normals are expressed in the mesh local spac
  87675. * @returns an array of Vector3
  87676. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87677. */
  87678. getFacetLocalNormals(): Vector3[];
  87679. /**
  87680. * Returns the facetLocalPositions array.
  87681. * The facet positions are expressed in the mesh local space
  87682. * @returns an array of Vector3
  87683. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87684. */
  87685. getFacetLocalPositions(): Vector3[];
  87686. /**
  87687. * Returns the facetLocalPartioning array
  87688. * @returns an array of array of numbers
  87689. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87690. */
  87691. getFacetLocalPartitioning(): number[][];
  87692. /**
  87693. * Returns the i-th facet position in the world system.
  87694. * This method allocates a new Vector3 per call
  87695. * @param i defines the facet index
  87696. * @returns a new Vector3
  87697. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87698. */
  87699. getFacetPosition(i: number): Vector3;
  87700. /**
  87701. * Sets the reference Vector3 with the i-th facet position in the world system
  87702. * @param i defines the facet index
  87703. * @param ref defines the target vector
  87704. * @returns the current mesh
  87705. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87706. */
  87707. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  87708. /**
  87709. * Returns the i-th facet normal in the world system.
  87710. * This method allocates a new Vector3 per call
  87711. * @param i defines the facet index
  87712. * @returns a new Vector3
  87713. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87714. */
  87715. getFacetNormal(i: number): Vector3;
  87716. /**
  87717. * Sets the reference Vector3 with the i-th facet normal in the world system
  87718. * @param i defines the facet index
  87719. * @param ref defines the target vector
  87720. * @returns the current mesh
  87721. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87722. */
  87723. getFacetNormalToRef(i: number, ref: Vector3): this;
  87724. /**
  87725. * 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)
  87726. * @param x defines x coordinate
  87727. * @param y defines y coordinate
  87728. * @param z defines z coordinate
  87729. * @returns the array of facet indexes
  87730. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87731. */
  87732. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  87733. /**
  87734. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  87735. * @param projected sets as the (x,y,z) world projection on the facet
  87736. * @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
  87737. * @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
  87738. * @param x defines x coordinate
  87739. * @param y defines y coordinate
  87740. * @param z defines z coordinate
  87741. * @returns the face index if found (or null instead)
  87742. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87743. */
  87744. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  87745. /**
  87746. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  87747. * @param projected sets as the (x,y,z) local projection on the facet
  87748. * @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
  87749. * @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
  87750. * @param x defines x coordinate
  87751. * @param y defines y coordinate
  87752. * @param z defines z coordinate
  87753. * @returns the face index if found (or null instead)
  87754. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87755. */
  87756. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  87757. /**
  87758. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  87759. * @returns the parameters
  87760. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87761. */
  87762. getFacetDataParameters(): any;
  87763. /**
  87764. * Disables the feature FacetData and frees the related memory
  87765. * @returns the current mesh
  87766. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87767. */
  87768. disableFacetData(): AbstractMesh;
  87769. /**
  87770. * Updates the AbstractMesh indices array
  87771. * @param indices defines the data source
  87772. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  87773. * @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)
  87774. * @returns the current mesh
  87775. */
  87776. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  87777. /**
  87778. * Creates new normals data for the mesh
  87779. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  87780. * @returns the current mesh
  87781. */
  87782. createNormals(updatable: boolean): AbstractMesh;
  87783. /**
  87784. * Align the mesh with a normal
  87785. * @param normal defines the normal to use
  87786. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  87787. * @returns the current mesh
  87788. */
  87789. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  87790. /** @hidden */
  87791. _checkOcclusionQuery(): boolean;
  87792. /**
  87793. * Disables the mesh edge rendering mode
  87794. * @returns the currentAbstractMesh
  87795. */
  87796. disableEdgesRendering(): AbstractMesh;
  87797. /**
  87798. * Enables the edge rendering mode on the mesh.
  87799. * This mode makes the mesh edges visible
  87800. * @param epsilon defines the maximal distance between two angles to detect a face
  87801. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  87802. * @returns the currentAbstractMesh
  87803. * @see https://www.babylonjs-playground.com/#19O9TU#0
  87804. */
  87805. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  87806. }
  87807. }
  87808. declare module BABYLON {
  87809. /**
  87810. * Interface used to define ActionEvent
  87811. */
  87812. export interface IActionEvent {
  87813. /** The mesh or sprite that triggered the action */
  87814. source: any;
  87815. /** The X mouse cursor position at the time of the event */
  87816. pointerX: number;
  87817. /** The Y mouse cursor position at the time of the event */
  87818. pointerY: number;
  87819. /** The mesh that is currently pointed at (can be null) */
  87820. meshUnderPointer: Nullable<AbstractMesh>;
  87821. /** the original (browser) event that triggered the ActionEvent */
  87822. sourceEvent?: any;
  87823. /** additional data for the event */
  87824. additionalData?: any;
  87825. }
  87826. /**
  87827. * ActionEvent is the event being sent when an action is triggered.
  87828. */
  87829. export class ActionEvent implements IActionEvent {
  87830. /** The mesh or sprite that triggered the action */
  87831. source: any;
  87832. /** The X mouse cursor position at the time of the event */
  87833. pointerX: number;
  87834. /** The Y mouse cursor position at the time of the event */
  87835. pointerY: number;
  87836. /** The mesh that is currently pointed at (can be null) */
  87837. meshUnderPointer: Nullable<AbstractMesh>;
  87838. /** the original (browser) event that triggered the ActionEvent */
  87839. sourceEvent?: any;
  87840. /** additional data for the event */
  87841. additionalData?: any;
  87842. /**
  87843. * Creates a new ActionEvent
  87844. * @param source The mesh or sprite that triggered the action
  87845. * @param pointerX The X mouse cursor position at the time of the event
  87846. * @param pointerY The Y mouse cursor position at the time of the event
  87847. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  87848. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  87849. * @param additionalData additional data for the event
  87850. */
  87851. constructor(
  87852. /** The mesh or sprite that triggered the action */
  87853. source: any,
  87854. /** The X mouse cursor position at the time of the event */
  87855. pointerX: number,
  87856. /** The Y mouse cursor position at the time of the event */
  87857. pointerY: number,
  87858. /** The mesh that is currently pointed at (can be null) */
  87859. meshUnderPointer: Nullable<AbstractMesh>,
  87860. /** the original (browser) event that triggered the ActionEvent */
  87861. sourceEvent?: any,
  87862. /** additional data for the event */
  87863. additionalData?: any);
  87864. /**
  87865. * Helper function to auto-create an ActionEvent from a source mesh.
  87866. * @param source The source mesh that triggered the event
  87867. * @param evt The original (browser) event
  87868. * @param additionalData additional data for the event
  87869. * @returns the new ActionEvent
  87870. */
  87871. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  87872. /**
  87873. * Helper function to auto-create an ActionEvent from a source sprite
  87874. * @param source The source sprite that triggered the event
  87875. * @param scene Scene associated with the sprite
  87876. * @param evt The original (browser) event
  87877. * @param additionalData additional data for the event
  87878. * @returns the new ActionEvent
  87879. */
  87880. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  87881. /**
  87882. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  87883. * @param scene the scene where the event occurred
  87884. * @param evt The original (browser) event
  87885. * @returns the new ActionEvent
  87886. */
  87887. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  87888. /**
  87889. * Helper function to auto-create an ActionEvent from a primitive
  87890. * @param prim defines the target primitive
  87891. * @param pointerPos defines the pointer position
  87892. * @param evt The original (browser) event
  87893. * @param additionalData additional data for the event
  87894. * @returns the new ActionEvent
  87895. */
  87896. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  87897. }
  87898. }
  87899. declare module BABYLON {
  87900. /**
  87901. * Abstract class used to decouple action Manager from scene and meshes.
  87902. * Do not instantiate.
  87903. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87904. */
  87905. export abstract class AbstractActionManager implements IDisposable {
  87906. /** Gets the list of active triggers */
  87907. static Triggers: {
  87908. [key: string]: number;
  87909. };
  87910. /** Gets the cursor to use when hovering items */
  87911. hoverCursor: string;
  87912. /** Gets the list of actions */
  87913. actions: IAction[];
  87914. /**
  87915. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  87916. */
  87917. isRecursive: boolean;
  87918. /**
  87919. * Releases all associated resources
  87920. */
  87921. abstract dispose(): void;
  87922. /**
  87923. * Does this action manager has pointer triggers
  87924. */
  87925. abstract readonly hasPointerTriggers: boolean;
  87926. /**
  87927. * Does this action manager has pick triggers
  87928. */
  87929. abstract readonly hasPickTriggers: boolean;
  87930. /**
  87931. * Process a specific trigger
  87932. * @param trigger defines the trigger to process
  87933. * @param evt defines the event details to be processed
  87934. */
  87935. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  87936. /**
  87937. * Does this action manager handles actions of any of the given triggers
  87938. * @param triggers defines the triggers to be tested
  87939. * @return a boolean indicating whether one (or more) of the triggers is handled
  87940. */
  87941. abstract hasSpecificTriggers(triggers: number[]): boolean;
  87942. /**
  87943. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  87944. * speed.
  87945. * @param triggerA defines the trigger to be tested
  87946. * @param triggerB defines the trigger to be tested
  87947. * @return a boolean indicating whether one (or more) of the triggers is handled
  87948. */
  87949. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  87950. /**
  87951. * Does this action manager handles actions of a given trigger
  87952. * @param trigger defines the trigger to be tested
  87953. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  87954. * @return whether the trigger is handled
  87955. */
  87956. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  87957. /**
  87958. * Serialize this manager to a JSON object
  87959. * @param name defines the property name to store this manager
  87960. * @returns a JSON representation of this manager
  87961. */
  87962. abstract serialize(name: string): any;
  87963. /**
  87964. * Registers an action to this action manager
  87965. * @param action defines the action to be registered
  87966. * @return the action amended (prepared) after registration
  87967. */
  87968. abstract registerAction(action: IAction): Nullable<IAction>;
  87969. /**
  87970. * Unregisters an action to this action manager
  87971. * @param action defines the action to be unregistered
  87972. * @return a boolean indicating whether the action has been unregistered
  87973. */
  87974. abstract unregisterAction(action: IAction): Boolean;
  87975. /**
  87976. * Does exist one action manager with at least one trigger
  87977. **/
  87978. static readonly HasTriggers: boolean;
  87979. /**
  87980. * Does exist one action manager with at least one pick trigger
  87981. **/
  87982. static readonly HasPickTriggers: boolean;
  87983. /**
  87984. * Does exist one action manager that handles actions of a given trigger
  87985. * @param trigger defines the trigger to be tested
  87986. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  87987. **/
  87988. static HasSpecificTrigger(trigger: number): boolean;
  87989. }
  87990. }
  87991. declare module BABYLON {
  87992. /**
  87993. * Defines how a node can be built from a string name.
  87994. */
  87995. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  87996. /**
  87997. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  87998. */
  87999. export class Node implements IBehaviorAware<Node> {
  88000. /** @hidden */
  88001. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  88002. private static _NodeConstructors;
  88003. /**
  88004. * Add a new node constructor
  88005. * @param type defines the type name of the node to construct
  88006. * @param constructorFunc defines the constructor function
  88007. */
  88008. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  88009. /**
  88010. * Returns a node constructor based on type name
  88011. * @param type defines the type name
  88012. * @param name defines the new node name
  88013. * @param scene defines the hosting scene
  88014. * @param options defines optional options to transmit to constructors
  88015. * @returns the new constructor or null
  88016. */
  88017. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  88018. /**
  88019. * Gets or sets the name of the node
  88020. */
  88021. name: string;
  88022. /**
  88023. * Gets or sets the id of the node
  88024. */
  88025. id: string;
  88026. /**
  88027. * Gets or sets the unique id of the node
  88028. */
  88029. uniqueId: number;
  88030. /**
  88031. * Gets or sets a string used to store user defined state for the node
  88032. */
  88033. state: string;
  88034. /**
  88035. * Gets or sets an object used to store user defined information for the node
  88036. */
  88037. metadata: any;
  88038. /**
  88039. * For internal use only. Please do not use.
  88040. */
  88041. reservedDataStore: any;
  88042. /**
  88043. * List of inspectable custom properties (used by the Inspector)
  88044. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  88045. */
  88046. inspectableCustomProperties: IInspectable[];
  88047. /**
  88048. * Gets or sets a boolean used to define if the node must be serialized
  88049. */
  88050. doNotSerialize: boolean;
  88051. /** @hidden */
  88052. _isDisposed: boolean;
  88053. /**
  88054. * Gets a list of Animations associated with the node
  88055. */
  88056. animations: Animation[];
  88057. protected _ranges: {
  88058. [name: string]: Nullable<AnimationRange>;
  88059. };
  88060. /**
  88061. * Callback raised when the node is ready to be used
  88062. */
  88063. onReady: Nullable<(node: Node) => void>;
  88064. private _isEnabled;
  88065. private _isParentEnabled;
  88066. private _isReady;
  88067. /** @hidden */
  88068. _currentRenderId: number;
  88069. private _parentUpdateId;
  88070. /** @hidden */
  88071. _childUpdateId: number;
  88072. /** @hidden */
  88073. _waitingParentId: Nullable<string>;
  88074. /** @hidden */
  88075. _scene: Scene;
  88076. /** @hidden */
  88077. _cache: any;
  88078. private _parentNode;
  88079. private _children;
  88080. /** @hidden */
  88081. _worldMatrix: Matrix;
  88082. /** @hidden */
  88083. _worldMatrixDeterminant: number;
  88084. /** @hidden */
  88085. _worldMatrixDeterminantIsDirty: boolean;
  88086. /** @hidden */
  88087. private _sceneRootNodesIndex;
  88088. /**
  88089. * Gets a boolean indicating if the node has been disposed
  88090. * @returns true if the node was disposed
  88091. */
  88092. isDisposed(): boolean;
  88093. /**
  88094. * Gets or sets the parent of the node (without keeping the current position in the scene)
  88095. * @see https://doc.babylonjs.com/how_to/parenting
  88096. */
  88097. parent: Nullable<Node>;
  88098. private addToSceneRootNodes;
  88099. private removeFromSceneRootNodes;
  88100. private _animationPropertiesOverride;
  88101. /**
  88102. * Gets or sets the animation properties override
  88103. */
  88104. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  88105. /**
  88106. * Gets a string idenfifying the name of the class
  88107. * @returns "Node" string
  88108. */
  88109. getClassName(): string;
  88110. /** @hidden */
  88111. readonly _isNode: boolean;
  88112. /**
  88113. * An event triggered when the mesh is disposed
  88114. */
  88115. onDisposeObservable: Observable<Node>;
  88116. private _onDisposeObserver;
  88117. /**
  88118. * Sets a callback that will be raised when the node will be disposed
  88119. */
  88120. onDispose: () => void;
  88121. /**
  88122. * Creates a new Node
  88123. * @param name the name and id to be given to this node
  88124. * @param scene the scene this node will be added to
  88125. * @param addToRootNodes the node will be added to scene.rootNodes
  88126. */
  88127. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  88128. /**
  88129. * Gets the scene of the node
  88130. * @returns a scene
  88131. */
  88132. getScene(): Scene;
  88133. /**
  88134. * Gets the engine of the node
  88135. * @returns a Engine
  88136. */
  88137. getEngine(): Engine;
  88138. private _behaviors;
  88139. /**
  88140. * Attach a behavior to the node
  88141. * @see http://doc.babylonjs.com/features/behaviour
  88142. * @param behavior defines the behavior to attach
  88143. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  88144. * @returns the current Node
  88145. */
  88146. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  88147. /**
  88148. * Remove an attached behavior
  88149. * @see http://doc.babylonjs.com/features/behaviour
  88150. * @param behavior defines the behavior to attach
  88151. * @returns the current Node
  88152. */
  88153. removeBehavior(behavior: Behavior<Node>): Node;
  88154. /**
  88155. * Gets the list of attached behaviors
  88156. * @see http://doc.babylonjs.com/features/behaviour
  88157. */
  88158. readonly behaviors: Behavior<Node>[];
  88159. /**
  88160. * Gets an attached behavior by name
  88161. * @param name defines the name of the behavior to look for
  88162. * @see http://doc.babylonjs.com/features/behaviour
  88163. * @returns null if behavior was not found else the requested behavior
  88164. */
  88165. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  88166. /**
  88167. * Returns the latest update of the World matrix
  88168. * @returns a Matrix
  88169. */
  88170. getWorldMatrix(): Matrix;
  88171. /** @hidden */
  88172. _getWorldMatrixDeterminant(): number;
  88173. /**
  88174. * Returns directly the latest state of the mesh World matrix.
  88175. * A Matrix is returned.
  88176. */
  88177. readonly worldMatrixFromCache: Matrix;
  88178. /** @hidden */
  88179. _initCache(): void;
  88180. /** @hidden */
  88181. updateCache(force?: boolean): void;
  88182. /** @hidden */
  88183. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  88184. /** @hidden */
  88185. _updateCache(ignoreParentClass?: boolean): void;
  88186. /** @hidden */
  88187. _isSynchronized(): boolean;
  88188. /** @hidden */
  88189. _markSyncedWithParent(): void;
  88190. /** @hidden */
  88191. isSynchronizedWithParent(): boolean;
  88192. /** @hidden */
  88193. isSynchronized(): boolean;
  88194. /**
  88195. * Is this node ready to be used/rendered
  88196. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  88197. * @return true if the node is ready
  88198. */
  88199. isReady(completeCheck?: boolean): boolean;
  88200. /**
  88201. * Is this node enabled?
  88202. * 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
  88203. * @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
  88204. * @return whether this node (and its parent) is enabled
  88205. */
  88206. isEnabled(checkAncestors?: boolean): boolean;
  88207. /** @hidden */
  88208. protected _syncParentEnabledState(): void;
  88209. /**
  88210. * Set the enabled state of this node
  88211. * @param value defines the new enabled state
  88212. */
  88213. setEnabled(value: boolean): void;
  88214. /**
  88215. * Is this node a descendant of the given node?
  88216. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  88217. * @param ancestor defines the parent node to inspect
  88218. * @returns a boolean indicating if this node is a descendant of the given node
  88219. */
  88220. isDescendantOf(ancestor: Node): boolean;
  88221. /** @hidden */
  88222. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  88223. /**
  88224. * Will return all nodes that have this node as ascendant
  88225. * @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
  88226. * @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
  88227. * @return all children nodes of all types
  88228. */
  88229. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  88230. /**
  88231. * Get all child-meshes of this node
  88232. * @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)
  88233. * @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
  88234. * @returns an array of AbstractMesh
  88235. */
  88236. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  88237. /**
  88238. * Get all direct children of this node
  88239. * @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
  88240. * @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)
  88241. * @returns an array of Node
  88242. */
  88243. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  88244. /** @hidden */
  88245. _setReady(state: boolean): void;
  88246. /**
  88247. * Get an animation by name
  88248. * @param name defines the name of the animation to look for
  88249. * @returns null if not found else the requested animation
  88250. */
  88251. getAnimationByName(name: string): Nullable<Animation>;
  88252. /**
  88253. * Creates an animation range for this node
  88254. * @param name defines the name of the range
  88255. * @param from defines the starting key
  88256. * @param to defines the end key
  88257. */
  88258. createAnimationRange(name: string, from: number, to: number): void;
  88259. /**
  88260. * Delete a specific animation range
  88261. * @param name defines the name of the range to delete
  88262. * @param deleteFrames defines if animation frames from the range must be deleted as well
  88263. */
  88264. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  88265. /**
  88266. * Get an animation range by name
  88267. * @param name defines the name of the animation range to look for
  88268. * @returns null if not found else the requested animation range
  88269. */
  88270. getAnimationRange(name: string): Nullable<AnimationRange>;
  88271. /**
  88272. * Gets the list of all animation ranges defined on this node
  88273. * @returns an array
  88274. */
  88275. getAnimationRanges(): Nullable<AnimationRange>[];
  88276. /**
  88277. * Will start the animation sequence
  88278. * @param name defines the range frames for animation sequence
  88279. * @param loop defines if the animation should loop (false by default)
  88280. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  88281. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  88282. * @returns the object created for this animation. If range does not exist, it will return null
  88283. */
  88284. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  88285. /**
  88286. * Serialize animation ranges into a JSON compatible object
  88287. * @returns serialization object
  88288. */
  88289. serializeAnimationRanges(): any;
  88290. /**
  88291. * Computes the world matrix of the node
  88292. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  88293. * @returns the world matrix
  88294. */
  88295. computeWorldMatrix(force?: boolean): Matrix;
  88296. /**
  88297. * Releases resources associated with this node.
  88298. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  88299. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  88300. */
  88301. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  88302. /**
  88303. * Parse animation range data from a serialization object and store them into a given node
  88304. * @param node defines where to store the animation ranges
  88305. * @param parsedNode defines the serialization object to read data from
  88306. * @param scene defines the hosting scene
  88307. */
  88308. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  88309. /**
  88310. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  88311. * @param includeDescendants Include bounding info from descendants as well (true by default)
  88312. * @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
  88313. * @returns the new bounding vectors
  88314. */
  88315. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  88316. min: Vector3;
  88317. max: Vector3;
  88318. };
  88319. }
  88320. }
  88321. declare module BABYLON {
  88322. /**
  88323. * @hidden
  88324. */
  88325. export class _IAnimationState {
  88326. key: number;
  88327. repeatCount: number;
  88328. workValue?: any;
  88329. loopMode?: number;
  88330. offsetValue?: any;
  88331. highLimitValue?: any;
  88332. }
  88333. /**
  88334. * Class used to store any kind of animation
  88335. */
  88336. export class Animation {
  88337. /**Name of the animation */
  88338. name: string;
  88339. /**Property to animate */
  88340. targetProperty: string;
  88341. /**The frames per second of the animation */
  88342. framePerSecond: number;
  88343. /**The data type of the animation */
  88344. dataType: number;
  88345. /**The loop mode of the animation */
  88346. loopMode?: number | undefined;
  88347. /**Specifies if blending should be enabled */
  88348. enableBlending?: boolean | undefined;
  88349. /**
  88350. * Use matrix interpolation instead of using direct key value when animating matrices
  88351. */
  88352. static AllowMatricesInterpolation: boolean;
  88353. /**
  88354. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  88355. */
  88356. static AllowMatrixDecomposeForInterpolation: boolean;
  88357. /**
  88358. * Stores the key frames of the animation
  88359. */
  88360. private _keys;
  88361. /**
  88362. * Stores the easing function of the animation
  88363. */
  88364. private _easingFunction;
  88365. /**
  88366. * @hidden Internal use only
  88367. */
  88368. _runtimeAnimations: RuntimeAnimation[];
  88369. /**
  88370. * The set of event that will be linked to this animation
  88371. */
  88372. private _events;
  88373. /**
  88374. * Stores an array of target property paths
  88375. */
  88376. targetPropertyPath: string[];
  88377. /**
  88378. * Stores the blending speed of the animation
  88379. */
  88380. blendingSpeed: number;
  88381. /**
  88382. * Stores the animation ranges for the animation
  88383. */
  88384. private _ranges;
  88385. /**
  88386. * @hidden Internal use
  88387. */
  88388. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  88389. /**
  88390. * Sets up an animation
  88391. * @param property The property to animate
  88392. * @param animationType The animation type to apply
  88393. * @param framePerSecond The frames per second of the animation
  88394. * @param easingFunction The easing function used in the animation
  88395. * @returns The created animation
  88396. */
  88397. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  88398. /**
  88399. * Create and start an animation on a node
  88400. * @param name defines the name of the global animation that will be run on all nodes
  88401. * @param node defines the root node where the animation will take place
  88402. * @param targetProperty defines property to animate
  88403. * @param framePerSecond defines the number of frame per second yo use
  88404. * @param totalFrame defines the number of frames in total
  88405. * @param from defines the initial value
  88406. * @param to defines the final value
  88407. * @param loopMode defines which loop mode you want to use (off by default)
  88408. * @param easingFunction defines the easing function to use (linear by default)
  88409. * @param onAnimationEnd defines the callback to call when animation end
  88410. * @returns the animatable created for this animation
  88411. */
  88412. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  88413. /**
  88414. * Create and start an animation on a node and its descendants
  88415. * @param name defines the name of the global animation that will be run on all nodes
  88416. * @param node defines the root node where the animation will take place
  88417. * @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
  88418. * @param targetProperty defines property to animate
  88419. * @param framePerSecond defines the number of frame per second to use
  88420. * @param totalFrame defines the number of frames in total
  88421. * @param from defines the initial value
  88422. * @param to defines the final value
  88423. * @param loopMode defines which loop mode you want to use (off by default)
  88424. * @param easingFunction defines the easing function to use (linear by default)
  88425. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  88426. * @returns the list of animatables created for all nodes
  88427. * @example https://www.babylonjs-playground.com/#MH0VLI
  88428. */
  88429. 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[]>;
  88430. /**
  88431. * Creates a new animation, merges it with the existing animations and starts it
  88432. * @param name Name of the animation
  88433. * @param node Node which contains the scene that begins the animations
  88434. * @param targetProperty Specifies which property to animate
  88435. * @param framePerSecond The frames per second of the animation
  88436. * @param totalFrame The total number of frames
  88437. * @param from The frame at the beginning of the animation
  88438. * @param to The frame at the end of the animation
  88439. * @param loopMode Specifies the loop mode of the animation
  88440. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  88441. * @param onAnimationEnd Callback to run once the animation is complete
  88442. * @returns Nullable animation
  88443. */
  88444. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  88445. /**
  88446. * Transition property of an host to the target Value
  88447. * @param property The property to transition
  88448. * @param targetValue The target Value of the property
  88449. * @param host The object where the property to animate belongs
  88450. * @param scene Scene used to run the animation
  88451. * @param frameRate Framerate (in frame/s) to use
  88452. * @param transition The transition type we want to use
  88453. * @param duration The duration of the animation, in milliseconds
  88454. * @param onAnimationEnd Callback trigger at the end of the animation
  88455. * @returns Nullable animation
  88456. */
  88457. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  88458. /**
  88459. * Return the array of runtime animations currently using this animation
  88460. */
  88461. readonly runtimeAnimations: RuntimeAnimation[];
  88462. /**
  88463. * Specifies if any of the runtime animations are currently running
  88464. */
  88465. readonly hasRunningRuntimeAnimations: boolean;
  88466. /**
  88467. * Initializes the animation
  88468. * @param name Name of the animation
  88469. * @param targetProperty Property to animate
  88470. * @param framePerSecond The frames per second of the animation
  88471. * @param dataType The data type of the animation
  88472. * @param loopMode The loop mode of the animation
  88473. * @param enableBlending Specifies if blending should be enabled
  88474. */
  88475. constructor(
  88476. /**Name of the animation */
  88477. name: string,
  88478. /**Property to animate */
  88479. targetProperty: string,
  88480. /**The frames per second of the animation */
  88481. framePerSecond: number,
  88482. /**The data type of the animation */
  88483. dataType: number,
  88484. /**The loop mode of the animation */
  88485. loopMode?: number | undefined,
  88486. /**Specifies if blending should be enabled */
  88487. enableBlending?: boolean | undefined);
  88488. /**
  88489. * Converts the animation to a string
  88490. * @param fullDetails support for multiple levels of logging within scene loading
  88491. * @returns String form of the animation
  88492. */
  88493. toString(fullDetails?: boolean): string;
  88494. /**
  88495. * Add an event to this animation
  88496. * @param event Event to add
  88497. */
  88498. addEvent(event: AnimationEvent): void;
  88499. /**
  88500. * Remove all events found at the given frame
  88501. * @param frame The frame to remove events from
  88502. */
  88503. removeEvents(frame: number): void;
  88504. /**
  88505. * Retrieves all the events from the animation
  88506. * @returns Events from the animation
  88507. */
  88508. getEvents(): AnimationEvent[];
  88509. /**
  88510. * Creates an animation range
  88511. * @param name Name of the animation range
  88512. * @param from Starting frame of the animation range
  88513. * @param to Ending frame of the animation
  88514. */
  88515. createRange(name: string, from: number, to: number): void;
  88516. /**
  88517. * Deletes an animation range by name
  88518. * @param name Name of the animation range to delete
  88519. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  88520. */
  88521. deleteRange(name: string, deleteFrames?: boolean): void;
  88522. /**
  88523. * Gets the animation range by name, or null if not defined
  88524. * @param name Name of the animation range
  88525. * @returns Nullable animation range
  88526. */
  88527. getRange(name: string): Nullable<AnimationRange>;
  88528. /**
  88529. * Gets the key frames from the animation
  88530. * @returns The key frames of the animation
  88531. */
  88532. getKeys(): Array<IAnimationKey>;
  88533. /**
  88534. * Gets the highest frame rate of the animation
  88535. * @returns Highest frame rate of the animation
  88536. */
  88537. getHighestFrame(): number;
  88538. /**
  88539. * Gets the easing function of the animation
  88540. * @returns Easing function of the animation
  88541. */
  88542. getEasingFunction(): IEasingFunction;
  88543. /**
  88544. * Sets the easing function of the animation
  88545. * @param easingFunction A custom mathematical formula for animation
  88546. */
  88547. setEasingFunction(easingFunction: EasingFunction): void;
  88548. /**
  88549. * Interpolates a scalar linearly
  88550. * @param startValue Start value of the animation curve
  88551. * @param endValue End value of the animation curve
  88552. * @param gradient Scalar amount to interpolate
  88553. * @returns Interpolated scalar value
  88554. */
  88555. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  88556. /**
  88557. * Interpolates a scalar cubically
  88558. * @param startValue Start value of the animation curve
  88559. * @param outTangent End tangent of the animation
  88560. * @param endValue End value of the animation curve
  88561. * @param inTangent Start tangent of the animation curve
  88562. * @param gradient Scalar amount to interpolate
  88563. * @returns Interpolated scalar value
  88564. */
  88565. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  88566. /**
  88567. * Interpolates a quaternion using a spherical linear interpolation
  88568. * @param startValue Start value of the animation curve
  88569. * @param endValue End value of the animation curve
  88570. * @param gradient Scalar amount to interpolate
  88571. * @returns Interpolated quaternion value
  88572. */
  88573. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  88574. /**
  88575. * Interpolates a quaternion cubically
  88576. * @param startValue Start value of the animation curve
  88577. * @param outTangent End tangent of the animation curve
  88578. * @param endValue End value of the animation curve
  88579. * @param inTangent Start tangent of the animation curve
  88580. * @param gradient Scalar amount to interpolate
  88581. * @returns Interpolated quaternion value
  88582. */
  88583. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  88584. /**
  88585. * Interpolates a Vector3 linearl
  88586. * @param startValue Start value of the animation curve
  88587. * @param endValue End value of the animation curve
  88588. * @param gradient Scalar amount to interpolate
  88589. * @returns Interpolated scalar value
  88590. */
  88591. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  88592. /**
  88593. * Interpolates a Vector3 cubically
  88594. * @param startValue Start value of the animation curve
  88595. * @param outTangent End tangent of the animation
  88596. * @param endValue End value of the animation curve
  88597. * @param inTangent Start tangent of the animation curve
  88598. * @param gradient Scalar amount to interpolate
  88599. * @returns InterpolatedVector3 value
  88600. */
  88601. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  88602. /**
  88603. * Interpolates a Vector2 linearly
  88604. * @param startValue Start value of the animation curve
  88605. * @param endValue End value of the animation curve
  88606. * @param gradient Scalar amount to interpolate
  88607. * @returns Interpolated Vector2 value
  88608. */
  88609. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  88610. /**
  88611. * Interpolates a Vector2 cubically
  88612. * @param startValue Start value of the animation curve
  88613. * @param outTangent End tangent of the animation
  88614. * @param endValue End value of the animation curve
  88615. * @param inTangent Start tangent of the animation curve
  88616. * @param gradient Scalar amount to interpolate
  88617. * @returns Interpolated Vector2 value
  88618. */
  88619. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  88620. /**
  88621. * Interpolates a size linearly
  88622. * @param startValue Start value of the animation curve
  88623. * @param endValue End value of the animation curve
  88624. * @param gradient Scalar amount to interpolate
  88625. * @returns Interpolated Size value
  88626. */
  88627. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  88628. /**
  88629. * Interpolates a Color3 linearly
  88630. * @param startValue Start value of the animation curve
  88631. * @param endValue End value of the animation curve
  88632. * @param gradient Scalar amount to interpolate
  88633. * @returns Interpolated Color3 value
  88634. */
  88635. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  88636. /**
  88637. * @hidden Internal use only
  88638. */
  88639. _getKeyValue(value: any): any;
  88640. /**
  88641. * @hidden Internal use only
  88642. */
  88643. _interpolate(currentFrame: number, state: _IAnimationState): any;
  88644. /**
  88645. * Defines the function to use to interpolate matrices
  88646. * @param startValue defines the start matrix
  88647. * @param endValue defines the end matrix
  88648. * @param gradient defines the gradient between both matrices
  88649. * @param result defines an optional target matrix where to store the interpolation
  88650. * @returns the interpolated matrix
  88651. */
  88652. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  88653. /**
  88654. * Makes a copy of the animation
  88655. * @returns Cloned animation
  88656. */
  88657. clone(): Animation;
  88658. /**
  88659. * Sets the key frames of the animation
  88660. * @param values The animation key frames to set
  88661. */
  88662. setKeys(values: Array<IAnimationKey>): void;
  88663. /**
  88664. * Serializes the animation to an object
  88665. * @returns Serialized object
  88666. */
  88667. serialize(): any;
  88668. /**
  88669. * Float animation type
  88670. */
  88671. private static _ANIMATIONTYPE_FLOAT;
  88672. /**
  88673. * Vector3 animation type
  88674. */
  88675. private static _ANIMATIONTYPE_VECTOR3;
  88676. /**
  88677. * Quaternion animation type
  88678. */
  88679. private static _ANIMATIONTYPE_QUATERNION;
  88680. /**
  88681. * Matrix animation type
  88682. */
  88683. private static _ANIMATIONTYPE_MATRIX;
  88684. /**
  88685. * Color3 animation type
  88686. */
  88687. private static _ANIMATIONTYPE_COLOR3;
  88688. /**
  88689. * Vector2 animation type
  88690. */
  88691. private static _ANIMATIONTYPE_VECTOR2;
  88692. /**
  88693. * Size animation type
  88694. */
  88695. private static _ANIMATIONTYPE_SIZE;
  88696. /**
  88697. * Relative Loop Mode
  88698. */
  88699. private static _ANIMATIONLOOPMODE_RELATIVE;
  88700. /**
  88701. * Cycle Loop Mode
  88702. */
  88703. private static _ANIMATIONLOOPMODE_CYCLE;
  88704. /**
  88705. * Constant Loop Mode
  88706. */
  88707. private static _ANIMATIONLOOPMODE_CONSTANT;
  88708. /**
  88709. * Get the float animation type
  88710. */
  88711. static readonly ANIMATIONTYPE_FLOAT: number;
  88712. /**
  88713. * Get the Vector3 animation type
  88714. */
  88715. static readonly ANIMATIONTYPE_VECTOR3: number;
  88716. /**
  88717. * Get the Vector2 animation type
  88718. */
  88719. static readonly ANIMATIONTYPE_VECTOR2: number;
  88720. /**
  88721. * Get the Size animation type
  88722. */
  88723. static readonly ANIMATIONTYPE_SIZE: number;
  88724. /**
  88725. * Get the Quaternion animation type
  88726. */
  88727. static readonly ANIMATIONTYPE_QUATERNION: number;
  88728. /**
  88729. * Get the Matrix animation type
  88730. */
  88731. static readonly ANIMATIONTYPE_MATRIX: number;
  88732. /**
  88733. * Get the Color3 animation type
  88734. */
  88735. static readonly ANIMATIONTYPE_COLOR3: number;
  88736. /**
  88737. * Get the Relative Loop Mode
  88738. */
  88739. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  88740. /**
  88741. * Get the Cycle Loop Mode
  88742. */
  88743. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  88744. /**
  88745. * Get the Constant Loop Mode
  88746. */
  88747. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  88748. /** @hidden */
  88749. static _UniversalLerp(left: any, right: any, amount: number): any;
  88750. /**
  88751. * Parses an animation object and creates an animation
  88752. * @param parsedAnimation Parsed animation object
  88753. * @returns Animation object
  88754. */
  88755. static Parse(parsedAnimation: any): Animation;
  88756. /**
  88757. * Appends the serialized animations from the source animations
  88758. * @param source Source containing the animations
  88759. * @param destination Target to store the animations
  88760. */
  88761. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  88762. }
  88763. }
  88764. declare module BABYLON {
  88765. /**
  88766. * Base class of all the textures in babylon.
  88767. * It groups all the common properties the materials, post process, lights... might need
  88768. * in order to make a correct use of the texture.
  88769. */
  88770. export class BaseTexture implements IAnimatable {
  88771. /**
  88772. * Default anisotropic filtering level for the application.
  88773. * It is set to 4 as a good tradeoff between perf and quality.
  88774. */
  88775. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  88776. /**
  88777. * Gets or sets the unique id of the texture
  88778. */
  88779. uniqueId: number;
  88780. /**
  88781. * Define the name of the texture.
  88782. */
  88783. name: string;
  88784. /**
  88785. * Gets or sets an object used to store user defined information.
  88786. */
  88787. metadata: any;
  88788. /**
  88789. * For internal use only. Please do not use.
  88790. */
  88791. reservedDataStore: any;
  88792. private _hasAlpha;
  88793. /**
  88794. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  88795. */
  88796. hasAlpha: boolean;
  88797. /**
  88798. * Defines if the alpha value should be determined via the rgb values.
  88799. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  88800. */
  88801. getAlphaFromRGB: boolean;
  88802. /**
  88803. * Intensity or strength of the texture.
  88804. * It is commonly used by materials to fine tune the intensity of the texture
  88805. */
  88806. level: number;
  88807. /**
  88808. * Define the UV chanel to use starting from 0 and defaulting to 0.
  88809. * This is part of the texture as textures usually maps to one uv set.
  88810. */
  88811. coordinatesIndex: number;
  88812. private _coordinatesMode;
  88813. /**
  88814. * How a texture is mapped.
  88815. *
  88816. * | Value | Type | Description |
  88817. * | ----- | ----------------------------------- | ----------- |
  88818. * | 0 | EXPLICIT_MODE | |
  88819. * | 1 | SPHERICAL_MODE | |
  88820. * | 2 | PLANAR_MODE | |
  88821. * | 3 | CUBIC_MODE | |
  88822. * | 4 | PROJECTION_MODE | |
  88823. * | 5 | SKYBOX_MODE | |
  88824. * | 6 | INVCUBIC_MODE | |
  88825. * | 7 | EQUIRECTANGULAR_MODE | |
  88826. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  88827. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  88828. */
  88829. coordinatesMode: number;
  88830. /**
  88831. * | Value | Type | Description |
  88832. * | ----- | ------------------ | ----------- |
  88833. * | 0 | CLAMP_ADDRESSMODE | |
  88834. * | 1 | WRAP_ADDRESSMODE | |
  88835. * | 2 | MIRROR_ADDRESSMODE | |
  88836. */
  88837. wrapU: number;
  88838. /**
  88839. * | Value | Type | Description |
  88840. * | ----- | ------------------ | ----------- |
  88841. * | 0 | CLAMP_ADDRESSMODE | |
  88842. * | 1 | WRAP_ADDRESSMODE | |
  88843. * | 2 | MIRROR_ADDRESSMODE | |
  88844. */
  88845. wrapV: number;
  88846. /**
  88847. * | Value | Type | Description |
  88848. * | ----- | ------------------ | ----------- |
  88849. * | 0 | CLAMP_ADDRESSMODE | |
  88850. * | 1 | WRAP_ADDRESSMODE | |
  88851. * | 2 | MIRROR_ADDRESSMODE | |
  88852. */
  88853. wrapR: number;
  88854. /**
  88855. * With compliant hardware and browser (supporting anisotropic filtering)
  88856. * this defines the level of anisotropic filtering in the texture.
  88857. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  88858. */
  88859. anisotropicFilteringLevel: number;
  88860. /**
  88861. * Define if the texture is a cube texture or if false a 2d texture.
  88862. */
  88863. isCube: boolean;
  88864. /**
  88865. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  88866. */
  88867. is3D: boolean;
  88868. /**
  88869. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  88870. * HDR texture are usually stored in linear space.
  88871. * This only impacts the PBR and Background materials
  88872. */
  88873. gammaSpace: boolean;
  88874. /**
  88875. * Gets whether or not the texture contains RGBD data.
  88876. */
  88877. readonly isRGBD: boolean;
  88878. /**
  88879. * Is Z inverted in the texture (useful in a cube texture).
  88880. */
  88881. invertZ: boolean;
  88882. /**
  88883. * Are mip maps generated for this texture or not.
  88884. */
  88885. readonly noMipmap: boolean;
  88886. /**
  88887. * @hidden
  88888. */
  88889. lodLevelInAlpha: boolean;
  88890. /**
  88891. * With prefiltered texture, defined the offset used during the prefiltering steps.
  88892. */
  88893. lodGenerationOffset: number;
  88894. /**
  88895. * With prefiltered texture, defined the scale used during the prefiltering steps.
  88896. */
  88897. lodGenerationScale: number;
  88898. /**
  88899. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  88900. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  88901. * average roughness values.
  88902. */
  88903. linearSpecularLOD: boolean;
  88904. /**
  88905. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  88906. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  88907. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  88908. */
  88909. irradianceTexture: Nullable<BaseTexture>;
  88910. /**
  88911. * Define if the texture is a render target.
  88912. */
  88913. isRenderTarget: boolean;
  88914. /**
  88915. * Define the unique id of the texture in the scene.
  88916. */
  88917. readonly uid: string;
  88918. /**
  88919. * Return a string representation of the texture.
  88920. * @returns the texture as a string
  88921. */
  88922. toString(): string;
  88923. /**
  88924. * Get the class name of the texture.
  88925. * @returns "BaseTexture"
  88926. */
  88927. getClassName(): string;
  88928. /**
  88929. * Define the list of animation attached to the texture.
  88930. */
  88931. animations: Animation[];
  88932. /**
  88933. * An event triggered when the texture is disposed.
  88934. */
  88935. onDisposeObservable: Observable<BaseTexture>;
  88936. private _onDisposeObserver;
  88937. /**
  88938. * Callback triggered when the texture has been disposed.
  88939. * Kept for back compatibility, you can use the onDisposeObservable instead.
  88940. */
  88941. onDispose: () => void;
  88942. /**
  88943. * Define the current state of the loading sequence when in delayed load mode.
  88944. */
  88945. delayLoadState: number;
  88946. private _scene;
  88947. /** @hidden */
  88948. _texture: Nullable<InternalTexture>;
  88949. private _uid;
  88950. /**
  88951. * Define if the texture is preventinga material to render or not.
  88952. * If not and the texture is not ready, the engine will use a default black texture instead.
  88953. */
  88954. readonly isBlocking: boolean;
  88955. /**
  88956. * Instantiates a new BaseTexture.
  88957. * Base class of all the textures in babylon.
  88958. * It groups all the common properties the materials, post process, lights... might need
  88959. * in order to make a correct use of the texture.
  88960. * @param scene Define the scene the texture blongs to
  88961. */
  88962. constructor(scene: Nullable<Scene>);
  88963. /**
  88964. * Get the scene the texture belongs to.
  88965. * @returns the scene or null if undefined
  88966. */
  88967. getScene(): Nullable<Scene>;
  88968. /**
  88969. * Get the texture transform matrix used to offset tile the texture for istance.
  88970. * @returns the transformation matrix
  88971. */
  88972. getTextureMatrix(): Matrix;
  88973. /**
  88974. * Get the texture reflection matrix used to rotate/transform the reflection.
  88975. * @returns the reflection matrix
  88976. */
  88977. getReflectionTextureMatrix(): Matrix;
  88978. /**
  88979. * Get the underlying lower level texture from Babylon.
  88980. * @returns the insternal texture
  88981. */
  88982. getInternalTexture(): Nullable<InternalTexture>;
  88983. /**
  88984. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  88985. * @returns true if ready or not blocking
  88986. */
  88987. isReadyOrNotBlocking(): boolean;
  88988. /**
  88989. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  88990. * @returns true if fully ready
  88991. */
  88992. isReady(): boolean;
  88993. private _cachedSize;
  88994. /**
  88995. * Get the size of the texture.
  88996. * @returns the texture size.
  88997. */
  88998. getSize(): ISize;
  88999. /**
  89000. * Get the base size of the texture.
  89001. * It can be different from the size if the texture has been resized for POT for instance
  89002. * @returns the base size
  89003. */
  89004. getBaseSize(): ISize;
  89005. /**
  89006. * Update the sampling mode of the texture.
  89007. * Default is Trilinear mode.
  89008. *
  89009. * | Value | Type | Description |
  89010. * | ----- | ------------------ | ----------- |
  89011. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  89012. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  89013. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  89014. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  89015. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  89016. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  89017. * | 7 | NEAREST_LINEAR | |
  89018. * | 8 | NEAREST_NEAREST | |
  89019. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  89020. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  89021. * | 11 | LINEAR_LINEAR | |
  89022. * | 12 | LINEAR_NEAREST | |
  89023. *
  89024. * > _mag_: magnification filter (close to the viewer)
  89025. * > _min_: minification filter (far from the viewer)
  89026. * > _mip_: filter used between mip map levels
  89027. *@param samplingMode Define the new sampling mode of the texture
  89028. */
  89029. updateSamplingMode(samplingMode: number): void;
  89030. /**
  89031. * Scales the texture if is `canRescale()`
  89032. * @param ratio the resize factor we want to use to rescale
  89033. */
  89034. scale(ratio: number): void;
  89035. /**
  89036. * Get if the texture can rescale.
  89037. */
  89038. readonly canRescale: boolean;
  89039. /** @hidden */
  89040. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  89041. /** @hidden */
  89042. _rebuild(): void;
  89043. /**
  89044. * Triggers the load sequence in delayed load mode.
  89045. */
  89046. delayLoad(): void;
  89047. /**
  89048. * Clones the texture.
  89049. * @returns the cloned texture
  89050. */
  89051. clone(): Nullable<BaseTexture>;
  89052. /**
  89053. * Get the texture underlying type (INT, FLOAT...)
  89054. */
  89055. readonly textureType: number;
  89056. /**
  89057. * Get the texture underlying format (RGB, RGBA...)
  89058. */
  89059. readonly textureFormat: number;
  89060. /**
  89061. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  89062. * This will returns an RGBA array buffer containing either in values (0-255) or
  89063. * float values (0-1) depending of the underlying buffer type.
  89064. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  89065. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  89066. * @param buffer defines a user defined buffer to fill with data (can be null)
  89067. * @returns The Array buffer containing the pixels data.
  89068. */
  89069. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  89070. /**
  89071. * Release and destroy the underlying lower level texture aka internalTexture.
  89072. */
  89073. releaseInternalTexture(): void;
  89074. /**
  89075. * Get the polynomial representation of the texture data.
  89076. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  89077. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  89078. */
  89079. sphericalPolynomial: Nullable<SphericalPolynomial>;
  89080. /** @hidden */
  89081. readonly _lodTextureHigh: Nullable<BaseTexture>;
  89082. /** @hidden */
  89083. readonly _lodTextureMid: Nullable<BaseTexture>;
  89084. /** @hidden */
  89085. readonly _lodTextureLow: Nullable<BaseTexture>;
  89086. /**
  89087. * Dispose the texture and release its associated resources.
  89088. */
  89089. dispose(): void;
  89090. /**
  89091. * Serialize the texture into a JSON representation that can be parsed later on.
  89092. * @returns the JSON representation of the texture
  89093. */
  89094. serialize(): any;
  89095. /**
  89096. * Helper function to be called back once a list of texture contains only ready textures.
  89097. * @param textures Define the list of textures to wait for
  89098. * @param callback Define the callback triggered once the entire list will be ready
  89099. */
  89100. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  89101. }
  89102. }
  89103. declare module BABYLON {
  89104. /**
  89105. * Uniform buffer objects.
  89106. *
  89107. * Handles blocks of uniform on the GPU.
  89108. *
  89109. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  89110. *
  89111. * For more information, please refer to :
  89112. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  89113. */
  89114. export class UniformBuffer {
  89115. private _engine;
  89116. private _buffer;
  89117. private _data;
  89118. private _bufferData;
  89119. private _dynamic?;
  89120. private _uniformLocations;
  89121. private _uniformSizes;
  89122. private _uniformLocationPointer;
  89123. private _needSync;
  89124. private _noUBO;
  89125. private _currentEffect;
  89126. private static _MAX_UNIFORM_SIZE;
  89127. private static _tempBuffer;
  89128. /**
  89129. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  89130. * This is dynamic to allow compat with webgl 1 and 2.
  89131. * You will need to pass the name of the uniform as well as the value.
  89132. */
  89133. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  89134. /**
  89135. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  89136. * This is dynamic to allow compat with webgl 1 and 2.
  89137. * You will need to pass the name of the uniform as well as the value.
  89138. */
  89139. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  89140. /**
  89141. * Lambda to Update a single float in a uniform buffer.
  89142. * This is dynamic to allow compat with webgl 1 and 2.
  89143. * You will need to pass the name of the uniform as well as the value.
  89144. */
  89145. updateFloat: (name: string, x: number) => void;
  89146. /**
  89147. * Lambda to Update a vec2 of float in a uniform buffer.
  89148. * This is dynamic to allow compat with webgl 1 and 2.
  89149. * You will need to pass the name of the uniform as well as the value.
  89150. */
  89151. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  89152. /**
  89153. * Lambda to Update a vec3 of float in a uniform buffer.
  89154. * This is dynamic to allow compat with webgl 1 and 2.
  89155. * You will need to pass the name of the uniform as well as the value.
  89156. */
  89157. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  89158. /**
  89159. * Lambda to Update a vec4 of float in a uniform buffer.
  89160. * This is dynamic to allow compat with webgl 1 and 2.
  89161. * You will need to pass the name of the uniform as well as the value.
  89162. */
  89163. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  89164. /**
  89165. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  89166. * This is dynamic to allow compat with webgl 1 and 2.
  89167. * You will need to pass the name of the uniform as well as the value.
  89168. */
  89169. updateMatrix: (name: string, mat: Matrix) => void;
  89170. /**
  89171. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  89172. * This is dynamic to allow compat with webgl 1 and 2.
  89173. * You will need to pass the name of the uniform as well as the value.
  89174. */
  89175. updateVector3: (name: string, vector: Vector3) => void;
  89176. /**
  89177. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  89178. * This is dynamic to allow compat with webgl 1 and 2.
  89179. * You will need to pass the name of the uniform as well as the value.
  89180. */
  89181. updateVector4: (name: string, vector: Vector4) => void;
  89182. /**
  89183. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  89184. * This is dynamic to allow compat with webgl 1 and 2.
  89185. * You will need to pass the name of the uniform as well as the value.
  89186. */
  89187. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  89188. /**
  89189. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  89190. * This is dynamic to allow compat with webgl 1 and 2.
  89191. * You will need to pass the name of the uniform as well as the value.
  89192. */
  89193. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  89194. /**
  89195. * Instantiates a new Uniform buffer objects.
  89196. *
  89197. * Handles blocks of uniform on the GPU.
  89198. *
  89199. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  89200. *
  89201. * For more information, please refer to :
  89202. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  89203. * @param engine Define the engine the buffer is associated with
  89204. * @param data Define the data contained in the buffer
  89205. * @param dynamic Define if the buffer is updatable
  89206. */
  89207. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  89208. /**
  89209. * Indicates if the buffer is using the WebGL2 UBO implementation,
  89210. * or just falling back on setUniformXXX calls.
  89211. */
  89212. readonly useUbo: boolean;
  89213. /**
  89214. * Indicates if the WebGL underlying uniform buffer is in sync
  89215. * with the javascript cache data.
  89216. */
  89217. readonly isSync: boolean;
  89218. /**
  89219. * Indicates if the WebGL underlying uniform buffer is dynamic.
  89220. * Also, a dynamic UniformBuffer will disable cache verification and always
  89221. * update the underlying WebGL uniform buffer to the GPU.
  89222. * @returns if Dynamic, otherwise false
  89223. */
  89224. isDynamic(): boolean;
  89225. /**
  89226. * The data cache on JS side.
  89227. * @returns the underlying data as a float array
  89228. */
  89229. getData(): Float32Array;
  89230. /**
  89231. * The underlying WebGL Uniform buffer.
  89232. * @returns the webgl buffer
  89233. */
  89234. getBuffer(): Nullable<DataBuffer>;
  89235. /**
  89236. * std140 layout specifies how to align data within an UBO structure.
  89237. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  89238. * for specs.
  89239. */
  89240. private _fillAlignment;
  89241. /**
  89242. * Adds an uniform in the buffer.
  89243. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  89244. * for the layout to be correct !
  89245. * @param name Name of the uniform, as used in the uniform block in the shader.
  89246. * @param size Data size, or data directly.
  89247. */
  89248. addUniform(name: string, size: number | number[]): void;
  89249. /**
  89250. * Adds a Matrix 4x4 to the uniform buffer.
  89251. * @param name Name of the uniform, as used in the uniform block in the shader.
  89252. * @param mat A 4x4 matrix.
  89253. */
  89254. addMatrix(name: string, mat: Matrix): void;
  89255. /**
  89256. * Adds a vec2 to the uniform buffer.
  89257. * @param name Name of the uniform, as used in the uniform block in the shader.
  89258. * @param x Define the x component value of the vec2
  89259. * @param y Define the y component value of the vec2
  89260. */
  89261. addFloat2(name: string, x: number, y: number): void;
  89262. /**
  89263. * Adds a vec3 to the uniform buffer.
  89264. * @param name Name of the uniform, as used in the uniform block in the shader.
  89265. * @param x Define the x component value of the vec3
  89266. * @param y Define the y component value of the vec3
  89267. * @param z Define the z component value of the vec3
  89268. */
  89269. addFloat3(name: string, x: number, y: number, z: number): void;
  89270. /**
  89271. * Adds a vec3 to the uniform buffer.
  89272. * @param name Name of the uniform, as used in the uniform block in the shader.
  89273. * @param color Define the vec3 from a Color
  89274. */
  89275. addColor3(name: string, color: Color3): void;
  89276. /**
  89277. * Adds a vec4 to the uniform buffer.
  89278. * @param name Name of the uniform, as used in the uniform block in the shader.
  89279. * @param color Define the rgb components from a Color
  89280. * @param alpha Define the a component of the vec4
  89281. */
  89282. addColor4(name: string, color: Color3, alpha: number): void;
  89283. /**
  89284. * Adds a vec3 to the uniform buffer.
  89285. * @param name Name of the uniform, as used in the uniform block in the shader.
  89286. * @param vector Define the vec3 components from a Vector
  89287. */
  89288. addVector3(name: string, vector: Vector3): void;
  89289. /**
  89290. * Adds a Matrix 3x3 to the uniform buffer.
  89291. * @param name Name of the uniform, as used in the uniform block in the shader.
  89292. */
  89293. addMatrix3x3(name: string): void;
  89294. /**
  89295. * Adds a Matrix 2x2 to the uniform buffer.
  89296. * @param name Name of the uniform, as used in the uniform block in the shader.
  89297. */
  89298. addMatrix2x2(name: string): void;
  89299. /**
  89300. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  89301. */
  89302. create(): void;
  89303. /** @hidden */
  89304. _rebuild(): void;
  89305. /**
  89306. * Updates the WebGL Uniform Buffer on the GPU.
  89307. * If the `dynamic` flag is set to true, no cache comparison is done.
  89308. * Otherwise, the buffer will be updated only if the cache differs.
  89309. */
  89310. update(): void;
  89311. /**
  89312. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  89313. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  89314. * @param data Define the flattened data
  89315. * @param size Define the size of the data.
  89316. */
  89317. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  89318. private _updateMatrix3x3ForUniform;
  89319. private _updateMatrix3x3ForEffect;
  89320. private _updateMatrix2x2ForEffect;
  89321. private _updateMatrix2x2ForUniform;
  89322. private _updateFloatForEffect;
  89323. private _updateFloatForUniform;
  89324. private _updateFloat2ForEffect;
  89325. private _updateFloat2ForUniform;
  89326. private _updateFloat3ForEffect;
  89327. private _updateFloat3ForUniform;
  89328. private _updateFloat4ForEffect;
  89329. private _updateFloat4ForUniform;
  89330. private _updateMatrixForEffect;
  89331. private _updateMatrixForUniform;
  89332. private _updateVector3ForEffect;
  89333. private _updateVector3ForUniform;
  89334. private _updateVector4ForEffect;
  89335. private _updateVector4ForUniform;
  89336. private _updateColor3ForEffect;
  89337. private _updateColor3ForUniform;
  89338. private _updateColor4ForEffect;
  89339. private _updateColor4ForUniform;
  89340. /**
  89341. * Sets a sampler uniform on the effect.
  89342. * @param name Define the name of the sampler.
  89343. * @param texture Define the texture to set in the sampler
  89344. */
  89345. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  89346. /**
  89347. * Directly updates the value of the uniform in the cache AND on the GPU.
  89348. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  89349. * @param data Define the flattened data
  89350. */
  89351. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  89352. /**
  89353. * Binds this uniform buffer to an effect.
  89354. * @param effect Define the effect to bind the buffer to
  89355. * @param name Name of the uniform block in the shader.
  89356. */
  89357. bindToEffect(effect: Effect, name: string): void;
  89358. /**
  89359. * Disposes the uniform buffer.
  89360. */
  89361. dispose(): void;
  89362. }
  89363. }
  89364. declare module BABYLON {
  89365. /**
  89366. * Class used to work with sound analyzer using fast fourier transform (FFT)
  89367. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89368. */
  89369. export class Analyser {
  89370. /**
  89371. * Gets or sets the smoothing
  89372. * @ignorenaming
  89373. */
  89374. SMOOTHING: number;
  89375. /**
  89376. * Gets or sets the FFT table size
  89377. * @ignorenaming
  89378. */
  89379. FFT_SIZE: number;
  89380. /**
  89381. * Gets or sets the bar graph amplitude
  89382. * @ignorenaming
  89383. */
  89384. BARGRAPHAMPLITUDE: number;
  89385. /**
  89386. * Gets or sets the position of the debug canvas
  89387. * @ignorenaming
  89388. */
  89389. DEBUGCANVASPOS: {
  89390. x: number;
  89391. y: number;
  89392. };
  89393. /**
  89394. * Gets or sets the debug canvas size
  89395. * @ignorenaming
  89396. */
  89397. DEBUGCANVASSIZE: {
  89398. width: number;
  89399. height: number;
  89400. };
  89401. private _byteFreqs;
  89402. private _byteTime;
  89403. private _floatFreqs;
  89404. private _webAudioAnalyser;
  89405. private _debugCanvas;
  89406. private _debugCanvasContext;
  89407. private _scene;
  89408. private _registerFunc;
  89409. private _audioEngine;
  89410. /**
  89411. * Creates a new analyser
  89412. * @param scene defines hosting scene
  89413. */
  89414. constructor(scene: Scene);
  89415. /**
  89416. * Get the number of data values you will have to play with for the visualization
  89417. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  89418. * @returns a number
  89419. */
  89420. getFrequencyBinCount(): number;
  89421. /**
  89422. * Gets the current frequency data as a byte array
  89423. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  89424. * @returns a Uint8Array
  89425. */
  89426. getByteFrequencyData(): Uint8Array;
  89427. /**
  89428. * Gets the current waveform as a byte array
  89429. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  89430. * @returns a Uint8Array
  89431. */
  89432. getByteTimeDomainData(): Uint8Array;
  89433. /**
  89434. * Gets the current frequency data as a float array
  89435. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  89436. * @returns a Float32Array
  89437. */
  89438. getFloatFrequencyData(): Float32Array;
  89439. /**
  89440. * Renders the debug canvas
  89441. */
  89442. drawDebugCanvas(): void;
  89443. /**
  89444. * Stops rendering the debug canvas and removes it
  89445. */
  89446. stopDebugCanvas(): void;
  89447. /**
  89448. * Connects two audio nodes
  89449. * @param inputAudioNode defines first node to connect
  89450. * @param outputAudioNode defines second node to connect
  89451. */
  89452. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  89453. /**
  89454. * Releases all associated resources
  89455. */
  89456. dispose(): void;
  89457. }
  89458. }
  89459. declare module BABYLON {
  89460. /**
  89461. * This represents an audio engine and it is responsible
  89462. * to play, synchronize and analyse sounds throughout the application.
  89463. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89464. */
  89465. export interface IAudioEngine extends IDisposable {
  89466. /**
  89467. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  89468. */
  89469. readonly canUseWebAudio: boolean;
  89470. /**
  89471. * Gets the current AudioContext if available.
  89472. */
  89473. readonly audioContext: Nullable<AudioContext>;
  89474. /**
  89475. * The master gain node defines the global audio volume of your audio engine.
  89476. */
  89477. readonly masterGain: GainNode;
  89478. /**
  89479. * Gets whether or not mp3 are supported by your browser.
  89480. */
  89481. readonly isMP3supported: boolean;
  89482. /**
  89483. * Gets whether or not ogg are supported by your browser.
  89484. */
  89485. readonly isOGGsupported: boolean;
  89486. /**
  89487. * Defines if Babylon should emit a warning if WebAudio is not supported.
  89488. * @ignoreNaming
  89489. */
  89490. WarnedWebAudioUnsupported: boolean;
  89491. /**
  89492. * Defines if the audio engine relies on a custom unlocked button.
  89493. * In this case, the embedded button will not be displayed.
  89494. */
  89495. useCustomUnlockedButton: boolean;
  89496. /**
  89497. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  89498. */
  89499. readonly unlocked: boolean;
  89500. /**
  89501. * Event raised when audio has been unlocked on the browser.
  89502. */
  89503. onAudioUnlockedObservable: Observable<AudioEngine>;
  89504. /**
  89505. * Event raised when audio has been locked on the browser.
  89506. */
  89507. onAudioLockedObservable: Observable<AudioEngine>;
  89508. /**
  89509. * Flags the audio engine in Locked state.
  89510. * This happens due to new browser policies preventing audio to autoplay.
  89511. */
  89512. lock(): void;
  89513. /**
  89514. * Unlocks the audio engine once a user action has been done on the dom.
  89515. * This is helpful to resume play once browser policies have been satisfied.
  89516. */
  89517. unlock(): void;
  89518. }
  89519. /**
  89520. * This represents the default audio engine used in babylon.
  89521. * It is responsible to play, synchronize and analyse sounds throughout the application.
  89522. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89523. */
  89524. export class AudioEngine implements IAudioEngine {
  89525. private _audioContext;
  89526. private _audioContextInitialized;
  89527. private _muteButton;
  89528. private _hostElement;
  89529. /**
  89530. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  89531. */
  89532. canUseWebAudio: boolean;
  89533. /**
  89534. * The master gain node defines the global audio volume of your audio engine.
  89535. */
  89536. masterGain: GainNode;
  89537. /**
  89538. * Defines if Babylon should emit a warning if WebAudio is not supported.
  89539. * @ignoreNaming
  89540. */
  89541. WarnedWebAudioUnsupported: boolean;
  89542. /**
  89543. * Gets whether or not mp3 are supported by your browser.
  89544. */
  89545. isMP3supported: boolean;
  89546. /**
  89547. * Gets whether or not ogg are supported by your browser.
  89548. */
  89549. isOGGsupported: boolean;
  89550. /**
  89551. * Gets whether audio has been unlocked on the device.
  89552. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  89553. * a user interaction has happened.
  89554. */
  89555. unlocked: boolean;
  89556. /**
  89557. * Defines if the audio engine relies on a custom unlocked button.
  89558. * In this case, the embedded button will not be displayed.
  89559. */
  89560. useCustomUnlockedButton: boolean;
  89561. /**
  89562. * Event raised when audio has been unlocked on the browser.
  89563. */
  89564. onAudioUnlockedObservable: Observable<AudioEngine>;
  89565. /**
  89566. * Event raised when audio has been locked on the browser.
  89567. */
  89568. onAudioLockedObservable: Observable<AudioEngine>;
  89569. /**
  89570. * Gets the current AudioContext if available.
  89571. */
  89572. readonly audioContext: Nullable<AudioContext>;
  89573. private _connectedAnalyser;
  89574. /**
  89575. * Instantiates a new audio engine.
  89576. *
  89577. * There should be only one per page as some browsers restrict the number
  89578. * of audio contexts you can create.
  89579. * @param hostElement defines the host element where to display the mute icon if necessary
  89580. */
  89581. constructor(hostElement?: Nullable<HTMLElement>);
  89582. /**
  89583. * Flags the audio engine in Locked state.
  89584. * This happens due to new browser policies preventing audio to autoplay.
  89585. */
  89586. lock(): void;
  89587. /**
  89588. * Unlocks the audio engine once a user action has been done on the dom.
  89589. * This is helpful to resume play once browser policies have been satisfied.
  89590. */
  89591. unlock(): void;
  89592. private _resumeAudioContext;
  89593. private _initializeAudioContext;
  89594. private _tryToRun;
  89595. private _triggerRunningState;
  89596. private _triggerSuspendedState;
  89597. private _displayMuteButton;
  89598. private _moveButtonToTopLeft;
  89599. private _onResize;
  89600. private _hideMuteButton;
  89601. /**
  89602. * Destroy and release the resources associated with the audio ccontext.
  89603. */
  89604. dispose(): void;
  89605. /**
  89606. * Gets the global volume sets on the master gain.
  89607. * @returns the global volume if set or -1 otherwise
  89608. */
  89609. getGlobalVolume(): number;
  89610. /**
  89611. * Sets the global volume of your experience (sets on the master gain).
  89612. * @param newVolume Defines the new global volume of the application
  89613. */
  89614. setGlobalVolume(newVolume: number): void;
  89615. /**
  89616. * Connect the audio engine to an audio analyser allowing some amazing
  89617. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  89618. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  89619. * @param analyser The analyser to connect to the engine
  89620. */
  89621. connectToAnalyser(analyser: Analyser): void;
  89622. }
  89623. }
  89624. declare module BABYLON {
  89625. /**
  89626. * Interface used to present a loading screen while loading a scene
  89627. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  89628. */
  89629. export interface ILoadingScreen {
  89630. /**
  89631. * Function called to display the loading screen
  89632. */
  89633. displayLoadingUI: () => void;
  89634. /**
  89635. * Function called to hide the loading screen
  89636. */
  89637. hideLoadingUI: () => void;
  89638. /**
  89639. * Gets or sets the color to use for the background
  89640. */
  89641. loadingUIBackgroundColor: string;
  89642. /**
  89643. * Gets or sets the text to display while loading
  89644. */
  89645. loadingUIText: string;
  89646. }
  89647. /**
  89648. * Class used for the default loading screen
  89649. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  89650. */
  89651. export class DefaultLoadingScreen implements ILoadingScreen {
  89652. private _renderingCanvas;
  89653. private _loadingText;
  89654. private _loadingDivBackgroundColor;
  89655. private _loadingDiv;
  89656. private _loadingTextDiv;
  89657. /** Gets or sets the logo url to use for the default loading screen */
  89658. static DefaultLogoUrl: string;
  89659. /** Gets or sets the spinner url to use for the default loading screen */
  89660. static DefaultSpinnerUrl: string;
  89661. /**
  89662. * Creates a new default loading screen
  89663. * @param _renderingCanvas defines the canvas used to render the scene
  89664. * @param _loadingText defines the default text to display
  89665. * @param _loadingDivBackgroundColor defines the default background color
  89666. */
  89667. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  89668. /**
  89669. * Function called to display the loading screen
  89670. */
  89671. displayLoadingUI(): void;
  89672. /**
  89673. * Function called to hide the loading screen
  89674. */
  89675. hideLoadingUI(): void;
  89676. /**
  89677. * Gets or sets the text to display while loading
  89678. */
  89679. loadingUIText: string;
  89680. /**
  89681. * Gets or sets the color to use for the background
  89682. */
  89683. loadingUIBackgroundColor: string;
  89684. private _resizeLoadingUI;
  89685. }
  89686. }
  89687. declare module BABYLON {
  89688. /** @hidden */
  89689. export class WebGLPipelineContext implements IPipelineContext {
  89690. engine: Engine;
  89691. program: Nullable<WebGLProgram>;
  89692. context?: WebGLRenderingContext;
  89693. vertexShader?: WebGLShader;
  89694. fragmentShader?: WebGLShader;
  89695. isParallelCompiled: boolean;
  89696. onCompiled?: () => void;
  89697. transformFeedback?: WebGLTransformFeedback | null;
  89698. readonly isAsync: boolean;
  89699. readonly isReady: boolean;
  89700. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  89701. }
  89702. }
  89703. declare module BABYLON {
  89704. /** @hidden */
  89705. export class WebGLDataBuffer extends DataBuffer {
  89706. private _buffer;
  89707. constructor(resource: WebGLBuffer);
  89708. readonly underlyingResource: any;
  89709. }
  89710. }
  89711. declare module BABYLON {
  89712. /** @hidden */
  89713. export class WebGL2ShaderProcessor implements IShaderProcessor {
  89714. attributeProcessor(attribute: string): string;
  89715. varyingProcessor(varying: string, isFragment: boolean): string;
  89716. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  89717. }
  89718. }
  89719. declare module BABYLON {
  89720. /**
  89721. * Settings for finer control over video usage
  89722. */
  89723. export interface VideoTextureSettings {
  89724. /**
  89725. * Applies `autoplay` to video, if specified
  89726. */
  89727. autoPlay?: boolean;
  89728. /**
  89729. * Applies `loop` to video, if specified
  89730. */
  89731. loop?: boolean;
  89732. /**
  89733. * Automatically updates internal texture from video at every frame in the render loop
  89734. */
  89735. autoUpdateTexture: boolean;
  89736. /**
  89737. * Image src displayed during the video loading or until the user interacts with the video.
  89738. */
  89739. poster?: string;
  89740. }
  89741. /**
  89742. * If you want to display a video in your scene, this is the special texture for that.
  89743. * This special texture works similar to other textures, with the exception of a few parameters.
  89744. * @see https://doc.babylonjs.com/how_to/video_texture
  89745. */
  89746. export class VideoTexture extends Texture {
  89747. /**
  89748. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  89749. */
  89750. readonly autoUpdateTexture: boolean;
  89751. /**
  89752. * The video instance used by the texture internally
  89753. */
  89754. readonly video: HTMLVideoElement;
  89755. private _onUserActionRequestedObservable;
  89756. /**
  89757. * Event triggerd when a dom action is required by the user to play the video.
  89758. * This happens due to recent changes in browser policies preventing video to auto start.
  89759. */
  89760. readonly onUserActionRequestedObservable: Observable<Texture>;
  89761. private _generateMipMaps;
  89762. private _engine;
  89763. private _stillImageCaptured;
  89764. private _displayingPosterTexture;
  89765. private _settings;
  89766. private _createInternalTextureOnEvent;
  89767. /**
  89768. * Creates a video texture.
  89769. * If you want to display a video in your scene, this is the special texture for that.
  89770. * This special texture works similar to other textures, with the exception of a few parameters.
  89771. * @see https://doc.babylonjs.com/how_to/video_texture
  89772. * @param name optional name, will detect from video source, if not defined
  89773. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  89774. * @param scene is obviously the current scene.
  89775. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  89776. * @param invertY is false by default but can be used to invert video on Y axis
  89777. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  89778. * @param settings allows finer control over video usage
  89779. */
  89780. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  89781. private _getName;
  89782. private _getVideo;
  89783. private _createInternalTexture;
  89784. private reset;
  89785. /**
  89786. * @hidden Internal method to initiate `update`.
  89787. */
  89788. _rebuild(): void;
  89789. /**
  89790. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  89791. */
  89792. update(): void;
  89793. /**
  89794. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  89795. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  89796. */
  89797. updateTexture(isVisible: boolean): void;
  89798. protected _updateInternalTexture: () => void;
  89799. /**
  89800. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  89801. * @param url New url.
  89802. */
  89803. updateURL(url: string): void;
  89804. /**
  89805. * Dispose the texture and release its associated resources.
  89806. */
  89807. dispose(): void;
  89808. /**
  89809. * Creates a video texture straight from a stream.
  89810. * @param scene Define the scene the texture should be created in
  89811. * @param stream Define the stream the texture should be created from
  89812. * @returns The created video texture as a promise
  89813. */
  89814. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  89815. /**
  89816. * Creates a video texture straight from your WebCam video feed.
  89817. * @param scene Define the scene the texture should be created in
  89818. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  89819. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  89820. * @returns The created video texture as a promise
  89821. */
  89822. static CreateFromWebCamAsync(scene: Scene, constraints: {
  89823. minWidth: number;
  89824. maxWidth: number;
  89825. minHeight: number;
  89826. maxHeight: number;
  89827. deviceId: string;
  89828. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  89829. /**
  89830. * Creates a video texture straight from your WebCam video feed.
  89831. * @param scene Define the scene the texture should be created in
  89832. * @param onReady Define a callback to triggered once the texture will be ready
  89833. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  89834. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  89835. */
  89836. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  89837. minWidth: number;
  89838. maxWidth: number;
  89839. minHeight: number;
  89840. maxHeight: number;
  89841. deviceId: string;
  89842. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  89843. }
  89844. }
  89845. declare module BABYLON {
  89846. /**
  89847. * Interface for attribute information associated with buffer instanciation
  89848. */
  89849. export class InstancingAttributeInfo {
  89850. /**
  89851. * Index/offset of the attribute in the vertex shader
  89852. */
  89853. index: number;
  89854. /**
  89855. * size of the attribute, 1, 2, 3 or 4
  89856. */
  89857. attributeSize: number;
  89858. /**
  89859. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  89860. * default is FLOAT
  89861. */
  89862. attribyteType: number;
  89863. /**
  89864. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  89865. */
  89866. normalized: boolean;
  89867. /**
  89868. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  89869. */
  89870. offset: number;
  89871. /**
  89872. * Name of the GLSL attribute, for debugging purpose only
  89873. */
  89874. attributeName: string;
  89875. }
  89876. /**
  89877. * Define options used to create a depth texture
  89878. */
  89879. export class DepthTextureCreationOptions {
  89880. /** Specifies whether or not a stencil should be allocated in the texture */
  89881. generateStencil?: boolean;
  89882. /** Specifies whether or not bilinear filtering is enable on the texture */
  89883. bilinearFiltering?: boolean;
  89884. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  89885. comparisonFunction?: number;
  89886. /** Specifies if the created texture is a cube texture */
  89887. isCube?: boolean;
  89888. }
  89889. /**
  89890. * Class used to describe the capabilities of the engine relatively to the current browser
  89891. */
  89892. export class EngineCapabilities {
  89893. /** Maximum textures units per fragment shader */
  89894. maxTexturesImageUnits: number;
  89895. /** Maximum texture units per vertex shader */
  89896. maxVertexTextureImageUnits: number;
  89897. /** Maximum textures units in the entire pipeline */
  89898. maxCombinedTexturesImageUnits: number;
  89899. /** Maximum texture size */
  89900. maxTextureSize: number;
  89901. /** Maximum cube texture size */
  89902. maxCubemapTextureSize: number;
  89903. /** Maximum render texture size */
  89904. maxRenderTextureSize: number;
  89905. /** Maximum number of vertex attributes */
  89906. maxVertexAttribs: number;
  89907. /** Maximum number of varyings */
  89908. maxVaryingVectors: number;
  89909. /** Maximum number of uniforms per vertex shader */
  89910. maxVertexUniformVectors: number;
  89911. /** Maximum number of uniforms per fragment shader */
  89912. maxFragmentUniformVectors: number;
  89913. /** Defines if standard derivates (dx/dy) are supported */
  89914. standardDerivatives: boolean;
  89915. /** Defines if s3tc texture compression is supported */
  89916. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  89917. /** Defines if pvrtc texture compression is supported */
  89918. pvrtc: any;
  89919. /** Defines if etc1 texture compression is supported */
  89920. etc1: any;
  89921. /** Defines if etc2 texture compression is supported */
  89922. etc2: any;
  89923. /** Defines if astc texture compression is supported */
  89924. astc: any;
  89925. /** Defines if float textures are supported */
  89926. textureFloat: boolean;
  89927. /** Defines if vertex array objects are supported */
  89928. vertexArrayObject: boolean;
  89929. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  89930. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  89931. /** Gets the maximum level of anisotropy supported */
  89932. maxAnisotropy: number;
  89933. /** Defines if instancing is supported */
  89934. instancedArrays: boolean;
  89935. /** Defines if 32 bits indices are supported */
  89936. uintIndices: boolean;
  89937. /** Defines if high precision shaders are supported */
  89938. highPrecisionShaderSupported: boolean;
  89939. /** Defines if depth reading in the fragment shader is supported */
  89940. fragmentDepthSupported: boolean;
  89941. /** Defines if float texture linear filtering is supported*/
  89942. textureFloatLinearFiltering: boolean;
  89943. /** Defines if rendering to float textures is supported */
  89944. textureFloatRender: boolean;
  89945. /** Defines if half float textures are supported*/
  89946. textureHalfFloat: boolean;
  89947. /** Defines if half float texture linear filtering is supported*/
  89948. textureHalfFloatLinearFiltering: boolean;
  89949. /** Defines if rendering to half float textures is supported */
  89950. textureHalfFloatRender: boolean;
  89951. /** Defines if textureLOD shader command is supported */
  89952. textureLOD: boolean;
  89953. /** Defines if draw buffers extension is supported */
  89954. drawBuffersExtension: boolean;
  89955. /** Defines if depth textures are supported */
  89956. depthTextureExtension: boolean;
  89957. /** Defines if float color buffer are supported */
  89958. colorBufferFloat: boolean;
  89959. /** Gets disjoint timer query extension (null if not supported) */
  89960. timerQuery: EXT_disjoint_timer_query;
  89961. /** Defines if timestamp can be used with timer query */
  89962. canUseTimestampForTimerQuery: boolean;
  89963. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  89964. multiview: any;
  89965. /** Function used to let the system compiles shaders in background */
  89966. parallelShaderCompile: {
  89967. COMPLETION_STATUS_KHR: number;
  89968. };
  89969. }
  89970. /** Interface defining initialization parameters for Engine class */
  89971. export interface EngineOptions extends WebGLContextAttributes {
  89972. /**
  89973. * Defines if the engine should no exceed a specified device ratio
  89974. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  89975. */
  89976. limitDeviceRatio?: number;
  89977. /**
  89978. * Defines if webvr should be enabled automatically
  89979. * @see http://doc.babylonjs.com/how_to/webvr_camera
  89980. */
  89981. autoEnableWebVR?: boolean;
  89982. /**
  89983. * Defines if webgl2 should be turned off even if supported
  89984. * @see http://doc.babylonjs.com/features/webgl2
  89985. */
  89986. disableWebGL2Support?: boolean;
  89987. /**
  89988. * Defines if webaudio should be initialized as well
  89989. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89990. */
  89991. audioEngine?: boolean;
  89992. /**
  89993. * Defines if animations should run using a deterministic lock step
  89994. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  89995. */
  89996. deterministicLockstep?: boolean;
  89997. /** Defines the maximum steps to use with deterministic lock step mode */
  89998. lockstepMaxSteps?: number;
  89999. /**
  90000. * Defines that engine should ignore context lost events
  90001. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  90002. */
  90003. doNotHandleContextLost?: boolean;
  90004. /**
  90005. * Defines that engine should ignore modifying touch action attribute and style
  90006. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  90007. */
  90008. doNotHandleTouchAction?: boolean;
  90009. /**
  90010. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  90011. */
  90012. useHighPrecisionFloats?: boolean;
  90013. }
  90014. /**
  90015. * Defines the interface used by display changed events
  90016. */
  90017. export interface IDisplayChangedEventArgs {
  90018. /** Gets the vrDisplay object (if any) */
  90019. vrDisplay: Nullable<any>;
  90020. /** Gets a boolean indicating if webVR is supported */
  90021. vrSupported: boolean;
  90022. }
  90023. /**
  90024. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  90025. */
  90026. export class Engine {
  90027. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  90028. static ExceptionList: ({
  90029. key: string;
  90030. capture: string;
  90031. captureConstraint: number;
  90032. targets: string[];
  90033. } | {
  90034. key: string;
  90035. capture: null;
  90036. captureConstraint: null;
  90037. targets: string[];
  90038. })[];
  90039. /** Gets the list of created engines */
  90040. static readonly Instances: Engine[];
  90041. /**
  90042. * Gets the latest created engine
  90043. */
  90044. static readonly LastCreatedEngine: Nullable<Engine>;
  90045. /**
  90046. * Gets the latest created scene
  90047. */
  90048. static readonly LastCreatedScene: Nullable<Scene>;
  90049. /**
  90050. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  90051. * @param flag defines which part of the materials must be marked as dirty
  90052. * @param predicate defines a predicate used to filter which materials should be affected
  90053. */
  90054. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  90055. /** @hidden */
  90056. static _TextureLoaders: IInternalTextureLoader[];
  90057. /** Defines that alpha blending is disabled */
  90058. static readonly ALPHA_DISABLE: number;
  90059. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  90060. static readonly ALPHA_ADD: number;
  90061. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  90062. static readonly ALPHA_COMBINE: number;
  90063. /** Defines that alpha blending to DEST - SRC * DEST */
  90064. static readonly ALPHA_SUBTRACT: number;
  90065. /** Defines that alpha blending to SRC * DEST */
  90066. static readonly ALPHA_MULTIPLY: number;
  90067. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  90068. static readonly ALPHA_MAXIMIZED: number;
  90069. /** Defines that alpha blending to SRC + DEST */
  90070. static readonly ALPHA_ONEONE: number;
  90071. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  90072. static readonly ALPHA_PREMULTIPLIED: number;
  90073. /**
  90074. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  90075. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  90076. */
  90077. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  90078. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  90079. static readonly ALPHA_INTERPOLATE: number;
  90080. /**
  90081. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  90082. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  90083. */
  90084. static readonly ALPHA_SCREENMODE: number;
  90085. /** Defines that the ressource is not delayed*/
  90086. static readonly DELAYLOADSTATE_NONE: number;
  90087. /** Defines that the ressource was successfully delay loaded */
  90088. static readonly DELAYLOADSTATE_LOADED: number;
  90089. /** Defines that the ressource is currently delay loading */
  90090. static readonly DELAYLOADSTATE_LOADING: number;
  90091. /** Defines that the ressource is delayed and has not started loading */
  90092. static readonly DELAYLOADSTATE_NOTLOADED: number;
  90093. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  90094. static readonly NEVER: number;
  90095. /** 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 */
  90096. static readonly ALWAYS: number;
  90097. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  90098. static readonly LESS: number;
  90099. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  90100. static readonly EQUAL: number;
  90101. /** 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 */
  90102. static readonly LEQUAL: number;
  90103. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  90104. static readonly GREATER: number;
  90105. /** 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 */
  90106. static readonly GEQUAL: number;
  90107. /** 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 */
  90108. static readonly NOTEQUAL: number;
  90109. /** Passed to stencilOperation to specify that stencil value must be kept */
  90110. static readonly KEEP: number;
  90111. /** Passed to stencilOperation to specify that stencil value must be replaced */
  90112. static readonly REPLACE: number;
  90113. /** Passed to stencilOperation to specify that stencil value must be incremented */
  90114. static readonly INCR: number;
  90115. /** Passed to stencilOperation to specify that stencil value must be decremented */
  90116. static readonly DECR: number;
  90117. /** Passed to stencilOperation to specify that stencil value must be inverted */
  90118. static readonly INVERT: number;
  90119. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  90120. static readonly INCR_WRAP: number;
  90121. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  90122. static readonly DECR_WRAP: number;
  90123. /** Texture is not repeating outside of 0..1 UVs */
  90124. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  90125. /** Texture is repeating outside of 0..1 UVs */
  90126. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  90127. /** Texture is repeating and mirrored */
  90128. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  90129. /** ALPHA */
  90130. static readonly TEXTUREFORMAT_ALPHA: number;
  90131. /** LUMINANCE */
  90132. static readonly TEXTUREFORMAT_LUMINANCE: number;
  90133. /** LUMINANCE_ALPHA */
  90134. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  90135. /** RGB */
  90136. static readonly TEXTUREFORMAT_RGB: number;
  90137. /** RGBA */
  90138. static readonly TEXTUREFORMAT_RGBA: number;
  90139. /** RED */
  90140. static readonly TEXTUREFORMAT_RED: number;
  90141. /** RED (2nd reference) */
  90142. static readonly TEXTUREFORMAT_R: number;
  90143. /** RG */
  90144. static readonly TEXTUREFORMAT_RG: number;
  90145. /** RED_INTEGER */
  90146. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  90147. /** RED_INTEGER (2nd reference) */
  90148. static readonly TEXTUREFORMAT_R_INTEGER: number;
  90149. /** RG_INTEGER */
  90150. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  90151. /** RGB_INTEGER */
  90152. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  90153. /** RGBA_INTEGER */
  90154. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  90155. /** UNSIGNED_BYTE */
  90156. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  90157. /** UNSIGNED_BYTE (2nd reference) */
  90158. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  90159. /** FLOAT */
  90160. static readonly TEXTURETYPE_FLOAT: number;
  90161. /** HALF_FLOAT */
  90162. static readonly TEXTURETYPE_HALF_FLOAT: number;
  90163. /** BYTE */
  90164. static readonly TEXTURETYPE_BYTE: number;
  90165. /** SHORT */
  90166. static readonly TEXTURETYPE_SHORT: number;
  90167. /** UNSIGNED_SHORT */
  90168. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  90169. /** INT */
  90170. static readonly TEXTURETYPE_INT: number;
  90171. /** UNSIGNED_INT */
  90172. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  90173. /** UNSIGNED_SHORT_4_4_4_4 */
  90174. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  90175. /** UNSIGNED_SHORT_5_5_5_1 */
  90176. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  90177. /** UNSIGNED_SHORT_5_6_5 */
  90178. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  90179. /** UNSIGNED_INT_2_10_10_10_REV */
  90180. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  90181. /** UNSIGNED_INT_24_8 */
  90182. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  90183. /** UNSIGNED_INT_10F_11F_11F_REV */
  90184. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  90185. /** UNSIGNED_INT_5_9_9_9_REV */
  90186. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  90187. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  90188. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  90189. /** nearest is mag = nearest and min = nearest and mip = linear */
  90190. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  90191. /** Bilinear is mag = linear and min = linear and mip = nearest */
  90192. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  90193. /** Trilinear is mag = linear and min = linear and mip = linear */
  90194. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  90195. /** nearest is mag = nearest and min = nearest and mip = linear */
  90196. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  90197. /** Bilinear is mag = linear and min = linear and mip = nearest */
  90198. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  90199. /** Trilinear is mag = linear and min = linear and mip = linear */
  90200. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  90201. /** mag = nearest and min = nearest and mip = nearest */
  90202. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  90203. /** mag = nearest and min = linear and mip = nearest */
  90204. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  90205. /** mag = nearest and min = linear and mip = linear */
  90206. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  90207. /** mag = nearest and min = linear and mip = none */
  90208. static readonly TEXTURE_NEAREST_LINEAR: number;
  90209. /** mag = nearest and min = nearest and mip = none */
  90210. static readonly TEXTURE_NEAREST_NEAREST: number;
  90211. /** mag = linear and min = nearest and mip = nearest */
  90212. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  90213. /** mag = linear and min = nearest and mip = linear */
  90214. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  90215. /** mag = linear and min = linear and mip = none */
  90216. static readonly TEXTURE_LINEAR_LINEAR: number;
  90217. /** mag = linear and min = nearest and mip = none */
  90218. static readonly TEXTURE_LINEAR_NEAREST: number;
  90219. /** Explicit coordinates mode */
  90220. static readonly TEXTURE_EXPLICIT_MODE: number;
  90221. /** Spherical coordinates mode */
  90222. static readonly TEXTURE_SPHERICAL_MODE: number;
  90223. /** Planar coordinates mode */
  90224. static readonly TEXTURE_PLANAR_MODE: number;
  90225. /** Cubic coordinates mode */
  90226. static readonly TEXTURE_CUBIC_MODE: number;
  90227. /** Projection coordinates mode */
  90228. static readonly TEXTURE_PROJECTION_MODE: number;
  90229. /** Skybox coordinates mode */
  90230. static readonly TEXTURE_SKYBOX_MODE: number;
  90231. /** Inverse Cubic coordinates mode */
  90232. static readonly TEXTURE_INVCUBIC_MODE: number;
  90233. /** Equirectangular coordinates mode */
  90234. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  90235. /** Equirectangular Fixed coordinates mode */
  90236. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  90237. /** Equirectangular Fixed Mirrored coordinates mode */
  90238. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  90239. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  90240. static readonly SCALEMODE_FLOOR: number;
  90241. /** Defines that texture rescaling will look for the nearest power of 2 size */
  90242. static readonly SCALEMODE_NEAREST: number;
  90243. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  90244. static readonly SCALEMODE_CEILING: number;
  90245. /**
  90246. * Returns the current npm package of the sdk
  90247. */
  90248. static readonly NpmPackage: string;
  90249. /**
  90250. * Returns the current version of the framework
  90251. */
  90252. static readonly Version: string;
  90253. /**
  90254. * Returns a string describing the current engine
  90255. */
  90256. readonly description: string;
  90257. /**
  90258. * Gets or sets the epsilon value used by collision engine
  90259. */
  90260. static CollisionsEpsilon: number;
  90261. /**
  90262. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  90263. */
  90264. static ShadersRepository: string;
  90265. /**
  90266. * Method called to create the default loading screen.
  90267. * This can be overriden in your own app.
  90268. * @param canvas The rendering canvas element
  90269. * @returns The loading screen
  90270. */
  90271. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  90272. /**
  90273. * Method called to create the default rescale post process on each engine.
  90274. */
  90275. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  90276. /** @hidden */
  90277. _shaderProcessor: IShaderProcessor;
  90278. /**
  90279. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  90280. */
  90281. forcePOTTextures: boolean;
  90282. /**
  90283. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  90284. */
  90285. isFullscreen: boolean;
  90286. /**
  90287. * Gets a boolean indicating if the pointer is currently locked
  90288. */
  90289. isPointerLock: boolean;
  90290. /**
  90291. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  90292. */
  90293. cullBackFaces: boolean;
  90294. /**
  90295. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  90296. */
  90297. renderEvenInBackground: boolean;
  90298. /**
  90299. * Gets or sets a boolean indicating that cache can be kept between frames
  90300. */
  90301. preventCacheWipeBetweenFrames: boolean;
  90302. /**
  90303. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  90304. **/
  90305. enableOfflineSupport: boolean;
  90306. /**
  90307. * 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)
  90308. **/
  90309. disableManifestCheck: boolean;
  90310. /**
  90311. * Gets the list of created scenes
  90312. */
  90313. scenes: Scene[];
  90314. /**
  90315. * Event raised when a new scene is created
  90316. */
  90317. onNewSceneAddedObservable: Observable<Scene>;
  90318. /**
  90319. * Gets the list of created postprocesses
  90320. */
  90321. postProcesses: PostProcess[];
  90322. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  90323. validateShaderPrograms: boolean;
  90324. /**
  90325. * Observable event triggered each time the rendering canvas is resized
  90326. */
  90327. onResizeObservable: Observable<Engine>;
  90328. /**
  90329. * Observable event triggered each time the canvas loses focus
  90330. */
  90331. onCanvasBlurObservable: Observable<Engine>;
  90332. /**
  90333. * Observable event triggered each time the canvas gains focus
  90334. */
  90335. onCanvasFocusObservable: Observable<Engine>;
  90336. /**
  90337. * Observable event triggered each time the canvas receives pointerout event
  90338. */
  90339. onCanvasPointerOutObservable: Observable<PointerEvent>;
  90340. /**
  90341. * Observable event triggered before each texture is initialized
  90342. */
  90343. onBeforeTextureInitObservable: Observable<Texture>;
  90344. /**
  90345. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  90346. */
  90347. disableUniformBuffers: boolean;
  90348. /** @hidden */
  90349. _uniformBuffers: UniformBuffer[];
  90350. /**
  90351. * Gets a boolean indicating that the engine supports uniform buffers
  90352. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  90353. */
  90354. readonly supportsUniformBuffers: boolean;
  90355. /**
  90356. * Observable raised when the engine begins a new frame
  90357. */
  90358. onBeginFrameObservable: Observable<Engine>;
  90359. /**
  90360. * If set, will be used to request the next animation frame for the render loop
  90361. */
  90362. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  90363. /**
  90364. * Observable raised when the engine ends the current frame
  90365. */
  90366. onEndFrameObservable: Observable<Engine>;
  90367. /**
  90368. * Observable raised when the engine is about to compile a shader
  90369. */
  90370. onBeforeShaderCompilationObservable: Observable<Engine>;
  90371. /**
  90372. * Observable raised when the engine has jsut compiled a shader
  90373. */
  90374. onAfterShaderCompilationObservable: Observable<Engine>;
  90375. /** @hidden */
  90376. _gl: WebGLRenderingContext;
  90377. private _renderingCanvas;
  90378. private _windowIsBackground;
  90379. private _webGLVersion;
  90380. protected _highPrecisionShadersAllowed: boolean;
  90381. /** @hidden */
  90382. readonly _shouldUseHighPrecisionShader: boolean;
  90383. /**
  90384. * Gets a boolean indicating that only power of 2 textures are supported
  90385. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  90386. */
  90387. readonly needPOTTextures: boolean;
  90388. /** @hidden */
  90389. _badOS: boolean;
  90390. /** @hidden */
  90391. _badDesktopOS: boolean;
  90392. /**
  90393. * Gets the audio engine
  90394. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  90395. * @ignorenaming
  90396. */
  90397. static audioEngine: IAudioEngine;
  90398. /**
  90399. * Default AudioEngine factory responsible of creating the Audio Engine.
  90400. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  90401. */
  90402. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  90403. /**
  90404. * Default offline support factory responsible of creating a tool used to store data locally.
  90405. * By default, this will create a Database object if the workload has been embedded.
  90406. */
  90407. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  90408. private _onFocus;
  90409. private _onBlur;
  90410. private _onCanvasPointerOut;
  90411. private _onCanvasBlur;
  90412. private _onCanvasFocus;
  90413. private _onFullscreenChange;
  90414. private _onPointerLockChange;
  90415. private _hardwareScalingLevel;
  90416. /** @hidden */
  90417. _caps: EngineCapabilities;
  90418. private _pointerLockRequested;
  90419. private _isStencilEnable;
  90420. private _colorWrite;
  90421. private _loadingScreen;
  90422. /** @hidden */
  90423. _drawCalls: PerfCounter;
  90424. private _glVersion;
  90425. private _glRenderer;
  90426. private _glVendor;
  90427. private _videoTextureSupported;
  90428. private _renderingQueueLaunched;
  90429. private _activeRenderLoops;
  90430. private _deterministicLockstep;
  90431. private _lockstepMaxSteps;
  90432. /**
  90433. * Observable signaled when a context lost event is raised
  90434. */
  90435. onContextLostObservable: Observable<Engine>;
  90436. /**
  90437. * Observable signaled when a context restored event is raised
  90438. */
  90439. onContextRestoredObservable: Observable<Engine>;
  90440. private _onContextLost;
  90441. private _onContextRestored;
  90442. private _contextWasLost;
  90443. /** @hidden */
  90444. _doNotHandleContextLost: boolean;
  90445. /**
  90446. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  90447. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  90448. */
  90449. doNotHandleContextLost: boolean;
  90450. private _performanceMonitor;
  90451. private _fps;
  90452. private _deltaTime;
  90453. /**
  90454. * Turn this value on if you want to pause FPS computation when in background
  90455. */
  90456. disablePerformanceMonitorInBackground: boolean;
  90457. /**
  90458. * Gets the performance monitor attached to this engine
  90459. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  90460. */
  90461. readonly performanceMonitor: PerformanceMonitor;
  90462. /**
  90463. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  90464. */
  90465. disableVertexArrayObjects: boolean;
  90466. /** @hidden */
  90467. protected _depthCullingState: _DepthCullingState;
  90468. /** @hidden */
  90469. protected _stencilState: _StencilState;
  90470. /** @hidden */
  90471. protected _alphaState: _AlphaState;
  90472. /** @hidden */
  90473. protected _alphaMode: number;
  90474. /** @hidden */
  90475. _internalTexturesCache: InternalTexture[];
  90476. /** @hidden */
  90477. protected _activeChannel: number;
  90478. private _currentTextureChannel;
  90479. /** @hidden */
  90480. protected _boundTexturesCache: {
  90481. [key: string]: Nullable<InternalTexture>;
  90482. };
  90483. /** @hidden */
  90484. protected _currentEffect: Nullable<Effect>;
  90485. /** @hidden */
  90486. protected _currentProgram: Nullable<WebGLProgram>;
  90487. private _compiledEffects;
  90488. private _vertexAttribArraysEnabled;
  90489. /** @hidden */
  90490. protected _cachedViewport: Nullable<Viewport>;
  90491. private _cachedVertexArrayObject;
  90492. /** @hidden */
  90493. protected _cachedVertexBuffers: any;
  90494. /** @hidden */
  90495. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  90496. /** @hidden */
  90497. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  90498. /** @hidden */
  90499. _currentRenderTarget: Nullable<InternalTexture>;
  90500. private _uintIndicesCurrentlySet;
  90501. private _currentBoundBuffer;
  90502. /** @hidden */
  90503. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  90504. private _currentBufferPointers;
  90505. private _currentInstanceLocations;
  90506. private _currentInstanceBuffers;
  90507. private _textureUnits;
  90508. /** @hidden */
  90509. _workingCanvas: Nullable<HTMLCanvasElement>;
  90510. /** @hidden */
  90511. _workingContext: Nullable<CanvasRenderingContext2D>;
  90512. private _rescalePostProcess;
  90513. private _dummyFramebuffer;
  90514. private _externalData;
  90515. /** @hidden */
  90516. _bindedRenderFunction: any;
  90517. private _vaoRecordInProgress;
  90518. private _mustWipeVertexAttributes;
  90519. private _emptyTexture;
  90520. private _emptyCubeTexture;
  90521. private _emptyTexture3D;
  90522. /** @hidden */
  90523. _frameHandler: number;
  90524. private _nextFreeTextureSlots;
  90525. private _maxSimultaneousTextures;
  90526. private _activeRequests;
  90527. private _texturesSupported;
  90528. /** @hidden */
  90529. _textureFormatInUse: Nullable<string>;
  90530. /**
  90531. * Gets the list of texture formats supported
  90532. */
  90533. readonly texturesSupported: Array<string>;
  90534. /**
  90535. * Gets the list of texture formats in use
  90536. */
  90537. readonly textureFormatInUse: Nullable<string>;
  90538. /**
  90539. * Gets the current viewport
  90540. */
  90541. readonly currentViewport: Nullable<Viewport>;
  90542. /**
  90543. * Gets the default empty texture
  90544. */
  90545. readonly emptyTexture: InternalTexture;
  90546. /**
  90547. * Gets the default empty 3D texture
  90548. */
  90549. readonly emptyTexture3D: InternalTexture;
  90550. /**
  90551. * Gets the default empty cube texture
  90552. */
  90553. readonly emptyCubeTexture: InternalTexture;
  90554. /**
  90555. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  90556. */
  90557. readonly premultipliedAlpha: boolean;
  90558. /**
  90559. * Creates a new engine
  90560. * @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
  90561. * @param antialias defines enable antialiasing (default: false)
  90562. * @param options defines further options to be sent to the getContext() function
  90563. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  90564. */
  90565. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  90566. /**
  90567. * Initializes a webVR display and starts listening to display change events
  90568. * The onVRDisplayChangedObservable will be notified upon these changes
  90569. * @returns The onVRDisplayChangedObservable
  90570. */
  90571. initWebVR(): Observable<IDisplayChangedEventArgs>;
  90572. /** @hidden */
  90573. _prepareVRComponent(): void;
  90574. /** @hidden */
  90575. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  90576. /** @hidden */
  90577. _submitVRFrame(): void;
  90578. /**
  90579. * Call this function to leave webVR mode
  90580. * Will do nothing if webVR is not supported or if there is no webVR device
  90581. * @see http://doc.babylonjs.com/how_to/webvr_camera
  90582. */
  90583. disableVR(): void;
  90584. /**
  90585. * Gets a boolean indicating that the system is in VR mode and is presenting
  90586. * @returns true if VR mode is engaged
  90587. */
  90588. isVRPresenting(): boolean;
  90589. /** @hidden */
  90590. _requestVRFrame(): void;
  90591. private _disableTouchAction;
  90592. private _rebuildInternalTextures;
  90593. private _rebuildEffects;
  90594. /**
  90595. * Gets a boolean indicating if all created effects are ready
  90596. * @returns true if all effects are ready
  90597. */
  90598. areAllEffectsReady(): boolean;
  90599. private _rebuildBuffers;
  90600. private _initGLContext;
  90601. /**
  90602. * Gets version of the current webGL context
  90603. */
  90604. readonly webGLVersion: number;
  90605. /**
  90606. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  90607. */
  90608. readonly isStencilEnable: boolean;
  90609. /** @hidden */
  90610. _prepareWorkingCanvas(): void;
  90611. /**
  90612. * Reset the texture cache to empty state
  90613. */
  90614. resetTextureCache(): void;
  90615. /**
  90616. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  90617. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  90618. * @returns true if engine is in deterministic lock step mode
  90619. */
  90620. isDeterministicLockStep(): boolean;
  90621. /**
  90622. * Gets the max steps when engine is running in deterministic lock step
  90623. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  90624. * @returns the max steps
  90625. */
  90626. getLockstepMaxSteps(): number;
  90627. /**
  90628. * Gets an object containing information about the current webGL context
  90629. * @returns an object containing the vender, the renderer and the version of the current webGL context
  90630. */
  90631. getGlInfo(): {
  90632. vendor: string;
  90633. renderer: string;
  90634. version: string;
  90635. };
  90636. /**
  90637. * Gets current aspect ratio
  90638. * @param camera defines the camera to use to get the aspect ratio
  90639. * @param useScreen defines if screen size must be used (or the current render target if any)
  90640. * @returns a number defining the aspect ratio
  90641. */
  90642. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  90643. /**
  90644. * Gets current screen aspect ratio
  90645. * @returns a number defining the aspect ratio
  90646. */
  90647. getScreenAspectRatio(): number;
  90648. /**
  90649. * Gets the current render width
  90650. * @param useScreen defines if screen size must be used (or the current render target if any)
  90651. * @returns a number defining the current render width
  90652. */
  90653. getRenderWidth(useScreen?: boolean): number;
  90654. /**
  90655. * Gets the current render height
  90656. * @param useScreen defines if screen size must be used (or the current render target if any)
  90657. * @returns a number defining the current render height
  90658. */
  90659. getRenderHeight(useScreen?: boolean): number;
  90660. /**
  90661. * Gets the HTML canvas attached with the current webGL context
  90662. * @returns a HTML canvas
  90663. */
  90664. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  90665. /**
  90666. * Gets the client rect of the HTML canvas attached with the current webGL context
  90667. * @returns a client rectanglee
  90668. */
  90669. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  90670. /**
  90671. * Defines the hardware scaling level.
  90672. * By default the hardware scaling level is computed from the window device ratio.
  90673. * 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.
  90674. * @param level defines the level to use
  90675. */
  90676. setHardwareScalingLevel(level: number): void;
  90677. /**
  90678. * Gets the current hardware scaling level.
  90679. * By default the hardware scaling level is computed from the window device ratio.
  90680. * 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.
  90681. * @returns a number indicating the current hardware scaling level
  90682. */
  90683. getHardwareScalingLevel(): number;
  90684. /**
  90685. * Gets the list of loaded textures
  90686. * @returns an array containing all loaded textures
  90687. */
  90688. getLoadedTexturesCache(): InternalTexture[];
  90689. /**
  90690. * Gets the object containing all engine capabilities
  90691. * @returns the EngineCapabilities object
  90692. */
  90693. getCaps(): EngineCapabilities;
  90694. /**
  90695. * Gets the current depth function
  90696. * @returns a number defining the depth function
  90697. */
  90698. getDepthFunction(): Nullable<number>;
  90699. /**
  90700. * Sets the current depth function
  90701. * @param depthFunc defines the function to use
  90702. */
  90703. setDepthFunction(depthFunc: number): void;
  90704. /**
  90705. * Sets the current depth function to GREATER
  90706. */
  90707. setDepthFunctionToGreater(): void;
  90708. /**
  90709. * Sets the current depth function to GEQUAL
  90710. */
  90711. setDepthFunctionToGreaterOrEqual(): void;
  90712. /**
  90713. * Sets the current depth function to LESS
  90714. */
  90715. setDepthFunctionToLess(): void;
  90716. private _cachedStencilBuffer;
  90717. private _cachedStencilFunction;
  90718. private _cachedStencilMask;
  90719. private _cachedStencilOperationPass;
  90720. private _cachedStencilOperationFail;
  90721. private _cachedStencilOperationDepthFail;
  90722. private _cachedStencilReference;
  90723. /**
  90724. * Caches the the state of the stencil buffer
  90725. */
  90726. cacheStencilState(): void;
  90727. /**
  90728. * Restores the state of the stencil buffer
  90729. */
  90730. restoreStencilState(): void;
  90731. /**
  90732. * Sets the current depth function to LEQUAL
  90733. */
  90734. setDepthFunctionToLessOrEqual(): void;
  90735. /**
  90736. * Gets a boolean indicating if stencil buffer is enabled
  90737. * @returns the current stencil buffer state
  90738. */
  90739. getStencilBuffer(): boolean;
  90740. /**
  90741. * Enable or disable the stencil buffer
  90742. * @param enable defines if the stencil buffer must be enabled or disabled
  90743. */
  90744. setStencilBuffer(enable: boolean): void;
  90745. /**
  90746. * Gets the current stencil mask
  90747. * @returns a number defining the new stencil mask to use
  90748. */
  90749. getStencilMask(): number;
  90750. /**
  90751. * Sets the current stencil mask
  90752. * @param mask defines the new stencil mask to use
  90753. */
  90754. setStencilMask(mask: number): void;
  90755. /**
  90756. * Gets the current stencil function
  90757. * @returns a number defining the stencil function to use
  90758. */
  90759. getStencilFunction(): number;
  90760. /**
  90761. * Gets the current stencil reference value
  90762. * @returns a number defining the stencil reference value to use
  90763. */
  90764. getStencilFunctionReference(): number;
  90765. /**
  90766. * Gets the current stencil mask
  90767. * @returns a number defining the stencil mask to use
  90768. */
  90769. getStencilFunctionMask(): number;
  90770. /**
  90771. * Sets the current stencil function
  90772. * @param stencilFunc defines the new stencil function to use
  90773. */
  90774. setStencilFunction(stencilFunc: number): void;
  90775. /**
  90776. * Sets the current stencil reference
  90777. * @param reference defines the new stencil reference to use
  90778. */
  90779. setStencilFunctionReference(reference: number): void;
  90780. /**
  90781. * Sets the current stencil mask
  90782. * @param mask defines the new stencil mask to use
  90783. */
  90784. setStencilFunctionMask(mask: number): void;
  90785. /**
  90786. * Gets the current stencil operation when stencil fails
  90787. * @returns a number defining stencil operation to use when stencil fails
  90788. */
  90789. getStencilOperationFail(): number;
  90790. /**
  90791. * Gets the current stencil operation when depth fails
  90792. * @returns a number defining stencil operation to use when depth fails
  90793. */
  90794. getStencilOperationDepthFail(): number;
  90795. /**
  90796. * Gets the current stencil operation when stencil passes
  90797. * @returns a number defining stencil operation to use when stencil passes
  90798. */
  90799. getStencilOperationPass(): number;
  90800. /**
  90801. * Sets the stencil operation to use when stencil fails
  90802. * @param operation defines the stencil operation to use when stencil fails
  90803. */
  90804. setStencilOperationFail(operation: number): void;
  90805. /**
  90806. * Sets the stencil operation to use when depth fails
  90807. * @param operation defines the stencil operation to use when depth fails
  90808. */
  90809. setStencilOperationDepthFail(operation: number): void;
  90810. /**
  90811. * Sets the stencil operation to use when stencil passes
  90812. * @param operation defines the stencil operation to use when stencil passes
  90813. */
  90814. setStencilOperationPass(operation: number): void;
  90815. /**
  90816. * Sets a boolean indicating if the dithering state is enabled or disabled
  90817. * @param value defines the dithering state
  90818. */
  90819. setDitheringState(value: boolean): void;
  90820. /**
  90821. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  90822. * @param value defines the rasterizer state
  90823. */
  90824. setRasterizerState(value: boolean): void;
  90825. /**
  90826. * stop executing a render loop function and remove it from the execution array
  90827. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  90828. */
  90829. stopRenderLoop(renderFunction?: () => void): void;
  90830. /** @hidden */
  90831. _renderLoop(): void;
  90832. /**
  90833. * Register and execute a render loop. The engine can have more than one render function
  90834. * @param renderFunction defines the function to continuously execute
  90835. */
  90836. runRenderLoop(renderFunction: () => void): void;
  90837. /**
  90838. * Toggle full screen mode
  90839. * @param requestPointerLock defines if a pointer lock should be requested from the user
  90840. */
  90841. switchFullscreen(requestPointerLock: boolean): void;
  90842. /**
  90843. * Enters full screen mode
  90844. * @param requestPointerLock defines if a pointer lock should be requested from the user
  90845. */
  90846. enterFullscreen(requestPointerLock: boolean): void;
  90847. /**
  90848. * Exits full screen mode
  90849. */
  90850. exitFullscreen(): void;
  90851. /**
  90852. * Enters Pointerlock mode
  90853. */
  90854. enterPointerlock(): void;
  90855. /**
  90856. * Exits Pointerlock mode
  90857. */
  90858. exitPointerlock(): void;
  90859. /**
  90860. * Clear the current render buffer or the current render target (if any is set up)
  90861. * @param color defines the color to use
  90862. * @param backBuffer defines if the back buffer must be cleared
  90863. * @param depth defines if the depth buffer must be cleared
  90864. * @param stencil defines if the stencil buffer must be cleared
  90865. */
  90866. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  90867. /**
  90868. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  90869. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  90870. * @param y defines the y-coordinate of the corner of the clear rectangle
  90871. * @param width defines the width of the clear rectangle
  90872. * @param height defines the height of the clear rectangle
  90873. * @param clearColor defines the clear color
  90874. */
  90875. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  90876. /**
  90877. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  90878. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  90879. * @param y defines the y-coordinate of the corner of the clear rectangle
  90880. * @param width defines the width of the clear rectangle
  90881. * @param height defines the height of the clear rectangle
  90882. */
  90883. enableScissor(x: number, y: number, width: number, height: number): void;
  90884. /**
  90885. * Disable previously set scissor test rectangle
  90886. */
  90887. disableScissor(): void;
  90888. private _viewportCached;
  90889. /** @hidden */
  90890. _viewport(x: number, y: number, width: number, height: number): void;
  90891. /**
  90892. * Set the WebGL's viewport
  90893. * @param viewport defines the viewport element to be used
  90894. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  90895. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  90896. */
  90897. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  90898. /**
  90899. * Directly set the WebGL Viewport
  90900. * @param x defines the x coordinate of the viewport (in screen space)
  90901. * @param y defines the y coordinate of the viewport (in screen space)
  90902. * @param width defines the width of the viewport (in screen space)
  90903. * @param height defines the height of the viewport (in screen space)
  90904. * @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
  90905. */
  90906. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  90907. /**
  90908. * Begin a new frame
  90909. */
  90910. beginFrame(): void;
  90911. /**
  90912. * Enf the current frame
  90913. */
  90914. endFrame(): void;
  90915. /**
  90916. * Resize the view according to the canvas' size
  90917. */
  90918. resize(): void;
  90919. /**
  90920. * Force a specific size of the canvas
  90921. * @param width defines the new canvas' width
  90922. * @param height defines the new canvas' height
  90923. */
  90924. setSize(width: number, height: number): void;
  90925. /**
  90926. * Binds the frame buffer to the specified texture.
  90927. * @param texture The texture to render to or null for the default canvas
  90928. * @param faceIndex The face of the texture to render to in case of cube texture
  90929. * @param requiredWidth The width of the target to render to
  90930. * @param requiredHeight The height of the target to render to
  90931. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  90932. * @param depthStencilTexture The depth stencil texture to use to render
  90933. * @param lodLevel defines le lod level to bind to the frame buffer
  90934. */
  90935. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  90936. /** @hidden */
  90937. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  90938. /**
  90939. * Unbind the current render target texture from the webGL context
  90940. * @param texture defines the render target texture to unbind
  90941. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  90942. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  90943. */
  90944. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  90945. /**
  90946. * Force the mipmap generation for the given render target texture
  90947. * @param texture defines the render target texture to use
  90948. */
  90949. generateMipMapsForCubemap(texture: InternalTexture): void;
  90950. /**
  90951. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  90952. */
  90953. flushFramebuffer(): void;
  90954. /**
  90955. * Unbind the current render target and bind the default framebuffer
  90956. */
  90957. restoreDefaultFramebuffer(): void;
  90958. /**
  90959. * Create an uniform buffer
  90960. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  90961. * @param elements defines the content of the uniform buffer
  90962. * @returns the webGL uniform buffer
  90963. */
  90964. createUniformBuffer(elements: FloatArray): DataBuffer;
  90965. /**
  90966. * Create a dynamic uniform buffer
  90967. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  90968. * @param elements defines the content of the uniform buffer
  90969. * @returns the webGL uniform buffer
  90970. */
  90971. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  90972. /**
  90973. * Update an existing uniform buffer
  90974. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  90975. * @param uniformBuffer defines the target uniform buffer
  90976. * @param elements defines the content to update
  90977. * @param offset defines the offset in the uniform buffer where update should start
  90978. * @param count defines the size of the data to update
  90979. */
  90980. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  90981. private _resetVertexBufferBinding;
  90982. /**
  90983. * Creates a vertex buffer
  90984. * @param data the data for the vertex buffer
  90985. * @returns the new WebGL static buffer
  90986. */
  90987. createVertexBuffer(data: DataArray): DataBuffer;
  90988. /**
  90989. * Creates a dynamic vertex buffer
  90990. * @param data the data for the dynamic vertex buffer
  90991. * @returns the new WebGL dynamic buffer
  90992. */
  90993. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  90994. /**
  90995. * Update a dynamic index buffer
  90996. * @param indexBuffer defines the target index buffer
  90997. * @param indices defines the data to update
  90998. * @param offset defines the offset in the target index buffer where update should start
  90999. */
  91000. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  91001. /**
  91002. * Updates a dynamic vertex buffer.
  91003. * @param vertexBuffer the vertex buffer to update
  91004. * @param data the data used to update the vertex buffer
  91005. * @param byteOffset the byte offset of the data
  91006. * @param byteLength the byte length of the data
  91007. */
  91008. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  91009. private _resetIndexBufferBinding;
  91010. /**
  91011. * Creates a new index buffer
  91012. * @param indices defines the content of the index buffer
  91013. * @param updatable defines if the index buffer must be updatable
  91014. * @returns a new webGL buffer
  91015. */
  91016. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  91017. /**
  91018. * Bind a webGL buffer to the webGL context
  91019. * @param buffer defines the buffer to bind
  91020. */
  91021. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  91022. /**
  91023. * Bind an uniform buffer to the current webGL context
  91024. * @param buffer defines the buffer to bind
  91025. */
  91026. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  91027. /**
  91028. * Bind a buffer to the current webGL context at a given location
  91029. * @param buffer defines the buffer to bind
  91030. * @param location defines the index where to bind the buffer
  91031. */
  91032. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  91033. /**
  91034. * Bind a specific block at a given index in a specific shader program
  91035. * @param pipelineContext defines the pipeline context to use
  91036. * @param blockName defines the block name
  91037. * @param index defines the index where to bind the block
  91038. */
  91039. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  91040. private bindIndexBuffer;
  91041. private bindBuffer;
  91042. /**
  91043. * update the bound buffer with the given data
  91044. * @param data defines the data to update
  91045. */
  91046. updateArrayBuffer(data: Float32Array): void;
  91047. private _vertexAttribPointer;
  91048. private _bindIndexBufferWithCache;
  91049. private _bindVertexBuffersAttributes;
  91050. /**
  91051. * Records a vertex array object
  91052. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  91053. * @param vertexBuffers defines the list of vertex buffers to store
  91054. * @param indexBuffer defines the index buffer to store
  91055. * @param effect defines the effect to store
  91056. * @returns the new vertex array object
  91057. */
  91058. recordVertexArrayObject(vertexBuffers: {
  91059. [key: string]: VertexBuffer;
  91060. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  91061. /**
  91062. * Bind a specific vertex array object
  91063. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  91064. * @param vertexArrayObject defines the vertex array object to bind
  91065. * @param indexBuffer defines the index buffer to bind
  91066. */
  91067. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  91068. /**
  91069. * Bind webGl buffers directly to the webGL context
  91070. * @param vertexBuffer defines the vertex buffer to bind
  91071. * @param indexBuffer defines the index buffer to bind
  91072. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  91073. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  91074. * @param effect defines the effect associated with the vertex buffer
  91075. */
  91076. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  91077. private _unbindVertexArrayObject;
  91078. /**
  91079. * Bind a list of vertex buffers to the webGL context
  91080. * @param vertexBuffers defines the list of vertex buffers to bind
  91081. * @param indexBuffer defines the index buffer to bind
  91082. * @param effect defines the effect associated with the vertex buffers
  91083. */
  91084. bindBuffers(vertexBuffers: {
  91085. [key: string]: Nullable<VertexBuffer>;
  91086. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  91087. /**
  91088. * Unbind all instance attributes
  91089. */
  91090. unbindInstanceAttributes(): void;
  91091. /**
  91092. * Release and free the memory of a vertex array object
  91093. * @param vao defines the vertex array object to delete
  91094. */
  91095. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  91096. /** @hidden */
  91097. _releaseBuffer(buffer: DataBuffer): boolean;
  91098. /**
  91099. * Creates a webGL buffer to use with instanciation
  91100. * @param capacity defines the size of the buffer
  91101. * @returns the webGL buffer
  91102. */
  91103. createInstancesBuffer(capacity: number): DataBuffer;
  91104. /**
  91105. * Delete a webGL buffer used with instanciation
  91106. * @param buffer defines the webGL buffer to delete
  91107. */
  91108. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  91109. /**
  91110. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  91111. * @param instancesBuffer defines the webGL buffer to update and bind
  91112. * @param data defines the data to store in the buffer
  91113. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  91114. */
  91115. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  91116. /**
  91117. * Apply all cached states (depth, culling, stencil and alpha)
  91118. */
  91119. applyStates(): void;
  91120. /**
  91121. * Send a draw order
  91122. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  91123. * @param indexStart defines the starting index
  91124. * @param indexCount defines the number of index to draw
  91125. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  91126. */
  91127. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  91128. /**
  91129. * Draw a list of points
  91130. * @param verticesStart defines the index of first vertex to draw
  91131. * @param verticesCount defines the count of vertices to draw
  91132. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  91133. */
  91134. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  91135. /**
  91136. * Draw a list of unindexed primitives
  91137. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  91138. * @param verticesStart defines the index of first vertex to draw
  91139. * @param verticesCount defines the count of vertices to draw
  91140. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  91141. */
  91142. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  91143. /**
  91144. * Draw a list of indexed primitives
  91145. * @param fillMode defines the primitive to use
  91146. * @param indexStart defines the starting index
  91147. * @param indexCount defines the number of index to draw
  91148. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  91149. */
  91150. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  91151. /**
  91152. * Draw a list of unindexed primitives
  91153. * @param fillMode defines the primitive to use
  91154. * @param verticesStart defines the index of first vertex to draw
  91155. * @param verticesCount defines the count of vertices to draw
  91156. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  91157. */
  91158. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  91159. private _drawMode;
  91160. /** @hidden */
  91161. _releaseEffect(effect: Effect): void;
  91162. /** @hidden */
  91163. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  91164. /**
  91165. * Create a new effect (used to store vertex/fragment shaders)
  91166. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  91167. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  91168. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  91169. * @param samplers defines an array of string used to represent textures
  91170. * @param defines defines the string containing the defines to use to compile the shaders
  91171. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  91172. * @param onCompiled defines a function to call when the effect creation is successful
  91173. * @param onError defines a function to call when the effect creation has failed
  91174. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  91175. * @returns the new Effect
  91176. */
  91177. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  91178. private _compileShader;
  91179. private _compileRawShader;
  91180. /**
  91181. * Directly creates a webGL program
  91182. * @param pipelineContext defines the pipeline context to attach to
  91183. * @param vertexCode defines the vertex shader code to use
  91184. * @param fragmentCode defines the fragment shader code to use
  91185. * @param context defines the webGL context to use (if not set, the current one will be used)
  91186. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  91187. * @returns the new webGL program
  91188. */
  91189. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  91190. /**
  91191. * Creates a webGL program
  91192. * @param pipelineContext defines the pipeline context to attach to
  91193. * @param vertexCode defines the vertex shader code to use
  91194. * @param fragmentCode defines the fragment shader code to use
  91195. * @param defines defines the string containing the defines to use to compile the shaders
  91196. * @param context defines the webGL context to use (if not set, the current one will be used)
  91197. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  91198. * @returns the new webGL program
  91199. */
  91200. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  91201. /**
  91202. * Creates a new pipeline context
  91203. * @returns the new pipeline
  91204. */
  91205. createPipelineContext(): WebGLPipelineContext;
  91206. private _createShaderProgram;
  91207. private _finalizePipelineContext;
  91208. /** @hidden */
  91209. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  91210. /** @hidden */
  91211. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  91212. /** @hidden */
  91213. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  91214. /**
  91215. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  91216. * @param pipelineContext defines the pipeline context to use
  91217. * @param uniformsNames defines the list of uniform names
  91218. * @returns an array of webGL uniform locations
  91219. */
  91220. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  91221. /**
  91222. * Gets the lsit of active attributes for a given webGL program
  91223. * @param pipelineContext defines the pipeline context to use
  91224. * @param attributesNames defines the list of attribute names to get
  91225. * @returns an array of indices indicating the offset of each attribute
  91226. */
  91227. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  91228. /**
  91229. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  91230. * @param effect defines the effect to activate
  91231. */
  91232. enableEffect(effect: Nullable<Effect>): void;
  91233. /**
  91234. * Set the value of an uniform to an array of int32
  91235. * @param uniform defines the webGL uniform location where to store the value
  91236. * @param array defines the array of int32 to store
  91237. */
  91238. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  91239. /**
  91240. * Set the value of an uniform to an array of int32 (stored as vec2)
  91241. * @param uniform defines the webGL uniform location where to store the value
  91242. * @param array defines the array of int32 to store
  91243. */
  91244. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  91245. /**
  91246. * Set the value of an uniform to an array of int32 (stored as vec3)
  91247. * @param uniform defines the webGL uniform location where to store the value
  91248. * @param array defines the array of int32 to store
  91249. */
  91250. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  91251. /**
  91252. * Set the value of an uniform to an array of int32 (stored as vec4)
  91253. * @param uniform defines the webGL uniform location where to store the value
  91254. * @param array defines the array of int32 to store
  91255. */
  91256. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  91257. /**
  91258. * Set the value of an uniform to an array of float32
  91259. * @param uniform defines the webGL uniform location where to store the value
  91260. * @param array defines the array of float32 to store
  91261. */
  91262. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  91263. /**
  91264. * Set the value of an uniform to an array of float32 (stored as vec2)
  91265. * @param uniform defines the webGL uniform location where to store the value
  91266. * @param array defines the array of float32 to store
  91267. */
  91268. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  91269. /**
  91270. * Set the value of an uniform to an array of float32 (stored as vec3)
  91271. * @param uniform defines the webGL uniform location where to store the value
  91272. * @param array defines the array of float32 to store
  91273. */
  91274. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  91275. /**
  91276. * Set the value of an uniform to an array of float32 (stored as vec4)
  91277. * @param uniform defines the webGL uniform location where to store the value
  91278. * @param array defines the array of float32 to store
  91279. */
  91280. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  91281. /**
  91282. * Set the value of an uniform to an array of number
  91283. * @param uniform defines the webGL uniform location where to store the value
  91284. * @param array defines the array of number to store
  91285. */
  91286. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  91287. /**
  91288. * Set the value of an uniform to an array of number (stored as vec2)
  91289. * @param uniform defines the webGL uniform location where to store the value
  91290. * @param array defines the array of number to store
  91291. */
  91292. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  91293. /**
  91294. * Set the value of an uniform to an array of number (stored as vec3)
  91295. * @param uniform defines the webGL uniform location where to store the value
  91296. * @param array defines the array of number to store
  91297. */
  91298. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  91299. /**
  91300. * Set the value of an uniform to an array of number (stored as vec4)
  91301. * @param uniform defines the webGL uniform location where to store the value
  91302. * @param array defines the array of number to store
  91303. */
  91304. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  91305. /**
  91306. * Set the value of an uniform to an array of float32 (stored as matrices)
  91307. * @param uniform defines the webGL uniform location where to store the value
  91308. * @param matrices defines the array of float32 to store
  91309. */
  91310. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  91311. /**
  91312. * Set the value of an uniform to a matrix
  91313. * @param uniform defines the webGL uniform location where to store the value
  91314. * @param matrix defines the matrix to store
  91315. */
  91316. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  91317. /**
  91318. * Set the value of an uniform to a matrix (3x3)
  91319. * @param uniform defines the webGL uniform location where to store the value
  91320. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  91321. */
  91322. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  91323. /**
  91324. * Set the value of an uniform to a matrix (2x2)
  91325. * @param uniform defines the webGL uniform location where to store the value
  91326. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  91327. */
  91328. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  91329. /**
  91330. * Set the value of an uniform to a number (int)
  91331. * @param uniform defines the webGL uniform location where to store the value
  91332. * @param value defines the int number to store
  91333. */
  91334. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  91335. /**
  91336. * Set the value of an uniform to a number (float)
  91337. * @param uniform defines the webGL uniform location where to store the value
  91338. * @param value defines the float number to store
  91339. */
  91340. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  91341. /**
  91342. * Set the value of an uniform to a vec2
  91343. * @param uniform defines the webGL uniform location where to store the value
  91344. * @param x defines the 1st component of the value
  91345. * @param y defines the 2nd component of the value
  91346. */
  91347. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  91348. /**
  91349. * Set the value of an uniform to a vec3
  91350. * @param uniform defines the webGL uniform location where to store the value
  91351. * @param x defines the 1st component of the value
  91352. * @param y defines the 2nd component of the value
  91353. * @param z defines the 3rd component of the value
  91354. */
  91355. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  91356. /**
  91357. * Set the value of an uniform to a boolean
  91358. * @param uniform defines the webGL uniform location where to store the value
  91359. * @param bool defines the boolean to store
  91360. */
  91361. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  91362. /**
  91363. * Set the value of an uniform to a vec4
  91364. * @param uniform defines the webGL uniform location where to store the value
  91365. * @param x defines the 1st component of the value
  91366. * @param y defines the 2nd component of the value
  91367. * @param z defines the 3rd component of the value
  91368. * @param w defines the 4th component of the value
  91369. */
  91370. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  91371. /**
  91372. * Set the value of an uniform to a Color3
  91373. * @param uniform defines the webGL uniform location where to store the value
  91374. * @param color3 defines the color to store
  91375. */
  91376. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  91377. /**
  91378. * Set the value of an uniform to a Color3 and an alpha value
  91379. * @param uniform defines the webGL uniform location where to store the value
  91380. * @param color3 defines the color to store
  91381. * @param alpha defines the alpha component to store
  91382. */
  91383. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  91384. /**
  91385. * Sets a Color4 on a uniform variable
  91386. * @param uniform defines the uniform location
  91387. * @param color4 defines the value to be set
  91388. */
  91389. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  91390. /**
  91391. * Set various states to the webGL context
  91392. * @param culling defines backface culling state
  91393. * @param zOffset defines the value to apply to zOffset (0 by default)
  91394. * @param force defines if states must be applied even if cache is up to date
  91395. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  91396. */
  91397. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  91398. /**
  91399. * Set the z offset to apply to current rendering
  91400. * @param value defines the offset to apply
  91401. */
  91402. setZOffset(value: number): void;
  91403. /**
  91404. * Gets the current value of the zOffset
  91405. * @returns the current zOffset state
  91406. */
  91407. getZOffset(): number;
  91408. /**
  91409. * Enable or disable depth buffering
  91410. * @param enable defines the state to set
  91411. */
  91412. setDepthBuffer(enable: boolean): void;
  91413. /**
  91414. * Gets a boolean indicating if depth writing is enabled
  91415. * @returns the current depth writing state
  91416. */
  91417. getDepthWrite(): boolean;
  91418. /**
  91419. * Enable or disable depth writing
  91420. * @param enable defines the state to set
  91421. */
  91422. setDepthWrite(enable: boolean): void;
  91423. /**
  91424. * Enable or disable color writing
  91425. * @param enable defines the state to set
  91426. */
  91427. setColorWrite(enable: boolean): void;
  91428. /**
  91429. * Gets a boolean indicating if color writing is enabled
  91430. * @returns the current color writing state
  91431. */
  91432. getColorWrite(): boolean;
  91433. /**
  91434. * Sets alpha constants used by some alpha blending modes
  91435. * @param r defines the red component
  91436. * @param g defines the green component
  91437. * @param b defines the blue component
  91438. * @param a defines the alpha component
  91439. */
  91440. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  91441. /**
  91442. * Sets the current alpha mode
  91443. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  91444. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  91445. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  91446. */
  91447. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  91448. /**
  91449. * Gets the current alpha mode
  91450. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  91451. * @returns the current alpha mode
  91452. */
  91453. getAlphaMode(): number;
  91454. /**
  91455. * Clears the list of texture accessible through engine.
  91456. * This can help preventing texture load conflict due to name collision.
  91457. */
  91458. clearInternalTexturesCache(): void;
  91459. /**
  91460. * Force the entire cache to be cleared
  91461. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  91462. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  91463. */
  91464. wipeCaches(bruteForce?: boolean): void;
  91465. /**
  91466. * Set the compressed texture format to use, based on the formats you have, and the formats
  91467. * supported by the hardware / browser.
  91468. *
  91469. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  91470. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  91471. * to API arguments needed to compressed textures. This puts the burden on the container
  91472. * generator to house the arcane code for determining these for current & future formats.
  91473. *
  91474. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  91475. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  91476. *
  91477. * Note: The result of this call is not taken into account when a texture is base64.
  91478. *
  91479. * @param formatsAvailable defines the list of those format families you have created
  91480. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  91481. *
  91482. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  91483. * @returns The extension selected.
  91484. */
  91485. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  91486. /** @hidden */
  91487. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  91488. min: number;
  91489. mag: number;
  91490. };
  91491. /** @hidden */
  91492. _createTexture(): WebGLTexture;
  91493. /**
  91494. * Usually called from Texture.ts.
  91495. * Passed information to create a WebGLTexture
  91496. * @param urlArg defines a value which contains one of the following:
  91497. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  91498. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  91499. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  91500. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  91501. * @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)
  91502. * @param scene needed for loading to the correct scene
  91503. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  91504. * @param onLoad optional callback to be called upon successful completion
  91505. * @param onError optional callback to be called upon failure
  91506. * @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
  91507. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  91508. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  91509. * @param forcedExtension defines the extension to use to pick the right loader
  91510. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  91511. * @returns a InternalTexture for assignment back into BABYLON.Texture
  91512. */
  91513. 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;
  91514. /**
  91515. * @hidden
  91516. * Rescales a texture
  91517. * @param source input texutre
  91518. * @param destination destination texture
  91519. * @param scene scene to use to render the resize
  91520. * @param internalFormat format to use when resizing
  91521. * @param onComplete callback to be called when resize has completed
  91522. */
  91523. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  91524. private _unpackFlipYCached;
  91525. /**
  91526. * In case you are sharing the context with other applications, it might
  91527. * be interested to not cache the unpack flip y state to ensure a consistent
  91528. * value would be set.
  91529. */
  91530. enableUnpackFlipYCached: boolean;
  91531. /** @hidden */
  91532. _unpackFlipY(value: boolean): void;
  91533. /** @hidden */
  91534. _getUnpackAlignement(): number;
  91535. /**
  91536. * Creates a dynamic texture
  91537. * @param width defines the width of the texture
  91538. * @param height defines the height of the texture
  91539. * @param generateMipMaps defines if the engine should generate the mip levels
  91540. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  91541. * @returns the dynamic texture inside an InternalTexture
  91542. */
  91543. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  91544. /**
  91545. * Update the sampling mode of a given texture
  91546. * @param samplingMode defines the required sampling mode
  91547. * @param texture defines the texture to update
  91548. */
  91549. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  91550. /**
  91551. * Update the content of a dynamic texture
  91552. * @param texture defines the texture to update
  91553. * @param canvas defines the canvas containing the source
  91554. * @param invertY defines if data must be stored with Y axis inverted
  91555. * @param premulAlpha defines if alpha is stored as premultiplied
  91556. * @param format defines the format of the data
  91557. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  91558. */
  91559. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  91560. /**
  91561. * Update a video texture
  91562. * @param texture defines the texture to update
  91563. * @param video defines the video element to use
  91564. * @param invertY defines if data must be stored with Y axis inverted
  91565. */
  91566. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  91567. /**
  91568. * Updates a depth texture Comparison Mode and Function.
  91569. * If the comparison Function is equal to 0, the mode will be set to none.
  91570. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  91571. * @param texture The texture to set the comparison function for
  91572. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  91573. */
  91574. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  91575. /** @hidden */
  91576. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  91577. width: number;
  91578. height: number;
  91579. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  91580. /**
  91581. * Creates a depth stencil texture.
  91582. * This is only available in WebGL 2 or with the depth texture extension available.
  91583. * @param size The size of face edge in the texture.
  91584. * @param options The options defining the texture.
  91585. * @returns The texture
  91586. */
  91587. createDepthStencilTexture(size: number | {
  91588. width: number;
  91589. height: number;
  91590. }, options: DepthTextureCreationOptions): InternalTexture;
  91591. /**
  91592. * Creates a depth stencil texture.
  91593. * This is only available in WebGL 2 or with the depth texture extension available.
  91594. * @param size The size of face edge in the texture.
  91595. * @param options The options defining the texture.
  91596. * @returns The texture
  91597. */
  91598. private _createDepthStencilTexture;
  91599. /**
  91600. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  91601. * @param renderTarget The render target to set the frame buffer for
  91602. */
  91603. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  91604. /**
  91605. * Creates a new render target texture
  91606. * @param size defines the size of the texture
  91607. * @param options defines the options used to create the texture
  91608. * @returns a new render target texture stored in an InternalTexture
  91609. */
  91610. createRenderTargetTexture(size: number | {
  91611. width: number;
  91612. height: number;
  91613. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  91614. /** @hidden */
  91615. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  91616. /**
  91617. * Updates the sample count of a render target texture
  91618. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  91619. * @param texture defines the texture to update
  91620. * @param samples defines the sample count to set
  91621. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  91622. */
  91623. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  91624. /** @hidden */
  91625. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  91626. /** @hidden */
  91627. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  91628. /** @hidden */
  91629. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  91630. /** @hidden */
  91631. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  91632. /**
  91633. * @hidden
  91634. */
  91635. _setCubeMapTextureParams(loadMipmap: boolean): void;
  91636. private _prepareWebGLTextureContinuation;
  91637. private _prepareWebGLTexture;
  91638. /** @hidden */
  91639. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  91640. /** @hidden */
  91641. _releaseFramebufferObjects(texture: InternalTexture): void;
  91642. /** @hidden */
  91643. _releaseTexture(texture: InternalTexture): void;
  91644. private setProgram;
  91645. private _boundUniforms;
  91646. /**
  91647. * Binds an effect to the webGL context
  91648. * @param effect defines the effect to bind
  91649. */
  91650. bindSamplers(effect: Effect): void;
  91651. private _activateCurrentTexture;
  91652. /** @hidden */
  91653. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  91654. /** @hidden */
  91655. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  91656. /**
  91657. * Sets a texture to the webGL context from a postprocess
  91658. * @param channel defines the channel to use
  91659. * @param postProcess defines the source postprocess
  91660. */
  91661. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  91662. /**
  91663. * Binds the output of the passed in post process to the texture channel specified
  91664. * @param channel The channel the texture should be bound to
  91665. * @param postProcess The post process which's output should be bound
  91666. */
  91667. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  91668. /**
  91669. * Unbind all textures from the webGL context
  91670. */
  91671. unbindAllTextures(): void;
  91672. /**
  91673. * Sets a texture to the according uniform.
  91674. * @param channel The texture channel
  91675. * @param uniform The uniform to set
  91676. * @param texture The texture to apply
  91677. */
  91678. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  91679. /**
  91680. * Sets a depth stencil texture from a render target to the according uniform.
  91681. * @param channel The texture channel
  91682. * @param uniform The uniform to set
  91683. * @param texture The render target texture containing the depth stencil texture to apply
  91684. */
  91685. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  91686. private _bindSamplerUniformToChannel;
  91687. private _getTextureWrapMode;
  91688. private _setTexture;
  91689. /**
  91690. * Sets an array of texture to the webGL context
  91691. * @param channel defines the channel where the texture array must be set
  91692. * @param uniform defines the associated uniform location
  91693. * @param textures defines the array of textures to bind
  91694. */
  91695. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  91696. /** @hidden */
  91697. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  91698. private _setTextureParameterFloat;
  91699. private _setTextureParameterInteger;
  91700. /**
  91701. * Reads pixels from the current frame buffer. Please note that this function can be slow
  91702. * @param x defines the x coordinate of the rectangle where pixels must be read
  91703. * @param y defines the y coordinate of the rectangle where pixels must be read
  91704. * @param width defines the width of the rectangle where pixels must be read
  91705. * @param height defines the height of the rectangle where pixels must be read
  91706. * @returns a Uint8Array containing RGBA colors
  91707. */
  91708. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  91709. /**
  91710. * Add an externaly attached data from its key.
  91711. * This method call will fail and return false, if such key already exists.
  91712. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  91713. * @param key the unique key that identifies the data
  91714. * @param data the data object to associate to the key for this Engine instance
  91715. * @return true if no such key were already present and the data was added successfully, false otherwise
  91716. */
  91717. addExternalData<T>(key: string, data: T): boolean;
  91718. /**
  91719. * Get an externaly attached data from its key
  91720. * @param key the unique key that identifies the data
  91721. * @return the associated data, if present (can be null), or undefined if not present
  91722. */
  91723. getExternalData<T>(key: string): T;
  91724. /**
  91725. * Get an externaly attached data from its key, create it using a factory if it's not already present
  91726. * @param key the unique key that identifies the data
  91727. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  91728. * @return the associated data, can be null if the factory returned null.
  91729. */
  91730. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  91731. /**
  91732. * Remove an externaly attached data from the Engine instance
  91733. * @param key the unique key that identifies the data
  91734. * @return true if the data was successfully removed, false if it doesn't exist
  91735. */
  91736. removeExternalData(key: string): boolean;
  91737. /**
  91738. * Unbind all vertex attributes from the webGL context
  91739. */
  91740. unbindAllAttributes(): void;
  91741. /**
  91742. * 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
  91743. */
  91744. releaseEffects(): void;
  91745. /**
  91746. * Dispose and release all associated resources
  91747. */
  91748. dispose(): void;
  91749. /**
  91750. * Display the loading screen
  91751. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  91752. */
  91753. displayLoadingUI(): void;
  91754. /**
  91755. * Hide the loading screen
  91756. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  91757. */
  91758. hideLoadingUI(): void;
  91759. /**
  91760. * Gets the current loading screen object
  91761. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  91762. */
  91763. /**
  91764. * Sets the current loading screen object
  91765. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  91766. */
  91767. loadingScreen: ILoadingScreen;
  91768. /**
  91769. * Sets the current loading screen text
  91770. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  91771. */
  91772. loadingUIText: string;
  91773. /**
  91774. * Sets the current loading screen background color
  91775. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  91776. */
  91777. loadingUIBackgroundColor: string;
  91778. /**
  91779. * Attach a new callback raised when context lost event is fired
  91780. * @param callback defines the callback to call
  91781. */
  91782. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  91783. /**
  91784. * Attach a new callback raised when context restored event is fired
  91785. * @param callback defines the callback to call
  91786. */
  91787. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  91788. /**
  91789. * Gets the source code of the vertex shader associated with a specific webGL program
  91790. * @param program defines the program to use
  91791. * @returns a string containing the source code of the vertex shader associated with the program
  91792. */
  91793. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  91794. /**
  91795. * Gets the source code of the fragment shader associated with a specific webGL program
  91796. * @param program defines the program to use
  91797. * @returns a string containing the source code of the fragment shader associated with the program
  91798. */
  91799. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  91800. /**
  91801. * Get the current error code of the webGL context
  91802. * @returns the error code
  91803. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  91804. */
  91805. getError(): number;
  91806. /**
  91807. * Gets the current framerate
  91808. * @returns a number representing the framerate
  91809. */
  91810. getFps(): number;
  91811. /**
  91812. * Gets the time spent between current and previous frame
  91813. * @returns a number representing the delta time in ms
  91814. */
  91815. getDeltaTime(): number;
  91816. private _measureFps;
  91817. /** @hidden */
  91818. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  91819. private _canRenderToFloatFramebuffer;
  91820. private _canRenderToHalfFloatFramebuffer;
  91821. private _canRenderToFramebuffer;
  91822. /** @hidden */
  91823. _getWebGLTextureType(type: number): number;
  91824. /** @hidden */
  91825. _getInternalFormat(format: number): number;
  91826. /** @hidden */
  91827. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  91828. /** @hidden */
  91829. _getRGBAMultiSampleBufferFormat(type: number): number;
  91830. /** @hidden */
  91831. _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;
  91832. /** @hidden */
  91833. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  91834. /**
  91835. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  91836. * @returns true if the engine can be created
  91837. * @ignorenaming
  91838. */
  91839. static isSupported(): boolean;
  91840. }
  91841. }
  91842. declare module BABYLON {
  91843. /**
  91844. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  91845. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  91846. */
  91847. export class EffectFallbacks {
  91848. private _defines;
  91849. private _currentRank;
  91850. private _maxRank;
  91851. private _mesh;
  91852. /**
  91853. * Removes the fallback from the bound mesh.
  91854. */
  91855. unBindMesh(): void;
  91856. /**
  91857. * Adds a fallback on the specified property.
  91858. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  91859. * @param define The name of the define in the shader
  91860. */
  91861. addFallback(rank: number, define: string): void;
  91862. /**
  91863. * Sets the mesh to use CPU skinning when needing to fallback.
  91864. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  91865. * @param mesh The mesh to use the fallbacks.
  91866. */
  91867. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  91868. /**
  91869. * Checks to see if more fallbacks are still availible.
  91870. */
  91871. readonly isMoreFallbacks: boolean;
  91872. /**
  91873. * Removes the defines that should be removed when falling back.
  91874. * @param currentDefines defines the current define statements for the shader.
  91875. * @param effect defines the current effect we try to compile
  91876. * @returns The resulting defines with defines of the current rank removed.
  91877. */
  91878. reduce(currentDefines: string, effect: Effect): string;
  91879. }
  91880. /**
  91881. * Options to be used when creating an effect.
  91882. */
  91883. export class EffectCreationOptions {
  91884. /**
  91885. * Atrributes that will be used in the shader.
  91886. */
  91887. attributes: string[];
  91888. /**
  91889. * Uniform varible names that will be set in the shader.
  91890. */
  91891. uniformsNames: string[];
  91892. /**
  91893. * Uniform buffer varible names that will be set in the shader.
  91894. */
  91895. uniformBuffersNames: string[];
  91896. /**
  91897. * Sampler texture variable names that will be set in the shader.
  91898. */
  91899. samplers: string[];
  91900. /**
  91901. * Define statements that will be set in the shader.
  91902. */
  91903. defines: any;
  91904. /**
  91905. * Possible fallbacks for this effect to improve performance when needed.
  91906. */
  91907. fallbacks: Nullable<EffectFallbacks>;
  91908. /**
  91909. * Callback that will be called when the shader is compiled.
  91910. */
  91911. onCompiled: Nullable<(effect: Effect) => void>;
  91912. /**
  91913. * Callback that will be called if an error occurs during shader compilation.
  91914. */
  91915. onError: Nullable<(effect: Effect, errors: string) => void>;
  91916. /**
  91917. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  91918. */
  91919. indexParameters: any;
  91920. /**
  91921. * Max number of lights that can be used in the shader.
  91922. */
  91923. maxSimultaneousLights: number;
  91924. /**
  91925. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  91926. */
  91927. transformFeedbackVaryings: Nullable<string[]>;
  91928. }
  91929. /**
  91930. * Effect containing vertex and fragment shader that can be executed on an object.
  91931. */
  91932. export class Effect implements IDisposable {
  91933. /**
  91934. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  91935. */
  91936. static ShadersRepository: string;
  91937. /**
  91938. * Name of the effect.
  91939. */
  91940. name: any;
  91941. /**
  91942. * String container all the define statements that should be set on the shader.
  91943. */
  91944. defines: string;
  91945. /**
  91946. * Callback that will be called when the shader is compiled.
  91947. */
  91948. onCompiled: Nullable<(effect: Effect) => void>;
  91949. /**
  91950. * Callback that will be called if an error occurs during shader compilation.
  91951. */
  91952. onError: Nullable<(effect: Effect, errors: string) => void>;
  91953. /**
  91954. * Callback that will be called when effect is bound.
  91955. */
  91956. onBind: Nullable<(effect: Effect) => void>;
  91957. /**
  91958. * Unique ID of the effect.
  91959. */
  91960. uniqueId: number;
  91961. /**
  91962. * Observable that will be called when the shader is compiled.
  91963. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  91964. */
  91965. onCompileObservable: Observable<Effect>;
  91966. /**
  91967. * Observable that will be called if an error occurs during shader compilation.
  91968. */
  91969. onErrorObservable: Observable<Effect>;
  91970. /** @hidden */
  91971. _onBindObservable: Nullable<Observable<Effect>>;
  91972. /**
  91973. * Observable that will be called when effect is bound.
  91974. */
  91975. readonly onBindObservable: Observable<Effect>;
  91976. /** @hidden */
  91977. _bonesComputationForcedToCPU: boolean;
  91978. private static _uniqueIdSeed;
  91979. private _engine;
  91980. private _uniformBuffersNames;
  91981. private _uniformsNames;
  91982. private _samplerList;
  91983. private _samplers;
  91984. private _isReady;
  91985. private _compilationError;
  91986. private _attributesNames;
  91987. private _attributes;
  91988. private _uniforms;
  91989. /**
  91990. * Key for the effect.
  91991. * @hidden
  91992. */
  91993. _key: string;
  91994. private _indexParameters;
  91995. private _fallbacks;
  91996. private _vertexSourceCode;
  91997. private _fragmentSourceCode;
  91998. private _vertexSourceCodeOverride;
  91999. private _fragmentSourceCodeOverride;
  92000. private _transformFeedbackVaryings;
  92001. /**
  92002. * Compiled shader to webGL program.
  92003. * @hidden
  92004. */
  92005. _pipelineContext: Nullable<IPipelineContext>;
  92006. private _valueCache;
  92007. private static _baseCache;
  92008. /**
  92009. * Instantiates an effect.
  92010. * An effect can be used to create/manage/execute vertex and fragment shaders.
  92011. * @param baseName Name of the effect.
  92012. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  92013. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  92014. * @param samplers List of sampler variables that will be passed to the shader.
  92015. * @param engine Engine to be used to render the effect
  92016. * @param defines Define statements to be added to the shader.
  92017. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  92018. * @param onCompiled Callback that will be called when the shader is compiled.
  92019. * @param onError Callback that will be called if an error occurs during shader compilation.
  92020. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  92021. */
  92022. 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);
  92023. private _useFinalCode;
  92024. /**
  92025. * Unique key for this effect
  92026. */
  92027. readonly key: string;
  92028. /**
  92029. * If the effect has been compiled and prepared.
  92030. * @returns if the effect is compiled and prepared.
  92031. */
  92032. isReady(): boolean;
  92033. /**
  92034. * The engine the effect was initialized with.
  92035. * @returns the engine.
  92036. */
  92037. getEngine(): Engine;
  92038. /**
  92039. * The pipeline context for this effect
  92040. * @returns the associated pipeline context
  92041. */
  92042. getPipelineContext(): Nullable<IPipelineContext>;
  92043. /**
  92044. * The set of names of attribute variables for the shader.
  92045. * @returns An array of attribute names.
  92046. */
  92047. getAttributesNames(): string[];
  92048. /**
  92049. * Returns the attribute at the given index.
  92050. * @param index The index of the attribute.
  92051. * @returns The location of the attribute.
  92052. */
  92053. getAttributeLocation(index: number): number;
  92054. /**
  92055. * Returns the attribute based on the name of the variable.
  92056. * @param name of the attribute to look up.
  92057. * @returns the attribute location.
  92058. */
  92059. getAttributeLocationByName(name: string): number;
  92060. /**
  92061. * The number of attributes.
  92062. * @returns the numnber of attributes.
  92063. */
  92064. getAttributesCount(): number;
  92065. /**
  92066. * Gets the index of a uniform variable.
  92067. * @param uniformName of the uniform to look up.
  92068. * @returns the index.
  92069. */
  92070. getUniformIndex(uniformName: string): number;
  92071. /**
  92072. * Returns the attribute based on the name of the variable.
  92073. * @param uniformName of the uniform to look up.
  92074. * @returns the location of the uniform.
  92075. */
  92076. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  92077. /**
  92078. * Returns an array of sampler variable names
  92079. * @returns The array of sampler variable neames.
  92080. */
  92081. getSamplers(): string[];
  92082. /**
  92083. * The error from the last compilation.
  92084. * @returns the error string.
  92085. */
  92086. getCompilationError(): string;
  92087. /**
  92088. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  92089. * @param func The callback to be used.
  92090. */
  92091. executeWhenCompiled(func: (effect: Effect) => void): void;
  92092. private _checkIsReady;
  92093. /** @hidden */
  92094. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  92095. /** @hidden */
  92096. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  92097. /** @hidden */
  92098. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  92099. /**
  92100. * Recompiles the webGL program
  92101. * @param vertexSourceCode The source code for the vertex shader.
  92102. * @param fragmentSourceCode The source code for the fragment shader.
  92103. * @param onCompiled Callback called when completed.
  92104. * @param onError Callback called on error.
  92105. * @hidden
  92106. */
  92107. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  92108. /**
  92109. * Prepares the effect
  92110. * @hidden
  92111. */
  92112. _prepareEffect(): void;
  92113. /**
  92114. * Checks if the effect is supported. (Must be called after compilation)
  92115. */
  92116. readonly isSupported: boolean;
  92117. /**
  92118. * Binds a texture to the engine to be used as output of the shader.
  92119. * @param channel Name of the output variable.
  92120. * @param texture Texture to bind.
  92121. * @hidden
  92122. */
  92123. _bindTexture(channel: string, texture: InternalTexture): void;
  92124. /**
  92125. * Sets a texture on the engine to be used in the shader.
  92126. * @param channel Name of the sampler variable.
  92127. * @param texture Texture to set.
  92128. */
  92129. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  92130. /**
  92131. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  92132. * @param channel Name of the sampler variable.
  92133. * @param texture Texture to set.
  92134. */
  92135. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  92136. /**
  92137. * Sets an array of textures on the engine to be used in the shader.
  92138. * @param channel Name of the variable.
  92139. * @param textures Textures to set.
  92140. */
  92141. setTextureArray(channel: string, textures: BaseTexture[]): void;
  92142. /**
  92143. * 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)
  92144. * @param channel Name of the sampler variable.
  92145. * @param postProcess Post process to get the input texture from.
  92146. */
  92147. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  92148. /**
  92149. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  92150. * 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)
  92151. * @param channel Name of the sampler variable.
  92152. * @param postProcess Post process to get the output texture from.
  92153. */
  92154. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  92155. /** @hidden */
  92156. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  92157. /** @hidden */
  92158. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  92159. /** @hidden */
  92160. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  92161. /** @hidden */
  92162. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  92163. /**
  92164. * Binds a buffer to a uniform.
  92165. * @param buffer Buffer to bind.
  92166. * @param name Name of the uniform variable to bind to.
  92167. */
  92168. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  92169. /**
  92170. * Binds block to a uniform.
  92171. * @param blockName Name of the block to bind.
  92172. * @param index Index to bind.
  92173. */
  92174. bindUniformBlock(blockName: string, index: number): void;
  92175. /**
  92176. * Sets an interger value on a uniform variable.
  92177. * @param uniformName Name of the variable.
  92178. * @param value Value to be set.
  92179. * @returns this effect.
  92180. */
  92181. setInt(uniformName: string, value: number): Effect;
  92182. /**
  92183. * Sets an int array on a uniform variable.
  92184. * @param uniformName Name of the variable.
  92185. * @param array array to be set.
  92186. * @returns this effect.
  92187. */
  92188. setIntArray(uniformName: string, array: Int32Array): Effect;
  92189. /**
  92190. * 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)
  92191. * @param uniformName Name of the variable.
  92192. * @param array array to be set.
  92193. * @returns this effect.
  92194. */
  92195. setIntArray2(uniformName: string, array: Int32Array): Effect;
  92196. /**
  92197. * 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)
  92198. * @param uniformName Name of the variable.
  92199. * @param array array to be set.
  92200. * @returns this effect.
  92201. */
  92202. setIntArray3(uniformName: string, array: Int32Array): Effect;
  92203. /**
  92204. * 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)
  92205. * @param uniformName Name of the variable.
  92206. * @param array array to be set.
  92207. * @returns this effect.
  92208. */
  92209. setIntArray4(uniformName: string, array: Int32Array): Effect;
  92210. /**
  92211. * Sets an float array on a uniform variable.
  92212. * @param uniformName Name of the variable.
  92213. * @param array array to be set.
  92214. * @returns this effect.
  92215. */
  92216. setFloatArray(uniformName: string, array: Float32Array): Effect;
  92217. /**
  92218. * 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)
  92219. * @param uniformName Name of the variable.
  92220. * @param array array to be set.
  92221. * @returns this effect.
  92222. */
  92223. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  92224. /**
  92225. * 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)
  92226. * @param uniformName Name of the variable.
  92227. * @param array array to be set.
  92228. * @returns this effect.
  92229. */
  92230. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  92231. /**
  92232. * 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)
  92233. * @param uniformName Name of the variable.
  92234. * @param array array to be set.
  92235. * @returns this effect.
  92236. */
  92237. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  92238. /**
  92239. * Sets an array on a uniform variable.
  92240. * @param uniformName Name of the variable.
  92241. * @param array array to be set.
  92242. * @returns this effect.
  92243. */
  92244. setArray(uniformName: string, array: number[]): Effect;
  92245. /**
  92246. * 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)
  92247. * @param uniformName Name of the variable.
  92248. * @param array array to be set.
  92249. * @returns this effect.
  92250. */
  92251. setArray2(uniformName: string, array: number[]): Effect;
  92252. /**
  92253. * 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)
  92254. * @param uniformName Name of the variable.
  92255. * @param array array to be set.
  92256. * @returns this effect.
  92257. */
  92258. setArray3(uniformName: string, array: number[]): Effect;
  92259. /**
  92260. * 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)
  92261. * @param uniformName Name of the variable.
  92262. * @param array array to be set.
  92263. * @returns this effect.
  92264. */
  92265. setArray4(uniformName: string, array: number[]): Effect;
  92266. /**
  92267. * Sets matrices on a uniform variable.
  92268. * @param uniformName Name of the variable.
  92269. * @param matrices matrices to be set.
  92270. * @returns this effect.
  92271. */
  92272. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  92273. /**
  92274. * Sets matrix on a uniform variable.
  92275. * @param uniformName Name of the variable.
  92276. * @param matrix matrix to be set.
  92277. * @returns this effect.
  92278. */
  92279. setMatrix(uniformName: string, matrix: Matrix): Effect;
  92280. /**
  92281. * 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)
  92282. * @param uniformName Name of the variable.
  92283. * @param matrix matrix to be set.
  92284. * @returns this effect.
  92285. */
  92286. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  92287. /**
  92288. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  92289. * @param uniformName Name of the variable.
  92290. * @param matrix matrix to be set.
  92291. * @returns this effect.
  92292. */
  92293. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  92294. /**
  92295. * Sets a float on a uniform variable.
  92296. * @param uniformName Name of the variable.
  92297. * @param value value to be set.
  92298. * @returns this effect.
  92299. */
  92300. setFloat(uniformName: string, value: number): Effect;
  92301. /**
  92302. * Sets a boolean on a uniform variable.
  92303. * @param uniformName Name of the variable.
  92304. * @param bool value to be set.
  92305. * @returns this effect.
  92306. */
  92307. setBool(uniformName: string, bool: boolean): Effect;
  92308. /**
  92309. * Sets a Vector2 on a uniform variable.
  92310. * @param uniformName Name of the variable.
  92311. * @param vector2 vector2 to be set.
  92312. * @returns this effect.
  92313. */
  92314. setVector2(uniformName: string, vector2: Vector2): Effect;
  92315. /**
  92316. * Sets a float2 on a uniform variable.
  92317. * @param uniformName Name of the variable.
  92318. * @param x First float in float2.
  92319. * @param y Second float in float2.
  92320. * @returns this effect.
  92321. */
  92322. setFloat2(uniformName: string, x: number, y: number): Effect;
  92323. /**
  92324. * Sets a Vector3 on a uniform variable.
  92325. * @param uniformName Name of the variable.
  92326. * @param vector3 Value to be set.
  92327. * @returns this effect.
  92328. */
  92329. setVector3(uniformName: string, vector3: Vector3): Effect;
  92330. /**
  92331. * Sets a float3 on a uniform variable.
  92332. * @param uniformName Name of the variable.
  92333. * @param x First float in float3.
  92334. * @param y Second float in float3.
  92335. * @param z Third float in float3.
  92336. * @returns this effect.
  92337. */
  92338. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  92339. /**
  92340. * Sets a Vector4 on a uniform variable.
  92341. * @param uniformName Name of the variable.
  92342. * @param vector4 Value to be set.
  92343. * @returns this effect.
  92344. */
  92345. setVector4(uniformName: string, vector4: Vector4): Effect;
  92346. /**
  92347. * Sets a float4 on a uniform variable.
  92348. * @param uniformName Name of the variable.
  92349. * @param x First float in float4.
  92350. * @param y Second float in float4.
  92351. * @param z Third float in float4.
  92352. * @param w Fourth float in float4.
  92353. * @returns this effect.
  92354. */
  92355. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  92356. /**
  92357. * Sets a Color3 on a uniform variable.
  92358. * @param uniformName Name of the variable.
  92359. * @param color3 Value to be set.
  92360. * @returns this effect.
  92361. */
  92362. setColor3(uniformName: string, color3: Color3): Effect;
  92363. /**
  92364. * Sets a Color4 on a uniform variable.
  92365. * @param uniformName Name of the variable.
  92366. * @param color3 Value to be set.
  92367. * @param alpha Alpha value to be set.
  92368. * @returns this effect.
  92369. */
  92370. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  92371. /**
  92372. * Sets a Color4 on a uniform variable
  92373. * @param uniformName defines the name of the variable
  92374. * @param color4 defines the value to be set
  92375. * @returns this effect.
  92376. */
  92377. setDirectColor4(uniformName: string, color4: Color4): Effect;
  92378. /** Release all associated resources */
  92379. dispose(): void;
  92380. /**
  92381. * This function will add a new shader to the shader store
  92382. * @param name the name of the shader
  92383. * @param pixelShader optional pixel shader content
  92384. * @param vertexShader optional vertex shader content
  92385. */
  92386. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  92387. /**
  92388. * Store of each shader (The can be looked up using effect.key)
  92389. */
  92390. static ShadersStore: {
  92391. [key: string]: string;
  92392. };
  92393. /**
  92394. * Store of each included file for a shader (The can be looked up using effect.key)
  92395. */
  92396. static IncludesShadersStore: {
  92397. [key: string]: string;
  92398. };
  92399. /**
  92400. * Resets the cache of effects.
  92401. */
  92402. static ResetCache(): void;
  92403. }
  92404. }
  92405. declare module BABYLON {
  92406. /**
  92407. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  92408. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  92409. * 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;
  92410. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  92411. */
  92412. export class ColorCurves {
  92413. private _dirty;
  92414. private _tempColor;
  92415. private _globalCurve;
  92416. private _highlightsCurve;
  92417. private _midtonesCurve;
  92418. private _shadowsCurve;
  92419. private _positiveCurve;
  92420. private _negativeCurve;
  92421. private _globalHue;
  92422. private _globalDensity;
  92423. private _globalSaturation;
  92424. private _globalExposure;
  92425. /**
  92426. * Gets the global Hue value.
  92427. * 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).
  92428. */
  92429. /**
  92430. * Sets the global Hue value.
  92431. * 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).
  92432. */
  92433. globalHue: number;
  92434. /**
  92435. * Gets the global Density value.
  92436. * 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.
  92437. * Values less than zero provide a filter of opposite hue.
  92438. */
  92439. /**
  92440. * Sets the global Density value.
  92441. * 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.
  92442. * Values less than zero provide a filter of opposite hue.
  92443. */
  92444. globalDensity: number;
  92445. /**
  92446. * Gets the global Saturation value.
  92447. * 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.
  92448. */
  92449. /**
  92450. * Sets the global Saturation value.
  92451. * 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.
  92452. */
  92453. globalSaturation: number;
  92454. /**
  92455. * Gets the global Exposure value.
  92456. * 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.
  92457. */
  92458. /**
  92459. * Sets the global Exposure value.
  92460. * 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.
  92461. */
  92462. globalExposure: number;
  92463. private _highlightsHue;
  92464. private _highlightsDensity;
  92465. private _highlightsSaturation;
  92466. private _highlightsExposure;
  92467. /**
  92468. * Gets the highlights Hue value.
  92469. * 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).
  92470. */
  92471. /**
  92472. * Sets the highlights Hue value.
  92473. * 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).
  92474. */
  92475. highlightsHue: number;
  92476. /**
  92477. * Gets the highlights Density value.
  92478. * 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.
  92479. * Values less than zero provide a filter of opposite hue.
  92480. */
  92481. /**
  92482. * Sets the highlights Density value.
  92483. * 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.
  92484. * Values less than zero provide a filter of opposite hue.
  92485. */
  92486. highlightsDensity: number;
  92487. /**
  92488. * Gets the highlights Saturation value.
  92489. * 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.
  92490. */
  92491. /**
  92492. * Sets the highlights Saturation value.
  92493. * 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.
  92494. */
  92495. highlightsSaturation: number;
  92496. /**
  92497. * Gets the highlights Exposure value.
  92498. * 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.
  92499. */
  92500. /**
  92501. * Sets the highlights Exposure value.
  92502. * 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.
  92503. */
  92504. highlightsExposure: number;
  92505. private _midtonesHue;
  92506. private _midtonesDensity;
  92507. private _midtonesSaturation;
  92508. private _midtonesExposure;
  92509. /**
  92510. * Gets the midtones Hue value.
  92511. * 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).
  92512. */
  92513. /**
  92514. * Sets the midtones Hue value.
  92515. * 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).
  92516. */
  92517. midtonesHue: number;
  92518. /**
  92519. * Gets the midtones Density value.
  92520. * 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.
  92521. * Values less than zero provide a filter of opposite hue.
  92522. */
  92523. /**
  92524. * Sets the midtones Density value.
  92525. * 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.
  92526. * Values less than zero provide a filter of opposite hue.
  92527. */
  92528. midtonesDensity: number;
  92529. /**
  92530. * Gets the midtones Saturation value.
  92531. * 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.
  92532. */
  92533. /**
  92534. * Sets the midtones Saturation value.
  92535. * 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.
  92536. */
  92537. midtonesSaturation: number;
  92538. /**
  92539. * Gets the midtones Exposure value.
  92540. * 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.
  92541. */
  92542. /**
  92543. * Sets the midtones Exposure value.
  92544. * 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.
  92545. */
  92546. midtonesExposure: number;
  92547. private _shadowsHue;
  92548. private _shadowsDensity;
  92549. private _shadowsSaturation;
  92550. private _shadowsExposure;
  92551. /**
  92552. * Gets the shadows Hue value.
  92553. * 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).
  92554. */
  92555. /**
  92556. * Sets the shadows Hue value.
  92557. * 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).
  92558. */
  92559. shadowsHue: number;
  92560. /**
  92561. * Gets the shadows Density value.
  92562. * 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.
  92563. * Values less than zero provide a filter of opposite hue.
  92564. */
  92565. /**
  92566. * Sets the shadows Density value.
  92567. * 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.
  92568. * Values less than zero provide a filter of opposite hue.
  92569. */
  92570. shadowsDensity: number;
  92571. /**
  92572. * Gets the shadows Saturation value.
  92573. * 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.
  92574. */
  92575. /**
  92576. * Sets the shadows Saturation value.
  92577. * 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.
  92578. */
  92579. shadowsSaturation: number;
  92580. /**
  92581. * Gets the shadows Exposure value.
  92582. * 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.
  92583. */
  92584. /**
  92585. * Sets the shadows Exposure value.
  92586. * 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.
  92587. */
  92588. shadowsExposure: number;
  92589. /**
  92590. * Returns the class name
  92591. * @returns The class name
  92592. */
  92593. getClassName(): string;
  92594. /**
  92595. * Binds the color curves to the shader.
  92596. * @param colorCurves The color curve to bind
  92597. * @param effect The effect to bind to
  92598. * @param positiveUniform The positive uniform shader parameter
  92599. * @param neutralUniform The neutral uniform shader parameter
  92600. * @param negativeUniform The negative uniform shader parameter
  92601. */
  92602. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  92603. /**
  92604. * Prepare the list of uniforms associated with the ColorCurves effects.
  92605. * @param uniformsList The list of uniforms used in the effect
  92606. */
  92607. static PrepareUniforms(uniformsList: string[]): void;
  92608. /**
  92609. * Returns color grading data based on a hue, density, saturation and exposure value.
  92610. * @param filterHue The hue of the color filter.
  92611. * @param filterDensity The density of the color filter.
  92612. * @param saturation The saturation.
  92613. * @param exposure The exposure.
  92614. * @param result The result data container.
  92615. */
  92616. private getColorGradingDataToRef;
  92617. /**
  92618. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  92619. * @param value The input slider value in range [-100,100].
  92620. * @returns Adjusted value.
  92621. */
  92622. private static applyColorGradingSliderNonlinear;
  92623. /**
  92624. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  92625. * @param hue The hue (H) input.
  92626. * @param saturation The saturation (S) input.
  92627. * @param brightness The brightness (B) input.
  92628. * @result An RGBA color represented as Vector4.
  92629. */
  92630. private static fromHSBToRef;
  92631. /**
  92632. * Returns a value clamped between min and max
  92633. * @param value The value to clamp
  92634. * @param min The minimum of value
  92635. * @param max The maximum of value
  92636. * @returns The clamped value.
  92637. */
  92638. private static clamp;
  92639. /**
  92640. * Clones the current color curve instance.
  92641. * @return The cloned curves
  92642. */
  92643. clone(): ColorCurves;
  92644. /**
  92645. * Serializes the current color curve instance to a json representation.
  92646. * @return a JSON representation
  92647. */
  92648. serialize(): any;
  92649. /**
  92650. * Parses the color curve from a json representation.
  92651. * @param source the JSON source to parse
  92652. * @return The parsed curves
  92653. */
  92654. static Parse(source: any): ColorCurves;
  92655. }
  92656. }
  92657. declare module BABYLON {
  92658. /**
  92659. * Interface to follow in your material defines to integrate easily the
  92660. * Image proccessing functions.
  92661. * @hidden
  92662. */
  92663. export interface IImageProcessingConfigurationDefines {
  92664. IMAGEPROCESSING: boolean;
  92665. VIGNETTE: boolean;
  92666. VIGNETTEBLENDMODEMULTIPLY: boolean;
  92667. VIGNETTEBLENDMODEOPAQUE: boolean;
  92668. TONEMAPPING: boolean;
  92669. TONEMAPPING_ACES: boolean;
  92670. CONTRAST: boolean;
  92671. EXPOSURE: boolean;
  92672. COLORCURVES: boolean;
  92673. COLORGRADING: boolean;
  92674. COLORGRADING3D: boolean;
  92675. SAMPLER3DGREENDEPTH: boolean;
  92676. SAMPLER3DBGRMAP: boolean;
  92677. IMAGEPROCESSINGPOSTPROCESS: boolean;
  92678. }
  92679. /**
  92680. * @hidden
  92681. */
  92682. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  92683. IMAGEPROCESSING: boolean;
  92684. VIGNETTE: boolean;
  92685. VIGNETTEBLENDMODEMULTIPLY: boolean;
  92686. VIGNETTEBLENDMODEOPAQUE: boolean;
  92687. TONEMAPPING: boolean;
  92688. TONEMAPPING_ACES: boolean;
  92689. CONTRAST: boolean;
  92690. COLORCURVES: boolean;
  92691. COLORGRADING: boolean;
  92692. COLORGRADING3D: boolean;
  92693. SAMPLER3DGREENDEPTH: boolean;
  92694. SAMPLER3DBGRMAP: boolean;
  92695. IMAGEPROCESSINGPOSTPROCESS: boolean;
  92696. EXPOSURE: boolean;
  92697. constructor();
  92698. }
  92699. /**
  92700. * This groups together the common properties used for image processing either in direct forward pass
  92701. * or through post processing effect depending on the use of the image processing pipeline in your scene
  92702. * or not.
  92703. */
  92704. export class ImageProcessingConfiguration {
  92705. /**
  92706. * Default tone mapping applied in BabylonJS.
  92707. */
  92708. static readonly TONEMAPPING_STANDARD: number;
  92709. /**
  92710. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  92711. * to other engines rendering to increase portability.
  92712. */
  92713. static readonly TONEMAPPING_ACES: number;
  92714. /**
  92715. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  92716. */
  92717. colorCurves: Nullable<ColorCurves>;
  92718. private _colorCurvesEnabled;
  92719. /**
  92720. * Gets wether the color curves effect is enabled.
  92721. */
  92722. /**
  92723. * Sets wether the color curves effect is enabled.
  92724. */
  92725. colorCurvesEnabled: boolean;
  92726. private _colorGradingTexture;
  92727. /**
  92728. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  92729. */
  92730. /**
  92731. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  92732. */
  92733. colorGradingTexture: Nullable<BaseTexture>;
  92734. private _colorGradingEnabled;
  92735. /**
  92736. * Gets wether the color grading effect is enabled.
  92737. */
  92738. /**
  92739. * Sets wether the color grading effect is enabled.
  92740. */
  92741. colorGradingEnabled: boolean;
  92742. private _colorGradingWithGreenDepth;
  92743. /**
  92744. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  92745. */
  92746. /**
  92747. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  92748. */
  92749. colorGradingWithGreenDepth: boolean;
  92750. private _colorGradingBGR;
  92751. /**
  92752. * Gets wether the color grading texture contains BGR values.
  92753. */
  92754. /**
  92755. * Sets wether the color grading texture contains BGR values.
  92756. */
  92757. colorGradingBGR: boolean;
  92758. /** @hidden */
  92759. _exposure: number;
  92760. /**
  92761. * Gets the Exposure used in the effect.
  92762. */
  92763. /**
  92764. * Sets the Exposure used in the effect.
  92765. */
  92766. exposure: number;
  92767. private _toneMappingEnabled;
  92768. /**
  92769. * Gets wether the tone mapping effect is enabled.
  92770. */
  92771. /**
  92772. * Sets wether the tone mapping effect is enabled.
  92773. */
  92774. toneMappingEnabled: boolean;
  92775. private _toneMappingType;
  92776. /**
  92777. * Gets the type of tone mapping effect.
  92778. */
  92779. /**
  92780. * Sets the type of tone mapping effect used in BabylonJS.
  92781. */
  92782. toneMappingType: number;
  92783. protected _contrast: number;
  92784. /**
  92785. * Gets the contrast used in the effect.
  92786. */
  92787. /**
  92788. * Sets the contrast used in the effect.
  92789. */
  92790. contrast: number;
  92791. /**
  92792. * Vignette stretch size.
  92793. */
  92794. vignetteStretch: number;
  92795. /**
  92796. * Vignette centre X Offset.
  92797. */
  92798. vignetteCentreX: number;
  92799. /**
  92800. * Vignette centre Y Offset.
  92801. */
  92802. vignetteCentreY: number;
  92803. /**
  92804. * Vignette weight or intensity of the vignette effect.
  92805. */
  92806. vignetteWeight: number;
  92807. /**
  92808. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  92809. * if vignetteEnabled is set to true.
  92810. */
  92811. vignetteColor: Color4;
  92812. /**
  92813. * Camera field of view used by the Vignette effect.
  92814. */
  92815. vignetteCameraFov: number;
  92816. private _vignetteBlendMode;
  92817. /**
  92818. * Gets the vignette blend mode allowing different kind of effect.
  92819. */
  92820. /**
  92821. * Sets the vignette blend mode allowing different kind of effect.
  92822. */
  92823. vignetteBlendMode: number;
  92824. private _vignetteEnabled;
  92825. /**
  92826. * Gets wether the vignette effect is enabled.
  92827. */
  92828. /**
  92829. * Sets wether the vignette effect is enabled.
  92830. */
  92831. vignetteEnabled: boolean;
  92832. private _applyByPostProcess;
  92833. /**
  92834. * Gets wether the image processing is applied through a post process or not.
  92835. */
  92836. /**
  92837. * Sets wether the image processing is applied through a post process or not.
  92838. */
  92839. applyByPostProcess: boolean;
  92840. private _isEnabled;
  92841. /**
  92842. * Gets wether the image processing is enabled or not.
  92843. */
  92844. /**
  92845. * Sets wether the image processing is enabled or not.
  92846. */
  92847. isEnabled: boolean;
  92848. /**
  92849. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  92850. */
  92851. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  92852. /**
  92853. * Method called each time the image processing information changes requires to recompile the effect.
  92854. */
  92855. protected _updateParameters(): void;
  92856. /**
  92857. * Gets the current class name.
  92858. * @return "ImageProcessingConfiguration"
  92859. */
  92860. getClassName(): string;
  92861. /**
  92862. * Prepare the list of uniforms associated with the Image Processing effects.
  92863. * @param uniforms The list of uniforms used in the effect
  92864. * @param defines the list of defines currently in use
  92865. */
  92866. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  92867. /**
  92868. * Prepare the list of samplers associated with the Image Processing effects.
  92869. * @param samplersList The list of uniforms used in the effect
  92870. * @param defines the list of defines currently in use
  92871. */
  92872. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  92873. /**
  92874. * Prepare the list of defines associated to the shader.
  92875. * @param defines the list of defines to complete
  92876. * @param forPostProcess Define if we are currently in post process mode or not
  92877. */
  92878. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  92879. /**
  92880. * Returns true if all the image processing information are ready.
  92881. * @returns True if ready, otherwise, false
  92882. */
  92883. isReady(): boolean;
  92884. /**
  92885. * Binds the image processing to the shader.
  92886. * @param effect The effect to bind to
  92887. * @param aspectRatio Define the current aspect ratio of the effect
  92888. */
  92889. bind(effect: Effect, aspectRatio?: number): void;
  92890. /**
  92891. * Clones the current image processing instance.
  92892. * @return The cloned image processing
  92893. */
  92894. clone(): ImageProcessingConfiguration;
  92895. /**
  92896. * Serializes the current image processing instance to a json representation.
  92897. * @return a JSON representation
  92898. */
  92899. serialize(): any;
  92900. /**
  92901. * Parses the image processing from a json representation.
  92902. * @param source the JSON source to parse
  92903. * @return The parsed image processing
  92904. */
  92905. static Parse(source: any): ImageProcessingConfiguration;
  92906. private static _VIGNETTEMODE_MULTIPLY;
  92907. private static _VIGNETTEMODE_OPAQUE;
  92908. /**
  92909. * Used to apply the vignette as a mix with the pixel color.
  92910. */
  92911. static readonly VIGNETTEMODE_MULTIPLY: number;
  92912. /**
  92913. * Used to apply the vignette as a replacement of the pixel color.
  92914. */
  92915. static readonly VIGNETTEMODE_OPAQUE: number;
  92916. }
  92917. }
  92918. declare module BABYLON {
  92919. /**
  92920. * This represents all the required information to add a fresnel effect on a material:
  92921. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  92922. */
  92923. export class FresnelParameters {
  92924. private _isEnabled;
  92925. /**
  92926. * Define if the fresnel effect is enable or not.
  92927. */
  92928. isEnabled: boolean;
  92929. /**
  92930. * Define the color used on edges (grazing angle)
  92931. */
  92932. leftColor: Color3;
  92933. /**
  92934. * Define the color used on center
  92935. */
  92936. rightColor: Color3;
  92937. /**
  92938. * Define bias applied to computed fresnel term
  92939. */
  92940. bias: number;
  92941. /**
  92942. * Defined the power exponent applied to fresnel term
  92943. */
  92944. power: number;
  92945. /**
  92946. * Clones the current fresnel and its valuues
  92947. * @returns a clone fresnel configuration
  92948. */
  92949. clone(): FresnelParameters;
  92950. /**
  92951. * Serializes the current fresnel parameters to a JSON representation.
  92952. * @return the JSON serialization
  92953. */
  92954. serialize(): any;
  92955. /**
  92956. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  92957. * @param parsedFresnelParameters Define the JSON representation
  92958. * @returns the parsed parameters
  92959. */
  92960. static Parse(parsedFresnelParameters: any): FresnelParameters;
  92961. }
  92962. }
  92963. declare module BABYLON {
  92964. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  92965. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92966. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92967. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92968. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92969. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92970. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92971. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92972. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92973. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92974. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92975. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92976. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92977. /**
  92978. * Decorator used to define property that can be serialized as reference to a camera
  92979. * @param sourceName defines the name of the property to decorate
  92980. */
  92981. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92982. /**
  92983. * Class used to help serialization objects
  92984. */
  92985. export class SerializationHelper {
  92986. /** @hidden */
  92987. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  92988. /** @hidden */
  92989. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  92990. /** @hidden */
  92991. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  92992. /** @hidden */
  92993. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  92994. /**
  92995. * Appends the serialized animations from the source animations
  92996. * @param source Source containing the animations
  92997. * @param destination Target to store the animations
  92998. */
  92999. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  93000. /**
  93001. * Static function used to serialized a specific entity
  93002. * @param entity defines the entity to serialize
  93003. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  93004. * @returns a JSON compatible object representing the serialization of the entity
  93005. */
  93006. static Serialize<T>(entity: T, serializationObject?: any): any;
  93007. /**
  93008. * Creates a new entity from a serialization data object
  93009. * @param creationFunction defines a function used to instanciated the new entity
  93010. * @param source defines the source serialization data
  93011. * @param scene defines the hosting scene
  93012. * @param rootUrl defines the root url for resources
  93013. * @returns a new entity
  93014. */
  93015. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  93016. /**
  93017. * Clones an object
  93018. * @param creationFunction defines the function used to instanciate the new object
  93019. * @param source defines the source object
  93020. * @returns the cloned object
  93021. */
  93022. static Clone<T>(creationFunction: () => T, source: T): T;
  93023. /**
  93024. * Instanciates a new object based on a source one (some data will be shared between both object)
  93025. * @param creationFunction defines the function used to instanciate the new object
  93026. * @param source defines the source object
  93027. * @returns the new object
  93028. */
  93029. static Instanciate<T>(creationFunction: () => T, source: T): T;
  93030. }
  93031. }
  93032. declare module BABYLON {
  93033. /**
  93034. * This is the base class of all the camera used in the application.
  93035. * @see http://doc.babylonjs.com/features/cameras
  93036. */
  93037. export class Camera extends Node {
  93038. /** @hidden */
  93039. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  93040. /**
  93041. * This is the default projection mode used by the cameras.
  93042. * It helps recreating a feeling of perspective and better appreciate depth.
  93043. * This is the best way to simulate real life cameras.
  93044. */
  93045. static readonly PERSPECTIVE_CAMERA: number;
  93046. /**
  93047. * This helps creating camera with an orthographic mode.
  93048. * 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.
  93049. */
  93050. static readonly ORTHOGRAPHIC_CAMERA: number;
  93051. /**
  93052. * This is the default FOV mode for perspective cameras.
  93053. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  93054. */
  93055. static readonly FOVMODE_VERTICAL_FIXED: number;
  93056. /**
  93057. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  93058. */
  93059. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  93060. /**
  93061. * This specifies ther is no need for a camera rig.
  93062. * Basically only one eye is rendered corresponding to the camera.
  93063. */
  93064. static readonly RIG_MODE_NONE: number;
  93065. /**
  93066. * Simulates a camera Rig with one blue eye and one red eye.
  93067. * This can be use with 3d blue and red glasses.
  93068. */
  93069. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  93070. /**
  93071. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  93072. */
  93073. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  93074. /**
  93075. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  93076. */
  93077. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  93078. /**
  93079. * Defines that both eyes of the camera will be rendered over under each other.
  93080. */
  93081. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  93082. /**
  93083. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  93084. */
  93085. static readonly RIG_MODE_VR: number;
  93086. /**
  93087. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  93088. */
  93089. static readonly RIG_MODE_WEBVR: number;
  93090. /**
  93091. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  93092. */
  93093. static readonly RIG_MODE_CUSTOM: number;
  93094. /**
  93095. * Defines if by default attaching controls should prevent the default javascript event to continue.
  93096. */
  93097. static ForceAttachControlToAlwaysPreventDefault: boolean;
  93098. /**
  93099. * Define the input manager associated with the camera.
  93100. */
  93101. inputs: CameraInputsManager<Camera>;
  93102. /** @hidden */
  93103. _position: Vector3;
  93104. /**
  93105. * Define the current local position of the camera in the scene
  93106. */
  93107. position: Vector3;
  93108. /**
  93109. * The vector the camera should consider as up.
  93110. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  93111. */
  93112. upVector: Vector3;
  93113. /**
  93114. * Define the current limit on the left side for an orthographic camera
  93115. * In scene unit
  93116. */
  93117. orthoLeft: Nullable<number>;
  93118. /**
  93119. * Define the current limit on the right side for an orthographic camera
  93120. * In scene unit
  93121. */
  93122. orthoRight: Nullable<number>;
  93123. /**
  93124. * Define the current limit on the bottom side for an orthographic camera
  93125. * In scene unit
  93126. */
  93127. orthoBottom: Nullable<number>;
  93128. /**
  93129. * Define the current limit on the top side for an orthographic camera
  93130. * In scene unit
  93131. */
  93132. orthoTop: Nullable<number>;
  93133. /**
  93134. * Field Of View is set in Radians. (default is 0.8)
  93135. */
  93136. fov: number;
  93137. /**
  93138. * Define the minimum distance the camera can see from.
  93139. * This is important to note that the depth buffer are not infinite and the closer it starts
  93140. * the more your scene might encounter depth fighting issue.
  93141. */
  93142. minZ: number;
  93143. /**
  93144. * Define the maximum distance the camera can see to.
  93145. * This is important to note that the depth buffer are not infinite and the further it end
  93146. * the more your scene might encounter depth fighting issue.
  93147. */
  93148. maxZ: number;
  93149. /**
  93150. * Define the default inertia of the camera.
  93151. * This helps giving a smooth feeling to the camera movement.
  93152. */
  93153. inertia: number;
  93154. /**
  93155. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  93156. */
  93157. mode: number;
  93158. /**
  93159. * Define wether the camera is intermediate.
  93160. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  93161. */
  93162. isIntermediate: boolean;
  93163. /**
  93164. * Define the viewport of the camera.
  93165. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  93166. */
  93167. viewport: Viewport;
  93168. /**
  93169. * Restricts the camera to viewing objects with the same layerMask.
  93170. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  93171. */
  93172. layerMask: number;
  93173. /**
  93174. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  93175. */
  93176. fovMode: number;
  93177. /**
  93178. * Rig mode of the camera.
  93179. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  93180. * This is normally controlled byt the camera themselves as internal use.
  93181. */
  93182. cameraRigMode: number;
  93183. /**
  93184. * Defines the distance between both "eyes" in case of a RIG
  93185. */
  93186. interaxialDistance: number;
  93187. /**
  93188. * Defines if stereoscopic rendering is done side by side or over under.
  93189. */
  93190. isStereoscopicSideBySide: boolean;
  93191. /**
  93192. * 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
  93193. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  93194. * else in the scene.
  93195. */
  93196. customRenderTargets: RenderTargetTexture[];
  93197. /**
  93198. * When set, the camera will render to this render target instead of the default canvas
  93199. */
  93200. outputRenderTarget: Nullable<RenderTargetTexture>;
  93201. /**
  93202. * Observable triggered when the camera view matrix has changed.
  93203. */
  93204. onViewMatrixChangedObservable: Observable<Camera>;
  93205. /**
  93206. * Observable triggered when the camera Projection matrix has changed.
  93207. */
  93208. onProjectionMatrixChangedObservable: Observable<Camera>;
  93209. /**
  93210. * Observable triggered when the inputs have been processed.
  93211. */
  93212. onAfterCheckInputsObservable: Observable<Camera>;
  93213. /**
  93214. * Observable triggered when reset has been called and applied to the camera.
  93215. */
  93216. onRestoreStateObservable: Observable<Camera>;
  93217. /** @hidden */
  93218. _cameraRigParams: any;
  93219. /** @hidden */
  93220. _rigCameras: Camera[];
  93221. /** @hidden */
  93222. _rigPostProcess: Nullable<PostProcess>;
  93223. protected _webvrViewMatrix: Matrix;
  93224. /** @hidden */
  93225. _skipRendering: boolean;
  93226. /** @hidden */
  93227. _projectionMatrix: Matrix;
  93228. /** @hidden */
  93229. _postProcesses: Nullable<PostProcess>[];
  93230. /** @hidden */
  93231. _activeMeshes: SmartArray<AbstractMesh>;
  93232. protected _globalPosition: Vector3;
  93233. /** @hidden */
  93234. _computedViewMatrix: Matrix;
  93235. private _doNotComputeProjectionMatrix;
  93236. private _transformMatrix;
  93237. private _frustumPlanes;
  93238. private _refreshFrustumPlanes;
  93239. private _storedFov;
  93240. private _stateStored;
  93241. /**
  93242. * Instantiates a new camera object.
  93243. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  93244. * @see http://doc.babylonjs.com/features/cameras
  93245. * @param name Defines the name of the camera in the scene
  93246. * @param position Defines the position of the camera
  93247. * @param scene Defines the scene the camera belongs too
  93248. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  93249. */
  93250. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  93251. /**
  93252. * Store current camera state (fov, position, etc..)
  93253. * @returns the camera
  93254. */
  93255. storeState(): Camera;
  93256. /**
  93257. * Restores the camera state values if it has been stored. You must call storeState() first
  93258. */
  93259. protected _restoreStateValues(): boolean;
  93260. /**
  93261. * Restored camera state. You must call storeState() first.
  93262. * @returns true if restored and false otherwise
  93263. */
  93264. restoreState(): boolean;
  93265. /**
  93266. * Gets the class name of the camera.
  93267. * @returns the class name
  93268. */
  93269. getClassName(): string;
  93270. /** @hidden */
  93271. readonly _isCamera: boolean;
  93272. /**
  93273. * Gets a string representation of the camera useful for debug purpose.
  93274. * @param fullDetails Defines that a more verboe level of logging is required
  93275. * @returns the string representation
  93276. */
  93277. toString(fullDetails?: boolean): string;
  93278. /**
  93279. * Gets the current world space position of the camera.
  93280. */
  93281. readonly globalPosition: Vector3;
  93282. /**
  93283. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  93284. * @returns the active meshe list
  93285. */
  93286. getActiveMeshes(): SmartArray<AbstractMesh>;
  93287. /**
  93288. * Check wether a mesh is part of the current active mesh list of the camera
  93289. * @param mesh Defines the mesh to check
  93290. * @returns true if active, false otherwise
  93291. */
  93292. isActiveMesh(mesh: Mesh): boolean;
  93293. /**
  93294. * Is this camera ready to be used/rendered
  93295. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  93296. * @return true if the camera is ready
  93297. */
  93298. isReady(completeCheck?: boolean): boolean;
  93299. /** @hidden */
  93300. _initCache(): void;
  93301. /** @hidden */
  93302. _updateCache(ignoreParentClass?: boolean): void;
  93303. /** @hidden */
  93304. _isSynchronized(): boolean;
  93305. /** @hidden */
  93306. _isSynchronizedViewMatrix(): boolean;
  93307. /** @hidden */
  93308. _isSynchronizedProjectionMatrix(): boolean;
  93309. /**
  93310. * Attach the input controls to a specific dom element to get the input from.
  93311. * @param element Defines the element the controls should be listened from
  93312. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93313. */
  93314. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93315. /**
  93316. * Detach the current controls from the specified dom element.
  93317. * @param element Defines the element to stop listening the inputs from
  93318. */
  93319. detachControl(element: HTMLElement): void;
  93320. /**
  93321. * Update the camera state according to the different inputs gathered during the frame.
  93322. */
  93323. update(): void;
  93324. /** @hidden */
  93325. _checkInputs(): void;
  93326. /** @hidden */
  93327. readonly rigCameras: Camera[];
  93328. /**
  93329. * Gets the post process used by the rig cameras
  93330. */
  93331. readonly rigPostProcess: Nullable<PostProcess>;
  93332. /**
  93333. * Internal, gets the first post proces.
  93334. * @returns the first post process to be run on this camera.
  93335. */
  93336. _getFirstPostProcess(): Nullable<PostProcess>;
  93337. private _cascadePostProcessesToRigCams;
  93338. /**
  93339. * Attach a post process to the camera.
  93340. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  93341. * @param postProcess The post process to attach to the camera
  93342. * @param insertAt The position of the post process in case several of them are in use in the scene
  93343. * @returns the position the post process has been inserted at
  93344. */
  93345. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  93346. /**
  93347. * Detach a post process to the camera.
  93348. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  93349. * @param postProcess The post process to detach from the camera
  93350. */
  93351. detachPostProcess(postProcess: PostProcess): void;
  93352. /**
  93353. * Gets the current world matrix of the camera
  93354. */
  93355. getWorldMatrix(): Matrix;
  93356. /** @hidden */
  93357. _getViewMatrix(): Matrix;
  93358. /**
  93359. * Gets the current view matrix of the camera.
  93360. * @param force forces the camera to recompute the matrix without looking at the cached state
  93361. * @returns the view matrix
  93362. */
  93363. getViewMatrix(force?: boolean): Matrix;
  93364. /**
  93365. * Freeze the projection matrix.
  93366. * It will prevent the cache check of the camera projection compute and can speed up perf
  93367. * if no parameter of the camera are meant to change
  93368. * @param projection Defines manually a projection if necessary
  93369. */
  93370. freezeProjectionMatrix(projection?: Matrix): void;
  93371. /**
  93372. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  93373. */
  93374. unfreezeProjectionMatrix(): void;
  93375. /**
  93376. * Gets the current projection matrix of the camera.
  93377. * @param force forces the camera to recompute the matrix without looking at the cached state
  93378. * @returns the projection matrix
  93379. */
  93380. getProjectionMatrix(force?: boolean): Matrix;
  93381. /**
  93382. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  93383. * @returns a Matrix
  93384. */
  93385. getTransformationMatrix(): Matrix;
  93386. private _updateFrustumPlanes;
  93387. /**
  93388. * Checks if a cullable object (mesh...) is in the camera frustum
  93389. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  93390. * @param target The object to check
  93391. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  93392. * @returns true if the object is in frustum otherwise false
  93393. */
  93394. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  93395. /**
  93396. * Checks if a cullable object (mesh...) is in the camera frustum
  93397. * Unlike isInFrustum this cheks the full bounding box
  93398. * @param target The object to check
  93399. * @returns true if the object is in frustum otherwise false
  93400. */
  93401. isCompletelyInFrustum(target: ICullable): boolean;
  93402. /**
  93403. * Gets a ray in the forward direction from the camera.
  93404. * @param length Defines the length of the ray to create
  93405. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  93406. * @param origin Defines the start point of the ray which defaults to the camera position
  93407. * @returns the forward ray
  93408. */
  93409. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  93410. /**
  93411. * Releases resources associated with this node.
  93412. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93413. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93414. */
  93415. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93416. /** @hidden */
  93417. _isLeftCamera: boolean;
  93418. /**
  93419. * Gets the left camera of a rig setup in case of Rigged Camera
  93420. */
  93421. readonly isLeftCamera: boolean;
  93422. /** @hidden */
  93423. _isRightCamera: boolean;
  93424. /**
  93425. * Gets the right camera of a rig setup in case of Rigged Camera
  93426. */
  93427. readonly isRightCamera: boolean;
  93428. /**
  93429. * Gets the left camera of a rig setup in case of Rigged Camera
  93430. */
  93431. readonly leftCamera: Nullable<FreeCamera>;
  93432. /**
  93433. * Gets the right camera of a rig setup in case of Rigged Camera
  93434. */
  93435. readonly rightCamera: Nullable<FreeCamera>;
  93436. /**
  93437. * Gets the left camera target of a rig setup in case of Rigged Camera
  93438. * @returns the target position
  93439. */
  93440. getLeftTarget(): Nullable<Vector3>;
  93441. /**
  93442. * Gets the right camera target of a rig setup in case of Rigged Camera
  93443. * @returns the target position
  93444. */
  93445. getRightTarget(): Nullable<Vector3>;
  93446. /**
  93447. * @hidden
  93448. */
  93449. setCameraRigMode(mode: number, rigParams: any): void;
  93450. /** @hidden */
  93451. static _setStereoscopicRigMode(camera: Camera): void;
  93452. /** @hidden */
  93453. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  93454. /** @hidden */
  93455. static _setVRRigMode(camera: Camera, rigParams: any): void;
  93456. /** @hidden */
  93457. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  93458. /** @hidden */
  93459. _getVRProjectionMatrix(): Matrix;
  93460. protected _updateCameraRotationMatrix(): void;
  93461. protected _updateWebVRCameraRotationMatrix(): void;
  93462. /**
  93463. * This function MUST be overwritten by the different WebVR cameras available.
  93464. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  93465. * @hidden
  93466. */
  93467. _getWebVRProjectionMatrix(): Matrix;
  93468. /**
  93469. * This function MUST be overwritten by the different WebVR cameras available.
  93470. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  93471. * @hidden
  93472. */
  93473. _getWebVRViewMatrix(): Matrix;
  93474. /** @hidden */
  93475. setCameraRigParameter(name: string, value: any): void;
  93476. /**
  93477. * needs to be overridden by children so sub has required properties to be copied
  93478. * @hidden
  93479. */
  93480. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  93481. /**
  93482. * May need to be overridden by children
  93483. * @hidden
  93484. */
  93485. _updateRigCameras(): void;
  93486. /** @hidden */
  93487. _setupInputs(): void;
  93488. /**
  93489. * Serialiaze the camera setup to a json represention
  93490. * @returns the JSON representation
  93491. */
  93492. serialize(): any;
  93493. /**
  93494. * Clones the current camera.
  93495. * @param name The cloned camera name
  93496. * @returns the cloned camera
  93497. */
  93498. clone(name: string): Camera;
  93499. /**
  93500. * Gets the direction of the camera relative to a given local axis.
  93501. * @param localAxis Defines the reference axis to provide a relative direction.
  93502. * @return the direction
  93503. */
  93504. getDirection(localAxis: Vector3): Vector3;
  93505. /**
  93506. * Gets the direction of the camera relative to a given local axis into a passed vector.
  93507. * @param localAxis Defines the reference axis to provide a relative direction.
  93508. * @param result Defines the vector to store the result in
  93509. */
  93510. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  93511. /**
  93512. * Gets a camera constructor for a given camera type
  93513. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  93514. * @param name The name of the camera the result will be able to instantiate
  93515. * @param scene The scene the result will construct the camera in
  93516. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  93517. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  93518. * @returns a factory method to construc the camera
  93519. */
  93520. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  93521. /**
  93522. * Compute the world matrix of the camera.
  93523. * @returns the camera workd matrix
  93524. */
  93525. computeWorldMatrix(): Matrix;
  93526. /**
  93527. * Parse a JSON and creates the camera from the parsed information
  93528. * @param parsedCamera The JSON to parse
  93529. * @param scene The scene to instantiate the camera in
  93530. * @returns the newly constructed camera
  93531. */
  93532. static Parse(parsedCamera: any, scene: Scene): Camera;
  93533. }
  93534. }
  93535. declare module BABYLON {
  93536. /**
  93537. * Interface for any object that can request an animation frame
  93538. */
  93539. export interface ICustomAnimationFrameRequester {
  93540. /**
  93541. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  93542. */
  93543. renderFunction?: Function;
  93544. /**
  93545. * Called to request the next frame to render to
  93546. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  93547. */
  93548. requestAnimationFrame: Function;
  93549. /**
  93550. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  93551. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  93552. */
  93553. requestID?: number;
  93554. }
  93555. /**
  93556. * Interface containing an array of animations
  93557. */
  93558. export interface IAnimatable {
  93559. /**
  93560. * Array of animations
  93561. */
  93562. animations: Nullable<Array<Animation>>;
  93563. }
  93564. /** Interface used by value gradients (color, factor, ...) */
  93565. export interface IValueGradient {
  93566. /**
  93567. * Gets or sets the gradient value (between 0 and 1)
  93568. */
  93569. gradient: number;
  93570. }
  93571. /** Class used to store color4 gradient */
  93572. export class ColorGradient implements IValueGradient {
  93573. /**
  93574. * Gets or sets the gradient value (between 0 and 1)
  93575. */
  93576. gradient: number;
  93577. /**
  93578. * Gets or sets first associated color
  93579. */
  93580. color1: Color4;
  93581. /**
  93582. * Gets or sets second associated color
  93583. */
  93584. color2?: Color4;
  93585. /**
  93586. * Will get a color picked randomly between color1 and color2.
  93587. * If color2 is undefined then color1 will be used
  93588. * @param result defines the target Color4 to store the result in
  93589. */
  93590. getColorToRef(result: Color4): void;
  93591. }
  93592. /** Class used to store color 3 gradient */
  93593. export class Color3Gradient implements IValueGradient {
  93594. /**
  93595. * Gets or sets the gradient value (between 0 and 1)
  93596. */
  93597. gradient: number;
  93598. /**
  93599. * Gets or sets the associated color
  93600. */
  93601. color: Color3;
  93602. }
  93603. /** Class used to store factor gradient */
  93604. export class FactorGradient implements IValueGradient {
  93605. /**
  93606. * Gets or sets the gradient value (between 0 and 1)
  93607. */
  93608. gradient: number;
  93609. /**
  93610. * Gets or sets first associated factor
  93611. */
  93612. factor1: number;
  93613. /**
  93614. * Gets or sets second associated factor
  93615. */
  93616. factor2?: number;
  93617. /**
  93618. * Will get a number picked randomly between factor1 and factor2.
  93619. * If factor2 is undefined then factor1 will be used
  93620. * @returns the picked number
  93621. */
  93622. getFactor(): number;
  93623. }
  93624. /**
  93625. * @ignore
  93626. * Application error to support additional information when loading a file
  93627. */
  93628. export class LoadFileError extends Error {
  93629. /** defines the optional web request */
  93630. request?: WebRequest | undefined;
  93631. private static _setPrototypeOf;
  93632. /**
  93633. * Creates a new LoadFileError
  93634. * @param message defines the message of the error
  93635. * @param request defines the optional web request
  93636. */
  93637. constructor(message: string,
  93638. /** defines the optional web request */
  93639. request?: WebRequest | undefined);
  93640. }
  93641. /**
  93642. * Class used to define a retry strategy when error happens while loading assets
  93643. */
  93644. export class RetryStrategy {
  93645. /**
  93646. * Function used to defines an exponential back off strategy
  93647. * @param maxRetries defines the maximum number of retries (3 by default)
  93648. * @param baseInterval defines the interval between retries
  93649. * @returns the strategy function to use
  93650. */
  93651. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  93652. }
  93653. /**
  93654. * File request interface
  93655. */
  93656. export interface IFileRequest {
  93657. /**
  93658. * Raised when the request is complete (success or error).
  93659. */
  93660. onCompleteObservable: Observable<IFileRequest>;
  93661. /**
  93662. * Aborts the request for a file.
  93663. */
  93664. abort: () => void;
  93665. }
  93666. /**
  93667. * Class containing a set of static utilities functions
  93668. */
  93669. export class Tools {
  93670. /**
  93671. * Gets or sets the base URL to use to load assets
  93672. */
  93673. static BaseUrl: string;
  93674. /**
  93675. * Enable/Disable Custom HTTP Request Headers globally.
  93676. * default = false
  93677. * @see CustomRequestHeaders
  93678. */
  93679. static UseCustomRequestHeaders: boolean;
  93680. /**
  93681. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  93682. * i.e. when loading files, where the server/service expects an Authorization header
  93683. */
  93684. static CustomRequestHeaders: {
  93685. [key: string]: string;
  93686. };
  93687. /**
  93688. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  93689. */
  93690. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  93691. /**
  93692. * Default behaviour for cors in the application.
  93693. * It can be a string if the expected behavior is identical in the entire app.
  93694. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  93695. */
  93696. static CorsBehavior: string | ((url: string | string[]) => string);
  93697. /**
  93698. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  93699. * @ignorenaming
  93700. */
  93701. static UseFallbackTexture: boolean;
  93702. /**
  93703. * Use this object to register external classes like custom textures or material
  93704. * to allow the laoders to instantiate them
  93705. */
  93706. static RegisteredExternalClasses: {
  93707. [key: string]: Object;
  93708. };
  93709. /**
  93710. * Texture content used if a texture cannot loaded
  93711. * @ignorenaming
  93712. */
  93713. static fallbackTexture: string;
  93714. /**
  93715. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  93716. * @param u defines the coordinate on X axis
  93717. * @param v defines the coordinate on Y axis
  93718. * @param width defines the width of the source data
  93719. * @param height defines the height of the source data
  93720. * @param pixels defines the source byte array
  93721. * @param color defines the output color
  93722. */
  93723. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  93724. /**
  93725. * Interpolates between a and b via alpha
  93726. * @param a The lower value (returned when alpha = 0)
  93727. * @param b The upper value (returned when alpha = 1)
  93728. * @param alpha The interpolation-factor
  93729. * @return The mixed value
  93730. */
  93731. static Mix(a: number, b: number, alpha: number): number;
  93732. /**
  93733. * Tries to instantiate a new object from a given class name
  93734. * @param className defines the class name to instantiate
  93735. * @returns the new object or null if the system was not able to do the instantiation
  93736. */
  93737. static Instantiate(className: string): any;
  93738. /**
  93739. * Provides a slice function that will work even on IE
  93740. * @param data defines the array to slice
  93741. * @param start defines the start of the data (optional)
  93742. * @param end defines the end of the data (optional)
  93743. * @returns the new sliced array
  93744. */
  93745. static Slice<T>(data: T, start?: number, end?: number): T;
  93746. /**
  93747. * Polyfill for setImmediate
  93748. * @param action defines the action to execute after the current execution block
  93749. */
  93750. static SetImmediate(action: () => void): void;
  93751. /**
  93752. * Function indicating if a number is an exponent of 2
  93753. * @param value defines the value to test
  93754. * @returns true if the value is an exponent of 2
  93755. */
  93756. static IsExponentOfTwo(value: number): boolean;
  93757. private static _tmpFloatArray;
  93758. /**
  93759. * Returns the nearest 32-bit single precision float representation of a Number
  93760. * @param value A Number. If the parameter is of a different type, it will get converted
  93761. * to a number or to NaN if it cannot be converted
  93762. * @returns number
  93763. */
  93764. static FloatRound(value: number): number;
  93765. /**
  93766. * Find the next highest power of two.
  93767. * @param x Number to start search from.
  93768. * @return Next highest power of two.
  93769. */
  93770. static CeilingPOT(x: number): number;
  93771. /**
  93772. * Find the next lowest power of two.
  93773. * @param x Number to start search from.
  93774. * @return Next lowest power of two.
  93775. */
  93776. static FloorPOT(x: number): number;
  93777. /**
  93778. * Find the nearest power of two.
  93779. * @param x Number to start search from.
  93780. * @return Next nearest power of two.
  93781. */
  93782. static NearestPOT(x: number): number;
  93783. /**
  93784. * Get the closest exponent of two
  93785. * @param value defines the value to approximate
  93786. * @param max defines the maximum value to return
  93787. * @param mode defines how to define the closest value
  93788. * @returns closest exponent of two of the given value
  93789. */
  93790. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  93791. /**
  93792. * Extracts the filename from a path
  93793. * @param path defines the path to use
  93794. * @returns the filename
  93795. */
  93796. static GetFilename(path: string): string;
  93797. /**
  93798. * Extracts the "folder" part of a path (everything before the filename).
  93799. * @param uri The URI to extract the info from
  93800. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  93801. * @returns The "folder" part of the path
  93802. */
  93803. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  93804. /**
  93805. * Extracts text content from a DOM element hierarchy
  93806. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  93807. */
  93808. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  93809. /**
  93810. * Convert an angle in radians to degrees
  93811. * @param angle defines the angle to convert
  93812. * @returns the angle in degrees
  93813. */
  93814. static ToDegrees(angle: number): number;
  93815. /**
  93816. * Convert an angle in degrees to radians
  93817. * @param angle defines the angle to convert
  93818. * @returns the angle in radians
  93819. */
  93820. static ToRadians(angle: number): number;
  93821. /**
  93822. * Encode a buffer to a base64 string
  93823. * @param buffer defines the buffer to encode
  93824. * @returns the encoded string
  93825. */
  93826. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  93827. /**
  93828. * Extracts minimum and maximum values from a list of indexed positions
  93829. * @param positions defines the positions to use
  93830. * @param indices defines the indices to the positions
  93831. * @param indexStart defines the start index
  93832. * @param indexCount defines the end index
  93833. * @param bias defines bias value to add to the result
  93834. * @return minimum and maximum values
  93835. */
  93836. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  93837. minimum: Vector3;
  93838. maximum: Vector3;
  93839. };
  93840. /**
  93841. * Extracts minimum and maximum values from a list of positions
  93842. * @param positions defines the positions to use
  93843. * @param start defines the start index in the positions array
  93844. * @param count defines the number of positions to handle
  93845. * @param bias defines bias value to add to the result
  93846. * @param stride defines the stride size to use (distance between two positions in the positions array)
  93847. * @return minimum and maximum values
  93848. */
  93849. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  93850. minimum: Vector3;
  93851. maximum: Vector3;
  93852. };
  93853. /**
  93854. * Returns an array if obj is not an array
  93855. * @param obj defines the object to evaluate as an array
  93856. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  93857. * @returns either obj directly if obj is an array or a new array containing obj
  93858. */
  93859. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  93860. /**
  93861. * Gets the pointer prefix to use
  93862. * @returns "pointer" if touch is enabled. Else returns "mouse"
  93863. */
  93864. static GetPointerPrefix(): string;
  93865. /**
  93866. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  93867. * @param func - the function to be called
  93868. * @param requester - the object that will request the next frame. Falls back to window.
  93869. * @returns frame number
  93870. */
  93871. static QueueNewFrame(func: () => void, requester?: any): number;
  93872. /**
  93873. * Ask the browser to promote the current element to fullscreen rendering mode
  93874. * @param element defines the DOM element to promote
  93875. */
  93876. static RequestFullscreen(element: HTMLElement): void;
  93877. /**
  93878. * Asks the browser to exit fullscreen mode
  93879. */
  93880. static ExitFullscreen(): void;
  93881. /**
  93882. * Ask the browser to promote the current element to pointerlock mode
  93883. * @param element defines the DOM element to promote
  93884. */
  93885. static RequestPointerlock(element: HTMLElement): void;
  93886. /**
  93887. * Asks the browser to exit pointerlock mode
  93888. */
  93889. static ExitPointerlock(): void;
  93890. /**
  93891. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  93892. * @param url define the url we are trying
  93893. * @param element define the dom element where to configure the cors policy
  93894. */
  93895. static SetCorsBehavior(url: string | string[], element: {
  93896. crossOrigin: string | null;
  93897. }): void;
  93898. /**
  93899. * Removes unwanted characters from an url
  93900. * @param url defines the url to clean
  93901. * @returns the cleaned url
  93902. */
  93903. static CleanUrl(url: string): string;
  93904. /**
  93905. * Gets or sets a function used to pre-process url before using them to load assets
  93906. */
  93907. static PreprocessUrl: (url: string) => string;
  93908. /**
  93909. * Loads an image as an HTMLImageElement.
  93910. * @param input url string, ArrayBuffer, or Blob to load
  93911. * @param onLoad callback called when the image successfully loads
  93912. * @param onError callback called when the image fails to load
  93913. * @param offlineProvider offline provider for caching
  93914. * @returns the HTMLImageElement of the loaded image
  93915. */
  93916. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  93917. /**
  93918. * Loads a file
  93919. * @param url url string, ArrayBuffer, or Blob to load
  93920. * @param onSuccess callback called when the file successfully loads
  93921. * @param onProgress callback called while file is loading (if the server supports this mode)
  93922. * @param offlineProvider defines the offline provider for caching
  93923. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  93924. * @param onError callback called when the file fails to load
  93925. * @returns a file request object
  93926. */
  93927. 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;
  93928. /**
  93929. * Load a script (identified by an url). When the url returns, the
  93930. * content of this file is added into a new script element, attached to the DOM (body element)
  93931. * @param scriptUrl defines the url of the script to laod
  93932. * @param onSuccess defines the callback called when the script is loaded
  93933. * @param onError defines the callback to call if an error occurs
  93934. * @param scriptId defines the id of the script element
  93935. */
  93936. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  93937. /**
  93938. * Load an asynchronous script (identified by an url). When the url returns, the
  93939. * content of this file is added into a new script element, attached to the DOM (body element)
  93940. * @param scriptUrl defines the url of the script to laod
  93941. * @param scriptId defines the id of the script element
  93942. * @returns a promise request object
  93943. */
  93944. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  93945. /**
  93946. * Loads a file from a blob
  93947. * @param fileToLoad defines the blob to use
  93948. * @param callback defines the callback to call when data is loaded
  93949. * @param progressCallback defines the callback to call during loading process
  93950. * @returns a file request object
  93951. */
  93952. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  93953. /**
  93954. * Loads a file
  93955. * @param fileToLoad defines the file to load
  93956. * @param callback defines the callback to call when data is loaded
  93957. * @param progressCallBack defines the callback to call during loading process
  93958. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  93959. * @returns a file request object
  93960. */
  93961. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  93962. /**
  93963. * Creates a data url from a given string content
  93964. * @param content defines the content to convert
  93965. * @returns the new data url link
  93966. */
  93967. static FileAsURL(content: string): string;
  93968. /**
  93969. * Format the given number to a specific decimal format
  93970. * @param value defines the number to format
  93971. * @param decimals defines the number of decimals to use
  93972. * @returns the formatted string
  93973. */
  93974. static Format(value: number, decimals?: number): string;
  93975. /**
  93976. * Checks if a given vector is inside a specific range
  93977. * @param v defines the vector to test
  93978. * @param min defines the minimum range
  93979. * @param max defines the maximum range
  93980. */
  93981. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  93982. /**
  93983. * Tries to copy an object by duplicating every property
  93984. * @param source defines the source object
  93985. * @param destination defines the target object
  93986. * @param doNotCopyList defines a list of properties to avoid
  93987. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  93988. */
  93989. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  93990. /**
  93991. * Gets a boolean indicating if the given object has no own property
  93992. * @param obj defines the object to test
  93993. * @returns true if object has no own property
  93994. */
  93995. static IsEmpty(obj: any): boolean;
  93996. /**
  93997. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  93998. * @param str Source string
  93999. * @param suffix Suffix to search for in the source string
  94000. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  94001. */
  94002. static EndsWith(str: string, suffix: string): boolean;
  94003. /**
  94004. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  94005. * @param str Source string
  94006. * @param suffix Suffix to search for in the source string
  94007. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  94008. */
  94009. static StartsWith(str: string, suffix: string): boolean;
  94010. /**
  94011. * Function used to register events at window level
  94012. * @param events defines the events to register
  94013. */
  94014. static RegisterTopRootEvents(events: {
  94015. name: string;
  94016. handler: Nullable<(e: FocusEvent) => any>;
  94017. }[]): void;
  94018. /**
  94019. * Function used to unregister events from window level
  94020. * @param events defines the events to unregister
  94021. */
  94022. static UnregisterTopRootEvents(events: {
  94023. name: string;
  94024. handler: Nullable<(e: FocusEvent) => any>;
  94025. }[]): void;
  94026. /**
  94027. * @ignore
  94028. */
  94029. static _ScreenshotCanvas: HTMLCanvasElement;
  94030. /**
  94031. * Dumps the current bound framebuffer
  94032. * @param width defines the rendering width
  94033. * @param height defines the rendering height
  94034. * @param engine defines the hosting engine
  94035. * @param successCallback defines the callback triggered once the data are available
  94036. * @param mimeType defines the mime type of the result
  94037. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  94038. */
  94039. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  94040. /**
  94041. * Converts the canvas data to blob.
  94042. * This acts as a polyfill for browsers not supporting the to blob function.
  94043. * @param canvas Defines the canvas to extract the data from
  94044. * @param successCallback Defines the callback triggered once the data are available
  94045. * @param mimeType Defines the mime type of the result
  94046. */
  94047. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  94048. /**
  94049. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  94050. * @param successCallback defines the callback triggered once the data are available
  94051. * @param mimeType defines the mime type of the result
  94052. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  94053. */
  94054. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  94055. /**
  94056. * Downloads a blob in the browser
  94057. * @param blob defines the blob to download
  94058. * @param fileName defines the name of the downloaded file
  94059. */
  94060. static Download(blob: Blob, fileName: string): void;
  94061. /**
  94062. * Captures a screenshot of the current rendering
  94063. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  94064. * @param engine defines the rendering engine
  94065. * @param camera defines the source camera
  94066. * @param size This parameter can be set to a single number or to an object with the
  94067. * following (optional) properties: precision, width, height. If a single number is passed,
  94068. * it will be used for both width and height. If an object is passed, the screenshot size
  94069. * will be derived from the parameters. The precision property is a multiplier allowing
  94070. * rendering at a higher or lower resolution
  94071. * @param successCallback defines the callback receives a single parameter which contains the
  94072. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  94073. * src parameter of an <img> to display it
  94074. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  94075. * Check your browser for supported MIME types
  94076. */
  94077. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  94078. /**
  94079. * Generates an image screenshot from the specified camera.
  94080. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  94081. * @param engine The engine to use for rendering
  94082. * @param camera The camera to use for rendering
  94083. * @param size This parameter can be set to a single number or to an object with the
  94084. * following (optional) properties: precision, width, height. If a single number is passed,
  94085. * it will be used for both width and height. If an object is passed, the screenshot size
  94086. * will be derived from the parameters. The precision property is a multiplier allowing
  94087. * rendering at a higher or lower resolution
  94088. * @param successCallback The callback receives a single parameter which contains the
  94089. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  94090. * src parameter of an <img> to display it
  94091. * @param mimeType The MIME type of the screenshot image (default: image/png).
  94092. * Check your browser for supported MIME types
  94093. * @param samples Texture samples (default: 1)
  94094. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  94095. * @param fileName A name for for the downloaded file.
  94096. */
  94097. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  94098. /**
  94099. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  94100. * Be aware Math.random() could cause collisions, but:
  94101. * "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"
  94102. * @returns a pseudo random id
  94103. */
  94104. static RandomId(): string;
  94105. /**
  94106. * Test if the given uri is a base64 string
  94107. * @param uri The uri to test
  94108. * @return True if the uri is a base64 string or false otherwise
  94109. */
  94110. static IsBase64(uri: string): boolean;
  94111. /**
  94112. * Decode the given base64 uri.
  94113. * @param uri The uri to decode
  94114. * @return The decoded base64 data.
  94115. */
  94116. static DecodeBase64(uri: string): ArrayBuffer;
  94117. /**
  94118. * Gets the absolute url.
  94119. * @param url the input url
  94120. * @return the absolute url
  94121. */
  94122. static GetAbsoluteUrl(url: string): string;
  94123. /**
  94124. * No log
  94125. */
  94126. static readonly NoneLogLevel: number;
  94127. /**
  94128. * Only message logs
  94129. */
  94130. static readonly MessageLogLevel: number;
  94131. /**
  94132. * Only warning logs
  94133. */
  94134. static readonly WarningLogLevel: number;
  94135. /**
  94136. * Only error logs
  94137. */
  94138. static readonly ErrorLogLevel: number;
  94139. /**
  94140. * All logs
  94141. */
  94142. static readonly AllLogLevel: number;
  94143. /**
  94144. * Gets a value indicating the number of loading errors
  94145. * @ignorenaming
  94146. */
  94147. static readonly errorsCount: number;
  94148. /**
  94149. * Callback called when a new log is added
  94150. */
  94151. static OnNewCacheEntry: (entry: string) => void;
  94152. /**
  94153. * Log a message to the console
  94154. * @param message defines the message to log
  94155. */
  94156. static Log(message: string): void;
  94157. /**
  94158. * Write a warning message to the console
  94159. * @param message defines the message to log
  94160. */
  94161. static Warn(message: string): void;
  94162. /**
  94163. * Write an error message to the console
  94164. * @param message defines the message to log
  94165. */
  94166. static Error(message: string): void;
  94167. /**
  94168. * Gets current log cache (list of logs)
  94169. */
  94170. static readonly LogCache: string;
  94171. /**
  94172. * Clears the log cache
  94173. */
  94174. static ClearLogCache(): void;
  94175. /**
  94176. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  94177. */
  94178. static LogLevels: number;
  94179. /**
  94180. * Checks if the loaded document was accessed via `file:`-Protocol.
  94181. * @returns boolean
  94182. */
  94183. static IsFileURL(): boolean;
  94184. /**
  94185. * Checks if the window object exists
  94186. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  94187. */
  94188. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  94189. /**
  94190. * No performance log
  94191. */
  94192. static readonly PerformanceNoneLogLevel: number;
  94193. /**
  94194. * Use user marks to log performance
  94195. */
  94196. static readonly PerformanceUserMarkLogLevel: number;
  94197. /**
  94198. * Log performance to the console
  94199. */
  94200. static readonly PerformanceConsoleLogLevel: number;
  94201. private static _performance;
  94202. /**
  94203. * Sets the current performance log level
  94204. */
  94205. static PerformanceLogLevel: number;
  94206. private static _StartPerformanceCounterDisabled;
  94207. private static _EndPerformanceCounterDisabled;
  94208. private static _StartUserMark;
  94209. private static _EndUserMark;
  94210. private static _StartPerformanceConsole;
  94211. private static _EndPerformanceConsole;
  94212. /**
  94213. * Starts a performance counter
  94214. */
  94215. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  94216. /**
  94217. * Ends a specific performance coutner
  94218. */
  94219. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  94220. /**
  94221. * Gets either window.performance.now() if supported or Date.now() else
  94222. */
  94223. static readonly Now: number;
  94224. /**
  94225. * This method will return the name of the class used to create the instance of the given object.
  94226. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  94227. * @param object the object to get the class name from
  94228. * @param isType defines if the object is actually a type
  94229. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  94230. */
  94231. static GetClassName(object: any, isType?: boolean): string;
  94232. /**
  94233. * Gets the first element of an array satisfying a given predicate
  94234. * @param array defines the array to browse
  94235. * @param predicate defines the predicate to use
  94236. * @returns null if not found or the element
  94237. */
  94238. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  94239. /**
  94240. * This method will return the name of the full name of the class, including its owning module (if any).
  94241. * 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).
  94242. * @param object the object to get the class name from
  94243. * @param isType defines if the object is actually a type
  94244. * @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.
  94245. * @ignorenaming
  94246. */
  94247. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  94248. /**
  94249. * Returns a promise that resolves after the given amount of time.
  94250. * @param delay Number of milliseconds to delay
  94251. * @returns Promise that resolves after the given amount of time
  94252. */
  94253. static DelayAsync(delay: number): Promise<void>;
  94254. /**
  94255. * Gets the current gradient from an array of IValueGradient
  94256. * @param ratio defines the current ratio to get
  94257. * @param gradients defines the array of IValueGradient
  94258. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  94259. */
  94260. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  94261. }
  94262. /**
  94263. * This class is used to track a performance counter which is number based.
  94264. * The user has access to many properties which give statistics of different nature.
  94265. *
  94266. * The implementer can track two kinds of Performance Counter: time and count.
  94267. * 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.
  94268. * 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.
  94269. */
  94270. export class PerfCounter {
  94271. /**
  94272. * Gets or sets a global boolean to turn on and off all the counters
  94273. */
  94274. static Enabled: boolean;
  94275. /**
  94276. * Returns the smallest value ever
  94277. */
  94278. readonly min: number;
  94279. /**
  94280. * Returns the biggest value ever
  94281. */
  94282. readonly max: number;
  94283. /**
  94284. * Returns the average value since the performance counter is running
  94285. */
  94286. readonly average: number;
  94287. /**
  94288. * Returns the average value of the last second the counter was monitored
  94289. */
  94290. readonly lastSecAverage: number;
  94291. /**
  94292. * Returns the current value
  94293. */
  94294. readonly current: number;
  94295. /**
  94296. * Gets the accumulated total
  94297. */
  94298. readonly total: number;
  94299. /**
  94300. * Gets the total value count
  94301. */
  94302. readonly count: number;
  94303. /**
  94304. * Creates a new counter
  94305. */
  94306. constructor();
  94307. /**
  94308. * Call this method to start monitoring a new frame.
  94309. * 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.
  94310. */
  94311. fetchNewFrame(): void;
  94312. /**
  94313. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  94314. * @param newCount the count value to add to the monitored count
  94315. * @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.
  94316. */
  94317. addCount(newCount: number, fetchResult: boolean): void;
  94318. /**
  94319. * Start monitoring this performance counter
  94320. */
  94321. beginMonitoring(): void;
  94322. /**
  94323. * Compute the time lapsed since the previous beginMonitoring() call.
  94324. * @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
  94325. */
  94326. endMonitoring(newFrame?: boolean): void;
  94327. private _fetchResult;
  94328. private _startMonitoringTime;
  94329. private _min;
  94330. private _max;
  94331. private _average;
  94332. private _current;
  94333. private _totalValueCount;
  94334. private _totalAccumulated;
  94335. private _lastSecAverage;
  94336. private _lastSecAccumulated;
  94337. private _lastSecTime;
  94338. private _lastSecValueCount;
  94339. }
  94340. /**
  94341. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  94342. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  94343. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  94344. * @param name The name of the class, case should be preserved
  94345. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  94346. */
  94347. export function className(name: string, module?: string): (target: Object) => void;
  94348. /**
  94349. * An implementation of a loop for asynchronous functions.
  94350. */
  94351. export class AsyncLoop {
  94352. /**
  94353. * Defines the number of iterations for the loop
  94354. */
  94355. iterations: number;
  94356. /**
  94357. * Defines the current index of the loop.
  94358. */
  94359. index: number;
  94360. private _done;
  94361. private _fn;
  94362. private _successCallback;
  94363. /**
  94364. * Constructor.
  94365. * @param iterations the number of iterations.
  94366. * @param func the function to run each iteration
  94367. * @param successCallback the callback that will be called upon succesful execution
  94368. * @param offset starting offset.
  94369. */
  94370. constructor(
  94371. /**
  94372. * Defines the number of iterations for the loop
  94373. */
  94374. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  94375. /**
  94376. * Execute the next iteration. Must be called after the last iteration was finished.
  94377. */
  94378. executeNext(): void;
  94379. /**
  94380. * Break the loop and run the success callback.
  94381. */
  94382. breakLoop(): void;
  94383. /**
  94384. * Create and run an async loop.
  94385. * @param iterations the number of iterations.
  94386. * @param fn the function to run each iteration
  94387. * @param successCallback the callback that will be called upon succesful execution
  94388. * @param offset starting offset.
  94389. * @returns the created async loop object
  94390. */
  94391. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  94392. /**
  94393. * A for-loop that will run a given number of iterations synchronous and the rest async.
  94394. * @param iterations total number of iterations
  94395. * @param syncedIterations number of synchronous iterations in each async iteration.
  94396. * @param fn the function to call each iteration.
  94397. * @param callback a success call back that will be called when iterating stops.
  94398. * @param breakFunction a break condition (optional)
  94399. * @param timeout timeout settings for the setTimeout function. default - 0.
  94400. * @returns the created async loop object
  94401. */
  94402. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  94403. }
  94404. }
  94405. declare module BABYLON {
  94406. /** @hidden */
  94407. export interface ICollisionCoordinator {
  94408. createCollider(): Collider;
  94409. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  94410. init(scene: Scene): void;
  94411. }
  94412. /** @hidden */
  94413. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  94414. private _scene;
  94415. private _scaledPosition;
  94416. private _scaledVelocity;
  94417. private _finalPosition;
  94418. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  94419. createCollider(): Collider;
  94420. init(scene: Scene): void;
  94421. private _collideWithWorld;
  94422. }
  94423. }
  94424. declare module BABYLON {
  94425. /**
  94426. * Class used to manage all inputs for the scene.
  94427. */
  94428. export class InputManager {
  94429. /** The distance in pixel that you have to move to prevent some events */
  94430. static DragMovementThreshold: number;
  94431. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  94432. static LongPressDelay: number;
  94433. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  94434. static DoubleClickDelay: number;
  94435. /** If you need to check double click without raising a single click at first click, enable this flag */
  94436. static ExclusiveDoubleClickMode: boolean;
  94437. private _wheelEventName;
  94438. private _onPointerMove;
  94439. private _onPointerDown;
  94440. private _onPointerUp;
  94441. private _initClickEvent;
  94442. private _initActionManager;
  94443. private _delayedSimpleClick;
  94444. private _delayedSimpleClickTimeout;
  94445. private _previousDelayedSimpleClickTimeout;
  94446. private _meshPickProceed;
  94447. private _previousButtonPressed;
  94448. private _currentPickResult;
  94449. private _previousPickResult;
  94450. private _totalPointersPressed;
  94451. private _doubleClickOccured;
  94452. private _pointerOverMesh;
  94453. private _pickedDownMesh;
  94454. private _pickedUpMesh;
  94455. private _pointerX;
  94456. private _pointerY;
  94457. private _unTranslatedPointerX;
  94458. private _unTranslatedPointerY;
  94459. private _startingPointerPosition;
  94460. private _previousStartingPointerPosition;
  94461. private _startingPointerTime;
  94462. private _previousStartingPointerTime;
  94463. private _pointerCaptures;
  94464. private _onKeyDown;
  94465. private _onKeyUp;
  94466. private _onCanvasFocusObserver;
  94467. private _onCanvasBlurObserver;
  94468. private _scene;
  94469. /**
  94470. * Creates a new InputManager
  94471. * @param scene defines the hosting scene
  94472. */
  94473. constructor(scene: Scene);
  94474. /**
  94475. * Gets the mesh that is currently under the pointer
  94476. */
  94477. readonly meshUnderPointer: Nullable<AbstractMesh>;
  94478. /**
  94479. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  94480. */
  94481. readonly unTranslatedPointer: Vector2;
  94482. /**
  94483. * Gets or sets the current on-screen X position of the pointer
  94484. */
  94485. pointerX: number;
  94486. /**
  94487. * Gets or sets the current on-screen Y position of the pointer
  94488. */
  94489. pointerY: number;
  94490. private _updatePointerPosition;
  94491. private _processPointerMove;
  94492. private _setRayOnPointerInfo;
  94493. private _checkPrePointerObservable;
  94494. /**
  94495. * Use this method to simulate a pointer move on a mesh
  94496. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  94497. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  94498. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  94499. */
  94500. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  94501. /**
  94502. * Use this method to simulate a pointer down on a mesh
  94503. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  94504. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  94505. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  94506. */
  94507. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  94508. private _processPointerDown;
  94509. /** @hidden */
  94510. _isPointerSwiping(): boolean;
  94511. /**
  94512. * Use this method to simulate a pointer up on a mesh
  94513. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  94514. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  94515. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  94516. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  94517. */
  94518. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  94519. private _processPointerUp;
  94520. /**
  94521. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  94522. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  94523. * @returns true if the pointer was captured
  94524. */
  94525. isPointerCaptured(pointerId?: number): boolean;
  94526. /**
  94527. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  94528. * @param attachUp defines if you want to attach events to pointerup
  94529. * @param attachDown defines if you want to attach events to pointerdown
  94530. * @param attachMove defines if you want to attach events to pointermove
  94531. */
  94532. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  94533. /**
  94534. * Detaches all event handlers
  94535. */
  94536. detachControl(): void;
  94537. /**
  94538. * Force the value of meshUnderPointer
  94539. * @param mesh defines the mesh to use
  94540. */
  94541. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  94542. /**
  94543. * Gets the mesh under the pointer
  94544. * @returns a Mesh or null if no mesh is under the pointer
  94545. */
  94546. getPointerOverMesh(): Nullable<AbstractMesh>;
  94547. }
  94548. }
  94549. declare module BABYLON {
  94550. /**
  94551. * This class defines the direct association between an animation and a target
  94552. */
  94553. export class TargetedAnimation {
  94554. /**
  94555. * Animation to perform
  94556. */
  94557. animation: Animation;
  94558. /**
  94559. * Target to animate
  94560. */
  94561. target: any;
  94562. /**
  94563. * Serialize the object
  94564. * @returns the JSON object representing the current entity
  94565. */
  94566. serialize(): any;
  94567. }
  94568. /**
  94569. * Use this class to create coordinated animations on multiple targets
  94570. */
  94571. export class AnimationGroup implements IDisposable {
  94572. /** The name of the animation group */
  94573. name: string;
  94574. private _scene;
  94575. private _targetedAnimations;
  94576. private _animatables;
  94577. private _from;
  94578. private _to;
  94579. private _isStarted;
  94580. private _isPaused;
  94581. private _speedRatio;
  94582. private _loopAnimation;
  94583. /**
  94584. * Gets or sets the unique id of the node
  94585. */
  94586. uniqueId: number;
  94587. /**
  94588. * This observable will notify when one animation have ended
  94589. */
  94590. onAnimationEndObservable: Observable<TargetedAnimation>;
  94591. /**
  94592. * Observer raised when one animation loops
  94593. */
  94594. onAnimationLoopObservable: Observable<TargetedAnimation>;
  94595. /**
  94596. * This observable will notify when all animations have ended.
  94597. */
  94598. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  94599. /**
  94600. * This observable will notify when all animations have paused.
  94601. */
  94602. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  94603. /**
  94604. * This observable will notify when all animations are playing.
  94605. */
  94606. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  94607. /**
  94608. * Gets the first frame
  94609. */
  94610. readonly from: number;
  94611. /**
  94612. * Gets the last frame
  94613. */
  94614. readonly to: number;
  94615. /**
  94616. * Define if the animations are started
  94617. */
  94618. readonly isStarted: boolean;
  94619. /**
  94620. * Gets a value indicating that the current group is playing
  94621. */
  94622. readonly isPlaying: boolean;
  94623. /**
  94624. * Gets or sets the speed ratio to use for all animations
  94625. */
  94626. /**
  94627. * Gets or sets the speed ratio to use for all animations
  94628. */
  94629. speedRatio: number;
  94630. /**
  94631. * Gets or sets if all animations should loop or not
  94632. */
  94633. loopAnimation: boolean;
  94634. /**
  94635. * Gets the targeted animations for this animation group
  94636. */
  94637. readonly targetedAnimations: Array<TargetedAnimation>;
  94638. /**
  94639. * returning the list of animatables controlled by this animation group.
  94640. */
  94641. readonly animatables: Array<Animatable>;
  94642. /**
  94643. * Instantiates a new Animation Group.
  94644. * This helps managing several animations at once.
  94645. * @see http://doc.babylonjs.com/how_to/group
  94646. * @param name Defines the name of the group
  94647. * @param scene Defines the scene the group belongs to
  94648. */
  94649. constructor(
  94650. /** The name of the animation group */
  94651. name: string, scene?: Nullable<Scene>);
  94652. /**
  94653. * Add an animation (with its target) in the group
  94654. * @param animation defines the animation we want to add
  94655. * @param target defines the target of the animation
  94656. * @returns the TargetedAnimation object
  94657. */
  94658. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  94659. /**
  94660. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  94661. * It can add constant keys at begin or end
  94662. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  94663. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  94664. * @returns the animation group
  94665. */
  94666. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  94667. /**
  94668. * Start all animations on given targets
  94669. * @param loop defines if animations must loop
  94670. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  94671. * @param from defines the from key (optional)
  94672. * @param to defines the to key (optional)
  94673. * @returns the current animation group
  94674. */
  94675. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  94676. /**
  94677. * Pause all animations
  94678. * @returns the animation group
  94679. */
  94680. pause(): AnimationGroup;
  94681. /**
  94682. * Play all animations to initial state
  94683. * This function will start() the animations if they were not started or will restart() them if they were paused
  94684. * @param loop defines if animations must loop
  94685. * @returns the animation group
  94686. */
  94687. play(loop?: boolean): AnimationGroup;
  94688. /**
  94689. * Reset all animations to initial state
  94690. * @returns the animation group
  94691. */
  94692. reset(): AnimationGroup;
  94693. /**
  94694. * Restart animations from key 0
  94695. * @returns the animation group
  94696. */
  94697. restart(): AnimationGroup;
  94698. /**
  94699. * Stop all animations
  94700. * @returns the animation group
  94701. */
  94702. stop(): AnimationGroup;
  94703. /**
  94704. * Set animation weight for all animatables
  94705. * @param weight defines the weight to use
  94706. * @return the animationGroup
  94707. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  94708. */
  94709. setWeightForAllAnimatables(weight: number): AnimationGroup;
  94710. /**
  94711. * Synchronize and normalize all animatables with a source animatable
  94712. * @param root defines the root animatable to synchronize with
  94713. * @return the animationGroup
  94714. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  94715. */
  94716. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  94717. /**
  94718. * Goes to a specific frame in this animation group
  94719. * @param frame the frame number to go to
  94720. * @return the animationGroup
  94721. */
  94722. goToFrame(frame: number): AnimationGroup;
  94723. /**
  94724. * Dispose all associated resources
  94725. */
  94726. dispose(): void;
  94727. private _checkAnimationGroupEnded;
  94728. /**
  94729. * Clone the current animation group and returns a copy
  94730. * @param newName defines the name of the new group
  94731. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  94732. * @returns the new aniamtion group
  94733. */
  94734. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  94735. /**
  94736. * Serializes the animationGroup to an object
  94737. * @returns Serialized object
  94738. */
  94739. serialize(): any;
  94740. /**
  94741. * Returns a new AnimationGroup object parsed from the source provided.
  94742. * @param parsedAnimationGroup defines the source
  94743. * @param scene defines the scene that will receive the animationGroup
  94744. * @returns a new AnimationGroup
  94745. */
  94746. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  94747. /**
  94748. * Returns the string "AnimationGroup"
  94749. * @returns "AnimationGroup"
  94750. */
  94751. getClassName(): string;
  94752. /**
  94753. * Creates a detailled string about the object
  94754. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  94755. * @returns a string representing the object
  94756. */
  94757. toString(fullDetails?: boolean): string;
  94758. }
  94759. }
  94760. declare module BABYLON {
  94761. /**
  94762. * Define an interface for all classes that will hold resources
  94763. */
  94764. export interface IDisposable {
  94765. /**
  94766. * Releases all held resources
  94767. */
  94768. dispose(): void;
  94769. }
  94770. /** Interface defining initialization parameters for Scene class */
  94771. export interface SceneOptions {
  94772. /**
  94773. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  94774. * It will improve performance when the number of geometries becomes important.
  94775. */
  94776. useGeometryUniqueIdsMap?: boolean;
  94777. /**
  94778. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  94779. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  94780. */
  94781. useMaterialMeshMap?: boolean;
  94782. /**
  94783. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  94784. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  94785. */
  94786. useClonedMeshhMap?: boolean;
  94787. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  94788. virtual?: boolean;
  94789. }
  94790. /**
  94791. * Represents a scene to be rendered by the engine.
  94792. * @see http://doc.babylonjs.com/features/scene
  94793. */
  94794. export class Scene extends AbstractScene implements IAnimatable {
  94795. private static _uniqueIdCounter;
  94796. /** The fog is deactivated */
  94797. static readonly FOGMODE_NONE: number;
  94798. /** The fog density is following an exponential function */
  94799. static readonly FOGMODE_EXP: number;
  94800. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  94801. static readonly FOGMODE_EXP2: number;
  94802. /** The fog density is following a linear function. */
  94803. static readonly FOGMODE_LINEAR: number;
  94804. /**
  94805. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  94806. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  94807. */
  94808. static MinDeltaTime: number;
  94809. /**
  94810. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  94811. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  94812. */
  94813. static MaxDeltaTime: number;
  94814. /**
  94815. * Factory used to create the default material.
  94816. * @param name The name of the material to create
  94817. * @param scene The scene to create the material for
  94818. * @returns The default material
  94819. */
  94820. static DefaultMaterialFactory(scene: Scene): Material;
  94821. /**
  94822. * Factory used to create the a collision coordinator.
  94823. * @returns The collision coordinator
  94824. */
  94825. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  94826. /** @hidden */
  94827. _inputManager: InputManager;
  94828. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  94829. cameraToUseForPointers: Nullable<Camera>;
  94830. /** @hidden */
  94831. readonly _isScene: boolean;
  94832. /**
  94833. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  94834. */
  94835. autoClear: boolean;
  94836. /**
  94837. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  94838. */
  94839. autoClearDepthAndStencil: boolean;
  94840. /**
  94841. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  94842. */
  94843. clearColor: Color4;
  94844. /**
  94845. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  94846. */
  94847. ambientColor: Color3;
  94848. /**
  94849. * This is use to store the default BRDF lookup for PBR materials in your scene.
  94850. * It should only be one of the following (if not the default embedded one):
  94851. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  94852. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  94853. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  94854. * The material properties need to be setup according to the type of texture in use.
  94855. */
  94856. environmentBRDFTexture: BaseTexture;
  94857. /** @hidden */
  94858. protected _environmentTexture: Nullable<BaseTexture>;
  94859. /**
  94860. * Texture used in all pbr material as the reflection texture.
  94861. * As in the majority of the scene they are the same (exception for multi room and so on),
  94862. * this is easier to reference from here than from all the materials.
  94863. */
  94864. /**
  94865. * Texture used in all pbr material as the reflection texture.
  94866. * As in the majority of the scene they are the same (exception for multi room and so on),
  94867. * this is easier to set here than in all the materials.
  94868. */
  94869. environmentTexture: Nullable<BaseTexture>;
  94870. /** @hidden */
  94871. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  94872. /**
  94873. * Default image processing configuration used either in the rendering
  94874. * Forward main pass or through the imageProcessingPostProcess if present.
  94875. * As in the majority of the scene they are the same (exception for multi camera),
  94876. * this is easier to reference from here than from all the materials and post process.
  94877. *
  94878. * No setter as we it is a shared configuration, you can set the values instead.
  94879. */
  94880. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  94881. private _forceWireframe;
  94882. /**
  94883. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  94884. */
  94885. forceWireframe: boolean;
  94886. private _forcePointsCloud;
  94887. /**
  94888. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  94889. */
  94890. forcePointsCloud: boolean;
  94891. /**
  94892. * Gets or sets the active clipplane 1
  94893. */
  94894. clipPlane: Nullable<Plane>;
  94895. /**
  94896. * Gets or sets the active clipplane 2
  94897. */
  94898. clipPlane2: Nullable<Plane>;
  94899. /**
  94900. * Gets or sets the active clipplane 3
  94901. */
  94902. clipPlane3: Nullable<Plane>;
  94903. /**
  94904. * Gets or sets the active clipplane 4
  94905. */
  94906. clipPlane4: Nullable<Plane>;
  94907. /**
  94908. * Gets or sets a boolean indicating if animations are enabled
  94909. */
  94910. animationsEnabled: boolean;
  94911. private _animationPropertiesOverride;
  94912. /**
  94913. * Gets or sets the animation properties override
  94914. */
  94915. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  94916. /**
  94917. * Gets or sets a boolean indicating if a constant deltatime has to be used
  94918. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  94919. */
  94920. useConstantAnimationDeltaTime: boolean;
  94921. /**
  94922. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  94923. * Please note that it requires to run a ray cast through the scene on every frame
  94924. */
  94925. constantlyUpdateMeshUnderPointer: boolean;
  94926. /**
  94927. * Defines the HTML cursor to use when hovering over interactive elements
  94928. */
  94929. hoverCursor: string;
  94930. /**
  94931. * Defines the HTML default cursor to use (empty by default)
  94932. */
  94933. defaultCursor: string;
  94934. /**
  94935. * This is used to call preventDefault() on pointer down
  94936. * in order to block unwanted artifacts like system double clicks
  94937. */
  94938. preventDefaultOnPointerDown: boolean;
  94939. /**
  94940. * This is used to call preventDefault() on pointer up
  94941. * in order to block unwanted artifacts like system double clicks
  94942. */
  94943. preventDefaultOnPointerUp: boolean;
  94944. /**
  94945. * Gets or sets user defined metadata
  94946. */
  94947. metadata: any;
  94948. /**
  94949. * For internal use only. Please do not use.
  94950. */
  94951. reservedDataStore: any;
  94952. /**
  94953. * Gets the name of the plugin used to load this scene (null by default)
  94954. */
  94955. loadingPluginName: string;
  94956. /**
  94957. * Use this array to add regular expressions used to disable offline support for specific urls
  94958. */
  94959. disableOfflineSupportExceptionRules: RegExp[];
  94960. /**
  94961. * An event triggered when the scene is disposed.
  94962. */
  94963. onDisposeObservable: Observable<Scene>;
  94964. private _onDisposeObserver;
  94965. /** Sets a function to be executed when this scene is disposed. */
  94966. onDispose: () => void;
  94967. /**
  94968. * An event triggered before rendering the scene (right after animations and physics)
  94969. */
  94970. onBeforeRenderObservable: Observable<Scene>;
  94971. private _onBeforeRenderObserver;
  94972. /** Sets a function to be executed before rendering this scene */
  94973. beforeRender: Nullable<() => void>;
  94974. /**
  94975. * An event triggered after rendering the scene
  94976. */
  94977. onAfterRenderObservable: Observable<Scene>;
  94978. /**
  94979. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  94980. */
  94981. onAfterRenderCameraObservable: Observable<Camera>;
  94982. private _onAfterRenderObserver;
  94983. /** Sets a function to be executed after rendering this scene */
  94984. afterRender: Nullable<() => void>;
  94985. /**
  94986. * An event triggered before animating the scene
  94987. */
  94988. onBeforeAnimationsObservable: Observable<Scene>;
  94989. /**
  94990. * An event triggered after animations processing
  94991. */
  94992. onAfterAnimationsObservable: Observable<Scene>;
  94993. /**
  94994. * An event triggered before draw calls are ready to be sent
  94995. */
  94996. onBeforeDrawPhaseObservable: Observable<Scene>;
  94997. /**
  94998. * An event triggered after draw calls have been sent
  94999. */
  95000. onAfterDrawPhaseObservable: Observable<Scene>;
  95001. /**
  95002. * An event triggered when the scene is ready
  95003. */
  95004. onReadyObservable: Observable<Scene>;
  95005. /**
  95006. * An event triggered before rendering a camera
  95007. */
  95008. onBeforeCameraRenderObservable: Observable<Camera>;
  95009. private _onBeforeCameraRenderObserver;
  95010. /** Sets a function to be executed before rendering a camera*/
  95011. beforeCameraRender: () => void;
  95012. /**
  95013. * An event triggered after rendering a camera
  95014. */
  95015. onAfterCameraRenderObservable: Observable<Camera>;
  95016. private _onAfterCameraRenderObserver;
  95017. /** Sets a function to be executed after rendering a camera*/
  95018. afterCameraRender: () => void;
  95019. /**
  95020. * An event triggered when active meshes evaluation is about to start
  95021. */
  95022. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  95023. /**
  95024. * An event triggered when active meshes evaluation is done
  95025. */
  95026. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  95027. /**
  95028. * An event triggered when particles rendering is about to start
  95029. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  95030. */
  95031. onBeforeParticlesRenderingObservable: Observable<Scene>;
  95032. /**
  95033. * An event triggered when particles rendering is done
  95034. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  95035. */
  95036. onAfterParticlesRenderingObservable: Observable<Scene>;
  95037. /**
  95038. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  95039. */
  95040. onDataLoadedObservable: Observable<Scene>;
  95041. /**
  95042. * An event triggered when a camera is created
  95043. */
  95044. onNewCameraAddedObservable: Observable<Camera>;
  95045. /**
  95046. * An event triggered when a camera is removed
  95047. */
  95048. onCameraRemovedObservable: Observable<Camera>;
  95049. /**
  95050. * An event triggered when a light is created
  95051. */
  95052. onNewLightAddedObservable: Observable<Light>;
  95053. /**
  95054. * An event triggered when a light is removed
  95055. */
  95056. onLightRemovedObservable: Observable<Light>;
  95057. /**
  95058. * An event triggered when a geometry is created
  95059. */
  95060. onNewGeometryAddedObservable: Observable<Geometry>;
  95061. /**
  95062. * An event triggered when a geometry is removed
  95063. */
  95064. onGeometryRemovedObservable: Observable<Geometry>;
  95065. /**
  95066. * An event triggered when a transform node is created
  95067. */
  95068. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  95069. /**
  95070. * An event triggered when a transform node is removed
  95071. */
  95072. onTransformNodeRemovedObservable: Observable<TransformNode>;
  95073. /**
  95074. * An event triggered when a mesh is created
  95075. */
  95076. onNewMeshAddedObservable: Observable<AbstractMesh>;
  95077. /**
  95078. * An event triggered when a mesh is removed
  95079. */
  95080. onMeshRemovedObservable: Observable<AbstractMesh>;
  95081. /**
  95082. * An event triggered when a skeleton is created
  95083. */
  95084. onNewSkeletonAddedObservable: Observable<Skeleton>;
  95085. /**
  95086. * An event triggered when a skeleton is removed
  95087. */
  95088. onSkeletonRemovedObservable: Observable<Skeleton>;
  95089. /**
  95090. * An event triggered when a material is created
  95091. */
  95092. onNewMaterialAddedObservable: Observable<Material>;
  95093. /**
  95094. * An event triggered when a material is removed
  95095. */
  95096. onMaterialRemovedObservable: Observable<Material>;
  95097. /**
  95098. * An event triggered when a texture is created
  95099. */
  95100. onNewTextureAddedObservable: Observable<BaseTexture>;
  95101. /**
  95102. * An event triggered when a texture is removed
  95103. */
  95104. onTextureRemovedObservable: Observable<BaseTexture>;
  95105. /**
  95106. * An event triggered when render targets are about to be rendered
  95107. * Can happen multiple times per frame.
  95108. */
  95109. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  95110. /**
  95111. * An event triggered when render targets were rendered.
  95112. * Can happen multiple times per frame.
  95113. */
  95114. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  95115. /**
  95116. * An event triggered before calculating deterministic simulation step
  95117. */
  95118. onBeforeStepObservable: Observable<Scene>;
  95119. /**
  95120. * An event triggered after calculating deterministic simulation step
  95121. */
  95122. onAfterStepObservable: Observable<Scene>;
  95123. /**
  95124. * An event triggered when the activeCamera property is updated
  95125. */
  95126. onActiveCameraChanged: Observable<Scene>;
  95127. /**
  95128. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  95129. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  95130. * 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)
  95131. */
  95132. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  95133. /**
  95134. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  95135. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  95136. * 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)
  95137. */
  95138. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  95139. /**
  95140. * This Observable will when a mesh has been imported into the scene.
  95141. */
  95142. onMeshImportedObservable: Observable<AbstractMesh>;
  95143. /**
  95144. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  95145. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  95146. */
  95147. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  95148. /** @hidden */
  95149. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  95150. /**
  95151. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  95152. */
  95153. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  95154. /**
  95155. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  95156. */
  95157. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  95158. /**
  95159. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  95160. */
  95161. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  95162. /** Callback called when a pointer move is detected */
  95163. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  95164. /** Callback called when a pointer down is detected */
  95165. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  95166. /** Callback called when a pointer up is detected */
  95167. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  95168. /** Callback called when a pointer pick is detected */
  95169. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  95170. /**
  95171. * 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).
  95172. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  95173. */
  95174. onPrePointerObservable: Observable<PointerInfoPre>;
  95175. /**
  95176. * Observable event triggered each time an input event is received from the rendering canvas
  95177. */
  95178. onPointerObservable: Observable<PointerInfo>;
  95179. /**
  95180. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  95181. */
  95182. readonly unTranslatedPointer: Vector2;
  95183. /**
  95184. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  95185. */
  95186. static DragMovementThreshold: number;
  95187. /**
  95188. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  95189. */
  95190. static LongPressDelay: number;
  95191. /**
  95192. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  95193. */
  95194. static DoubleClickDelay: number;
  95195. /** If you need to check double click without raising a single click at first click, enable this flag */
  95196. static ExclusiveDoubleClickMode: boolean;
  95197. /** @hidden */
  95198. _mirroredCameraPosition: Nullable<Vector3>;
  95199. /**
  95200. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  95201. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  95202. */
  95203. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  95204. /**
  95205. * Observable event triggered each time an keyboard event is received from the hosting window
  95206. */
  95207. onKeyboardObservable: Observable<KeyboardInfo>;
  95208. private _useRightHandedSystem;
  95209. /**
  95210. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  95211. */
  95212. useRightHandedSystem: boolean;
  95213. private _timeAccumulator;
  95214. private _currentStepId;
  95215. private _currentInternalStep;
  95216. /**
  95217. * Sets the step Id used by deterministic lock step
  95218. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95219. * @param newStepId defines the step Id
  95220. */
  95221. setStepId(newStepId: number): void;
  95222. /**
  95223. * Gets the step Id used by deterministic lock step
  95224. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95225. * @returns the step Id
  95226. */
  95227. getStepId(): number;
  95228. /**
  95229. * Gets the internal step used by deterministic lock step
  95230. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95231. * @returns the internal step
  95232. */
  95233. getInternalStep(): number;
  95234. private _fogEnabled;
  95235. /**
  95236. * Gets or sets a boolean indicating if fog is enabled on this scene
  95237. * @see http://doc.babylonjs.com/babylon101/environment#fog
  95238. * (Default is true)
  95239. */
  95240. fogEnabled: boolean;
  95241. private _fogMode;
  95242. /**
  95243. * Gets or sets the fog mode to use
  95244. * @see http://doc.babylonjs.com/babylon101/environment#fog
  95245. * | mode | value |
  95246. * | --- | --- |
  95247. * | FOGMODE_NONE | 0 |
  95248. * | FOGMODE_EXP | 1 |
  95249. * | FOGMODE_EXP2 | 2 |
  95250. * | FOGMODE_LINEAR | 3 |
  95251. */
  95252. fogMode: number;
  95253. /**
  95254. * Gets or sets the fog color to use
  95255. * @see http://doc.babylonjs.com/babylon101/environment#fog
  95256. * (Default is Color3(0.2, 0.2, 0.3))
  95257. */
  95258. fogColor: Color3;
  95259. /**
  95260. * Gets or sets the fog density to use
  95261. * @see http://doc.babylonjs.com/babylon101/environment#fog
  95262. * (Default is 0.1)
  95263. */
  95264. fogDensity: number;
  95265. /**
  95266. * Gets or sets the fog start distance to use
  95267. * @see http://doc.babylonjs.com/babylon101/environment#fog
  95268. * (Default is 0)
  95269. */
  95270. fogStart: number;
  95271. /**
  95272. * Gets or sets the fog end distance to use
  95273. * @see http://doc.babylonjs.com/babylon101/environment#fog
  95274. * (Default is 1000)
  95275. */
  95276. fogEnd: number;
  95277. private _shadowsEnabled;
  95278. /**
  95279. * Gets or sets a boolean indicating if shadows are enabled on this scene
  95280. */
  95281. shadowsEnabled: boolean;
  95282. private _lightsEnabled;
  95283. /**
  95284. * Gets or sets a boolean indicating if lights are enabled on this scene
  95285. */
  95286. lightsEnabled: boolean;
  95287. /** All of the active cameras added to this scene. */
  95288. activeCameras: Camera[];
  95289. /** @hidden */
  95290. _activeCamera: Nullable<Camera>;
  95291. /** Gets or sets the current active camera */
  95292. activeCamera: Nullable<Camera>;
  95293. private _defaultMaterial;
  95294. /** The default material used on meshes when no material is affected */
  95295. /** The default material used on meshes when no material is affected */
  95296. defaultMaterial: Material;
  95297. private _texturesEnabled;
  95298. /**
  95299. * Gets or sets a boolean indicating if textures are enabled on this scene
  95300. */
  95301. texturesEnabled: boolean;
  95302. /**
  95303. * Gets or sets a boolean indicating if particles are enabled on this scene
  95304. */
  95305. particlesEnabled: boolean;
  95306. /**
  95307. * Gets or sets a boolean indicating if sprites are enabled on this scene
  95308. */
  95309. spritesEnabled: boolean;
  95310. private _skeletonsEnabled;
  95311. /**
  95312. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  95313. */
  95314. skeletonsEnabled: boolean;
  95315. /**
  95316. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  95317. */
  95318. lensFlaresEnabled: boolean;
  95319. /**
  95320. * Gets or sets a boolean indicating if collisions are enabled on this scene
  95321. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  95322. */
  95323. collisionsEnabled: boolean;
  95324. private _collisionCoordinator;
  95325. /** @hidden */
  95326. readonly collisionCoordinator: ICollisionCoordinator;
  95327. /**
  95328. * Defines the gravity applied to this scene (used only for collisions)
  95329. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  95330. */
  95331. gravity: Vector3;
  95332. /**
  95333. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  95334. */
  95335. postProcessesEnabled: boolean;
  95336. /**
  95337. * The list of postprocesses added to the scene
  95338. */
  95339. postProcesses: PostProcess[];
  95340. /**
  95341. * Gets the current postprocess manager
  95342. */
  95343. postProcessManager: PostProcessManager;
  95344. /**
  95345. * Gets or sets a boolean indicating if render targets are enabled on this scene
  95346. */
  95347. renderTargetsEnabled: boolean;
  95348. /**
  95349. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  95350. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  95351. */
  95352. dumpNextRenderTargets: boolean;
  95353. /**
  95354. * The list of user defined render targets added to the scene
  95355. */
  95356. customRenderTargets: RenderTargetTexture[];
  95357. /**
  95358. * Defines if texture loading must be delayed
  95359. * If true, textures will only be loaded when they need to be rendered
  95360. */
  95361. useDelayedTextureLoading: boolean;
  95362. /**
  95363. * Gets the list of meshes imported to the scene through SceneLoader
  95364. */
  95365. importedMeshesFiles: String[];
  95366. /**
  95367. * Gets or sets a boolean indicating if probes are enabled on this scene
  95368. */
  95369. probesEnabled: boolean;
  95370. /**
  95371. * Gets or sets the current offline provider to use to store scene data
  95372. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  95373. */
  95374. offlineProvider: IOfflineProvider;
  95375. /**
  95376. * Gets or sets the action manager associated with the scene
  95377. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  95378. */
  95379. actionManager: AbstractActionManager;
  95380. private _meshesForIntersections;
  95381. /**
  95382. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  95383. */
  95384. proceduralTexturesEnabled: boolean;
  95385. private _engine;
  95386. private _totalVertices;
  95387. /** @hidden */
  95388. _activeIndices: PerfCounter;
  95389. /** @hidden */
  95390. _activeParticles: PerfCounter;
  95391. /** @hidden */
  95392. _activeBones: PerfCounter;
  95393. private _animationRatio;
  95394. /** @hidden */
  95395. _animationTimeLast: number;
  95396. /** @hidden */
  95397. _animationTime: number;
  95398. /**
  95399. * Gets or sets a general scale for animation speed
  95400. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  95401. */
  95402. animationTimeScale: number;
  95403. /** @hidden */
  95404. _cachedMaterial: Nullable<Material>;
  95405. /** @hidden */
  95406. _cachedEffect: Nullable<Effect>;
  95407. /** @hidden */
  95408. _cachedVisibility: Nullable<number>;
  95409. private _renderId;
  95410. private _frameId;
  95411. private _executeWhenReadyTimeoutId;
  95412. private _intermediateRendering;
  95413. private _viewUpdateFlag;
  95414. private _projectionUpdateFlag;
  95415. /** @hidden */
  95416. _toBeDisposed: Nullable<IDisposable>[];
  95417. private _activeRequests;
  95418. /** @hidden */
  95419. _pendingData: any[];
  95420. private _isDisposed;
  95421. /**
  95422. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  95423. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  95424. */
  95425. dispatchAllSubMeshesOfActiveMeshes: boolean;
  95426. private _activeMeshes;
  95427. private _processedMaterials;
  95428. private _renderTargets;
  95429. /** @hidden */
  95430. _activeParticleSystems: SmartArray<IParticleSystem>;
  95431. private _activeSkeletons;
  95432. private _softwareSkinnedMeshes;
  95433. private _renderingManager;
  95434. /** @hidden */
  95435. _activeAnimatables: Animatable[];
  95436. private _transformMatrix;
  95437. private _sceneUbo;
  95438. /** @hidden */
  95439. _viewMatrix: Matrix;
  95440. private _projectionMatrix;
  95441. /** @hidden */
  95442. _forcedViewPosition: Nullable<Vector3>;
  95443. /** @hidden */
  95444. _frustumPlanes: Plane[];
  95445. /**
  95446. * Gets the list of frustum planes (built from the active camera)
  95447. */
  95448. readonly frustumPlanes: Plane[];
  95449. /**
  95450. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  95451. * This is useful if there are more lights that the maximum simulteanous authorized
  95452. */
  95453. requireLightSorting: boolean;
  95454. /** @hidden */
  95455. readonly useMaterialMeshMap: boolean;
  95456. /** @hidden */
  95457. readonly useClonedMeshhMap: boolean;
  95458. private _externalData;
  95459. private _uid;
  95460. /**
  95461. * @hidden
  95462. * Backing store of defined scene components.
  95463. */
  95464. _components: ISceneComponent[];
  95465. /**
  95466. * @hidden
  95467. * Backing store of defined scene components.
  95468. */
  95469. _serializableComponents: ISceneSerializableComponent[];
  95470. /**
  95471. * List of components to register on the next registration step.
  95472. */
  95473. private _transientComponents;
  95474. /**
  95475. * Registers the transient components if needed.
  95476. */
  95477. private _registerTransientComponents;
  95478. /**
  95479. * @hidden
  95480. * Add a component to the scene.
  95481. * Note that the ccomponent could be registered on th next frame if this is called after
  95482. * the register component stage.
  95483. * @param component Defines the component to add to the scene
  95484. */
  95485. _addComponent(component: ISceneComponent): void;
  95486. /**
  95487. * @hidden
  95488. * Gets a component from the scene.
  95489. * @param name defines the name of the component to retrieve
  95490. * @returns the component or null if not present
  95491. */
  95492. _getComponent(name: string): Nullable<ISceneComponent>;
  95493. /**
  95494. * @hidden
  95495. * Defines the actions happening before camera updates.
  95496. */
  95497. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  95498. /**
  95499. * @hidden
  95500. * Defines the actions happening before clear the canvas.
  95501. */
  95502. _beforeClearStage: Stage<SimpleStageAction>;
  95503. /**
  95504. * @hidden
  95505. * Defines the actions when collecting render targets for the frame.
  95506. */
  95507. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  95508. /**
  95509. * @hidden
  95510. * Defines the actions happening for one camera in the frame.
  95511. */
  95512. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  95513. /**
  95514. * @hidden
  95515. * Defines the actions happening during the per mesh ready checks.
  95516. */
  95517. _isReadyForMeshStage: Stage<MeshStageAction>;
  95518. /**
  95519. * @hidden
  95520. * Defines the actions happening before evaluate active mesh checks.
  95521. */
  95522. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  95523. /**
  95524. * @hidden
  95525. * Defines the actions happening during the evaluate sub mesh checks.
  95526. */
  95527. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  95528. /**
  95529. * @hidden
  95530. * Defines the actions happening during the active mesh stage.
  95531. */
  95532. _activeMeshStage: Stage<ActiveMeshStageAction>;
  95533. /**
  95534. * @hidden
  95535. * Defines the actions happening during the per camera render target step.
  95536. */
  95537. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  95538. /**
  95539. * @hidden
  95540. * Defines the actions happening just before the active camera is drawing.
  95541. */
  95542. _beforeCameraDrawStage: Stage<CameraStageAction>;
  95543. /**
  95544. * @hidden
  95545. * Defines the actions happening just before a render target is drawing.
  95546. */
  95547. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  95548. /**
  95549. * @hidden
  95550. * Defines the actions happening just before a rendering group is drawing.
  95551. */
  95552. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  95553. /**
  95554. * @hidden
  95555. * Defines the actions happening just before a mesh is drawing.
  95556. */
  95557. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  95558. /**
  95559. * @hidden
  95560. * Defines the actions happening just after a mesh has been drawn.
  95561. */
  95562. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  95563. /**
  95564. * @hidden
  95565. * Defines the actions happening just after a rendering group has been drawn.
  95566. */
  95567. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  95568. /**
  95569. * @hidden
  95570. * Defines the actions happening just after the active camera has been drawn.
  95571. */
  95572. _afterCameraDrawStage: Stage<CameraStageAction>;
  95573. /**
  95574. * @hidden
  95575. * Defines the actions happening just after a render target has been drawn.
  95576. */
  95577. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  95578. /**
  95579. * @hidden
  95580. * Defines the actions happening just after rendering all cameras and computing intersections.
  95581. */
  95582. _afterRenderStage: Stage<SimpleStageAction>;
  95583. /**
  95584. * @hidden
  95585. * Defines the actions happening when a pointer move event happens.
  95586. */
  95587. _pointerMoveStage: Stage<PointerMoveStageAction>;
  95588. /**
  95589. * @hidden
  95590. * Defines the actions happening when a pointer down event happens.
  95591. */
  95592. _pointerDownStage: Stage<PointerUpDownStageAction>;
  95593. /**
  95594. * @hidden
  95595. * Defines the actions happening when a pointer up event happens.
  95596. */
  95597. _pointerUpStage: Stage<PointerUpDownStageAction>;
  95598. /**
  95599. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  95600. */
  95601. private geometriesByUniqueId;
  95602. /**
  95603. * Creates a new Scene
  95604. * @param engine defines the engine to use to render this scene
  95605. * @param options defines the scene options
  95606. */
  95607. constructor(engine: Engine, options?: SceneOptions);
  95608. /**
  95609. * Gets a string idenfifying the name of the class
  95610. * @returns "Scene" string
  95611. */
  95612. getClassName(): string;
  95613. private _defaultMeshCandidates;
  95614. /**
  95615. * @hidden
  95616. */
  95617. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  95618. private _defaultSubMeshCandidates;
  95619. /**
  95620. * @hidden
  95621. */
  95622. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  95623. /**
  95624. * Sets the default candidate providers for the scene.
  95625. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  95626. * and getCollidingSubMeshCandidates to their default function
  95627. */
  95628. setDefaultCandidateProviders(): void;
  95629. /**
  95630. * Gets the mesh that is currently under the pointer
  95631. */
  95632. readonly meshUnderPointer: Nullable<AbstractMesh>;
  95633. /**
  95634. * Gets or sets the current on-screen X position of the pointer
  95635. */
  95636. pointerX: number;
  95637. /**
  95638. * Gets or sets the current on-screen Y position of the pointer
  95639. */
  95640. pointerY: number;
  95641. /**
  95642. * Gets the cached material (ie. the latest rendered one)
  95643. * @returns the cached material
  95644. */
  95645. getCachedMaterial(): Nullable<Material>;
  95646. /**
  95647. * Gets the cached effect (ie. the latest rendered one)
  95648. * @returns the cached effect
  95649. */
  95650. getCachedEffect(): Nullable<Effect>;
  95651. /**
  95652. * Gets the cached visibility state (ie. the latest rendered one)
  95653. * @returns the cached visibility state
  95654. */
  95655. getCachedVisibility(): Nullable<number>;
  95656. /**
  95657. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  95658. * @param material defines the current material
  95659. * @param effect defines the current effect
  95660. * @param visibility defines the current visibility state
  95661. * @returns true if one parameter is not cached
  95662. */
  95663. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  95664. /**
  95665. * Gets the engine associated with the scene
  95666. * @returns an Engine
  95667. */
  95668. getEngine(): Engine;
  95669. /**
  95670. * Gets the total number of vertices rendered per frame
  95671. * @returns the total number of vertices rendered per frame
  95672. */
  95673. getTotalVertices(): number;
  95674. /**
  95675. * Gets the performance counter for total vertices
  95676. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  95677. */
  95678. readonly totalVerticesPerfCounter: PerfCounter;
  95679. /**
  95680. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  95681. * @returns the total number of active indices rendered per frame
  95682. */
  95683. getActiveIndices(): number;
  95684. /**
  95685. * Gets the performance counter for active indices
  95686. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  95687. */
  95688. readonly totalActiveIndicesPerfCounter: PerfCounter;
  95689. /**
  95690. * Gets the total number of active particles rendered per frame
  95691. * @returns the total number of active particles rendered per frame
  95692. */
  95693. getActiveParticles(): number;
  95694. /**
  95695. * Gets the performance counter for active particles
  95696. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  95697. */
  95698. readonly activeParticlesPerfCounter: PerfCounter;
  95699. /**
  95700. * Gets the total number of active bones rendered per frame
  95701. * @returns the total number of active bones rendered per frame
  95702. */
  95703. getActiveBones(): number;
  95704. /**
  95705. * Gets the performance counter for active bones
  95706. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  95707. */
  95708. readonly activeBonesPerfCounter: PerfCounter;
  95709. /**
  95710. * Gets the array of active meshes
  95711. * @returns an array of AbstractMesh
  95712. */
  95713. getActiveMeshes(): SmartArray<AbstractMesh>;
  95714. /**
  95715. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  95716. * @returns a number
  95717. */
  95718. getAnimationRatio(): number;
  95719. /**
  95720. * Gets an unique Id for the current render phase
  95721. * @returns a number
  95722. */
  95723. getRenderId(): number;
  95724. /**
  95725. * Gets an unique Id for the current frame
  95726. * @returns a number
  95727. */
  95728. getFrameId(): number;
  95729. /** Call this function if you want to manually increment the render Id*/
  95730. incrementRenderId(): void;
  95731. private _createUbo;
  95732. /**
  95733. * Use this method to simulate a pointer move on a mesh
  95734. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  95735. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  95736. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  95737. * @returns the current scene
  95738. */
  95739. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  95740. /**
  95741. * Use this method to simulate a pointer down on a mesh
  95742. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  95743. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  95744. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  95745. * @returns the current scene
  95746. */
  95747. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  95748. /**
  95749. * Use this method to simulate a pointer up on a mesh
  95750. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  95751. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  95752. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  95753. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  95754. * @returns the current scene
  95755. */
  95756. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  95757. /**
  95758. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  95759. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  95760. * @returns true if the pointer was captured
  95761. */
  95762. isPointerCaptured(pointerId?: number): boolean;
  95763. /**
  95764. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  95765. * @param attachUp defines if you want to attach events to pointerup
  95766. * @param attachDown defines if you want to attach events to pointerdown
  95767. * @param attachMove defines if you want to attach events to pointermove
  95768. */
  95769. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  95770. /** Detaches all event handlers*/
  95771. detachControl(): void;
  95772. /**
  95773. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  95774. * Delay loaded resources are not taking in account
  95775. * @return true if all required resources are ready
  95776. */
  95777. isReady(): boolean;
  95778. /** Resets all cached information relative to material (including effect and visibility) */
  95779. resetCachedMaterial(): void;
  95780. /**
  95781. * Registers a function to be called before every frame render
  95782. * @param func defines the function to register
  95783. */
  95784. registerBeforeRender(func: () => void): void;
  95785. /**
  95786. * Unregisters a function called before every frame render
  95787. * @param func defines the function to unregister
  95788. */
  95789. unregisterBeforeRender(func: () => void): void;
  95790. /**
  95791. * Registers a function to be called after every frame render
  95792. * @param func defines the function to register
  95793. */
  95794. registerAfterRender(func: () => void): void;
  95795. /**
  95796. * Unregisters a function called after every frame render
  95797. * @param func defines the function to unregister
  95798. */
  95799. unregisterAfterRender(func: () => void): void;
  95800. private _executeOnceBeforeRender;
  95801. /**
  95802. * The provided function will run before render once and will be disposed afterwards.
  95803. * A timeout delay can be provided so that the function will be executed in N ms.
  95804. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  95805. * @param func The function to be executed.
  95806. * @param timeout optional delay in ms
  95807. */
  95808. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  95809. /** @hidden */
  95810. _addPendingData(data: any): void;
  95811. /** @hidden */
  95812. _removePendingData(data: any): void;
  95813. /**
  95814. * Returns the number of items waiting to be loaded
  95815. * @returns the number of items waiting to be loaded
  95816. */
  95817. getWaitingItemsCount(): number;
  95818. /**
  95819. * Returns a boolean indicating if the scene is still loading data
  95820. */
  95821. readonly isLoading: boolean;
  95822. /**
  95823. * Registers a function to be executed when the scene is ready
  95824. * @param {Function} func - the function to be executed
  95825. */
  95826. executeWhenReady(func: () => void): void;
  95827. /**
  95828. * Returns a promise that resolves when the scene is ready
  95829. * @returns A promise that resolves when the scene is ready
  95830. */
  95831. whenReadyAsync(): Promise<void>;
  95832. /** @hidden */
  95833. _checkIsReady(): void;
  95834. /**
  95835. * Gets all animatable attached to the scene
  95836. */
  95837. readonly animatables: Animatable[];
  95838. /**
  95839. * Resets the last animation time frame.
  95840. * Useful to override when animations start running when loading a scene for the first time.
  95841. */
  95842. resetLastAnimationTimeFrame(): void;
  95843. /**
  95844. * Gets the current view matrix
  95845. * @returns a Matrix
  95846. */
  95847. getViewMatrix(): Matrix;
  95848. /**
  95849. * Gets the current projection matrix
  95850. * @returns a Matrix
  95851. */
  95852. getProjectionMatrix(): Matrix;
  95853. /**
  95854. * Gets the current transform matrix
  95855. * @returns a Matrix made of View * Projection
  95856. */
  95857. getTransformMatrix(): Matrix;
  95858. /**
  95859. * Sets the current transform matrix
  95860. * @param viewL defines the View matrix to use
  95861. * @param projectionL defines the Projection matrix to use
  95862. * @param viewR defines the right View matrix to use (if provided)
  95863. * @param projectionR defines the right Projection matrix to use (if provided)
  95864. */
  95865. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  95866. /**
  95867. * Gets the uniform buffer used to store scene data
  95868. * @returns a UniformBuffer
  95869. */
  95870. getSceneUniformBuffer(): UniformBuffer;
  95871. /**
  95872. * Gets an unique (relatively to the current scene) Id
  95873. * @returns an unique number for the scene
  95874. */
  95875. getUniqueId(): number;
  95876. /**
  95877. * Add a mesh to the list of scene's meshes
  95878. * @param newMesh defines the mesh to add
  95879. * @param recursive if all child meshes should also be added to the scene
  95880. */
  95881. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  95882. /**
  95883. * Remove a mesh for the list of scene's meshes
  95884. * @param toRemove defines the mesh to remove
  95885. * @param recursive if all child meshes should also be removed from the scene
  95886. * @returns the index where the mesh was in the mesh list
  95887. */
  95888. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  95889. /**
  95890. * Add a transform node to the list of scene's transform nodes
  95891. * @param newTransformNode defines the transform node to add
  95892. */
  95893. addTransformNode(newTransformNode: TransformNode): void;
  95894. /**
  95895. * Remove a transform node for the list of scene's transform nodes
  95896. * @param toRemove defines the transform node to remove
  95897. * @returns the index where the transform node was in the transform node list
  95898. */
  95899. removeTransformNode(toRemove: TransformNode): number;
  95900. /**
  95901. * Remove a skeleton for the list of scene's skeletons
  95902. * @param toRemove defines the skeleton to remove
  95903. * @returns the index where the skeleton was in the skeleton list
  95904. */
  95905. removeSkeleton(toRemove: Skeleton): number;
  95906. /**
  95907. * Remove a morph target for the list of scene's morph targets
  95908. * @param toRemove defines the morph target to remove
  95909. * @returns the index where the morph target was in the morph target list
  95910. */
  95911. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  95912. /**
  95913. * Remove a light for the list of scene's lights
  95914. * @param toRemove defines the light to remove
  95915. * @returns the index where the light was in the light list
  95916. */
  95917. removeLight(toRemove: Light): number;
  95918. /**
  95919. * Remove a camera for the list of scene's cameras
  95920. * @param toRemove defines the camera to remove
  95921. * @returns the index where the camera was in the camera list
  95922. */
  95923. removeCamera(toRemove: Camera): number;
  95924. /**
  95925. * Remove a particle system for the list of scene's particle systems
  95926. * @param toRemove defines the particle system to remove
  95927. * @returns the index where the particle system was in the particle system list
  95928. */
  95929. removeParticleSystem(toRemove: IParticleSystem): number;
  95930. /**
  95931. * Remove a animation for the list of scene's animations
  95932. * @param toRemove defines the animation to remove
  95933. * @returns the index where the animation was in the animation list
  95934. */
  95935. removeAnimation(toRemove: Animation): number;
  95936. /**
  95937. * Will stop the animation of the given target
  95938. * @param target - the target
  95939. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  95940. * @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)
  95941. */
  95942. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  95943. /**
  95944. * Removes the given animation group from this scene.
  95945. * @param toRemove The animation group to remove
  95946. * @returns The index of the removed animation group
  95947. */
  95948. removeAnimationGroup(toRemove: AnimationGroup): number;
  95949. /**
  95950. * Removes the given multi-material from this scene.
  95951. * @param toRemove The multi-material to remove
  95952. * @returns The index of the removed multi-material
  95953. */
  95954. removeMultiMaterial(toRemove: MultiMaterial): number;
  95955. /**
  95956. * Removes the given material from this scene.
  95957. * @param toRemove The material to remove
  95958. * @returns The index of the removed material
  95959. */
  95960. removeMaterial(toRemove: Material): number;
  95961. /**
  95962. * Removes the given action manager from this scene.
  95963. * @param toRemove The action manager to remove
  95964. * @returns The index of the removed action manager
  95965. */
  95966. removeActionManager(toRemove: AbstractActionManager): number;
  95967. /**
  95968. * Removes the given texture from this scene.
  95969. * @param toRemove The texture to remove
  95970. * @returns The index of the removed texture
  95971. */
  95972. removeTexture(toRemove: BaseTexture): number;
  95973. /**
  95974. * Adds the given light to this scene
  95975. * @param newLight The light to add
  95976. */
  95977. addLight(newLight: Light): void;
  95978. /**
  95979. * Sorts the list list based on light priorities
  95980. */
  95981. sortLightsByPriority(): void;
  95982. /**
  95983. * Adds the given camera to this scene
  95984. * @param newCamera The camera to add
  95985. */
  95986. addCamera(newCamera: Camera): void;
  95987. /**
  95988. * Adds the given skeleton to this scene
  95989. * @param newSkeleton The skeleton to add
  95990. */
  95991. addSkeleton(newSkeleton: Skeleton): void;
  95992. /**
  95993. * Adds the given particle system to this scene
  95994. * @param newParticleSystem The particle system to add
  95995. */
  95996. addParticleSystem(newParticleSystem: IParticleSystem): void;
  95997. /**
  95998. * Adds the given animation to this scene
  95999. * @param newAnimation The animation to add
  96000. */
  96001. addAnimation(newAnimation: Animation): void;
  96002. /**
  96003. * Adds the given animation group to this scene.
  96004. * @param newAnimationGroup The animation group to add
  96005. */
  96006. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  96007. /**
  96008. * Adds the given multi-material to this scene
  96009. * @param newMultiMaterial The multi-material to add
  96010. */
  96011. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  96012. /**
  96013. * Adds the given material to this scene
  96014. * @param newMaterial The material to add
  96015. */
  96016. addMaterial(newMaterial: Material): void;
  96017. /**
  96018. * Adds the given morph target to this scene
  96019. * @param newMorphTargetManager The morph target to add
  96020. */
  96021. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  96022. /**
  96023. * Adds the given geometry to this scene
  96024. * @param newGeometry The geometry to add
  96025. */
  96026. addGeometry(newGeometry: Geometry): void;
  96027. /**
  96028. * Adds the given action manager to this scene
  96029. * @param newActionManager The action manager to add
  96030. */
  96031. addActionManager(newActionManager: AbstractActionManager): void;
  96032. /**
  96033. * Adds the given texture to this scene.
  96034. * @param newTexture The texture to add
  96035. */
  96036. addTexture(newTexture: BaseTexture): void;
  96037. /**
  96038. * Switch active camera
  96039. * @param newCamera defines the new active camera
  96040. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  96041. */
  96042. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  96043. /**
  96044. * sets the active camera of the scene using its ID
  96045. * @param id defines the camera's ID
  96046. * @return the new active camera or null if none found.
  96047. */
  96048. setActiveCameraByID(id: string): Nullable<Camera>;
  96049. /**
  96050. * sets the active camera of the scene using its name
  96051. * @param name defines the camera's name
  96052. * @returns the new active camera or null if none found.
  96053. */
  96054. setActiveCameraByName(name: string): Nullable<Camera>;
  96055. /**
  96056. * get an animation group using its name
  96057. * @param name defines the material's name
  96058. * @return the animation group or null if none found.
  96059. */
  96060. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  96061. /**
  96062. * Get a material using its unique id
  96063. * @param uniqueId defines the material's unique id
  96064. * @return the material or null if none found.
  96065. */
  96066. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  96067. /**
  96068. * get a material using its id
  96069. * @param id defines the material's ID
  96070. * @return the material or null if none found.
  96071. */
  96072. getMaterialByID(id: string): Nullable<Material>;
  96073. /**
  96074. * Gets a material using its name
  96075. * @param name defines the material's name
  96076. * @return the material or null if none found.
  96077. */
  96078. getMaterialByName(name: string): Nullable<Material>;
  96079. /**
  96080. * Gets a camera using its id
  96081. * @param id defines the id to look for
  96082. * @returns the camera or null if not found
  96083. */
  96084. getCameraByID(id: string): Nullable<Camera>;
  96085. /**
  96086. * Gets a camera using its unique id
  96087. * @param uniqueId defines the unique id to look for
  96088. * @returns the camera or null if not found
  96089. */
  96090. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  96091. /**
  96092. * Gets a camera using its name
  96093. * @param name defines the camera's name
  96094. * @return the camera or null if none found.
  96095. */
  96096. getCameraByName(name: string): Nullable<Camera>;
  96097. /**
  96098. * Gets a bone using its id
  96099. * @param id defines the bone's id
  96100. * @return the bone or null if not found
  96101. */
  96102. getBoneByID(id: string): Nullable<Bone>;
  96103. /**
  96104. * Gets a bone using its id
  96105. * @param name defines the bone's name
  96106. * @return the bone or null if not found
  96107. */
  96108. getBoneByName(name: string): Nullable<Bone>;
  96109. /**
  96110. * Gets a light node using its name
  96111. * @param name defines the the light's name
  96112. * @return the light or null if none found.
  96113. */
  96114. getLightByName(name: string): Nullable<Light>;
  96115. /**
  96116. * Gets a light node using its id
  96117. * @param id defines the light's id
  96118. * @return the light or null if none found.
  96119. */
  96120. getLightByID(id: string): Nullable<Light>;
  96121. /**
  96122. * Gets a light node using its scene-generated unique ID
  96123. * @param uniqueId defines the light's unique id
  96124. * @return the light or null if none found.
  96125. */
  96126. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  96127. /**
  96128. * Gets a particle system by id
  96129. * @param id defines the particle system id
  96130. * @return the corresponding system or null if none found
  96131. */
  96132. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  96133. /**
  96134. * Gets a geometry using its ID
  96135. * @param id defines the geometry's id
  96136. * @return the geometry or null if none found.
  96137. */
  96138. getGeometryByID(id: string): Nullable<Geometry>;
  96139. private _getGeometryByUniqueID;
  96140. /**
  96141. * Add a new geometry to this scene
  96142. * @param geometry defines the geometry to be added to the scene.
  96143. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  96144. * @return a boolean defining if the geometry was added or not
  96145. */
  96146. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  96147. /**
  96148. * Removes an existing geometry
  96149. * @param geometry defines the geometry to be removed from the scene
  96150. * @return a boolean defining if the geometry was removed or not
  96151. */
  96152. removeGeometry(geometry: Geometry): boolean;
  96153. /**
  96154. * Gets the list of geometries attached to the scene
  96155. * @returns an array of Geometry
  96156. */
  96157. getGeometries(): Geometry[];
  96158. /**
  96159. * Gets the first added mesh found of a given ID
  96160. * @param id defines the id to search for
  96161. * @return the mesh found or null if not found at all
  96162. */
  96163. getMeshByID(id: string): Nullable<AbstractMesh>;
  96164. /**
  96165. * Gets a list of meshes using their id
  96166. * @param id defines the id to search for
  96167. * @returns a list of meshes
  96168. */
  96169. getMeshesByID(id: string): Array<AbstractMesh>;
  96170. /**
  96171. * Gets the first added transform node found of a given ID
  96172. * @param id defines the id to search for
  96173. * @return the found transform node or null if not found at all.
  96174. */
  96175. getTransformNodeByID(id: string): Nullable<TransformNode>;
  96176. /**
  96177. * Gets a transform node with its auto-generated unique id
  96178. * @param uniqueId efines the unique id to search for
  96179. * @return the found transform node or null if not found at all.
  96180. */
  96181. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  96182. /**
  96183. * Gets a list of transform nodes using their id
  96184. * @param id defines the id to search for
  96185. * @returns a list of transform nodes
  96186. */
  96187. getTransformNodesByID(id: string): Array<TransformNode>;
  96188. /**
  96189. * Gets a mesh with its auto-generated unique id
  96190. * @param uniqueId defines the unique id to search for
  96191. * @return the found mesh or null if not found at all.
  96192. */
  96193. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  96194. /**
  96195. * Gets a the last added mesh using a given id
  96196. * @param id defines the id to search for
  96197. * @return the found mesh or null if not found at all.
  96198. */
  96199. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  96200. /**
  96201. * Gets a the last added node (Mesh, Camera, Light) using a given id
  96202. * @param id defines the id to search for
  96203. * @return the found node or null if not found at all
  96204. */
  96205. getLastEntryByID(id: string): Nullable<Node>;
  96206. /**
  96207. * Gets a node (Mesh, Camera, Light) using a given id
  96208. * @param id defines the id to search for
  96209. * @return the found node or null if not found at all
  96210. */
  96211. getNodeByID(id: string): Nullable<Node>;
  96212. /**
  96213. * Gets a node (Mesh, Camera, Light) using a given name
  96214. * @param name defines the name to search for
  96215. * @return the found node or null if not found at all.
  96216. */
  96217. getNodeByName(name: string): Nullable<Node>;
  96218. /**
  96219. * Gets a mesh using a given name
  96220. * @param name defines the name to search for
  96221. * @return the found mesh or null if not found at all.
  96222. */
  96223. getMeshByName(name: string): Nullable<AbstractMesh>;
  96224. /**
  96225. * Gets a transform node using a given name
  96226. * @param name defines the name to search for
  96227. * @return the found transform node or null if not found at all.
  96228. */
  96229. getTransformNodeByName(name: string): Nullable<TransformNode>;
  96230. /**
  96231. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  96232. * @param id defines the id to search for
  96233. * @return the found skeleton or null if not found at all.
  96234. */
  96235. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  96236. /**
  96237. * Gets a skeleton using a given auto generated unique id
  96238. * @param uniqueId defines the unique id to search for
  96239. * @return the found skeleton or null if not found at all.
  96240. */
  96241. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  96242. /**
  96243. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  96244. * @param id defines the id to search for
  96245. * @return the found skeleton or null if not found at all.
  96246. */
  96247. getSkeletonById(id: string): Nullable<Skeleton>;
  96248. /**
  96249. * Gets a skeleton using a given name
  96250. * @param name defines the name to search for
  96251. * @return the found skeleton or null if not found at all.
  96252. */
  96253. getSkeletonByName(name: string): Nullable<Skeleton>;
  96254. /**
  96255. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  96256. * @param id defines the id to search for
  96257. * @return the found morph target manager or null if not found at all.
  96258. */
  96259. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  96260. /**
  96261. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  96262. * @param id defines the id to search for
  96263. * @return the found morph target or null if not found at all.
  96264. */
  96265. getMorphTargetById(id: string): Nullable<MorphTarget>;
  96266. /**
  96267. * Gets a boolean indicating if the given mesh is active
  96268. * @param mesh defines the mesh to look for
  96269. * @returns true if the mesh is in the active list
  96270. */
  96271. isActiveMesh(mesh: AbstractMesh): boolean;
  96272. /**
  96273. * Return a unique id as a string which can serve as an identifier for the scene
  96274. */
  96275. readonly uid: string;
  96276. /**
  96277. * Add an externaly attached data from its key.
  96278. * This method call will fail and return false, if such key already exists.
  96279. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  96280. * @param key the unique key that identifies the data
  96281. * @param data the data object to associate to the key for this Engine instance
  96282. * @return true if no such key were already present and the data was added successfully, false otherwise
  96283. */
  96284. addExternalData<T>(key: string, data: T): boolean;
  96285. /**
  96286. * Get an externaly attached data from its key
  96287. * @param key the unique key that identifies the data
  96288. * @return the associated data, if present (can be null), or undefined if not present
  96289. */
  96290. getExternalData<T>(key: string): Nullable<T>;
  96291. /**
  96292. * Get an externaly attached data from its key, create it using a factory if it's not already present
  96293. * @param key the unique key that identifies the data
  96294. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  96295. * @return the associated data, can be null if the factory returned null.
  96296. */
  96297. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  96298. /**
  96299. * Remove an externaly attached data from the Engine instance
  96300. * @param key the unique key that identifies the data
  96301. * @return true if the data was successfully removed, false if it doesn't exist
  96302. */
  96303. removeExternalData(key: string): boolean;
  96304. private _evaluateSubMesh;
  96305. /**
  96306. * Clear the processed materials smart array preventing retention point in material dispose.
  96307. */
  96308. freeProcessedMaterials(): void;
  96309. private _preventFreeActiveMeshesAndRenderingGroups;
  96310. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  96311. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  96312. * when disposing several meshes in a row or a hierarchy of meshes.
  96313. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  96314. */
  96315. blockfreeActiveMeshesAndRenderingGroups: boolean;
  96316. /**
  96317. * Clear the active meshes smart array preventing retention point in mesh dispose.
  96318. */
  96319. freeActiveMeshes(): void;
  96320. /**
  96321. * Clear the info related to rendering groups preventing retention points during dispose.
  96322. */
  96323. freeRenderingGroups(): void;
  96324. /** @hidden */
  96325. _isInIntermediateRendering(): boolean;
  96326. /**
  96327. * Lambda returning the list of potentially active meshes.
  96328. */
  96329. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  96330. /**
  96331. * Lambda returning the list of potentially active sub meshes.
  96332. */
  96333. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  96334. /**
  96335. * Lambda returning the list of potentially intersecting sub meshes.
  96336. */
  96337. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  96338. /**
  96339. * Lambda returning the list of potentially colliding sub meshes.
  96340. */
  96341. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  96342. private _activeMeshesFrozen;
  96343. /**
  96344. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  96345. * @returns the current scene
  96346. */
  96347. freezeActiveMeshes(): Scene;
  96348. /**
  96349. * Use this function to restart evaluating active meshes on every frame
  96350. * @returns the current scene
  96351. */
  96352. unfreezeActiveMeshes(): Scene;
  96353. private _evaluateActiveMeshes;
  96354. private _activeMesh;
  96355. /**
  96356. * Update the transform matrix to update from the current active camera
  96357. * @param force defines a boolean used to force the update even if cache is up to date
  96358. */
  96359. updateTransformMatrix(force?: boolean): void;
  96360. private _bindFrameBuffer;
  96361. /** @hidden */
  96362. _allowPostProcessClearColor: boolean;
  96363. /** @hidden */
  96364. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  96365. private _processSubCameras;
  96366. private _checkIntersections;
  96367. /** @hidden */
  96368. _advancePhysicsEngineStep(step: number): void;
  96369. /**
  96370. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  96371. */
  96372. getDeterministicFrameTime: () => number;
  96373. /** @hidden */
  96374. _animate(): void;
  96375. /** Execute all animations (for a frame) */
  96376. animate(): void;
  96377. /**
  96378. * Render the scene
  96379. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  96380. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  96381. */
  96382. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  96383. /**
  96384. * Freeze all materials
  96385. * A frozen material will not be updatable but should be faster to render
  96386. */
  96387. freezeMaterials(): void;
  96388. /**
  96389. * Unfreeze all materials
  96390. * A frozen material will not be updatable but should be faster to render
  96391. */
  96392. unfreezeMaterials(): void;
  96393. /**
  96394. * Releases all held ressources
  96395. */
  96396. dispose(): void;
  96397. /**
  96398. * Gets if the scene is already disposed
  96399. */
  96400. readonly isDisposed: boolean;
  96401. /**
  96402. * Call this function to reduce memory footprint of the scene.
  96403. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  96404. */
  96405. clearCachedVertexData(): void;
  96406. /**
  96407. * This function will remove the local cached buffer data from texture.
  96408. * It will save memory but will prevent the texture from being rebuilt
  96409. */
  96410. cleanCachedTextureBuffer(): void;
  96411. /**
  96412. * Get the world extend vectors with an optional filter
  96413. *
  96414. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  96415. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  96416. */
  96417. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  96418. min: Vector3;
  96419. max: Vector3;
  96420. };
  96421. /**
  96422. * Creates a ray that can be used to pick in the scene
  96423. * @param x defines the x coordinate of the origin (on-screen)
  96424. * @param y defines the y coordinate of the origin (on-screen)
  96425. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  96426. * @param camera defines the camera to use for the picking
  96427. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  96428. * @returns a Ray
  96429. */
  96430. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  96431. /**
  96432. * Creates a ray that can be used to pick in the scene
  96433. * @param x defines the x coordinate of the origin (on-screen)
  96434. * @param y defines the y coordinate of the origin (on-screen)
  96435. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  96436. * @param result defines the ray where to store the picking ray
  96437. * @param camera defines the camera to use for the picking
  96438. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  96439. * @returns the current scene
  96440. */
  96441. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  96442. /**
  96443. * Creates a ray that can be used to pick in the scene
  96444. * @param x defines the x coordinate of the origin (on-screen)
  96445. * @param y defines the y coordinate of the origin (on-screen)
  96446. * @param camera defines the camera to use for the picking
  96447. * @returns a Ray
  96448. */
  96449. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  96450. /**
  96451. * Creates a ray that can be used to pick in the scene
  96452. * @param x defines the x coordinate of the origin (on-screen)
  96453. * @param y defines the y coordinate of the origin (on-screen)
  96454. * @param result defines the ray where to store the picking ray
  96455. * @param camera defines the camera to use for the picking
  96456. * @returns the current scene
  96457. */
  96458. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  96459. /** Launch a ray to try to pick a mesh in the scene
  96460. * @param x position on screen
  96461. * @param y position on screen
  96462. * @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
  96463. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  96464. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  96465. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  96466. * @returns a PickingInfo
  96467. */
  96468. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  96469. /** Use the given ray to pick a mesh in the scene
  96470. * @param ray The ray to use to pick meshes
  96471. * @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
  96472. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  96473. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  96474. * @returns a PickingInfo
  96475. */
  96476. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  96477. /**
  96478. * Launch a ray to try to pick a mesh in the scene
  96479. * @param x X position on screen
  96480. * @param y Y position on screen
  96481. * @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
  96482. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  96483. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  96484. * @returns an array of PickingInfo
  96485. */
  96486. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  96487. /**
  96488. * Launch a ray to try to pick a mesh in the scene
  96489. * @param ray Ray to use
  96490. * @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
  96491. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  96492. * @returns an array of PickingInfo
  96493. */
  96494. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  96495. /**
  96496. * Force the value of meshUnderPointer
  96497. * @param mesh defines the mesh to use
  96498. */
  96499. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  96500. /**
  96501. * Gets the mesh under the pointer
  96502. * @returns a Mesh or null if no mesh is under the pointer
  96503. */
  96504. getPointerOverMesh(): Nullable<AbstractMesh>;
  96505. /** @hidden */
  96506. _rebuildGeometries(): void;
  96507. /** @hidden */
  96508. _rebuildTextures(): void;
  96509. private _getByTags;
  96510. /**
  96511. * Get a list of meshes by tags
  96512. * @param tagsQuery defines the tags query to use
  96513. * @param forEach defines a predicate used to filter results
  96514. * @returns an array of Mesh
  96515. */
  96516. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  96517. /**
  96518. * Get a list of cameras by tags
  96519. * @param tagsQuery defines the tags query to use
  96520. * @param forEach defines a predicate used to filter results
  96521. * @returns an array of Camera
  96522. */
  96523. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  96524. /**
  96525. * Get a list of lights by tags
  96526. * @param tagsQuery defines the tags query to use
  96527. * @param forEach defines a predicate used to filter results
  96528. * @returns an array of Light
  96529. */
  96530. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  96531. /**
  96532. * Get a list of materials by tags
  96533. * @param tagsQuery defines the tags query to use
  96534. * @param forEach defines a predicate used to filter results
  96535. * @returns an array of Material
  96536. */
  96537. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  96538. /**
  96539. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  96540. * This allowed control for front to back rendering or reversly depending of the special needs.
  96541. *
  96542. * @param renderingGroupId The rendering group id corresponding to its index
  96543. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  96544. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  96545. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  96546. */
  96547. 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;
  96548. /**
  96549. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  96550. *
  96551. * @param renderingGroupId The rendering group id corresponding to its index
  96552. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  96553. * @param depth Automatically clears depth between groups if true and autoClear is true.
  96554. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  96555. */
  96556. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  96557. /**
  96558. * Gets the current auto clear configuration for one rendering group of the rendering
  96559. * manager.
  96560. * @param index the rendering group index to get the information for
  96561. * @returns The auto clear setup for the requested rendering group
  96562. */
  96563. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  96564. private _blockMaterialDirtyMechanism;
  96565. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  96566. blockMaterialDirtyMechanism: boolean;
  96567. /**
  96568. * Will flag all materials as dirty to trigger new shader compilation
  96569. * @param flag defines the flag used to specify which material part must be marked as dirty
  96570. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  96571. */
  96572. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  96573. /** @hidden */
  96574. _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;
  96575. /** @hidden */
  96576. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  96577. }
  96578. }
  96579. declare module BABYLON {
  96580. /**
  96581. * Set of assets to keep when moving a scene into an asset container.
  96582. */
  96583. export class KeepAssets extends AbstractScene {
  96584. }
  96585. /**
  96586. * Container with a set of assets that can be added or removed from a scene.
  96587. */
  96588. export class AssetContainer extends AbstractScene {
  96589. /**
  96590. * The scene the AssetContainer belongs to.
  96591. */
  96592. scene: Scene;
  96593. /**
  96594. * Instantiates an AssetContainer.
  96595. * @param scene The scene the AssetContainer belongs to.
  96596. */
  96597. constructor(scene: Scene);
  96598. /**
  96599. * Adds all the assets from the container to the scene.
  96600. */
  96601. addAllToScene(): void;
  96602. /**
  96603. * Removes all the assets in the container from the scene
  96604. */
  96605. removeAllFromScene(): void;
  96606. /**
  96607. * Disposes all the assets in the container
  96608. */
  96609. dispose(): void;
  96610. private _moveAssets;
  96611. /**
  96612. * Removes all the assets contained in the scene and adds them to the container.
  96613. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  96614. */
  96615. moveAllFromScene(keepAssets?: KeepAssets): void;
  96616. /**
  96617. * 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.
  96618. * @returns the root mesh
  96619. */
  96620. createRootMesh(): Mesh;
  96621. }
  96622. }
  96623. declare module BABYLON {
  96624. /**
  96625. * Defines how the parser contract is defined.
  96626. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  96627. */
  96628. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  96629. /**
  96630. * Defines how the individual parser contract is defined.
  96631. * These parser can parse an individual asset
  96632. */
  96633. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  96634. /**
  96635. * Base class of the scene acting as a container for the different elements composing a scene.
  96636. * This class is dynamically extended by the different components of the scene increasing
  96637. * flexibility and reducing coupling
  96638. */
  96639. export abstract class AbstractScene {
  96640. /**
  96641. * Stores the list of available parsers in the application.
  96642. */
  96643. private static _BabylonFileParsers;
  96644. /**
  96645. * Stores the list of available individual parsers in the application.
  96646. */
  96647. private static _IndividualBabylonFileParsers;
  96648. /**
  96649. * Adds a parser in the list of available ones
  96650. * @param name Defines the name of the parser
  96651. * @param parser Defines the parser to add
  96652. */
  96653. static AddParser(name: string, parser: BabylonFileParser): void;
  96654. /**
  96655. * Gets a general parser from the list of avaialble ones
  96656. * @param name Defines the name of the parser
  96657. * @returns the requested parser or null
  96658. */
  96659. static GetParser(name: string): Nullable<BabylonFileParser>;
  96660. /**
  96661. * Adds n individual parser in the list of available ones
  96662. * @param name Defines the name of the parser
  96663. * @param parser Defines the parser to add
  96664. */
  96665. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  96666. /**
  96667. * Gets an individual parser from the list of avaialble ones
  96668. * @param name Defines the name of the parser
  96669. * @returns the requested parser or null
  96670. */
  96671. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  96672. /**
  96673. * Parser json data and populate both a scene and its associated container object
  96674. * @param jsonData Defines the data to parse
  96675. * @param scene Defines the scene to parse the data for
  96676. * @param container Defines the container attached to the parsing sequence
  96677. * @param rootUrl Defines the root url of the data
  96678. */
  96679. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  96680. /**
  96681. * Gets the list of root nodes (ie. nodes with no parent)
  96682. */
  96683. rootNodes: Node[];
  96684. /** All of the cameras added to this scene
  96685. * @see http://doc.babylonjs.com/babylon101/cameras
  96686. */
  96687. cameras: Camera[];
  96688. /**
  96689. * All of the lights added to this scene
  96690. * @see http://doc.babylonjs.com/babylon101/lights
  96691. */
  96692. lights: Light[];
  96693. /**
  96694. * All of the (abstract) meshes added to this scene
  96695. */
  96696. meshes: AbstractMesh[];
  96697. /**
  96698. * The list of skeletons added to the scene
  96699. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  96700. */
  96701. skeletons: Skeleton[];
  96702. /**
  96703. * All of the particle systems added to this scene
  96704. * @see http://doc.babylonjs.com/babylon101/particles
  96705. */
  96706. particleSystems: IParticleSystem[];
  96707. /**
  96708. * Gets a list of Animations associated with the scene
  96709. */
  96710. animations: Animation[];
  96711. /**
  96712. * All of the animation groups added to this scene
  96713. * @see http://doc.babylonjs.com/how_to/group
  96714. */
  96715. animationGroups: AnimationGroup[];
  96716. /**
  96717. * All of the multi-materials added to this scene
  96718. * @see http://doc.babylonjs.com/how_to/multi_materials
  96719. */
  96720. multiMaterials: MultiMaterial[];
  96721. /**
  96722. * All of the materials added to this scene
  96723. * In the context of a Scene, it is not supposed to be modified manually.
  96724. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  96725. * Note also that the order of the Material wihin the array is not significant and might change.
  96726. * @see http://doc.babylonjs.com/babylon101/materials
  96727. */
  96728. materials: Material[];
  96729. /**
  96730. * The list of morph target managers added to the scene
  96731. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  96732. */
  96733. morphTargetManagers: MorphTargetManager[];
  96734. /**
  96735. * The list of geometries used in the scene.
  96736. */
  96737. geometries: Geometry[];
  96738. /**
  96739. * All of the tranform nodes added to this scene
  96740. * In the context of a Scene, it is not supposed to be modified manually.
  96741. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  96742. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  96743. * @see http://doc.babylonjs.com/how_to/transformnode
  96744. */
  96745. transformNodes: TransformNode[];
  96746. /**
  96747. * ActionManagers available on the scene.
  96748. */
  96749. actionManagers: AbstractActionManager[];
  96750. /**
  96751. * Textures to keep.
  96752. */
  96753. textures: BaseTexture[];
  96754. /**
  96755. * Environment texture for the scene
  96756. */
  96757. environmentTexture: Nullable<BaseTexture>;
  96758. }
  96759. }
  96760. declare module BABYLON {
  96761. /**
  96762. * Defines a sound that can be played in the application.
  96763. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  96764. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  96765. */
  96766. export class Sound {
  96767. /**
  96768. * The name of the sound in the scene.
  96769. */
  96770. name: string;
  96771. /**
  96772. * Does the sound autoplay once loaded.
  96773. */
  96774. autoplay: boolean;
  96775. /**
  96776. * Does the sound loop after it finishes playing once.
  96777. */
  96778. loop: boolean;
  96779. /**
  96780. * Does the sound use a custom attenuation curve to simulate the falloff
  96781. * happening when the source gets further away from the camera.
  96782. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  96783. */
  96784. useCustomAttenuation: boolean;
  96785. /**
  96786. * The sound track id this sound belongs to.
  96787. */
  96788. soundTrackId: number;
  96789. /**
  96790. * Is this sound currently played.
  96791. */
  96792. isPlaying: boolean;
  96793. /**
  96794. * Is this sound currently paused.
  96795. */
  96796. isPaused: boolean;
  96797. /**
  96798. * Does this sound enables spatial sound.
  96799. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96800. */
  96801. spatialSound: boolean;
  96802. /**
  96803. * Define the reference distance the sound should be heard perfectly.
  96804. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96805. */
  96806. refDistance: number;
  96807. /**
  96808. * Define the roll off factor of spatial sounds.
  96809. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96810. */
  96811. rolloffFactor: number;
  96812. /**
  96813. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  96814. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96815. */
  96816. maxDistance: number;
  96817. /**
  96818. * Define the distance attenuation model the sound will follow.
  96819. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96820. */
  96821. distanceModel: string;
  96822. /**
  96823. * @hidden
  96824. * Back Compat
  96825. **/
  96826. onended: () => any;
  96827. /**
  96828. * Observable event when the current playing sound finishes.
  96829. */
  96830. onEndedObservable: Observable<Sound>;
  96831. private _panningModel;
  96832. private _playbackRate;
  96833. private _streaming;
  96834. private _startTime;
  96835. private _startOffset;
  96836. private _position;
  96837. /** @hidden */
  96838. _positionInEmitterSpace: boolean;
  96839. private _localDirection;
  96840. private _volume;
  96841. private _isReadyToPlay;
  96842. private _isDirectional;
  96843. private _readyToPlayCallback;
  96844. private _audioBuffer;
  96845. private _soundSource;
  96846. private _streamingSource;
  96847. private _soundPanner;
  96848. private _soundGain;
  96849. private _inputAudioNode;
  96850. private _outputAudioNode;
  96851. private _coneInnerAngle;
  96852. private _coneOuterAngle;
  96853. private _coneOuterGain;
  96854. private _scene;
  96855. private _connectedTransformNode;
  96856. private _customAttenuationFunction;
  96857. private _registerFunc;
  96858. private _isOutputConnected;
  96859. private _htmlAudioElement;
  96860. private _urlType;
  96861. /** @hidden */
  96862. static _SceneComponentInitialization: (scene: Scene) => void;
  96863. /**
  96864. * Create a sound and attach it to a scene
  96865. * @param name Name of your sound
  96866. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  96867. * @param scene defines the scene the sound belongs to
  96868. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  96869. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  96870. */
  96871. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  96872. /**
  96873. * Release the sound and its associated resources
  96874. */
  96875. dispose(): void;
  96876. /**
  96877. * Gets if the sounds is ready to be played or not.
  96878. * @returns true if ready, otherwise false
  96879. */
  96880. isReady(): boolean;
  96881. private _soundLoaded;
  96882. /**
  96883. * Sets the data of the sound from an audiobuffer
  96884. * @param audioBuffer The audioBuffer containing the data
  96885. */
  96886. setAudioBuffer(audioBuffer: AudioBuffer): void;
  96887. /**
  96888. * Updates the current sounds options such as maxdistance, loop...
  96889. * @param options A JSON object containing values named as the object properties
  96890. */
  96891. updateOptions(options: any): void;
  96892. private _createSpatialParameters;
  96893. private _updateSpatialParameters;
  96894. /**
  96895. * Switch the panning model to HRTF:
  96896. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  96897. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96898. */
  96899. switchPanningModelToHRTF(): void;
  96900. /**
  96901. * Switch the panning model to Equal Power:
  96902. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  96903. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96904. */
  96905. switchPanningModelToEqualPower(): void;
  96906. private _switchPanningModel;
  96907. /**
  96908. * Connect this sound to a sound track audio node like gain...
  96909. * @param soundTrackAudioNode the sound track audio node to connect to
  96910. */
  96911. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  96912. /**
  96913. * Transform this sound into a directional source
  96914. * @param coneInnerAngle Size of the inner cone in degree
  96915. * @param coneOuterAngle Size of the outer cone in degree
  96916. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  96917. */
  96918. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  96919. /**
  96920. * Gets or sets the inner angle for the directional cone.
  96921. */
  96922. /**
  96923. * Gets or sets the inner angle for the directional cone.
  96924. */
  96925. directionalConeInnerAngle: number;
  96926. /**
  96927. * Gets or sets the outer angle for the directional cone.
  96928. */
  96929. /**
  96930. * Gets or sets the outer angle for the directional cone.
  96931. */
  96932. directionalConeOuterAngle: number;
  96933. /**
  96934. * Sets the position of the emitter if spatial sound is enabled
  96935. * @param newPosition Defines the new posisiton
  96936. */
  96937. setPosition(newPosition: Vector3): void;
  96938. /**
  96939. * Sets the local direction of the emitter if spatial sound is enabled
  96940. * @param newLocalDirection Defines the new local direction
  96941. */
  96942. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  96943. private _updateDirection;
  96944. /** @hidden */
  96945. updateDistanceFromListener(): void;
  96946. /**
  96947. * Sets a new custom attenuation function for the sound.
  96948. * @param callback Defines the function used for the attenuation
  96949. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  96950. */
  96951. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  96952. /**
  96953. * Play the sound
  96954. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  96955. * @param offset (optional) Start the sound setting it at a specific time
  96956. */
  96957. play(time?: number, offset?: number): void;
  96958. private _onended;
  96959. /**
  96960. * Stop the sound
  96961. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  96962. */
  96963. stop(time?: number): void;
  96964. /**
  96965. * Put the sound in pause
  96966. */
  96967. pause(): void;
  96968. /**
  96969. * Sets a dedicated volume for this sounds
  96970. * @param newVolume Define the new volume of the sound
  96971. * @param time Define in how long the sound should be at this value
  96972. */
  96973. setVolume(newVolume: number, time?: number): void;
  96974. /**
  96975. * Set the sound play back rate
  96976. * @param newPlaybackRate Define the playback rate the sound should be played at
  96977. */
  96978. setPlaybackRate(newPlaybackRate: number): void;
  96979. /**
  96980. * Gets the volume of the sound.
  96981. * @returns the volume of the sound
  96982. */
  96983. getVolume(): number;
  96984. /**
  96985. * Attach the sound to a dedicated mesh
  96986. * @param transformNode The transform node to connect the sound with
  96987. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  96988. */
  96989. attachToMesh(transformNode: TransformNode): void;
  96990. /**
  96991. * Detach the sound from the previously attached mesh
  96992. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  96993. */
  96994. detachFromMesh(): void;
  96995. private _onRegisterAfterWorldMatrixUpdate;
  96996. /**
  96997. * Clone the current sound in the scene.
  96998. * @returns the new sound clone
  96999. */
  97000. clone(): Nullable<Sound>;
  97001. /**
  97002. * Gets the current underlying audio buffer containing the data
  97003. * @returns the audio buffer
  97004. */
  97005. getAudioBuffer(): Nullable<AudioBuffer>;
  97006. /**
  97007. * Serializes the Sound in a JSON representation
  97008. * @returns the JSON representation of the sound
  97009. */
  97010. serialize(): any;
  97011. /**
  97012. * Parse a JSON representation of a sound to innstantiate in a given scene
  97013. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  97014. * @param scene Define the scene the new parsed sound should be created in
  97015. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  97016. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  97017. * @returns the newly parsed sound
  97018. */
  97019. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  97020. }
  97021. }
  97022. declare module BABYLON {
  97023. /**
  97024. * This defines an action helpful to play a defined sound on a triggered action.
  97025. */
  97026. export class PlaySoundAction extends Action {
  97027. private _sound;
  97028. /**
  97029. * Instantiate the action
  97030. * @param triggerOptions defines the trigger options
  97031. * @param sound defines the sound to play
  97032. * @param condition defines the trigger related conditions
  97033. */
  97034. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  97035. /** @hidden */
  97036. _prepare(): void;
  97037. /**
  97038. * Execute the action and play the sound.
  97039. */
  97040. execute(): void;
  97041. /**
  97042. * Serializes the actions and its related information.
  97043. * @param parent defines the object to serialize in
  97044. * @returns the serialized object
  97045. */
  97046. serialize(parent: any): any;
  97047. }
  97048. /**
  97049. * This defines an action helpful to stop a defined sound on a triggered action.
  97050. */
  97051. export class StopSoundAction extends Action {
  97052. private _sound;
  97053. /**
  97054. * Instantiate the action
  97055. * @param triggerOptions defines the trigger options
  97056. * @param sound defines the sound to stop
  97057. * @param condition defines the trigger related conditions
  97058. */
  97059. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  97060. /** @hidden */
  97061. _prepare(): void;
  97062. /**
  97063. * Execute the action and stop the sound.
  97064. */
  97065. execute(): void;
  97066. /**
  97067. * Serializes the actions and its related information.
  97068. * @param parent defines the object to serialize in
  97069. * @returns the serialized object
  97070. */
  97071. serialize(parent: any): any;
  97072. }
  97073. }
  97074. declare module BABYLON {
  97075. /**
  97076. * This defines an action responsible to change the value of a property
  97077. * by interpolating between its current value and the newly set one once triggered.
  97078. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  97079. */
  97080. export class InterpolateValueAction extends Action {
  97081. /**
  97082. * Defines the path of the property where the value should be interpolated
  97083. */
  97084. propertyPath: string;
  97085. /**
  97086. * Defines the target value at the end of the interpolation.
  97087. */
  97088. value: any;
  97089. /**
  97090. * Defines the time it will take for the property to interpolate to the value.
  97091. */
  97092. duration: number;
  97093. /**
  97094. * Defines if the other scene animations should be stopped when the action has been triggered
  97095. */
  97096. stopOtherAnimations?: boolean;
  97097. /**
  97098. * Defines a callback raised once the interpolation animation has been done.
  97099. */
  97100. onInterpolationDone?: () => void;
  97101. /**
  97102. * Observable triggered once the interpolation animation has been done.
  97103. */
  97104. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  97105. private _target;
  97106. private _effectiveTarget;
  97107. private _property;
  97108. /**
  97109. * Instantiate the action
  97110. * @param triggerOptions defines the trigger options
  97111. * @param target defines the object containing the value to interpolate
  97112. * @param propertyPath defines the path to the property in the target object
  97113. * @param value defines the target value at the end of the interpolation
  97114. * @param duration deines the time it will take for the property to interpolate to the value.
  97115. * @param condition defines the trigger related conditions
  97116. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  97117. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  97118. */
  97119. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  97120. /** @hidden */
  97121. _prepare(): void;
  97122. /**
  97123. * Execute the action starts the value interpolation.
  97124. */
  97125. execute(): void;
  97126. /**
  97127. * Serializes the actions and its related information.
  97128. * @param parent defines the object to serialize in
  97129. * @returns the serialized object
  97130. */
  97131. serialize(parent: any): any;
  97132. }
  97133. }
  97134. declare module BABYLON {
  97135. /**
  97136. * Options allowed during the creation of a sound track.
  97137. */
  97138. export interface ISoundTrackOptions {
  97139. /**
  97140. * The volume the sound track should take during creation
  97141. */
  97142. volume?: number;
  97143. /**
  97144. * Define if the sound track is the main sound track of the scene
  97145. */
  97146. mainTrack?: boolean;
  97147. }
  97148. /**
  97149. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  97150. * It will be also used in a future release to apply effects on a specific track.
  97151. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  97152. */
  97153. export class SoundTrack {
  97154. /**
  97155. * The unique identifier of the sound track in the scene.
  97156. */
  97157. id: number;
  97158. /**
  97159. * The list of sounds included in the sound track.
  97160. */
  97161. soundCollection: Array<Sound>;
  97162. private _outputAudioNode;
  97163. private _scene;
  97164. private _isMainTrack;
  97165. private _connectedAnalyser;
  97166. private _options;
  97167. private _isInitialized;
  97168. /**
  97169. * Creates a new sound track.
  97170. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  97171. * @param scene Define the scene the sound track belongs to
  97172. * @param options
  97173. */
  97174. constructor(scene: Scene, options?: ISoundTrackOptions);
  97175. private _initializeSoundTrackAudioGraph;
  97176. /**
  97177. * Release the sound track and its associated resources
  97178. */
  97179. dispose(): void;
  97180. /**
  97181. * Adds a sound to this sound track
  97182. * @param sound define the cound to add
  97183. * @ignoreNaming
  97184. */
  97185. AddSound(sound: Sound): void;
  97186. /**
  97187. * Removes a sound to this sound track
  97188. * @param sound define the cound to remove
  97189. * @ignoreNaming
  97190. */
  97191. RemoveSound(sound: Sound): void;
  97192. /**
  97193. * Set a global volume for the full sound track.
  97194. * @param newVolume Define the new volume of the sound track
  97195. */
  97196. setVolume(newVolume: number): void;
  97197. /**
  97198. * Switch the panning model to HRTF:
  97199. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  97200. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97201. */
  97202. switchPanningModelToHRTF(): void;
  97203. /**
  97204. * Switch the panning model to Equal Power:
  97205. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  97206. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97207. */
  97208. switchPanningModelToEqualPower(): void;
  97209. /**
  97210. * Connect the sound track to an audio analyser allowing some amazing
  97211. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  97212. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  97213. * @param analyser The analyser to connect to the engine
  97214. */
  97215. connectToAnalyser(analyser: Analyser): void;
  97216. }
  97217. }
  97218. declare module BABYLON {
  97219. interface AbstractScene {
  97220. /**
  97221. * The list of sounds used in the scene.
  97222. */
  97223. sounds: Nullable<Array<Sound>>;
  97224. }
  97225. interface Scene {
  97226. /**
  97227. * @hidden
  97228. * Backing field
  97229. */
  97230. _mainSoundTrack: SoundTrack;
  97231. /**
  97232. * The main sound track played by the scene.
  97233. * It cotains your primary collection of sounds.
  97234. */
  97235. mainSoundTrack: SoundTrack;
  97236. /**
  97237. * The list of sound tracks added to the scene
  97238. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97239. */
  97240. soundTracks: Nullable<Array<SoundTrack>>;
  97241. /**
  97242. * Gets a sound using a given name
  97243. * @param name defines the name to search for
  97244. * @return the found sound or null if not found at all.
  97245. */
  97246. getSoundByName(name: string): Nullable<Sound>;
  97247. /**
  97248. * Gets or sets if audio support is enabled
  97249. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97250. */
  97251. audioEnabled: boolean;
  97252. /**
  97253. * Gets or sets if audio will be output to headphones
  97254. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97255. */
  97256. headphone: boolean;
  97257. }
  97258. /**
  97259. * Defines the sound scene component responsible to manage any sounds
  97260. * in a given scene.
  97261. */
  97262. export class AudioSceneComponent implements ISceneSerializableComponent {
  97263. /**
  97264. * The component name helpfull to identify the component in the list of scene components.
  97265. */
  97266. readonly name: string;
  97267. /**
  97268. * The scene the component belongs to.
  97269. */
  97270. scene: Scene;
  97271. private _audioEnabled;
  97272. /**
  97273. * Gets whether audio is enabled or not.
  97274. * Please use related enable/disable method to switch state.
  97275. */
  97276. readonly audioEnabled: boolean;
  97277. private _headphone;
  97278. /**
  97279. * Gets whether audio is outputing to headphone or not.
  97280. * Please use the according Switch methods to change output.
  97281. */
  97282. readonly headphone: boolean;
  97283. /**
  97284. * Creates a new instance of the component for the given scene
  97285. * @param scene Defines the scene to register the component in
  97286. */
  97287. constructor(scene: Scene);
  97288. /**
  97289. * Registers the component in a given scene
  97290. */
  97291. register(): void;
  97292. /**
  97293. * Rebuilds the elements related to this component in case of
  97294. * context lost for instance.
  97295. */
  97296. rebuild(): void;
  97297. /**
  97298. * Serializes the component data to the specified json object
  97299. * @param serializationObject The object to serialize to
  97300. */
  97301. serialize(serializationObject: any): void;
  97302. /**
  97303. * Adds all the elements from the container to the scene
  97304. * @param container the container holding the elements
  97305. */
  97306. addFromContainer(container: AbstractScene): void;
  97307. /**
  97308. * Removes all the elements in the container from the scene
  97309. * @param container contains the elements to remove
  97310. * @param dispose if the removed element should be disposed (default: false)
  97311. */
  97312. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  97313. /**
  97314. * Disposes the component and the associated ressources.
  97315. */
  97316. dispose(): void;
  97317. /**
  97318. * Disables audio in the associated scene.
  97319. */
  97320. disableAudio(): void;
  97321. /**
  97322. * Enables audio in the associated scene.
  97323. */
  97324. enableAudio(): void;
  97325. /**
  97326. * Switch audio to headphone output.
  97327. */
  97328. switchAudioModeForHeadphones(): void;
  97329. /**
  97330. * Switch audio to normal speakers.
  97331. */
  97332. switchAudioModeForNormalSpeakers(): void;
  97333. private _afterRender;
  97334. }
  97335. }
  97336. declare module BABYLON {
  97337. /**
  97338. * Wraps one or more Sound objects and selects one with random weight for playback.
  97339. */
  97340. export class WeightedSound {
  97341. /** When true a Sound will be selected and played when the current playing Sound completes. */
  97342. loop: boolean;
  97343. private _coneInnerAngle;
  97344. private _coneOuterAngle;
  97345. private _volume;
  97346. /** A Sound is currently playing. */
  97347. isPlaying: boolean;
  97348. /** A Sound is currently paused. */
  97349. isPaused: boolean;
  97350. private _sounds;
  97351. private _weights;
  97352. private _currentIndex?;
  97353. /**
  97354. * Creates a new WeightedSound from the list of sounds given.
  97355. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  97356. * @param sounds Array of Sounds that will be selected from.
  97357. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  97358. */
  97359. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  97360. /**
  97361. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  97362. */
  97363. /**
  97364. * The size of cone in degress for a directional sound in which there will be no attenuation.
  97365. */
  97366. directionalConeInnerAngle: number;
  97367. /**
  97368. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  97369. * Listener angles between innerAngle and outerAngle will falloff linearly.
  97370. */
  97371. /**
  97372. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  97373. * Listener angles between innerAngle and outerAngle will falloff linearly.
  97374. */
  97375. directionalConeOuterAngle: number;
  97376. /**
  97377. * Playback volume.
  97378. */
  97379. /**
  97380. * Playback volume.
  97381. */
  97382. volume: number;
  97383. private _onended;
  97384. /**
  97385. * Suspend playback
  97386. */
  97387. pause(): void;
  97388. /**
  97389. * Stop playback
  97390. */
  97391. stop(): void;
  97392. /**
  97393. * Start playback.
  97394. * @param startOffset Position the clip head at a specific time in seconds.
  97395. */
  97396. play(startOffset?: number): void;
  97397. }
  97398. }
  97399. declare module BABYLON {
  97400. /**
  97401. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  97402. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  97403. */
  97404. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  97405. /**
  97406. * Gets the name of the behavior.
  97407. */
  97408. readonly name: string;
  97409. /**
  97410. * The easing function used by animations
  97411. */
  97412. static EasingFunction: BackEase;
  97413. /**
  97414. * The easing mode used by animations
  97415. */
  97416. static EasingMode: number;
  97417. /**
  97418. * The duration of the animation, in milliseconds
  97419. */
  97420. transitionDuration: number;
  97421. /**
  97422. * Length of the distance animated by the transition when lower radius is reached
  97423. */
  97424. lowerRadiusTransitionRange: number;
  97425. /**
  97426. * Length of the distance animated by the transition when upper radius is reached
  97427. */
  97428. upperRadiusTransitionRange: number;
  97429. private _autoTransitionRange;
  97430. /**
  97431. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  97432. */
  97433. /**
  97434. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  97435. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  97436. */
  97437. autoTransitionRange: boolean;
  97438. private _attachedCamera;
  97439. private _onAfterCheckInputsObserver;
  97440. private _onMeshTargetChangedObserver;
  97441. /**
  97442. * Initializes the behavior.
  97443. */
  97444. init(): void;
  97445. /**
  97446. * Attaches the behavior to its arc rotate camera.
  97447. * @param camera Defines the camera to attach the behavior to
  97448. */
  97449. attach(camera: ArcRotateCamera): void;
  97450. /**
  97451. * Detaches the behavior from its current arc rotate camera.
  97452. */
  97453. detach(): void;
  97454. private _radiusIsAnimating;
  97455. private _radiusBounceTransition;
  97456. private _animatables;
  97457. private _cachedWheelPrecision;
  97458. /**
  97459. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  97460. * @param radiusLimit The limit to check against.
  97461. * @return Bool to indicate if at limit.
  97462. */
  97463. private _isRadiusAtLimit;
  97464. /**
  97465. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  97466. * @param radiusDelta The delta by which to animate to. Can be negative.
  97467. */
  97468. private _applyBoundRadiusAnimation;
  97469. /**
  97470. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  97471. */
  97472. protected _clearAnimationLocks(): void;
  97473. /**
  97474. * Stops and removes all animations that have been applied to the camera
  97475. */
  97476. stopAllAnimations(): void;
  97477. }
  97478. }
  97479. declare module BABYLON {
  97480. /**
  97481. * 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.
  97482. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  97483. */
  97484. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  97485. /**
  97486. * Gets the name of the behavior.
  97487. */
  97488. readonly name: string;
  97489. private _mode;
  97490. private _radiusScale;
  97491. private _positionScale;
  97492. private _defaultElevation;
  97493. private _elevationReturnTime;
  97494. private _elevationReturnWaitTime;
  97495. private _zoomStopsAnimation;
  97496. private _framingTime;
  97497. /**
  97498. * The easing function used by animations
  97499. */
  97500. static EasingFunction: ExponentialEase;
  97501. /**
  97502. * The easing mode used by animations
  97503. */
  97504. static EasingMode: number;
  97505. /**
  97506. * Sets the current mode used by the behavior
  97507. */
  97508. /**
  97509. * Gets current mode used by the behavior.
  97510. */
  97511. mode: number;
  97512. /**
  97513. * Sets the scale applied to the radius (1 by default)
  97514. */
  97515. /**
  97516. * Gets the scale applied to the radius
  97517. */
  97518. radiusScale: number;
  97519. /**
  97520. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  97521. */
  97522. /**
  97523. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  97524. */
  97525. positionScale: number;
  97526. /**
  97527. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  97528. * behaviour is triggered, in radians.
  97529. */
  97530. /**
  97531. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  97532. * behaviour is triggered, in radians.
  97533. */
  97534. defaultElevation: number;
  97535. /**
  97536. * Sets the time (in milliseconds) taken to return to the default beta position.
  97537. * Negative value indicates camera should not return to default.
  97538. */
  97539. /**
  97540. * Gets the time (in milliseconds) taken to return to the default beta position.
  97541. * Negative value indicates camera should not return to default.
  97542. */
  97543. elevationReturnTime: number;
  97544. /**
  97545. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  97546. */
  97547. /**
  97548. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  97549. */
  97550. elevationReturnWaitTime: number;
  97551. /**
  97552. * Sets the flag that indicates if user zooming should stop animation.
  97553. */
  97554. /**
  97555. * Gets the flag that indicates if user zooming should stop animation.
  97556. */
  97557. zoomStopsAnimation: boolean;
  97558. /**
  97559. * Sets the transition time when framing the mesh, in milliseconds
  97560. */
  97561. /**
  97562. * Gets the transition time when framing the mesh, in milliseconds
  97563. */
  97564. framingTime: number;
  97565. /**
  97566. * Define if the behavior should automatically change the configured
  97567. * camera limits and sensibilities.
  97568. */
  97569. autoCorrectCameraLimitsAndSensibility: boolean;
  97570. private _onPrePointerObservableObserver;
  97571. private _onAfterCheckInputsObserver;
  97572. private _onMeshTargetChangedObserver;
  97573. private _attachedCamera;
  97574. private _isPointerDown;
  97575. private _lastInteractionTime;
  97576. /**
  97577. * Initializes the behavior.
  97578. */
  97579. init(): void;
  97580. /**
  97581. * Attaches the behavior to its arc rotate camera.
  97582. * @param camera Defines the camera to attach the behavior to
  97583. */
  97584. attach(camera: ArcRotateCamera): void;
  97585. /**
  97586. * Detaches the behavior from its current arc rotate camera.
  97587. */
  97588. detach(): void;
  97589. private _animatables;
  97590. private _betaIsAnimating;
  97591. private _betaTransition;
  97592. private _radiusTransition;
  97593. private _vectorTransition;
  97594. /**
  97595. * Targets the given mesh and updates zoom level accordingly.
  97596. * @param mesh The mesh to target.
  97597. * @param radius Optional. If a cached radius position already exists, overrides default.
  97598. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  97599. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  97600. * @param onAnimationEnd Callback triggered at the end of the framing animation
  97601. */
  97602. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  97603. /**
  97604. * Targets the given mesh with its children and updates zoom level accordingly.
  97605. * @param mesh The mesh to target.
  97606. * @param radius Optional. If a cached radius position already exists, overrides default.
  97607. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  97608. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  97609. * @param onAnimationEnd Callback triggered at the end of the framing animation
  97610. */
  97611. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  97612. /**
  97613. * Targets the given meshes with their children and updates zoom level accordingly.
  97614. * @param meshes The mesh to target.
  97615. * @param radius Optional. If a cached radius position already exists, overrides default.
  97616. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  97617. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  97618. * @param onAnimationEnd Callback triggered at the end of the framing animation
  97619. */
  97620. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  97621. /**
  97622. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  97623. * @param minimumWorld Determines the smaller position of the bounding box extend
  97624. * @param maximumWorld Determines the bigger position of the bounding box extend
  97625. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  97626. * @param onAnimationEnd Callback triggered at the end of the framing animation
  97627. */
  97628. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  97629. /**
  97630. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  97631. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  97632. * frustum width.
  97633. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  97634. * to fully enclose the mesh in the viewing frustum.
  97635. */
  97636. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  97637. /**
  97638. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  97639. * is automatically returned to its default position (expected to be above ground plane).
  97640. */
  97641. private _maintainCameraAboveGround;
  97642. /**
  97643. * Returns the frustum slope based on the canvas ratio and camera FOV
  97644. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  97645. */
  97646. private _getFrustumSlope;
  97647. /**
  97648. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  97649. */
  97650. private _clearAnimationLocks;
  97651. /**
  97652. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  97653. */
  97654. private _applyUserInteraction;
  97655. /**
  97656. * Stops and removes all animations that have been applied to the camera
  97657. */
  97658. stopAllAnimations(): void;
  97659. /**
  97660. * Gets a value indicating if the user is moving the camera
  97661. */
  97662. readonly isUserIsMoving: boolean;
  97663. /**
  97664. * The camera can move all the way towards the mesh.
  97665. */
  97666. static IgnoreBoundsSizeMode: number;
  97667. /**
  97668. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  97669. */
  97670. static FitFrustumSidesMode: number;
  97671. }
  97672. }
  97673. declare module BABYLON {
  97674. /**
  97675. * Base class for Camera Pointer Inputs.
  97676. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  97677. * for example usage.
  97678. */
  97679. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  97680. /**
  97681. * Defines the camera the input is attached to.
  97682. */
  97683. abstract camera: Camera;
  97684. /**
  97685. * Whether keyboard modifier keys are pressed at time of last mouse event.
  97686. */
  97687. protected _altKey: boolean;
  97688. protected _ctrlKey: boolean;
  97689. protected _metaKey: boolean;
  97690. protected _shiftKey: boolean;
  97691. /**
  97692. * Which mouse buttons were pressed at time of last mouse event.
  97693. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  97694. */
  97695. protected _buttonsPressed: number;
  97696. /**
  97697. * Defines the buttons associated with the input to handle camera move.
  97698. */
  97699. buttons: number[];
  97700. /**
  97701. * Attach the input controls to a specific dom element to get the input from.
  97702. * @param element Defines the element the controls should be listened from
  97703. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97704. */
  97705. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97706. /**
  97707. * Detach the current controls from the specified dom element.
  97708. * @param element Defines the element to stop listening the inputs from
  97709. */
  97710. detachControl(element: Nullable<HTMLElement>): void;
  97711. /**
  97712. * Gets the class name of the current input.
  97713. * @returns the class name
  97714. */
  97715. getClassName(): string;
  97716. /**
  97717. * Get the friendly name associated with the input class.
  97718. * @returns the input friendly name
  97719. */
  97720. getSimpleName(): string;
  97721. /**
  97722. * Called on pointer POINTERDOUBLETAP event.
  97723. * Override this method to provide functionality on POINTERDOUBLETAP event.
  97724. */
  97725. protected onDoubleTap(type: string): void;
  97726. /**
  97727. * Called on pointer POINTERMOVE event if only a single touch is active.
  97728. * Override this method to provide functionality.
  97729. */
  97730. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  97731. /**
  97732. * Called on pointer POINTERMOVE event if multiple touches are active.
  97733. * Override this method to provide functionality.
  97734. */
  97735. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  97736. /**
  97737. * Called on JS contextmenu event.
  97738. * Override this method to provide functionality.
  97739. */
  97740. protected onContextMenu(evt: PointerEvent): void;
  97741. /**
  97742. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  97743. * press.
  97744. * Override this method to provide functionality.
  97745. */
  97746. protected onButtonDown(evt: PointerEvent): void;
  97747. /**
  97748. * Called each time a new POINTERUP event occurs. Ie, for each button
  97749. * release.
  97750. * Override this method to provide functionality.
  97751. */
  97752. protected onButtonUp(evt: PointerEvent): void;
  97753. /**
  97754. * Called when window becomes inactive.
  97755. * Override this method to provide functionality.
  97756. */
  97757. protected onLostFocus(): void;
  97758. private _pointerInput;
  97759. private _observer;
  97760. private _onLostFocus;
  97761. private pointA;
  97762. private pointB;
  97763. }
  97764. }
  97765. declare module BABYLON {
  97766. /**
  97767. * Manage the pointers inputs to control an arc rotate camera.
  97768. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  97769. */
  97770. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  97771. /**
  97772. * Defines the camera the input is attached to.
  97773. */
  97774. camera: ArcRotateCamera;
  97775. /**
  97776. * Gets the class name of the current input.
  97777. * @returns the class name
  97778. */
  97779. getClassName(): string;
  97780. /**
  97781. * Defines the buttons associated with the input to handle camera move.
  97782. */
  97783. buttons: number[];
  97784. /**
  97785. * Defines the pointer angular sensibility along the X axis or how fast is
  97786. * the camera rotating.
  97787. */
  97788. angularSensibilityX: number;
  97789. /**
  97790. * Defines the pointer angular sensibility along the Y axis or how fast is
  97791. * the camera rotating.
  97792. */
  97793. angularSensibilityY: number;
  97794. /**
  97795. * Defines the pointer pinch precision or how fast is the camera zooming.
  97796. */
  97797. pinchPrecision: number;
  97798. /**
  97799. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  97800. * from 0.
  97801. * It defines the percentage of current camera.radius to use as delta when
  97802. * pinch zoom is used.
  97803. */
  97804. pinchDeltaPercentage: number;
  97805. /**
  97806. * Defines the pointer panning sensibility or how fast is the camera moving.
  97807. */
  97808. panningSensibility: number;
  97809. /**
  97810. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  97811. */
  97812. multiTouchPanning: boolean;
  97813. /**
  97814. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  97815. * zoom (pinch) through multitouch.
  97816. */
  97817. multiTouchPanAndZoom: boolean;
  97818. /**
  97819. * Revers pinch action direction.
  97820. */
  97821. pinchInwards: boolean;
  97822. private _isPanClick;
  97823. private _twoFingerActivityCount;
  97824. private _isPinching;
  97825. /**
  97826. * Called on pointer POINTERMOVE event if only a single touch is active.
  97827. */
  97828. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  97829. /**
  97830. * Called on pointer POINTERDOUBLETAP event.
  97831. */
  97832. protected onDoubleTap(type: string): void;
  97833. /**
  97834. * Called on pointer POINTERMOVE event if multiple touches are active.
  97835. */
  97836. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  97837. /**
  97838. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  97839. * press.
  97840. */
  97841. protected onButtonDown(evt: PointerEvent): void;
  97842. /**
  97843. * Called each time a new POINTERUP event occurs. Ie, for each button
  97844. * release.
  97845. */
  97846. protected onButtonUp(evt: PointerEvent): void;
  97847. /**
  97848. * Called when window becomes inactive.
  97849. */
  97850. protected onLostFocus(): void;
  97851. }
  97852. }
  97853. declare module BABYLON {
  97854. /**
  97855. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  97856. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  97857. */
  97858. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  97859. /**
  97860. * Defines the camera the input is attached to.
  97861. */
  97862. camera: ArcRotateCamera;
  97863. /**
  97864. * Defines the list of key codes associated with the up action (increase alpha)
  97865. */
  97866. keysUp: number[];
  97867. /**
  97868. * Defines the list of key codes associated with the down action (decrease alpha)
  97869. */
  97870. keysDown: number[];
  97871. /**
  97872. * Defines the list of key codes associated with the left action (increase beta)
  97873. */
  97874. keysLeft: number[];
  97875. /**
  97876. * Defines the list of key codes associated with the right action (decrease beta)
  97877. */
  97878. keysRight: number[];
  97879. /**
  97880. * Defines the list of key codes associated with the reset action.
  97881. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  97882. */
  97883. keysReset: number[];
  97884. /**
  97885. * Defines the panning sensibility of the inputs.
  97886. * (How fast is the camera paning)
  97887. */
  97888. panningSensibility: number;
  97889. /**
  97890. * Defines the zooming sensibility of the inputs.
  97891. * (How fast is the camera zooming)
  97892. */
  97893. zoomingSensibility: number;
  97894. /**
  97895. * Defines wether maintaining the alt key down switch the movement mode from
  97896. * orientation to zoom.
  97897. */
  97898. useAltToZoom: boolean;
  97899. /**
  97900. * Rotation speed of the camera
  97901. */
  97902. angularSpeed: number;
  97903. private _keys;
  97904. private _ctrlPressed;
  97905. private _altPressed;
  97906. private _onCanvasBlurObserver;
  97907. private _onKeyboardObserver;
  97908. private _engine;
  97909. private _scene;
  97910. /**
  97911. * Attach the input controls to a specific dom element to get the input from.
  97912. * @param element Defines the element the controls should be listened from
  97913. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97914. */
  97915. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97916. /**
  97917. * Detach the current controls from the specified dom element.
  97918. * @param element Defines the element to stop listening the inputs from
  97919. */
  97920. detachControl(element: Nullable<HTMLElement>): void;
  97921. /**
  97922. * Update the current camera state depending on the inputs that have been used this frame.
  97923. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  97924. */
  97925. checkInputs(): void;
  97926. /**
  97927. * Gets the class name of the current intput.
  97928. * @returns the class name
  97929. */
  97930. getClassName(): string;
  97931. /**
  97932. * Get the friendly name associated with the input class.
  97933. * @returns the input friendly name
  97934. */
  97935. getSimpleName(): string;
  97936. }
  97937. }
  97938. declare module BABYLON {
  97939. /**
  97940. * Manage the mouse wheel inputs to control an arc rotate camera.
  97941. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  97942. */
  97943. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  97944. /**
  97945. * Defines the camera the input is attached to.
  97946. */
  97947. camera: ArcRotateCamera;
  97948. /**
  97949. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  97950. */
  97951. wheelPrecision: number;
  97952. /**
  97953. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  97954. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  97955. */
  97956. wheelDeltaPercentage: number;
  97957. private _wheel;
  97958. private _observer;
  97959. private computeDeltaFromMouseWheelLegacyEvent;
  97960. /**
  97961. * Attach the input controls to a specific dom element to get the input from.
  97962. * @param element Defines the element the controls should be listened from
  97963. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97964. */
  97965. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97966. /**
  97967. * Detach the current controls from the specified dom element.
  97968. * @param element Defines the element to stop listening the inputs from
  97969. */
  97970. detachControl(element: Nullable<HTMLElement>): void;
  97971. /**
  97972. * Gets the class name of the current intput.
  97973. * @returns the class name
  97974. */
  97975. getClassName(): string;
  97976. /**
  97977. * Get the friendly name associated with the input class.
  97978. * @returns the input friendly name
  97979. */
  97980. getSimpleName(): string;
  97981. }
  97982. }
  97983. declare module BABYLON {
  97984. /**
  97985. * Default Inputs manager for the ArcRotateCamera.
  97986. * It groups all the default supported inputs for ease of use.
  97987. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  97988. */
  97989. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  97990. /**
  97991. * Instantiates a new ArcRotateCameraInputsManager.
  97992. * @param camera Defines the camera the inputs belong to
  97993. */
  97994. constructor(camera: ArcRotateCamera);
  97995. /**
  97996. * Add mouse wheel input support to the input manager.
  97997. * @returns the current input manager
  97998. */
  97999. addMouseWheel(): ArcRotateCameraInputsManager;
  98000. /**
  98001. * Add pointers input support to the input manager.
  98002. * @returns the current input manager
  98003. */
  98004. addPointers(): ArcRotateCameraInputsManager;
  98005. /**
  98006. * Add keyboard input support to the input manager.
  98007. * @returns the current input manager
  98008. */
  98009. addKeyboard(): ArcRotateCameraInputsManager;
  98010. }
  98011. }
  98012. declare module BABYLON {
  98013. /**
  98014. * This represents an orbital type of camera.
  98015. *
  98016. * 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.
  98017. * 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.
  98018. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  98019. */
  98020. export class ArcRotateCamera extends TargetCamera {
  98021. /**
  98022. * Defines the rotation angle of the camera along the longitudinal axis.
  98023. */
  98024. alpha: number;
  98025. /**
  98026. * Defines the rotation angle of the camera along the latitudinal axis.
  98027. */
  98028. beta: number;
  98029. /**
  98030. * Defines the radius of the camera from it s target point.
  98031. */
  98032. radius: number;
  98033. protected _target: Vector3;
  98034. protected _targetHost: Nullable<AbstractMesh>;
  98035. /**
  98036. * Defines the target point of the camera.
  98037. * The camera looks towards it form the radius distance.
  98038. */
  98039. target: Vector3;
  98040. /**
  98041. * Define the current local position of the camera in the scene
  98042. */
  98043. position: Vector3;
  98044. protected _upVector: Vector3;
  98045. protected _upToYMatrix: Matrix;
  98046. protected _YToUpMatrix: Matrix;
  98047. /**
  98048. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  98049. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  98050. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  98051. */
  98052. upVector: Vector3;
  98053. /**
  98054. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  98055. */
  98056. setMatUp(): void;
  98057. /**
  98058. * Current inertia value on the longitudinal axis.
  98059. * The bigger this number the longer it will take for the camera to stop.
  98060. */
  98061. inertialAlphaOffset: number;
  98062. /**
  98063. * Current inertia value on the latitudinal axis.
  98064. * The bigger this number the longer it will take for the camera to stop.
  98065. */
  98066. inertialBetaOffset: number;
  98067. /**
  98068. * Current inertia value on the radius axis.
  98069. * The bigger this number the longer it will take for the camera to stop.
  98070. */
  98071. inertialRadiusOffset: number;
  98072. /**
  98073. * Minimum allowed angle on the longitudinal axis.
  98074. * This can help limiting how the Camera is able to move in the scene.
  98075. */
  98076. lowerAlphaLimit: Nullable<number>;
  98077. /**
  98078. * Maximum allowed angle on the longitudinal axis.
  98079. * This can help limiting how the Camera is able to move in the scene.
  98080. */
  98081. upperAlphaLimit: Nullable<number>;
  98082. /**
  98083. * Minimum allowed angle on the latitudinal axis.
  98084. * This can help limiting how the Camera is able to move in the scene.
  98085. */
  98086. lowerBetaLimit: number;
  98087. /**
  98088. * Maximum allowed angle on the latitudinal axis.
  98089. * This can help limiting how the Camera is able to move in the scene.
  98090. */
  98091. upperBetaLimit: number;
  98092. /**
  98093. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  98094. * This can help limiting how the Camera is able to move in the scene.
  98095. */
  98096. lowerRadiusLimit: Nullable<number>;
  98097. /**
  98098. * Maximum allowed distance of the camera to the target (The camera can not get further).
  98099. * This can help limiting how the Camera is able to move in the scene.
  98100. */
  98101. upperRadiusLimit: Nullable<number>;
  98102. /**
  98103. * Defines the current inertia value used during panning of the camera along the X axis.
  98104. */
  98105. inertialPanningX: number;
  98106. /**
  98107. * Defines the current inertia value used during panning of the camera along the Y axis.
  98108. */
  98109. inertialPanningY: number;
  98110. /**
  98111. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  98112. * Basically if your fingers moves away from more than this distance you will be considered
  98113. * in pinch mode.
  98114. */
  98115. pinchToPanMaxDistance: number;
  98116. /**
  98117. * Defines the maximum distance the camera can pan.
  98118. * This could help keeping the cammera always in your scene.
  98119. */
  98120. panningDistanceLimit: Nullable<number>;
  98121. /**
  98122. * Defines the target of the camera before paning.
  98123. */
  98124. panningOriginTarget: Vector3;
  98125. /**
  98126. * Defines the value of the inertia used during panning.
  98127. * 0 would mean stop inertia and one would mean no decelleration at all.
  98128. */
  98129. panningInertia: number;
  98130. /**
  98131. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  98132. */
  98133. angularSensibilityX: number;
  98134. /**
  98135. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  98136. */
  98137. angularSensibilityY: number;
  98138. /**
  98139. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  98140. */
  98141. pinchPrecision: number;
  98142. /**
  98143. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  98144. * It will be used instead of pinchDeltaPrecision if different from 0.
  98145. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  98146. */
  98147. pinchDeltaPercentage: number;
  98148. /**
  98149. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  98150. */
  98151. panningSensibility: number;
  98152. /**
  98153. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  98154. */
  98155. keysUp: number[];
  98156. /**
  98157. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  98158. */
  98159. keysDown: number[];
  98160. /**
  98161. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  98162. */
  98163. keysLeft: number[];
  98164. /**
  98165. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  98166. */
  98167. keysRight: number[];
  98168. /**
  98169. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  98170. */
  98171. wheelPrecision: number;
  98172. /**
  98173. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  98174. * It will be used instead of pinchDeltaPrecision if different from 0.
  98175. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  98176. */
  98177. wheelDeltaPercentage: number;
  98178. /**
  98179. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  98180. */
  98181. zoomOnFactor: number;
  98182. /**
  98183. * Defines a screen offset for the camera position.
  98184. */
  98185. targetScreenOffset: Vector2;
  98186. /**
  98187. * Allows the camera to be completely reversed.
  98188. * If false the camera can not arrive upside down.
  98189. */
  98190. allowUpsideDown: boolean;
  98191. /**
  98192. * Define if double tap/click is used to restore the previously saved state of the camera.
  98193. */
  98194. useInputToRestoreState: boolean;
  98195. /** @hidden */
  98196. _viewMatrix: Matrix;
  98197. /** @hidden */
  98198. _useCtrlForPanning: boolean;
  98199. /** @hidden */
  98200. _panningMouseButton: number;
  98201. /**
  98202. * Defines the input associated to the camera.
  98203. */
  98204. inputs: ArcRotateCameraInputsManager;
  98205. /** @hidden */
  98206. _reset: () => void;
  98207. /**
  98208. * Defines the allowed panning axis.
  98209. */
  98210. panningAxis: Vector3;
  98211. protected _localDirection: Vector3;
  98212. protected _transformedDirection: Vector3;
  98213. private _bouncingBehavior;
  98214. /**
  98215. * Gets the bouncing behavior of the camera if it has been enabled.
  98216. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  98217. */
  98218. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  98219. /**
  98220. * Defines if the bouncing behavior of the camera is enabled on the camera.
  98221. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  98222. */
  98223. useBouncingBehavior: boolean;
  98224. private _framingBehavior;
  98225. /**
  98226. * Gets the framing behavior of the camera if it has been enabled.
  98227. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  98228. */
  98229. readonly framingBehavior: Nullable<FramingBehavior>;
  98230. /**
  98231. * Defines if the framing behavior of the camera is enabled on the camera.
  98232. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  98233. */
  98234. useFramingBehavior: boolean;
  98235. private _autoRotationBehavior;
  98236. /**
  98237. * Gets the auto rotation behavior of the camera if it has been enabled.
  98238. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  98239. */
  98240. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  98241. /**
  98242. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  98243. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  98244. */
  98245. useAutoRotationBehavior: boolean;
  98246. /**
  98247. * Observable triggered when the mesh target has been changed on the camera.
  98248. */
  98249. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  98250. /**
  98251. * Event raised when the camera is colliding with a mesh.
  98252. */
  98253. onCollide: (collidedMesh: AbstractMesh) => void;
  98254. /**
  98255. * Defines whether the camera should check collision with the objects oh the scene.
  98256. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  98257. */
  98258. checkCollisions: boolean;
  98259. /**
  98260. * Defines the collision radius of the camera.
  98261. * This simulates a sphere around the camera.
  98262. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  98263. */
  98264. collisionRadius: Vector3;
  98265. protected _collider: Collider;
  98266. protected _previousPosition: Vector3;
  98267. protected _collisionVelocity: Vector3;
  98268. protected _newPosition: Vector3;
  98269. protected _previousAlpha: number;
  98270. protected _previousBeta: number;
  98271. protected _previousRadius: number;
  98272. protected _collisionTriggered: boolean;
  98273. protected _targetBoundingCenter: Nullable<Vector3>;
  98274. private _computationVector;
  98275. /**
  98276. * Instantiates a new ArcRotateCamera in a given scene
  98277. * @param name Defines the name of the camera
  98278. * @param alpha Defines the camera rotation along the logitudinal axis
  98279. * @param beta Defines the camera rotation along the latitudinal axis
  98280. * @param radius Defines the camera distance from its target
  98281. * @param target Defines the camera target
  98282. * @param scene Defines the scene the camera belongs to
  98283. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  98284. */
  98285. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  98286. /** @hidden */
  98287. _initCache(): void;
  98288. /** @hidden */
  98289. _updateCache(ignoreParentClass?: boolean): void;
  98290. protected _getTargetPosition(): Vector3;
  98291. private _storedAlpha;
  98292. private _storedBeta;
  98293. private _storedRadius;
  98294. private _storedTarget;
  98295. /**
  98296. * Stores the current state of the camera (alpha, beta, radius and target)
  98297. * @returns the camera itself
  98298. */
  98299. storeState(): Camera;
  98300. /**
  98301. * @hidden
  98302. * Restored camera state. You must call storeState() first
  98303. */
  98304. _restoreStateValues(): boolean;
  98305. /** @hidden */
  98306. _isSynchronizedViewMatrix(): boolean;
  98307. /**
  98308. * Attached controls to the current camera.
  98309. * @param element Defines the element the controls should be listened from
  98310. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98311. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  98312. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  98313. */
  98314. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  98315. /**
  98316. * Detach the current controls from the camera.
  98317. * The camera will stop reacting to inputs.
  98318. * @param element Defines the element to stop listening the inputs from
  98319. */
  98320. detachControl(element: HTMLElement): void;
  98321. /** @hidden */
  98322. _checkInputs(): void;
  98323. protected _checkLimits(): void;
  98324. /**
  98325. * Rebuilds angles (alpha, beta) and radius from the give position and target
  98326. */
  98327. rebuildAnglesAndRadius(): void;
  98328. /**
  98329. * Use a position to define the current camera related information like aplha, beta and radius
  98330. * @param position Defines the position to set the camera at
  98331. */
  98332. setPosition(position: Vector3): void;
  98333. /**
  98334. * Defines the target the camera should look at.
  98335. * This will automatically adapt alpha beta and radius to fit within the new target.
  98336. * @param target Defines the new target as a Vector or a mesh
  98337. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  98338. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  98339. */
  98340. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  98341. /** @hidden */
  98342. _getViewMatrix(): Matrix;
  98343. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  98344. /**
  98345. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  98346. * @param meshes Defines the mesh to zoom on
  98347. * @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)
  98348. */
  98349. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  98350. /**
  98351. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  98352. * The target will be changed but the radius
  98353. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  98354. * @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)
  98355. */
  98356. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  98357. min: Vector3;
  98358. max: Vector3;
  98359. distance: number;
  98360. }, doNotUpdateMaxZ?: boolean): void;
  98361. /**
  98362. * @override
  98363. * Override Camera.createRigCamera
  98364. */
  98365. createRigCamera(name: string, cameraIndex: number): Camera;
  98366. /**
  98367. * @hidden
  98368. * @override
  98369. * Override Camera._updateRigCameras
  98370. */
  98371. _updateRigCameras(): void;
  98372. /**
  98373. * Destroy the camera and release the current resources hold by it.
  98374. */
  98375. dispose(): void;
  98376. /**
  98377. * Gets the current object class name.
  98378. * @return the class name
  98379. */
  98380. getClassName(): string;
  98381. }
  98382. }
  98383. declare module BABYLON {
  98384. /**
  98385. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  98386. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  98387. */
  98388. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  98389. /**
  98390. * Gets the name of the behavior.
  98391. */
  98392. readonly name: string;
  98393. private _zoomStopsAnimation;
  98394. private _idleRotationSpeed;
  98395. private _idleRotationWaitTime;
  98396. private _idleRotationSpinupTime;
  98397. /**
  98398. * Sets the flag that indicates if user zooming should stop animation.
  98399. */
  98400. /**
  98401. * Gets the flag that indicates if user zooming should stop animation.
  98402. */
  98403. zoomStopsAnimation: boolean;
  98404. /**
  98405. * Sets the default speed at which the camera rotates around the model.
  98406. */
  98407. /**
  98408. * Gets the default speed at which the camera rotates around the model.
  98409. */
  98410. idleRotationSpeed: number;
  98411. /**
  98412. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  98413. */
  98414. /**
  98415. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  98416. */
  98417. idleRotationWaitTime: number;
  98418. /**
  98419. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  98420. */
  98421. /**
  98422. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  98423. */
  98424. idleRotationSpinupTime: number;
  98425. /**
  98426. * Gets a value indicating if the camera is currently rotating because of this behavior
  98427. */
  98428. readonly rotationInProgress: boolean;
  98429. private _onPrePointerObservableObserver;
  98430. private _onAfterCheckInputsObserver;
  98431. private _attachedCamera;
  98432. private _isPointerDown;
  98433. private _lastFrameTime;
  98434. private _lastInteractionTime;
  98435. private _cameraRotationSpeed;
  98436. /**
  98437. * Initializes the behavior.
  98438. */
  98439. init(): void;
  98440. /**
  98441. * Attaches the behavior to its arc rotate camera.
  98442. * @param camera Defines the camera to attach the behavior to
  98443. */
  98444. attach(camera: ArcRotateCamera): void;
  98445. /**
  98446. * Detaches the behavior from its current arc rotate camera.
  98447. */
  98448. detach(): void;
  98449. /**
  98450. * Returns true if user is scrolling.
  98451. * @return true if user is scrolling.
  98452. */
  98453. private _userIsZooming;
  98454. private _lastFrameRadius;
  98455. private _shouldAnimationStopForInteraction;
  98456. /**
  98457. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  98458. */
  98459. private _applyUserInteraction;
  98460. private _userIsMoving;
  98461. }
  98462. }
  98463. declare module BABYLON {
  98464. /**
  98465. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  98466. */
  98467. export class AttachToBoxBehavior implements Behavior<Mesh> {
  98468. private ui;
  98469. /**
  98470. * The name of the behavior
  98471. */
  98472. name: string;
  98473. /**
  98474. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  98475. */
  98476. distanceAwayFromFace: number;
  98477. /**
  98478. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  98479. */
  98480. distanceAwayFromBottomOfFace: number;
  98481. private _faceVectors;
  98482. private _target;
  98483. private _scene;
  98484. private _onRenderObserver;
  98485. private _tmpMatrix;
  98486. private _tmpVector;
  98487. /**
  98488. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  98489. * @param ui The transform node that should be attched to the mesh
  98490. */
  98491. constructor(ui: TransformNode);
  98492. /**
  98493. * Initializes the behavior
  98494. */
  98495. init(): void;
  98496. private _closestFace;
  98497. private _zeroVector;
  98498. private _lookAtTmpMatrix;
  98499. private _lookAtToRef;
  98500. /**
  98501. * Attaches the AttachToBoxBehavior to the passed in mesh
  98502. * @param target The mesh that the specified node will be attached to
  98503. */
  98504. attach(target: Mesh): void;
  98505. /**
  98506. * Detaches the behavior from the mesh
  98507. */
  98508. detach(): void;
  98509. }
  98510. }
  98511. declare module BABYLON {
  98512. /**
  98513. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  98514. */
  98515. export class FadeInOutBehavior implements Behavior<Mesh> {
  98516. /**
  98517. * Time in milliseconds to delay before fading in (Default: 0)
  98518. */
  98519. delay: number;
  98520. /**
  98521. * Time in milliseconds for the mesh to fade in (Default: 300)
  98522. */
  98523. fadeInTime: number;
  98524. private _millisecondsPerFrame;
  98525. private _hovered;
  98526. private _hoverValue;
  98527. private _ownerNode;
  98528. /**
  98529. * Instatiates the FadeInOutBehavior
  98530. */
  98531. constructor();
  98532. /**
  98533. * The name of the behavior
  98534. */
  98535. readonly name: string;
  98536. /**
  98537. * Initializes the behavior
  98538. */
  98539. init(): void;
  98540. /**
  98541. * Attaches the fade behavior on the passed in mesh
  98542. * @param ownerNode The mesh that will be faded in/out once attached
  98543. */
  98544. attach(ownerNode: Mesh): void;
  98545. /**
  98546. * Detaches the behavior from the mesh
  98547. */
  98548. detach(): void;
  98549. /**
  98550. * Triggers the mesh to begin fading in or out
  98551. * @param value if the object should fade in or out (true to fade in)
  98552. */
  98553. fadeIn(value: boolean): void;
  98554. private _update;
  98555. private _setAllVisibility;
  98556. }
  98557. }
  98558. declare module BABYLON {
  98559. /**
  98560. * Class containing a set of static utilities functions for managing Pivots
  98561. * @hidden
  98562. */
  98563. export class PivotTools {
  98564. private static _PivotCached;
  98565. private static _OldPivotPoint;
  98566. private static _PivotTranslation;
  98567. private static _PivotTmpVector;
  98568. /** @hidden */
  98569. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  98570. /** @hidden */
  98571. static _RestorePivotPoint(mesh: AbstractMesh): void;
  98572. }
  98573. }
  98574. declare module BABYLON {
  98575. /**
  98576. * Class containing static functions to help procedurally build meshes
  98577. */
  98578. export class PlaneBuilder {
  98579. /**
  98580. * Creates a plane mesh
  98581. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  98582. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  98583. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  98584. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  98585. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  98586. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98587. * @param name defines the name of the mesh
  98588. * @param options defines the options used to create the mesh
  98589. * @param scene defines the hosting scene
  98590. * @returns the plane mesh
  98591. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  98592. */
  98593. static CreatePlane(name: string, options: {
  98594. size?: number;
  98595. width?: number;
  98596. height?: number;
  98597. sideOrientation?: number;
  98598. frontUVs?: Vector4;
  98599. backUVs?: Vector4;
  98600. updatable?: boolean;
  98601. sourcePlane?: Plane;
  98602. }, scene?: Nullable<Scene>): Mesh;
  98603. }
  98604. }
  98605. declare module BABYLON {
  98606. /**
  98607. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  98608. */
  98609. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  98610. private static _AnyMouseID;
  98611. /**
  98612. * Abstract mesh the behavior is set on
  98613. */
  98614. attachedNode: AbstractMesh;
  98615. private _dragPlane;
  98616. private _scene;
  98617. private _pointerObserver;
  98618. private _beforeRenderObserver;
  98619. private static _planeScene;
  98620. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  98621. /**
  98622. * 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)
  98623. */
  98624. maxDragAngle: number;
  98625. /**
  98626. * @hidden
  98627. */
  98628. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  98629. /**
  98630. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  98631. */
  98632. currentDraggingPointerID: number;
  98633. /**
  98634. * The last position where the pointer hit the drag plane in world space
  98635. */
  98636. lastDragPosition: Vector3;
  98637. /**
  98638. * If the behavior is currently in a dragging state
  98639. */
  98640. dragging: boolean;
  98641. /**
  98642. * 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)
  98643. */
  98644. dragDeltaRatio: number;
  98645. /**
  98646. * If the drag plane orientation should be updated during the dragging (Default: true)
  98647. */
  98648. updateDragPlane: boolean;
  98649. private _debugMode;
  98650. private _moving;
  98651. /**
  98652. * Fires each time the attached mesh is dragged with the pointer
  98653. * * delta between last drag position and current drag position in world space
  98654. * * dragDistance along the drag axis
  98655. * * dragPlaneNormal normal of the current drag plane used during the drag
  98656. * * dragPlanePoint in world space where the drag intersects the drag plane
  98657. */
  98658. onDragObservable: Observable<{
  98659. delta: Vector3;
  98660. dragPlanePoint: Vector3;
  98661. dragPlaneNormal: Vector3;
  98662. dragDistance: number;
  98663. pointerId: number;
  98664. }>;
  98665. /**
  98666. * Fires each time a drag begins (eg. mouse down on mesh)
  98667. */
  98668. onDragStartObservable: Observable<{
  98669. dragPlanePoint: Vector3;
  98670. pointerId: number;
  98671. }>;
  98672. /**
  98673. * Fires each time a drag ends (eg. mouse release after drag)
  98674. */
  98675. onDragEndObservable: Observable<{
  98676. dragPlanePoint: Vector3;
  98677. pointerId: number;
  98678. }>;
  98679. /**
  98680. * If the attached mesh should be moved when dragged
  98681. */
  98682. moveAttached: boolean;
  98683. /**
  98684. * If the drag behavior will react to drag events (Default: true)
  98685. */
  98686. enabled: boolean;
  98687. /**
  98688. * If camera controls should be detached during the drag
  98689. */
  98690. detachCameraControls: boolean;
  98691. /**
  98692. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  98693. */
  98694. useObjectOrienationForDragging: boolean;
  98695. private _options;
  98696. /**
  98697. * Creates a pointer drag behavior that can be attached to a mesh
  98698. * @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)
  98699. */
  98700. constructor(options?: {
  98701. dragAxis?: Vector3;
  98702. dragPlaneNormal?: Vector3;
  98703. });
  98704. /**
  98705. * Predicate to determine if it is valid to move the object to a new position when it is moved
  98706. */
  98707. validateDrag: (targetPosition: Vector3) => boolean;
  98708. /**
  98709. * The name of the behavior
  98710. */
  98711. readonly name: string;
  98712. /**
  98713. * Initializes the behavior
  98714. */
  98715. init(): void;
  98716. private _tmpVector;
  98717. private _alternatePickedPoint;
  98718. private _worldDragAxis;
  98719. private _targetPosition;
  98720. private _attachedElement;
  98721. /**
  98722. * Attaches the drag behavior the passed in mesh
  98723. * @param ownerNode The mesh that will be dragged around once attached
  98724. */
  98725. attach(ownerNode: AbstractMesh): void;
  98726. /**
  98727. * Force relase the drag action by code.
  98728. */
  98729. releaseDrag(): void;
  98730. private _startDragRay;
  98731. private _lastPointerRay;
  98732. /**
  98733. * Simulates the start of a pointer drag event on the behavior
  98734. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  98735. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  98736. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  98737. */
  98738. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  98739. private _startDrag;
  98740. private _dragDelta;
  98741. private _moveDrag;
  98742. private _pickWithRayOnDragPlane;
  98743. private _pointA;
  98744. private _pointB;
  98745. private _pointC;
  98746. private _lineA;
  98747. private _lineB;
  98748. private _localAxis;
  98749. private _lookAt;
  98750. private _updateDragPlanePosition;
  98751. /**
  98752. * Detaches the behavior from the mesh
  98753. */
  98754. detach(): void;
  98755. }
  98756. }
  98757. declare module BABYLON {
  98758. /**
  98759. * A behavior that when attached to a mesh will allow the mesh to be scaled
  98760. */
  98761. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  98762. private _dragBehaviorA;
  98763. private _dragBehaviorB;
  98764. private _startDistance;
  98765. private _initialScale;
  98766. private _targetScale;
  98767. private _ownerNode;
  98768. private _sceneRenderObserver;
  98769. /**
  98770. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  98771. */
  98772. constructor();
  98773. /**
  98774. * The name of the behavior
  98775. */
  98776. readonly name: string;
  98777. /**
  98778. * Initializes the behavior
  98779. */
  98780. init(): void;
  98781. private _getCurrentDistance;
  98782. /**
  98783. * Attaches the scale behavior the passed in mesh
  98784. * @param ownerNode The mesh that will be scaled around once attached
  98785. */
  98786. attach(ownerNode: Mesh): void;
  98787. /**
  98788. * Detaches the behavior from the mesh
  98789. */
  98790. detach(): void;
  98791. }
  98792. }
  98793. declare module BABYLON {
  98794. /**
  98795. * 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
  98796. */
  98797. export class SixDofDragBehavior implements Behavior<Mesh> {
  98798. private static _virtualScene;
  98799. private _ownerNode;
  98800. private _sceneRenderObserver;
  98801. private _scene;
  98802. private _targetPosition;
  98803. private _virtualOriginMesh;
  98804. private _virtualDragMesh;
  98805. private _pointerObserver;
  98806. private _moving;
  98807. private _startingOrientation;
  98808. /**
  98809. * 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)
  98810. */
  98811. private zDragFactor;
  98812. /**
  98813. * If the object should rotate to face the drag origin
  98814. */
  98815. rotateDraggedObject: boolean;
  98816. /**
  98817. * If the behavior is currently in a dragging state
  98818. */
  98819. dragging: boolean;
  98820. /**
  98821. * 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)
  98822. */
  98823. dragDeltaRatio: number;
  98824. /**
  98825. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  98826. */
  98827. currentDraggingPointerID: number;
  98828. /**
  98829. * If camera controls should be detached during the drag
  98830. */
  98831. detachCameraControls: boolean;
  98832. /**
  98833. * Fires each time a drag starts
  98834. */
  98835. onDragStartObservable: Observable<{}>;
  98836. /**
  98837. * Fires each time a drag ends (eg. mouse release after drag)
  98838. */
  98839. onDragEndObservable: Observable<{}>;
  98840. /**
  98841. * 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
  98842. */
  98843. constructor();
  98844. /**
  98845. * The name of the behavior
  98846. */
  98847. readonly name: string;
  98848. /**
  98849. * Initializes the behavior
  98850. */
  98851. init(): void;
  98852. /**
  98853. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  98854. */
  98855. private readonly _pointerCamera;
  98856. /**
  98857. * Attaches the scale behavior the passed in mesh
  98858. * @param ownerNode The mesh that will be scaled around once attached
  98859. */
  98860. attach(ownerNode: Mesh): void;
  98861. /**
  98862. * Detaches the behavior from the mesh
  98863. */
  98864. detach(): void;
  98865. }
  98866. }
  98867. declare module BABYLON {
  98868. /**
  98869. * Class used to apply inverse kinematics to bones
  98870. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  98871. */
  98872. export class BoneIKController {
  98873. private static _tmpVecs;
  98874. private static _tmpQuat;
  98875. private static _tmpMats;
  98876. /**
  98877. * Gets or sets the target mesh
  98878. */
  98879. targetMesh: AbstractMesh;
  98880. /** Gets or sets the mesh used as pole */
  98881. poleTargetMesh: AbstractMesh;
  98882. /**
  98883. * Gets or sets the bone used as pole
  98884. */
  98885. poleTargetBone: Nullable<Bone>;
  98886. /**
  98887. * Gets or sets the target position
  98888. */
  98889. targetPosition: Vector3;
  98890. /**
  98891. * Gets or sets the pole target position
  98892. */
  98893. poleTargetPosition: Vector3;
  98894. /**
  98895. * Gets or sets the pole target local offset
  98896. */
  98897. poleTargetLocalOffset: Vector3;
  98898. /**
  98899. * Gets or sets the pole angle
  98900. */
  98901. poleAngle: number;
  98902. /**
  98903. * Gets or sets the mesh associated with the controller
  98904. */
  98905. mesh: AbstractMesh;
  98906. /**
  98907. * 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)
  98908. */
  98909. slerpAmount: number;
  98910. private _bone1Quat;
  98911. private _bone1Mat;
  98912. private _bone2Ang;
  98913. private _bone1;
  98914. private _bone2;
  98915. private _bone1Length;
  98916. private _bone2Length;
  98917. private _maxAngle;
  98918. private _maxReach;
  98919. private _rightHandedSystem;
  98920. private _bendAxis;
  98921. private _slerping;
  98922. private _adjustRoll;
  98923. /**
  98924. * Gets or sets maximum allowed angle
  98925. */
  98926. maxAngle: number;
  98927. /**
  98928. * Creates a new BoneIKController
  98929. * @param mesh defines the mesh to control
  98930. * @param bone defines the bone to control
  98931. * @param options defines options to set up the controller
  98932. */
  98933. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  98934. targetMesh?: AbstractMesh;
  98935. poleTargetMesh?: AbstractMesh;
  98936. poleTargetBone?: Bone;
  98937. poleTargetLocalOffset?: Vector3;
  98938. poleAngle?: number;
  98939. bendAxis?: Vector3;
  98940. maxAngle?: number;
  98941. slerpAmount?: number;
  98942. });
  98943. private _setMaxAngle;
  98944. /**
  98945. * Force the controller to update the bones
  98946. */
  98947. update(): void;
  98948. }
  98949. }
  98950. declare module BABYLON {
  98951. /**
  98952. * Class used to make a bone look toward a point in space
  98953. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  98954. */
  98955. export class BoneLookController {
  98956. private static _tmpVecs;
  98957. private static _tmpQuat;
  98958. private static _tmpMats;
  98959. /**
  98960. * The target Vector3 that the bone will look at
  98961. */
  98962. target: Vector3;
  98963. /**
  98964. * The mesh that the bone is attached to
  98965. */
  98966. mesh: AbstractMesh;
  98967. /**
  98968. * The bone that will be looking to the target
  98969. */
  98970. bone: Bone;
  98971. /**
  98972. * The up axis of the coordinate system that is used when the bone is rotated
  98973. */
  98974. upAxis: Vector3;
  98975. /**
  98976. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  98977. */
  98978. upAxisSpace: Space;
  98979. /**
  98980. * Used to make an adjustment to the yaw of the bone
  98981. */
  98982. adjustYaw: number;
  98983. /**
  98984. * Used to make an adjustment to the pitch of the bone
  98985. */
  98986. adjustPitch: number;
  98987. /**
  98988. * Used to make an adjustment to the roll of the bone
  98989. */
  98990. adjustRoll: number;
  98991. /**
  98992. * 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)
  98993. */
  98994. slerpAmount: number;
  98995. private _minYaw;
  98996. private _maxYaw;
  98997. private _minPitch;
  98998. private _maxPitch;
  98999. private _minYawSin;
  99000. private _minYawCos;
  99001. private _maxYawSin;
  99002. private _maxYawCos;
  99003. private _midYawConstraint;
  99004. private _minPitchTan;
  99005. private _maxPitchTan;
  99006. private _boneQuat;
  99007. private _slerping;
  99008. private _transformYawPitch;
  99009. private _transformYawPitchInv;
  99010. private _firstFrameSkipped;
  99011. private _yawRange;
  99012. private _fowardAxis;
  99013. /**
  99014. * Gets or sets the minimum yaw angle that the bone can look to
  99015. */
  99016. minYaw: number;
  99017. /**
  99018. * Gets or sets the maximum yaw angle that the bone can look to
  99019. */
  99020. maxYaw: number;
  99021. /**
  99022. * Gets or sets the minimum pitch angle that the bone can look to
  99023. */
  99024. minPitch: number;
  99025. /**
  99026. * Gets or sets the maximum pitch angle that the bone can look to
  99027. */
  99028. maxPitch: number;
  99029. /**
  99030. * Create a BoneLookController
  99031. * @param mesh the mesh that the bone belongs to
  99032. * @param bone the bone that will be looking to the target
  99033. * @param target the target Vector3 to look at
  99034. * @param options optional settings:
  99035. * * maxYaw: the maximum angle the bone will yaw to
  99036. * * minYaw: the minimum angle the bone will yaw to
  99037. * * maxPitch: the maximum angle the bone will pitch to
  99038. * * minPitch: the minimum angle the bone will yaw to
  99039. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  99040. * * upAxis: the up axis of the coordinate system
  99041. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  99042. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  99043. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  99044. * * adjustYaw: used to make an adjustment to the yaw of the bone
  99045. * * adjustPitch: used to make an adjustment to the pitch of the bone
  99046. * * adjustRoll: used to make an adjustment to the roll of the bone
  99047. **/
  99048. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  99049. maxYaw?: number;
  99050. minYaw?: number;
  99051. maxPitch?: number;
  99052. minPitch?: number;
  99053. slerpAmount?: number;
  99054. upAxis?: Vector3;
  99055. upAxisSpace?: Space;
  99056. yawAxis?: Vector3;
  99057. pitchAxis?: Vector3;
  99058. adjustYaw?: number;
  99059. adjustPitch?: number;
  99060. adjustRoll?: number;
  99061. });
  99062. /**
  99063. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  99064. */
  99065. update(): void;
  99066. private _getAngleDiff;
  99067. private _getAngleBetween;
  99068. private _isAngleBetween;
  99069. }
  99070. }
  99071. declare module BABYLON {
  99072. /**
  99073. * Manage the gamepad inputs to control an arc rotate camera.
  99074. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99075. */
  99076. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  99077. /**
  99078. * Defines the camera the input is attached to.
  99079. */
  99080. camera: ArcRotateCamera;
  99081. /**
  99082. * Defines the gamepad the input is gathering event from.
  99083. */
  99084. gamepad: Nullable<Gamepad>;
  99085. /**
  99086. * Defines the gamepad rotation sensiblity.
  99087. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  99088. */
  99089. gamepadRotationSensibility: number;
  99090. /**
  99091. * Defines the gamepad move sensiblity.
  99092. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  99093. */
  99094. gamepadMoveSensibility: number;
  99095. private _onGamepadConnectedObserver;
  99096. private _onGamepadDisconnectedObserver;
  99097. /**
  99098. * Attach the input controls to a specific dom element to get the input from.
  99099. * @param element Defines the element the controls should be listened from
  99100. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99101. */
  99102. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99103. /**
  99104. * Detach the current controls from the specified dom element.
  99105. * @param element Defines the element to stop listening the inputs from
  99106. */
  99107. detachControl(element: Nullable<HTMLElement>): void;
  99108. /**
  99109. * Update the current camera state depending on the inputs that have been used this frame.
  99110. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99111. */
  99112. checkInputs(): void;
  99113. /**
  99114. * Gets the class name of the current intput.
  99115. * @returns the class name
  99116. */
  99117. getClassName(): string;
  99118. /**
  99119. * Get the friendly name associated with the input class.
  99120. * @returns the input friendly name
  99121. */
  99122. getSimpleName(): string;
  99123. }
  99124. }
  99125. declare module BABYLON {
  99126. interface ArcRotateCameraInputsManager {
  99127. /**
  99128. * Add orientation input support to the input manager.
  99129. * @returns the current input manager
  99130. */
  99131. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  99132. }
  99133. /**
  99134. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  99135. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99136. */
  99137. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  99138. /**
  99139. * Defines the camera the input is attached to.
  99140. */
  99141. camera: ArcRotateCamera;
  99142. /**
  99143. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  99144. */
  99145. alphaCorrection: number;
  99146. /**
  99147. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  99148. */
  99149. gammaCorrection: number;
  99150. private _alpha;
  99151. private _gamma;
  99152. private _dirty;
  99153. private _deviceOrientationHandler;
  99154. /**
  99155. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  99156. */
  99157. constructor();
  99158. /**
  99159. * Attach the input controls to a specific dom element to get the input from.
  99160. * @param element Defines the element the controls should be listened from
  99161. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99162. */
  99163. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99164. /** @hidden */
  99165. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  99166. /**
  99167. * Update the current camera state depending on the inputs that have been used this frame.
  99168. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99169. */
  99170. checkInputs(): void;
  99171. /**
  99172. * Detach the current controls from the specified dom element.
  99173. * @param element Defines the element to stop listening the inputs from
  99174. */
  99175. detachControl(element: Nullable<HTMLElement>): void;
  99176. /**
  99177. * Gets the class name of the current intput.
  99178. * @returns the class name
  99179. */
  99180. getClassName(): string;
  99181. /**
  99182. * Get the friendly name associated with the input class.
  99183. * @returns the input friendly name
  99184. */
  99185. getSimpleName(): string;
  99186. }
  99187. }
  99188. declare module BABYLON {
  99189. /**
  99190. * Listen to mouse events to control the camera.
  99191. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99192. */
  99193. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  99194. /**
  99195. * Defines the camera the input is attached to.
  99196. */
  99197. camera: FlyCamera;
  99198. /**
  99199. * Defines if touch is enabled. (Default is true.)
  99200. */
  99201. touchEnabled: boolean;
  99202. /**
  99203. * Defines the buttons associated with the input to handle camera rotation.
  99204. */
  99205. buttons: number[];
  99206. /**
  99207. * Assign buttons for Yaw control.
  99208. */
  99209. buttonsYaw: number[];
  99210. /**
  99211. * Assign buttons for Pitch control.
  99212. */
  99213. buttonsPitch: number[];
  99214. /**
  99215. * Assign buttons for Roll control.
  99216. */
  99217. buttonsRoll: number[];
  99218. /**
  99219. * Detect if any button is being pressed while mouse is moved.
  99220. * -1 = Mouse locked.
  99221. * 0 = Left button.
  99222. * 1 = Middle Button.
  99223. * 2 = Right Button.
  99224. */
  99225. activeButton: number;
  99226. /**
  99227. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  99228. * Higher values reduce its sensitivity.
  99229. */
  99230. angularSensibility: number;
  99231. private _mousemoveCallback;
  99232. private _observer;
  99233. private _rollObserver;
  99234. private previousPosition;
  99235. private noPreventDefault;
  99236. private element;
  99237. /**
  99238. * Listen to mouse events to control the camera.
  99239. * @param touchEnabled Define if touch is enabled. (Default is true.)
  99240. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99241. */
  99242. constructor(touchEnabled?: boolean);
  99243. /**
  99244. * Attach the mouse control to the HTML DOM element.
  99245. * @param element Defines the element that listens to the input events.
  99246. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  99247. */
  99248. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99249. /**
  99250. * Detach the current controls from the specified dom element.
  99251. * @param element Defines the element to stop listening the inputs from
  99252. */
  99253. detachControl(element: Nullable<HTMLElement>): void;
  99254. /**
  99255. * Gets the class name of the current input.
  99256. * @returns the class name.
  99257. */
  99258. getClassName(): string;
  99259. /**
  99260. * Get the friendly name associated with the input class.
  99261. * @returns the input's friendly name.
  99262. */
  99263. getSimpleName(): string;
  99264. private _pointerInput;
  99265. private _onMouseMove;
  99266. /**
  99267. * Rotate camera by mouse offset.
  99268. */
  99269. private rotateCamera;
  99270. }
  99271. }
  99272. declare module BABYLON {
  99273. /**
  99274. * Default Inputs manager for the FlyCamera.
  99275. * It groups all the default supported inputs for ease of use.
  99276. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99277. */
  99278. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  99279. /**
  99280. * Instantiates a new FlyCameraInputsManager.
  99281. * @param camera Defines the camera the inputs belong to.
  99282. */
  99283. constructor(camera: FlyCamera);
  99284. /**
  99285. * Add keyboard input support to the input manager.
  99286. * @returns the new FlyCameraKeyboardMoveInput().
  99287. */
  99288. addKeyboard(): FlyCameraInputsManager;
  99289. /**
  99290. * Add mouse input support to the input manager.
  99291. * @param touchEnabled Enable touch screen support.
  99292. * @returns the new FlyCameraMouseInput().
  99293. */
  99294. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  99295. }
  99296. }
  99297. declare module BABYLON {
  99298. /**
  99299. * This is a flying camera, designed for 3D movement and rotation in all directions,
  99300. * such as in a 3D Space Shooter or a Flight Simulator.
  99301. */
  99302. export class FlyCamera extends TargetCamera {
  99303. /**
  99304. * Define the collision ellipsoid of the camera.
  99305. * This is helpful for simulating a camera body, like a player's body.
  99306. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  99307. */
  99308. ellipsoid: Vector3;
  99309. /**
  99310. * Define an offset for the position of the ellipsoid around the camera.
  99311. * This can be helpful if the camera is attached away from the player's body center,
  99312. * such as at its head.
  99313. */
  99314. ellipsoidOffset: Vector3;
  99315. /**
  99316. * Enable or disable collisions of the camera with the rest of the scene objects.
  99317. */
  99318. checkCollisions: boolean;
  99319. /**
  99320. * Enable or disable gravity on the camera.
  99321. */
  99322. applyGravity: boolean;
  99323. /**
  99324. * Define the current direction the camera is moving to.
  99325. */
  99326. cameraDirection: Vector3;
  99327. /**
  99328. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  99329. * This overrides and empties cameraRotation.
  99330. */
  99331. rotationQuaternion: Quaternion;
  99332. /**
  99333. * Track Roll to maintain the wanted Rolling when looking around.
  99334. */
  99335. _trackRoll: number;
  99336. /**
  99337. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  99338. */
  99339. rollCorrect: number;
  99340. /**
  99341. * Mimic a banked turn, Rolling the camera when Yawing.
  99342. * It's recommended to use rollCorrect = 10 for faster banking correction.
  99343. */
  99344. bankedTurn: boolean;
  99345. /**
  99346. * Limit in radians for how much Roll banking will add. (Default: 90°)
  99347. */
  99348. bankedTurnLimit: number;
  99349. /**
  99350. * Value of 0 disables the banked Roll.
  99351. * Value of 1 is equal to the Yaw angle in radians.
  99352. */
  99353. bankedTurnMultiplier: number;
  99354. /**
  99355. * The inputs manager loads all the input sources, such as keyboard and mouse.
  99356. */
  99357. inputs: FlyCameraInputsManager;
  99358. /**
  99359. * Gets the input sensibility for mouse input.
  99360. * Higher values reduce sensitivity.
  99361. */
  99362. /**
  99363. * Sets the input sensibility for a mouse input.
  99364. * Higher values reduce sensitivity.
  99365. */
  99366. angularSensibility: number;
  99367. /**
  99368. * Get the keys for camera movement forward.
  99369. */
  99370. /**
  99371. * Set the keys for camera movement forward.
  99372. */
  99373. keysForward: number[];
  99374. /**
  99375. * Get the keys for camera movement backward.
  99376. */
  99377. keysBackward: number[];
  99378. /**
  99379. * Get the keys for camera movement up.
  99380. */
  99381. /**
  99382. * Set the keys for camera movement up.
  99383. */
  99384. keysUp: number[];
  99385. /**
  99386. * Get the keys for camera movement down.
  99387. */
  99388. /**
  99389. * Set the keys for camera movement down.
  99390. */
  99391. keysDown: number[];
  99392. /**
  99393. * Get the keys for camera movement left.
  99394. */
  99395. /**
  99396. * Set the keys for camera movement left.
  99397. */
  99398. keysLeft: number[];
  99399. /**
  99400. * Set the keys for camera movement right.
  99401. */
  99402. /**
  99403. * Set the keys for camera movement right.
  99404. */
  99405. keysRight: number[];
  99406. /**
  99407. * Event raised when the camera collides with a mesh in the scene.
  99408. */
  99409. onCollide: (collidedMesh: AbstractMesh) => void;
  99410. private _collider;
  99411. private _needMoveForGravity;
  99412. private _oldPosition;
  99413. private _diffPosition;
  99414. private _newPosition;
  99415. /** @hidden */
  99416. _localDirection: Vector3;
  99417. /** @hidden */
  99418. _transformedDirection: Vector3;
  99419. /**
  99420. * Instantiates a FlyCamera.
  99421. * This is a flying camera, designed for 3D movement and rotation in all directions,
  99422. * such as in a 3D Space Shooter or a Flight Simulator.
  99423. * @param name Define the name of the camera in the scene.
  99424. * @param position Define the starting position of the camera in the scene.
  99425. * @param scene Define the scene the camera belongs to.
  99426. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  99427. */
  99428. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  99429. /**
  99430. * Attach a control to the HTML DOM element.
  99431. * @param element Defines the element that listens to the input events.
  99432. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  99433. */
  99434. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99435. /**
  99436. * Detach a control from the HTML DOM element.
  99437. * The camera will stop reacting to that input.
  99438. * @param element Defines the element that listens to the input events.
  99439. */
  99440. detachControl(element: HTMLElement): void;
  99441. private _collisionMask;
  99442. /**
  99443. * Get the mask that the camera ignores in collision events.
  99444. */
  99445. /**
  99446. * Set the mask that the camera ignores in collision events.
  99447. */
  99448. collisionMask: number;
  99449. /** @hidden */
  99450. _collideWithWorld(displacement: Vector3): void;
  99451. /** @hidden */
  99452. private _onCollisionPositionChange;
  99453. /** @hidden */
  99454. _checkInputs(): void;
  99455. /** @hidden */
  99456. _decideIfNeedsToMove(): boolean;
  99457. /** @hidden */
  99458. _updatePosition(): void;
  99459. /**
  99460. * Restore the Roll to its target value at the rate specified.
  99461. * @param rate - Higher means slower restoring.
  99462. * @hidden
  99463. */
  99464. restoreRoll(rate: number): void;
  99465. /**
  99466. * Destroy the camera and release the current resources held by it.
  99467. */
  99468. dispose(): void;
  99469. /**
  99470. * Get the current object class name.
  99471. * @returns the class name.
  99472. */
  99473. getClassName(): string;
  99474. }
  99475. }
  99476. declare module BABYLON {
  99477. /**
  99478. * Listen to keyboard events to control the camera.
  99479. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99480. */
  99481. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  99482. /**
  99483. * Defines the camera the input is attached to.
  99484. */
  99485. camera: FlyCamera;
  99486. /**
  99487. * The list of keyboard keys used to control the forward move of the camera.
  99488. */
  99489. keysForward: number[];
  99490. /**
  99491. * The list of keyboard keys used to control the backward move of the camera.
  99492. */
  99493. keysBackward: number[];
  99494. /**
  99495. * The list of keyboard keys used to control the forward move of the camera.
  99496. */
  99497. keysUp: number[];
  99498. /**
  99499. * The list of keyboard keys used to control the backward move of the camera.
  99500. */
  99501. keysDown: number[];
  99502. /**
  99503. * The list of keyboard keys used to control the right strafe move of the camera.
  99504. */
  99505. keysRight: number[];
  99506. /**
  99507. * The list of keyboard keys used to control the left strafe move of the camera.
  99508. */
  99509. keysLeft: number[];
  99510. private _keys;
  99511. private _onCanvasBlurObserver;
  99512. private _onKeyboardObserver;
  99513. private _engine;
  99514. private _scene;
  99515. /**
  99516. * Attach the input controls to a specific dom element to get the input from.
  99517. * @param element Defines the element the controls should be listened from
  99518. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99519. */
  99520. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99521. /**
  99522. * Detach the current controls from the specified dom element.
  99523. * @param element Defines the element to stop listening the inputs from
  99524. */
  99525. detachControl(element: Nullable<HTMLElement>): void;
  99526. /**
  99527. * Gets the class name of the current intput.
  99528. * @returns the class name
  99529. */
  99530. getClassName(): string;
  99531. /** @hidden */
  99532. _onLostFocus(e: FocusEvent): void;
  99533. /**
  99534. * Get the friendly name associated with the input class.
  99535. * @returns the input friendly name
  99536. */
  99537. getSimpleName(): string;
  99538. /**
  99539. * Update the current camera state depending on the inputs that have been used this frame.
  99540. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99541. */
  99542. checkInputs(): void;
  99543. }
  99544. }
  99545. declare module BABYLON {
  99546. /**
  99547. * Manage the mouse wheel inputs to control a follow camera.
  99548. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99549. */
  99550. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  99551. /**
  99552. * Defines the camera the input is attached to.
  99553. */
  99554. camera: FollowCamera;
  99555. /**
  99556. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  99557. */
  99558. axisControlRadius: boolean;
  99559. /**
  99560. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  99561. */
  99562. axisControlHeight: boolean;
  99563. /**
  99564. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  99565. */
  99566. axisControlRotation: boolean;
  99567. /**
  99568. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  99569. * relation to mouseWheel events.
  99570. */
  99571. wheelPrecision: number;
  99572. /**
  99573. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  99574. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  99575. */
  99576. wheelDeltaPercentage: number;
  99577. private _wheel;
  99578. private _observer;
  99579. /**
  99580. * Attach the input controls to a specific dom element to get the input from.
  99581. * @param element Defines the element the controls should be listened from
  99582. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99583. */
  99584. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99585. /**
  99586. * Detach the current controls from the specified dom element.
  99587. * @param element Defines the element to stop listening the inputs from
  99588. */
  99589. detachControl(element: Nullable<HTMLElement>): void;
  99590. /**
  99591. * Gets the class name of the current intput.
  99592. * @returns the class name
  99593. */
  99594. getClassName(): string;
  99595. /**
  99596. * Get the friendly name associated with the input class.
  99597. * @returns the input friendly name
  99598. */
  99599. getSimpleName(): string;
  99600. }
  99601. }
  99602. declare module BABYLON {
  99603. /**
  99604. * Manage the pointers inputs to control an follow camera.
  99605. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99606. */
  99607. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  99608. /**
  99609. * Defines the camera the input is attached to.
  99610. */
  99611. camera: FollowCamera;
  99612. /**
  99613. * Gets the class name of the current input.
  99614. * @returns the class name
  99615. */
  99616. getClassName(): string;
  99617. /**
  99618. * Defines the pointer angular sensibility along the X axis or how fast is
  99619. * the camera rotating.
  99620. * A negative number will reverse the axis direction.
  99621. */
  99622. angularSensibilityX: number;
  99623. /**
  99624. * Defines the pointer angular sensibility along the Y axis or how fast is
  99625. * the camera rotating.
  99626. * A negative number will reverse the axis direction.
  99627. */
  99628. angularSensibilityY: number;
  99629. /**
  99630. * Defines the pointer pinch precision or how fast is the camera zooming.
  99631. * A negative number will reverse the axis direction.
  99632. */
  99633. pinchPrecision: number;
  99634. /**
  99635. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  99636. * from 0.
  99637. * It defines the percentage of current camera.radius to use as delta when
  99638. * pinch zoom is used.
  99639. */
  99640. pinchDeltaPercentage: number;
  99641. /**
  99642. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  99643. */
  99644. axisXControlRadius: boolean;
  99645. /**
  99646. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  99647. */
  99648. axisXControlHeight: boolean;
  99649. /**
  99650. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  99651. */
  99652. axisXControlRotation: boolean;
  99653. /**
  99654. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  99655. */
  99656. axisYControlRadius: boolean;
  99657. /**
  99658. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  99659. */
  99660. axisYControlHeight: boolean;
  99661. /**
  99662. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  99663. */
  99664. axisYControlRotation: boolean;
  99665. /**
  99666. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  99667. */
  99668. axisPinchControlRadius: boolean;
  99669. /**
  99670. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  99671. */
  99672. axisPinchControlHeight: boolean;
  99673. /**
  99674. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  99675. */
  99676. axisPinchControlRotation: boolean;
  99677. /**
  99678. * Log error messages if basic misconfiguration has occurred.
  99679. */
  99680. warningEnable: boolean;
  99681. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  99682. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  99683. private _warningCounter;
  99684. private _warning;
  99685. }
  99686. }
  99687. declare module BABYLON {
  99688. /**
  99689. * Default Inputs manager for the FollowCamera.
  99690. * It groups all the default supported inputs for ease of use.
  99691. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99692. */
  99693. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  99694. /**
  99695. * Instantiates a new FollowCameraInputsManager.
  99696. * @param camera Defines the camera the inputs belong to
  99697. */
  99698. constructor(camera: FollowCamera);
  99699. /**
  99700. * Add keyboard input support to the input manager.
  99701. * @returns the current input manager
  99702. */
  99703. addKeyboard(): FollowCameraInputsManager;
  99704. /**
  99705. * Add mouse wheel input support to the input manager.
  99706. * @returns the current input manager
  99707. */
  99708. addMouseWheel(): FollowCameraInputsManager;
  99709. /**
  99710. * Add pointers input support to the input manager.
  99711. * @returns the current input manager
  99712. */
  99713. addPointers(): FollowCameraInputsManager;
  99714. /**
  99715. * Add orientation input support to the input manager.
  99716. * @returns the current input manager
  99717. */
  99718. addVRDeviceOrientation(): FollowCameraInputsManager;
  99719. }
  99720. }
  99721. declare module BABYLON {
  99722. /**
  99723. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  99724. * an arc rotate version arcFollowCamera are available.
  99725. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  99726. */
  99727. export class FollowCamera extends TargetCamera {
  99728. /**
  99729. * Distance the follow camera should follow an object at
  99730. */
  99731. radius: number;
  99732. /**
  99733. * Minimum allowed distance of the camera to the axis of rotation
  99734. * (The camera can not get closer).
  99735. * This can help limiting how the Camera is able to move in the scene.
  99736. */
  99737. lowerRadiusLimit: Nullable<number>;
  99738. /**
  99739. * Maximum allowed distance of the camera to the axis of rotation
  99740. * (The camera can not get further).
  99741. * This can help limiting how the Camera is able to move in the scene.
  99742. */
  99743. upperRadiusLimit: Nullable<number>;
  99744. /**
  99745. * Define a rotation offset between the camera and the object it follows
  99746. */
  99747. rotationOffset: number;
  99748. /**
  99749. * Minimum allowed angle to camera position relative to target object.
  99750. * This can help limiting how the Camera is able to move in the scene.
  99751. */
  99752. lowerRotationOffsetLimit: Nullable<number>;
  99753. /**
  99754. * Maximum allowed angle to camera position relative to target object.
  99755. * This can help limiting how the Camera is able to move in the scene.
  99756. */
  99757. upperRotationOffsetLimit: Nullable<number>;
  99758. /**
  99759. * Define a height offset between the camera and the object it follows.
  99760. * It can help following an object from the top (like a car chaing a plane)
  99761. */
  99762. heightOffset: number;
  99763. /**
  99764. * Minimum allowed height of camera position relative to target object.
  99765. * This can help limiting how the Camera is able to move in the scene.
  99766. */
  99767. lowerHeightOffsetLimit: Nullable<number>;
  99768. /**
  99769. * Maximum allowed height of camera position relative to target object.
  99770. * This can help limiting how the Camera is able to move in the scene.
  99771. */
  99772. upperHeightOffsetLimit: Nullable<number>;
  99773. /**
  99774. * Define how fast the camera can accelerate to follow it s target.
  99775. */
  99776. cameraAcceleration: number;
  99777. /**
  99778. * Define the speed limit of the camera following an object.
  99779. */
  99780. maxCameraSpeed: number;
  99781. /**
  99782. * Define the target of the camera.
  99783. */
  99784. lockedTarget: Nullable<AbstractMesh>;
  99785. /**
  99786. * Defines the input associated with the camera.
  99787. */
  99788. inputs: FollowCameraInputsManager;
  99789. /**
  99790. * Instantiates the follow camera.
  99791. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  99792. * @param name Define the name of the camera in the scene
  99793. * @param position Define the position of the camera
  99794. * @param scene Define the scene the camera belong to
  99795. * @param lockedTarget Define the target of the camera
  99796. */
  99797. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  99798. private _follow;
  99799. /**
  99800. * Attached controls to the current camera.
  99801. * @param element Defines the element the controls should be listened from
  99802. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99803. */
  99804. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99805. /**
  99806. * Detach the current controls from the camera.
  99807. * The camera will stop reacting to inputs.
  99808. * @param element Defines the element to stop listening the inputs from
  99809. */
  99810. detachControl(element: HTMLElement): void;
  99811. /** @hidden */
  99812. _checkInputs(): void;
  99813. private _checkLimits;
  99814. /**
  99815. * Gets the camera class name.
  99816. * @returns the class name
  99817. */
  99818. getClassName(): string;
  99819. }
  99820. /**
  99821. * Arc Rotate version of the follow camera.
  99822. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  99823. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  99824. */
  99825. export class ArcFollowCamera extends TargetCamera {
  99826. /** The longitudinal angle of the camera */
  99827. alpha: number;
  99828. /** The latitudinal angle of the camera */
  99829. beta: number;
  99830. /** The radius of the camera from its target */
  99831. radius: number;
  99832. /** Define the camera target (the messh it should follow) */
  99833. target: Nullable<AbstractMesh>;
  99834. private _cartesianCoordinates;
  99835. /**
  99836. * Instantiates a new ArcFollowCamera
  99837. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  99838. * @param name Define the name of the camera
  99839. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  99840. * @param beta Define the rotation angle of the camera around the elevation axis
  99841. * @param radius Define the radius of the camera from its target point
  99842. * @param target Define the target of the camera
  99843. * @param scene Define the scene the camera belongs to
  99844. */
  99845. constructor(name: string,
  99846. /** The longitudinal angle of the camera */
  99847. alpha: number,
  99848. /** The latitudinal angle of the camera */
  99849. beta: number,
  99850. /** The radius of the camera from its target */
  99851. radius: number,
  99852. /** Define the camera target (the messh it should follow) */
  99853. target: Nullable<AbstractMesh>, scene: Scene);
  99854. private _follow;
  99855. /** @hidden */
  99856. _checkInputs(): void;
  99857. /**
  99858. * Returns the class name of the object.
  99859. * It is mostly used internally for serialization purposes.
  99860. */
  99861. getClassName(): string;
  99862. }
  99863. }
  99864. declare module BABYLON {
  99865. /**
  99866. * Manage the keyboard inputs to control the movement of a follow camera.
  99867. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99868. */
  99869. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  99870. /**
  99871. * Defines the camera the input is attached to.
  99872. */
  99873. camera: FollowCamera;
  99874. /**
  99875. * Defines the list of key codes associated with the up action (increase heightOffset)
  99876. */
  99877. keysHeightOffsetIncr: number[];
  99878. /**
  99879. * Defines the list of key codes associated with the down action (decrease heightOffset)
  99880. */
  99881. keysHeightOffsetDecr: number[];
  99882. /**
  99883. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  99884. */
  99885. keysHeightOffsetModifierAlt: boolean;
  99886. /**
  99887. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  99888. */
  99889. keysHeightOffsetModifierCtrl: boolean;
  99890. /**
  99891. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  99892. */
  99893. keysHeightOffsetModifierShift: boolean;
  99894. /**
  99895. * Defines the list of key codes associated with the left action (increase rotationOffset)
  99896. */
  99897. keysRotationOffsetIncr: number[];
  99898. /**
  99899. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  99900. */
  99901. keysRotationOffsetDecr: number[];
  99902. /**
  99903. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  99904. */
  99905. keysRotationOffsetModifierAlt: boolean;
  99906. /**
  99907. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  99908. */
  99909. keysRotationOffsetModifierCtrl: boolean;
  99910. /**
  99911. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  99912. */
  99913. keysRotationOffsetModifierShift: boolean;
  99914. /**
  99915. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  99916. */
  99917. keysRadiusIncr: number[];
  99918. /**
  99919. * Defines the list of key codes associated with the zoom-out action (increase radius)
  99920. */
  99921. keysRadiusDecr: number[];
  99922. /**
  99923. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  99924. */
  99925. keysRadiusModifierAlt: boolean;
  99926. /**
  99927. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  99928. */
  99929. keysRadiusModifierCtrl: boolean;
  99930. /**
  99931. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  99932. */
  99933. keysRadiusModifierShift: boolean;
  99934. /**
  99935. * Defines the rate of change of heightOffset.
  99936. */
  99937. heightSensibility: number;
  99938. /**
  99939. * Defines the rate of change of rotationOffset.
  99940. */
  99941. rotationSensibility: number;
  99942. /**
  99943. * Defines the rate of change of radius.
  99944. */
  99945. radiusSensibility: number;
  99946. private _keys;
  99947. private _ctrlPressed;
  99948. private _altPressed;
  99949. private _shiftPressed;
  99950. private _onCanvasBlurObserver;
  99951. private _onKeyboardObserver;
  99952. private _engine;
  99953. private _scene;
  99954. /**
  99955. * Attach the input controls to a specific dom element to get the input from.
  99956. * @param element Defines the element the controls should be listened from
  99957. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99958. */
  99959. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99960. /**
  99961. * Detach the current controls from the specified dom element.
  99962. * @param element Defines the element to stop listening the inputs from
  99963. */
  99964. detachControl(element: Nullable<HTMLElement>): void;
  99965. /**
  99966. * Update the current camera state depending on the inputs that have been used this frame.
  99967. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99968. */
  99969. checkInputs(): void;
  99970. /**
  99971. * Gets the class name of the current input.
  99972. * @returns the class name
  99973. */
  99974. getClassName(): string;
  99975. /**
  99976. * Get the friendly name associated with the input class.
  99977. * @returns the input friendly name
  99978. */
  99979. getSimpleName(): string;
  99980. /**
  99981. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  99982. * allow modification of the heightOffset value.
  99983. */
  99984. private _modifierHeightOffset;
  99985. /**
  99986. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  99987. * allow modification of the rotationOffset value.
  99988. */
  99989. private _modifierRotationOffset;
  99990. /**
  99991. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  99992. * allow modification of the radius value.
  99993. */
  99994. private _modifierRadius;
  99995. }
  99996. }
  99997. declare module BABYLON {
  99998. interface FreeCameraInputsManager {
  99999. /**
  100000. * @hidden
  100001. */
  100002. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  100003. /**
  100004. * Add orientation input support to the input manager.
  100005. * @returns the current input manager
  100006. */
  100007. addDeviceOrientation(): FreeCameraInputsManager;
  100008. }
  100009. /**
  100010. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  100011. * Screen rotation is taken into account.
  100012. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100013. */
  100014. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  100015. private _camera;
  100016. private _screenOrientationAngle;
  100017. private _constantTranform;
  100018. private _screenQuaternion;
  100019. private _alpha;
  100020. private _beta;
  100021. private _gamma;
  100022. /**
  100023. * Can be used to detect if a device orientation sensor is availible on a device
  100024. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  100025. * @returns a promise that will resolve on orientation change
  100026. */
  100027. static WaitForOrientationChangeAsync(timeout?: number): Promise<{}>;
  100028. /**
  100029. * @hidden
  100030. */
  100031. _onDeviceOrientationChangedObservable: Observable<void>;
  100032. /**
  100033. * Instantiates a new input
  100034. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100035. */
  100036. constructor();
  100037. /**
  100038. * Define the camera controlled by the input.
  100039. */
  100040. camera: FreeCamera;
  100041. /**
  100042. * Attach the input controls to a specific dom element to get the input from.
  100043. * @param element Defines the element the controls should be listened from
  100044. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100045. */
  100046. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100047. private _orientationChanged;
  100048. private _deviceOrientation;
  100049. /**
  100050. * Detach the current controls from the specified dom element.
  100051. * @param element Defines the element to stop listening the inputs from
  100052. */
  100053. detachControl(element: Nullable<HTMLElement>): void;
  100054. /**
  100055. * Update the current camera state depending on the inputs that have been used this frame.
  100056. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  100057. */
  100058. checkInputs(): void;
  100059. /**
  100060. * Gets the class name of the current intput.
  100061. * @returns the class name
  100062. */
  100063. getClassName(): string;
  100064. /**
  100065. * Get the friendly name associated with the input class.
  100066. * @returns the input friendly name
  100067. */
  100068. getSimpleName(): string;
  100069. }
  100070. }
  100071. declare module BABYLON {
  100072. /**
  100073. * Manage the gamepad inputs to control a free camera.
  100074. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100075. */
  100076. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  100077. /**
  100078. * Define the camera the input is attached to.
  100079. */
  100080. camera: FreeCamera;
  100081. /**
  100082. * Define the Gamepad controlling the input
  100083. */
  100084. gamepad: Nullable<Gamepad>;
  100085. /**
  100086. * Defines the gamepad rotation sensiblity.
  100087. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  100088. */
  100089. gamepadAngularSensibility: number;
  100090. /**
  100091. * Defines the gamepad move sensiblity.
  100092. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  100093. */
  100094. gamepadMoveSensibility: number;
  100095. private _onGamepadConnectedObserver;
  100096. private _onGamepadDisconnectedObserver;
  100097. private _cameraTransform;
  100098. private _deltaTransform;
  100099. private _vector3;
  100100. private _vector2;
  100101. /**
  100102. * Attach the input controls to a specific dom element to get the input from.
  100103. * @param element Defines the element the controls should be listened from
  100104. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100105. */
  100106. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100107. /**
  100108. * Detach the current controls from the specified dom element.
  100109. * @param element Defines the element to stop listening the inputs from
  100110. */
  100111. detachControl(element: Nullable<HTMLElement>): void;
  100112. /**
  100113. * Update the current camera state depending on the inputs that have been used this frame.
  100114. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  100115. */
  100116. checkInputs(): void;
  100117. /**
  100118. * Gets the class name of the current intput.
  100119. * @returns the class name
  100120. */
  100121. getClassName(): string;
  100122. /**
  100123. * Get the friendly name associated with the input class.
  100124. * @returns the input friendly name
  100125. */
  100126. getSimpleName(): string;
  100127. }
  100128. }
  100129. declare module BABYLON {
  100130. /**
  100131. * Defines the potential axis of a Joystick
  100132. */
  100133. export enum JoystickAxis {
  100134. /** X axis */
  100135. X = 0,
  100136. /** Y axis */
  100137. Y = 1,
  100138. /** Z axis */
  100139. Z = 2
  100140. }
  100141. /**
  100142. * Class used to define virtual joystick (used in touch mode)
  100143. */
  100144. export class VirtualJoystick {
  100145. /**
  100146. * Gets or sets a boolean indicating that left and right values must be inverted
  100147. */
  100148. reverseLeftRight: boolean;
  100149. /**
  100150. * Gets or sets a boolean indicating that up and down values must be inverted
  100151. */
  100152. reverseUpDown: boolean;
  100153. /**
  100154. * Gets the offset value for the position (ie. the change of the position value)
  100155. */
  100156. deltaPosition: Vector3;
  100157. /**
  100158. * Gets a boolean indicating if the virtual joystick was pressed
  100159. */
  100160. pressed: boolean;
  100161. /**
  100162. * Canvas the virtual joystick will render onto, default z-index of this is 5
  100163. */
  100164. static Canvas: Nullable<HTMLCanvasElement>;
  100165. private static _globalJoystickIndex;
  100166. private static vjCanvasContext;
  100167. private static vjCanvasWidth;
  100168. private static vjCanvasHeight;
  100169. private static halfWidth;
  100170. private _action;
  100171. private _axisTargetedByLeftAndRight;
  100172. private _axisTargetedByUpAndDown;
  100173. private _joystickSensibility;
  100174. private _inversedSensibility;
  100175. private _joystickPointerID;
  100176. private _joystickColor;
  100177. private _joystickPointerPos;
  100178. private _joystickPreviousPointerPos;
  100179. private _joystickPointerStartPos;
  100180. private _deltaJoystickVector;
  100181. private _leftJoystick;
  100182. private _touches;
  100183. private _onPointerDownHandlerRef;
  100184. private _onPointerMoveHandlerRef;
  100185. private _onPointerUpHandlerRef;
  100186. private _onResize;
  100187. /**
  100188. * Creates a new virtual joystick
  100189. * @param leftJoystick defines that the joystick is for left hand (false by default)
  100190. */
  100191. constructor(leftJoystick?: boolean);
  100192. /**
  100193. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  100194. * @param newJoystickSensibility defines the new sensibility
  100195. */
  100196. setJoystickSensibility(newJoystickSensibility: number): void;
  100197. private _onPointerDown;
  100198. private _onPointerMove;
  100199. private _onPointerUp;
  100200. /**
  100201. * Change the color of the virtual joystick
  100202. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  100203. */
  100204. setJoystickColor(newColor: string): void;
  100205. /**
  100206. * Defines a callback to call when the joystick is touched
  100207. * @param action defines the callback
  100208. */
  100209. setActionOnTouch(action: () => any): void;
  100210. /**
  100211. * Defines which axis you'd like to control for left & right
  100212. * @param axis defines the axis to use
  100213. */
  100214. setAxisForLeftRight(axis: JoystickAxis): void;
  100215. /**
  100216. * Defines which axis you'd like to control for up & down
  100217. * @param axis defines the axis to use
  100218. */
  100219. setAxisForUpDown(axis: JoystickAxis): void;
  100220. private _drawVirtualJoystick;
  100221. /**
  100222. * Release internal HTML canvas
  100223. */
  100224. releaseCanvas(): void;
  100225. }
  100226. }
  100227. declare module BABYLON {
  100228. interface FreeCameraInputsManager {
  100229. /**
  100230. * Add virtual joystick input support to the input manager.
  100231. * @returns the current input manager
  100232. */
  100233. addVirtualJoystick(): FreeCameraInputsManager;
  100234. }
  100235. /**
  100236. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  100237. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100238. */
  100239. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  100240. /**
  100241. * Defines the camera the input is attached to.
  100242. */
  100243. camera: FreeCamera;
  100244. private _leftjoystick;
  100245. private _rightjoystick;
  100246. /**
  100247. * Gets the left stick of the virtual joystick.
  100248. * @returns The virtual Joystick
  100249. */
  100250. getLeftJoystick(): VirtualJoystick;
  100251. /**
  100252. * Gets the right stick of the virtual joystick.
  100253. * @returns The virtual Joystick
  100254. */
  100255. getRightJoystick(): VirtualJoystick;
  100256. /**
  100257. * Update the current camera state depending on the inputs that have been used this frame.
  100258. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  100259. */
  100260. checkInputs(): void;
  100261. /**
  100262. * Attach the input controls to a specific dom element to get the input from.
  100263. * @param element Defines the element the controls should be listened from
  100264. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100265. */
  100266. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100267. /**
  100268. * Detach the current controls from the specified dom element.
  100269. * @param element Defines the element to stop listening the inputs from
  100270. */
  100271. detachControl(element: Nullable<HTMLElement>): void;
  100272. /**
  100273. * Gets the class name of the current intput.
  100274. * @returns the class name
  100275. */
  100276. getClassName(): string;
  100277. /**
  100278. * Get the friendly name associated with the input class.
  100279. * @returns the input friendly name
  100280. */
  100281. getSimpleName(): string;
  100282. }
  100283. }
  100284. declare module BABYLON {
  100285. /**
  100286. * This represents a FPS type of camera controlled by touch.
  100287. * This is like a universal camera minus the Gamepad controls.
  100288. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  100289. */
  100290. export class TouchCamera extends FreeCamera {
  100291. /**
  100292. * Defines the touch sensibility for rotation.
  100293. * The higher the faster.
  100294. */
  100295. touchAngularSensibility: number;
  100296. /**
  100297. * Defines the touch sensibility for move.
  100298. * The higher the faster.
  100299. */
  100300. touchMoveSensibility: number;
  100301. /**
  100302. * Instantiates a new touch camera.
  100303. * This represents a FPS type of camera controlled by touch.
  100304. * This is like a universal camera minus the Gamepad controls.
  100305. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  100306. * @param name Define the name of the camera in the scene
  100307. * @param position Define the start position of the camera in the scene
  100308. * @param scene Define the scene the camera belongs to
  100309. */
  100310. constructor(name: string, position: Vector3, scene: Scene);
  100311. /**
  100312. * Gets the current object class name.
  100313. * @return the class name
  100314. */
  100315. getClassName(): string;
  100316. /** @hidden */
  100317. _setupInputs(): void;
  100318. }
  100319. }
  100320. declare module BABYLON {
  100321. /**
  100322. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  100323. * being tilted forward or back and left or right.
  100324. */
  100325. export class DeviceOrientationCamera extends FreeCamera {
  100326. private _initialQuaternion;
  100327. private _quaternionCache;
  100328. private _tmpDragQuaternion;
  100329. /**
  100330. * Creates a new device orientation camera
  100331. * @param name The name of the camera
  100332. * @param position The start position camera
  100333. * @param scene The scene the camera belongs to
  100334. */
  100335. constructor(name: string, position: Vector3, scene: Scene);
  100336. /**
  100337. * @hidden
  100338. * Disabled pointer input on first orientation sensor update (Default: true)
  100339. */
  100340. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  100341. private _dragFactor;
  100342. /**
  100343. * Enabled turning on the y axis when the orientation sensor is active
  100344. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  100345. */
  100346. enableHorizontalDragging(dragFactor?: number): void;
  100347. /**
  100348. * Gets the current instance class name ("DeviceOrientationCamera").
  100349. * This helps avoiding instanceof at run time.
  100350. * @returns the class name
  100351. */
  100352. getClassName(): string;
  100353. /**
  100354. * @hidden
  100355. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  100356. */
  100357. _checkInputs(): void;
  100358. /**
  100359. * Reset the camera to its default orientation on the specified axis only.
  100360. * @param axis The axis to reset
  100361. */
  100362. resetToCurrentRotation(axis?: Axis): void;
  100363. }
  100364. }
  100365. declare module BABYLON {
  100366. /**
  100367. * Defines supported buttons for XBox360 compatible gamepads
  100368. */
  100369. export enum Xbox360Button {
  100370. /** A */
  100371. A = 0,
  100372. /** B */
  100373. B = 1,
  100374. /** X */
  100375. X = 2,
  100376. /** Y */
  100377. Y = 3,
  100378. /** Start */
  100379. Start = 4,
  100380. /** Back */
  100381. Back = 5,
  100382. /** Left button */
  100383. LB = 6,
  100384. /** Right button */
  100385. RB = 7,
  100386. /** Left stick */
  100387. LeftStick = 8,
  100388. /** Right stick */
  100389. RightStick = 9
  100390. }
  100391. /** Defines values for XBox360 DPad */
  100392. export enum Xbox360Dpad {
  100393. /** Up */
  100394. Up = 0,
  100395. /** Down */
  100396. Down = 1,
  100397. /** Left */
  100398. Left = 2,
  100399. /** Right */
  100400. Right = 3
  100401. }
  100402. /**
  100403. * Defines a XBox360 gamepad
  100404. */
  100405. export class Xbox360Pad extends Gamepad {
  100406. private _leftTrigger;
  100407. private _rightTrigger;
  100408. private _onlefttriggerchanged;
  100409. private _onrighttriggerchanged;
  100410. private _onbuttondown;
  100411. private _onbuttonup;
  100412. private _ondpaddown;
  100413. private _ondpadup;
  100414. /** Observable raised when a button is pressed */
  100415. onButtonDownObservable: Observable<Xbox360Button>;
  100416. /** Observable raised when a button is released */
  100417. onButtonUpObservable: Observable<Xbox360Button>;
  100418. /** Observable raised when a pad is pressed */
  100419. onPadDownObservable: Observable<Xbox360Dpad>;
  100420. /** Observable raised when a pad is released */
  100421. onPadUpObservable: Observable<Xbox360Dpad>;
  100422. private _buttonA;
  100423. private _buttonB;
  100424. private _buttonX;
  100425. private _buttonY;
  100426. private _buttonBack;
  100427. private _buttonStart;
  100428. private _buttonLB;
  100429. private _buttonRB;
  100430. private _buttonLeftStick;
  100431. private _buttonRightStick;
  100432. private _dPadUp;
  100433. private _dPadDown;
  100434. private _dPadLeft;
  100435. private _dPadRight;
  100436. private _isXboxOnePad;
  100437. /**
  100438. * Creates a new XBox360 gamepad object
  100439. * @param id defines the id of this gamepad
  100440. * @param index defines its index
  100441. * @param gamepad defines the internal HTML gamepad object
  100442. * @param xboxOne defines if it is a XBox One gamepad
  100443. */
  100444. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  100445. /**
  100446. * Defines the callback to call when left trigger is pressed
  100447. * @param callback defines the callback to use
  100448. */
  100449. onlefttriggerchanged(callback: (value: number) => void): void;
  100450. /**
  100451. * Defines the callback to call when right trigger is pressed
  100452. * @param callback defines the callback to use
  100453. */
  100454. onrighttriggerchanged(callback: (value: number) => void): void;
  100455. /**
  100456. * Gets the left trigger value
  100457. */
  100458. /**
  100459. * Sets the left trigger value
  100460. */
  100461. leftTrigger: number;
  100462. /**
  100463. * Gets the right trigger value
  100464. */
  100465. /**
  100466. * Sets the right trigger value
  100467. */
  100468. rightTrigger: number;
  100469. /**
  100470. * Defines the callback to call when a button is pressed
  100471. * @param callback defines the callback to use
  100472. */
  100473. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  100474. /**
  100475. * Defines the callback to call when a button is released
  100476. * @param callback defines the callback to use
  100477. */
  100478. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  100479. /**
  100480. * Defines the callback to call when a pad is pressed
  100481. * @param callback defines the callback to use
  100482. */
  100483. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  100484. /**
  100485. * Defines the callback to call when a pad is released
  100486. * @param callback defines the callback to use
  100487. */
  100488. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  100489. private _setButtonValue;
  100490. private _setDPadValue;
  100491. /**
  100492. * Gets the value of the `A` button
  100493. */
  100494. /**
  100495. * Sets the value of the `A` button
  100496. */
  100497. buttonA: number;
  100498. /**
  100499. * Gets the value of the `B` button
  100500. */
  100501. /**
  100502. * Sets the value of the `B` button
  100503. */
  100504. buttonB: number;
  100505. /**
  100506. * Gets the value of the `X` button
  100507. */
  100508. /**
  100509. * Sets the value of the `X` button
  100510. */
  100511. buttonX: number;
  100512. /**
  100513. * Gets the value of the `Y` button
  100514. */
  100515. /**
  100516. * Sets the value of the `Y` button
  100517. */
  100518. buttonY: number;
  100519. /**
  100520. * Gets the value of the `Start` button
  100521. */
  100522. /**
  100523. * Sets the value of the `Start` button
  100524. */
  100525. buttonStart: number;
  100526. /**
  100527. * Gets the value of the `Back` button
  100528. */
  100529. /**
  100530. * Sets the value of the `Back` button
  100531. */
  100532. buttonBack: number;
  100533. /**
  100534. * Gets the value of the `Left` button
  100535. */
  100536. /**
  100537. * Sets the value of the `Left` button
  100538. */
  100539. buttonLB: number;
  100540. /**
  100541. * Gets the value of the `Right` button
  100542. */
  100543. /**
  100544. * Sets the value of the `Right` button
  100545. */
  100546. buttonRB: number;
  100547. /**
  100548. * Gets the value of the Left joystick
  100549. */
  100550. /**
  100551. * Sets the value of the Left joystick
  100552. */
  100553. buttonLeftStick: number;
  100554. /**
  100555. * Gets the value of the Right joystick
  100556. */
  100557. /**
  100558. * Sets the value of the Right joystick
  100559. */
  100560. buttonRightStick: number;
  100561. /**
  100562. * Gets the value of D-pad up
  100563. */
  100564. /**
  100565. * Sets the value of D-pad up
  100566. */
  100567. dPadUp: number;
  100568. /**
  100569. * Gets the value of D-pad down
  100570. */
  100571. /**
  100572. * Sets the value of D-pad down
  100573. */
  100574. dPadDown: number;
  100575. /**
  100576. * Gets the value of D-pad left
  100577. */
  100578. /**
  100579. * Sets the value of D-pad left
  100580. */
  100581. dPadLeft: number;
  100582. /**
  100583. * Gets the value of D-pad right
  100584. */
  100585. /**
  100586. * Sets the value of D-pad right
  100587. */
  100588. dPadRight: number;
  100589. /**
  100590. * Force the gamepad to synchronize with device values
  100591. */
  100592. update(): void;
  100593. /**
  100594. * Disposes the gamepad
  100595. */
  100596. dispose(): void;
  100597. }
  100598. }
  100599. declare module BABYLON {
  100600. /**
  100601. * Manager for handling gamepads
  100602. */
  100603. export class GamepadManager {
  100604. private _scene?;
  100605. private _babylonGamepads;
  100606. private _oneGamepadConnected;
  100607. /** @hidden */
  100608. _isMonitoring: boolean;
  100609. private _gamepadEventSupported;
  100610. private _gamepadSupport;
  100611. /**
  100612. * observable to be triggered when the gamepad controller has been connected
  100613. */
  100614. onGamepadConnectedObservable: Observable<Gamepad>;
  100615. /**
  100616. * observable to be triggered when the gamepad controller has been disconnected
  100617. */
  100618. onGamepadDisconnectedObservable: Observable<Gamepad>;
  100619. private _onGamepadConnectedEvent;
  100620. private _onGamepadDisconnectedEvent;
  100621. /**
  100622. * Initializes the gamepad manager
  100623. * @param _scene BabylonJS scene
  100624. */
  100625. constructor(_scene?: Scene | undefined);
  100626. /**
  100627. * The gamepads in the game pad manager
  100628. */
  100629. readonly gamepads: Gamepad[];
  100630. /**
  100631. * Get the gamepad controllers based on type
  100632. * @param type The type of gamepad controller
  100633. * @returns Nullable gamepad
  100634. */
  100635. getGamepadByType(type?: number): Nullable<Gamepad>;
  100636. /**
  100637. * Disposes the gamepad manager
  100638. */
  100639. dispose(): void;
  100640. private _addNewGamepad;
  100641. private _startMonitoringGamepads;
  100642. private _stopMonitoringGamepads;
  100643. /** @hidden */
  100644. _checkGamepadsStatus(): void;
  100645. private _updateGamepadObjects;
  100646. }
  100647. }
  100648. declare module BABYLON {
  100649. interface Scene {
  100650. /** @hidden */
  100651. _gamepadManager: Nullable<GamepadManager>;
  100652. /**
  100653. * Gets the gamepad manager associated with the scene
  100654. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  100655. */
  100656. gamepadManager: GamepadManager;
  100657. }
  100658. /**
  100659. * Interface representing a free camera inputs manager
  100660. */
  100661. interface FreeCameraInputsManager {
  100662. /**
  100663. * Adds gamepad input support to the FreeCameraInputsManager.
  100664. * @returns the FreeCameraInputsManager
  100665. */
  100666. addGamepad(): FreeCameraInputsManager;
  100667. }
  100668. /**
  100669. * Interface representing an arc rotate camera inputs manager
  100670. */
  100671. interface ArcRotateCameraInputsManager {
  100672. /**
  100673. * Adds gamepad input support to the ArcRotateCamera InputManager.
  100674. * @returns the camera inputs manager
  100675. */
  100676. addGamepad(): ArcRotateCameraInputsManager;
  100677. }
  100678. /**
  100679. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  100680. */
  100681. export class GamepadSystemSceneComponent implements ISceneComponent {
  100682. /**
  100683. * The component name helpfull to identify the component in the list of scene components.
  100684. */
  100685. readonly name: string;
  100686. /**
  100687. * The scene the component belongs to.
  100688. */
  100689. scene: Scene;
  100690. /**
  100691. * Creates a new instance of the component for the given scene
  100692. * @param scene Defines the scene to register the component in
  100693. */
  100694. constructor(scene: Scene);
  100695. /**
  100696. * Registers the component in a given scene
  100697. */
  100698. register(): void;
  100699. /**
  100700. * Rebuilds the elements related to this component in case of
  100701. * context lost for instance.
  100702. */
  100703. rebuild(): void;
  100704. /**
  100705. * Disposes the component and the associated ressources
  100706. */
  100707. dispose(): void;
  100708. private _beforeCameraUpdate;
  100709. }
  100710. }
  100711. declare module BABYLON {
  100712. /**
  100713. * 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,
  100714. * which still works and will still be found in many Playgrounds.
  100715. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  100716. */
  100717. export class UniversalCamera extends TouchCamera {
  100718. /**
  100719. * Defines the gamepad rotation sensiblity.
  100720. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  100721. */
  100722. gamepadAngularSensibility: number;
  100723. /**
  100724. * Defines the gamepad move sensiblity.
  100725. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  100726. */
  100727. gamepadMoveSensibility: number;
  100728. /**
  100729. * 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,
  100730. * which still works and will still be found in many Playgrounds.
  100731. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  100732. * @param name Define the name of the camera in the scene
  100733. * @param position Define the start position of the camera in the scene
  100734. * @param scene Define the scene the camera belongs to
  100735. */
  100736. constructor(name: string, position: Vector3, scene: Scene);
  100737. /**
  100738. * Gets the current object class name.
  100739. * @return the class name
  100740. */
  100741. getClassName(): string;
  100742. }
  100743. }
  100744. declare module BABYLON {
  100745. /**
  100746. * This represents a FPS type of camera. This is only here for back compat purpose.
  100747. * Please use the UniversalCamera instead as both are identical.
  100748. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  100749. */
  100750. export class GamepadCamera extends UniversalCamera {
  100751. /**
  100752. * Instantiates a new Gamepad Camera
  100753. * This represents a FPS type of camera. This is only here for back compat purpose.
  100754. * Please use the UniversalCamera instead as both are identical.
  100755. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  100756. * @param name Define the name of the camera in the scene
  100757. * @param position Define the start position of the camera in the scene
  100758. * @param scene Define the scene the camera belongs to
  100759. */
  100760. constructor(name: string, position: Vector3, scene: Scene);
  100761. /**
  100762. * Gets the current object class name.
  100763. * @return the class name
  100764. */
  100765. getClassName(): string;
  100766. }
  100767. }
  100768. declare module BABYLON {
  100769. /** @hidden */
  100770. export var passPixelShader: {
  100771. name: string;
  100772. shader: string;
  100773. };
  100774. }
  100775. declare module BABYLON {
  100776. /** @hidden */
  100777. export var passCubePixelShader: {
  100778. name: string;
  100779. shader: string;
  100780. };
  100781. }
  100782. declare module BABYLON {
  100783. /**
  100784. * PassPostProcess which produces an output the same as it's input
  100785. */
  100786. export class PassPostProcess extends PostProcess {
  100787. /**
  100788. * Creates the PassPostProcess
  100789. * @param name The name of the effect.
  100790. * @param options The required width/height ratio to downsize to before computing the render pass.
  100791. * @param camera The camera to apply the render pass to.
  100792. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  100793. * @param engine The engine which the post process will be applied. (default: current engine)
  100794. * @param reusable If the post process can be reused on the same frame. (default: false)
  100795. * @param textureType The type of texture to be used when performing the post processing.
  100796. * @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)
  100797. */
  100798. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  100799. }
  100800. /**
  100801. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  100802. */
  100803. export class PassCubePostProcess extends PostProcess {
  100804. private _face;
  100805. /**
  100806. * Gets or sets the cube face to display.
  100807. * * 0 is +X
  100808. * * 1 is -X
  100809. * * 2 is +Y
  100810. * * 3 is -Y
  100811. * * 4 is +Z
  100812. * * 5 is -Z
  100813. */
  100814. face: number;
  100815. /**
  100816. * Creates the PassCubePostProcess
  100817. * @param name The name of the effect.
  100818. * @param options The required width/height ratio to downsize to before computing the render pass.
  100819. * @param camera The camera to apply the render pass to.
  100820. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  100821. * @param engine The engine which the post process will be applied. (default: current engine)
  100822. * @param reusable If the post process can be reused on the same frame. (default: false)
  100823. * @param textureType The type of texture to be used when performing the post processing.
  100824. * @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)
  100825. */
  100826. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  100827. }
  100828. }
  100829. declare module BABYLON {
  100830. /** @hidden */
  100831. export var anaglyphPixelShader: {
  100832. name: string;
  100833. shader: string;
  100834. };
  100835. }
  100836. declare module BABYLON {
  100837. /**
  100838. * Postprocess used to generate anaglyphic rendering
  100839. */
  100840. export class AnaglyphPostProcess extends PostProcess {
  100841. private _passedProcess;
  100842. /**
  100843. * Creates a new AnaglyphPostProcess
  100844. * @param name defines postprocess name
  100845. * @param options defines creation options or target ratio scale
  100846. * @param rigCameras defines cameras using this postprocess
  100847. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  100848. * @param engine defines hosting engine
  100849. * @param reusable defines if the postprocess will be reused multiple times per frame
  100850. */
  100851. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  100852. }
  100853. }
  100854. declare module BABYLON {
  100855. /**
  100856. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  100857. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  100858. */
  100859. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  100860. /**
  100861. * Creates a new AnaglyphArcRotateCamera
  100862. * @param name defines camera name
  100863. * @param alpha defines alpha angle (in radians)
  100864. * @param beta defines beta angle (in radians)
  100865. * @param radius defines radius
  100866. * @param target defines camera target
  100867. * @param interaxialDistance defines distance between each color axis
  100868. * @param scene defines the hosting scene
  100869. */
  100870. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  100871. /**
  100872. * Gets camera class name
  100873. * @returns AnaglyphArcRotateCamera
  100874. */
  100875. getClassName(): string;
  100876. }
  100877. }
  100878. declare module BABYLON {
  100879. /**
  100880. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  100881. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  100882. */
  100883. export class AnaglyphFreeCamera extends FreeCamera {
  100884. /**
  100885. * Creates a new AnaglyphFreeCamera
  100886. * @param name defines camera name
  100887. * @param position defines initial position
  100888. * @param interaxialDistance defines distance between each color axis
  100889. * @param scene defines the hosting scene
  100890. */
  100891. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  100892. /**
  100893. * Gets camera class name
  100894. * @returns AnaglyphFreeCamera
  100895. */
  100896. getClassName(): string;
  100897. }
  100898. }
  100899. declare module BABYLON {
  100900. /**
  100901. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  100902. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  100903. */
  100904. export class AnaglyphGamepadCamera extends GamepadCamera {
  100905. /**
  100906. * Creates a new AnaglyphGamepadCamera
  100907. * @param name defines camera name
  100908. * @param position defines initial position
  100909. * @param interaxialDistance defines distance between each color axis
  100910. * @param scene defines the hosting scene
  100911. */
  100912. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  100913. /**
  100914. * Gets camera class name
  100915. * @returns AnaglyphGamepadCamera
  100916. */
  100917. getClassName(): string;
  100918. }
  100919. }
  100920. declare module BABYLON {
  100921. /**
  100922. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  100923. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  100924. */
  100925. export class AnaglyphUniversalCamera extends UniversalCamera {
  100926. /**
  100927. * Creates a new AnaglyphUniversalCamera
  100928. * @param name defines camera name
  100929. * @param position defines initial position
  100930. * @param interaxialDistance defines distance between each color axis
  100931. * @param scene defines the hosting scene
  100932. */
  100933. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  100934. /**
  100935. * Gets camera class name
  100936. * @returns AnaglyphUniversalCamera
  100937. */
  100938. getClassName(): string;
  100939. }
  100940. }
  100941. declare module BABYLON {
  100942. /** @hidden */
  100943. export var stereoscopicInterlacePixelShader: {
  100944. name: string;
  100945. shader: string;
  100946. };
  100947. }
  100948. declare module BABYLON {
  100949. /**
  100950. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  100951. */
  100952. export class StereoscopicInterlacePostProcess extends PostProcess {
  100953. private _stepSize;
  100954. private _passedProcess;
  100955. /**
  100956. * Initializes a StereoscopicInterlacePostProcess
  100957. * @param name The name of the effect.
  100958. * @param rigCameras The rig cameras to be appled to the post process
  100959. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  100960. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  100961. * @param engine The engine which the post process will be applied. (default: current engine)
  100962. * @param reusable If the post process can be reused on the same frame. (default: false)
  100963. */
  100964. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  100965. }
  100966. }
  100967. declare module BABYLON {
  100968. /**
  100969. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  100970. * @see http://doc.babylonjs.com/features/cameras
  100971. */
  100972. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  100973. /**
  100974. * Creates a new StereoscopicArcRotateCamera
  100975. * @param name defines camera name
  100976. * @param alpha defines alpha angle (in radians)
  100977. * @param beta defines beta angle (in radians)
  100978. * @param radius defines radius
  100979. * @param target defines camera target
  100980. * @param interaxialDistance defines distance between each color axis
  100981. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  100982. * @param scene defines the hosting scene
  100983. */
  100984. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  100985. /**
  100986. * Gets camera class name
  100987. * @returns StereoscopicArcRotateCamera
  100988. */
  100989. getClassName(): string;
  100990. }
  100991. }
  100992. declare module BABYLON {
  100993. /**
  100994. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  100995. * @see http://doc.babylonjs.com/features/cameras
  100996. */
  100997. export class StereoscopicFreeCamera extends FreeCamera {
  100998. /**
  100999. * Creates a new StereoscopicFreeCamera
  101000. * @param name defines camera name
  101001. * @param position defines initial position
  101002. * @param interaxialDistance defines distance between each color axis
  101003. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  101004. * @param scene defines the hosting scene
  101005. */
  101006. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  101007. /**
  101008. * Gets camera class name
  101009. * @returns StereoscopicFreeCamera
  101010. */
  101011. getClassName(): string;
  101012. }
  101013. }
  101014. declare module BABYLON {
  101015. /**
  101016. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  101017. * @see http://doc.babylonjs.com/features/cameras
  101018. */
  101019. export class StereoscopicGamepadCamera extends GamepadCamera {
  101020. /**
  101021. * Creates a new StereoscopicGamepadCamera
  101022. * @param name defines camera name
  101023. * @param position defines initial position
  101024. * @param interaxialDistance defines distance between each color axis
  101025. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  101026. * @param scene defines the hosting scene
  101027. */
  101028. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  101029. /**
  101030. * Gets camera class name
  101031. * @returns StereoscopicGamepadCamera
  101032. */
  101033. getClassName(): string;
  101034. }
  101035. }
  101036. declare module BABYLON {
  101037. /**
  101038. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  101039. * @see http://doc.babylonjs.com/features/cameras
  101040. */
  101041. export class StereoscopicUniversalCamera extends UniversalCamera {
  101042. /**
  101043. * Creates a new StereoscopicUniversalCamera
  101044. * @param name defines camera name
  101045. * @param position defines initial position
  101046. * @param interaxialDistance defines distance between each color axis
  101047. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  101048. * @param scene defines the hosting scene
  101049. */
  101050. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  101051. /**
  101052. * Gets camera class name
  101053. * @returns StereoscopicUniversalCamera
  101054. */
  101055. getClassName(): string;
  101056. }
  101057. }
  101058. declare module BABYLON {
  101059. /**
  101060. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  101061. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  101062. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  101063. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  101064. */
  101065. export class VirtualJoysticksCamera extends FreeCamera {
  101066. /**
  101067. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  101068. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  101069. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  101070. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  101071. * @param name Define the name of the camera in the scene
  101072. * @param position Define the start position of the camera in the scene
  101073. * @param scene Define the scene the camera belongs to
  101074. */
  101075. constructor(name: string, position: Vector3, scene: Scene);
  101076. /**
  101077. * Gets the current object class name.
  101078. * @return the class name
  101079. */
  101080. getClassName(): string;
  101081. }
  101082. }
  101083. declare module BABYLON {
  101084. /**
  101085. * This represents all the required metrics to create a VR camera.
  101086. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  101087. */
  101088. export class VRCameraMetrics {
  101089. /**
  101090. * Define the horizontal resolution off the screen.
  101091. */
  101092. hResolution: number;
  101093. /**
  101094. * Define the vertical resolution off the screen.
  101095. */
  101096. vResolution: number;
  101097. /**
  101098. * Define the horizontal screen size.
  101099. */
  101100. hScreenSize: number;
  101101. /**
  101102. * Define the vertical screen size.
  101103. */
  101104. vScreenSize: number;
  101105. /**
  101106. * Define the vertical screen center position.
  101107. */
  101108. vScreenCenter: number;
  101109. /**
  101110. * Define the distance of the eyes to the screen.
  101111. */
  101112. eyeToScreenDistance: number;
  101113. /**
  101114. * Define the distance between both lenses
  101115. */
  101116. lensSeparationDistance: number;
  101117. /**
  101118. * Define the distance between both viewer's eyes.
  101119. */
  101120. interpupillaryDistance: number;
  101121. /**
  101122. * Define the distortion factor of the VR postprocess.
  101123. * Please, touch with care.
  101124. */
  101125. distortionK: number[];
  101126. /**
  101127. * Define the chromatic aberration correction factors for the VR post process.
  101128. */
  101129. chromaAbCorrection: number[];
  101130. /**
  101131. * Define the scale factor of the post process.
  101132. * The smaller the better but the slower.
  101133. */
  101134. postProcessScaleFactor: number;
  101135. /**
  101136. * Define an offset for the lens center.
  101137. */
  101138. lensCenterOffset: number;
  101139. /**
  101140. * Define if the current vr camera should compensate the distortion of the lense or not.
  101141. */
  101142. compensateDistortion: boolean;
  101143. /**
  101144. * Defines if multiview should be enabled when rendering (Default: false)
  101145. */
  101146. multiviewEnabled: boolean;
  101147. /**
  101148. * Gets the rendering aspect ratio based on the provided resolutions.
  101149. */
  101150. readonly aspectRatio: number;
  101151. /**
  101152. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  101153. */
  101154. readonly aspectRatioFov: number;
  101155. /**
  101156. * @hidden
  101157. */
  101158. readonly leftHMatrix: Matrix;
  101159. /**
  101160. * @hidden
  101161. */
  101162. readonly rightHMatrix: Matrix;
  101163. /**
  101164. * @hidden
  101165. */
  101166. readonly leftPreViewMatrix: Matrix;
  101167. /**
  101168. * @hidden
  101169. */
  101170. readonly rightPreViewMatrix: Matrix;
  101171. /**
  101172. * Get the default VRMetrics based on the most generic setup.
  101173. * @returns the default vr metrics
  101174. */
  101175. static GetDefault(): VRCameraMetrics;
  101176. }
  101177. }
  101178. declare module BABYLON {
  101179. /** @hidden */
  101180. export var vrDistortionCorrectionPixelShader: {
  101181. name: string;
  101182. shader: string;
  101183. };
  101184. }
  101185. declare module BABYLON {
  101186. /**
  101187. * VRDistortionCorrectionPostProcess used for mobile VR
  101188. */
  101189. export class VRDistortionCorrectionPostProcess extends PostProcess {
  101190. private _isRightEye;
  101191. private _distortionFactors;
  101192. private _postProcessScaleFactor;
  101193. private _lensCenterOffset;
  101194. private _scaleIn;
  101195. private _scaleFactor;
  101196. private _lensCenter;
  101197. /**
  101198. * Initializes the VRDistortionCorrectionPostProcess
  101199. * @param name The name of the effect.
  101200. * @param camera The camera to apply the render pass to.
  101201. * @param isRightEye If this is for the right eye distortion
  101202. * @param vrMetrics All the required metrics for the VR camera
  101203. */
  101204. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  101205. }
  101206. }
  101207. declare module BABYLON {
  101208. /**
  101209. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  101210. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  101211. */
  101212. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  101213. /**
  101214. * Creates a new VRDeviceOrientationArcRotateCamera
  101215. * @param name defines camera name
  101216. * @param alpha defines the camera rotation along the logitudinal axis
  101217. * @param beta defines the camera rotation along the latitudinal axis
  101218. * @param radius defines the camera distance from its target
  101219. * @param target defines the camera target
  101220. * @param scene defines the scene the camera belongs to
  101221. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  101222. * @param vrCameraMetrics defines the vr metrics associated to the camera
  101223. */
  101224. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  101225. /**
  101226. * Gets camera class name
  101227. * @returns VRDeviceOrientationArcRotateCamera
  101228. */
  101229. getClassName(): string;
  101230. }
  101231. }
  101232. declare module BABYLON {
  101233. /**
  101234. * Camera used to simulate VR rendering (based on FreeCamera)
  101235. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  101236. */
  101237. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  101238. /**
  101239. * Creates a new VRDeviceOrientationFreeCamera
  101240. * @param name defines camera name
  101241. * @param position defines the start position of the camera
  101242. * @param scene defines the scene the camera belongs to
  101243. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  101244. * @param vrCameraMetrics defines the vr metrics associated to the camera
  101245. */
  101246. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  101247. /**
  101248. * Gets camera class name
  101249. * @returns VRDeviceOrientationFreeCamera
  101250. */
  101251. getClassName(): string;
  101252. }
  101253. }
  101254. declare module BABYLON {
  101255. /**
  101256. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  101257. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  101258. */
  101259. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  101260. /**
  101261. * Creates a new VRDeviceOrientationGamepadCamera
  101262. * @param name defines camera name
  101263. * @param position defines the start position of the camera
  101264. * @param scene defines the scene the camera belongs to
  101265. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  101266. * @param vrCameraMetrics defines the vr metrics associated to the camera
  101267. */
  101268. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  101269. /**
  101270. * Gets camera class name
  101271. * @returns VRDeviceOrientationGamepadCamera
  101272. */
  101273. getClassName(): string;
  101274. }
  101275. }
  101276. declare module BABYLON {
  101277. /**
  101278. * Base class of materials working in push mode in babylon JS
  101279. * @hidden
  101280. */
  101281. export class PushMaterial extends Material {
  101282. protected _activeEffect: Effect;
  101283. protected _normalMatrix: Matrix;
  101284. /**
  101285. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  101286. * This means that the material can keep using a previous shader while a new one is being compiled.
  101287. * This is mostly used when shader parallel compilation is supported (true by default)
  101288. */
  101289. allowShaderHotSwapping: boolean;
  101290. constructor(name: string, scene: Scene);
  101291. getEffect(): Effect;
  101292. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  101293. /**
  101294. * Binds the given world matrix to the active effect
  101295. *
  101296. * @param world the matrix to bind
  101297. */
  101298. bindOnlyWorldMatrix(world: Matrix): void;
  101299. /**
  101300. * Binds the given normal matrix to the active effect
  101301. *
  101302. * @param normalMatrix the matrix to bind
  101303. */
  101304. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  101305. bind(world: Matrix, mesh?: Mesh): void;
  101306. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  101307. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  101308. }
  101309. }
  101310. declare module BABYLON {
  101311. /**
  101312. * This groups all the flags used to control the materials channel.
  101313. */
  101314. export class MaterialFlags {
  101315. private static _DiffuseTextureEnabled;
  101316. /**
  101317. * Are diffuse textures enabled in the application.
  101318. */
  101319. static DiffuseTextureEnabled: boolean;
  101320. private static _AmbientTextureEnabled;
  101321. /**
  101322. * Are ambient textures enabled in the application.
  101323. */
  101324. static AmbientTextureEnabled: boolean;
  101325. private static _OpacityTextureEnabled;
  101326. /**
  101327. * Are opacity textures enabled in the application.
  101328. */
  101329. static OpacityTextureEnabled: boolean;
  101330. private static _ReflectionTextureEnabled;
  101331. /**
  101332. * Are reflection textures enabled in the application.
  101333. */
  101334. static ReflectionTextureEnabled: boolean;
  101335. private static _EmissiveTextureEnabled;
  101336. /**
  101337. * Are emissive textures enabled in the application.
  101338. */
  101339. static EmissiveTextureEnabled: boolean;
  101340. private static _SpecularTextureEnabled;
  101341. /**
  101342. * Are specular textures enabled in the application.
  101343. */
  101344. static SpecularTextureEnabled: boolean;
  101345. private static _BumpTextureEnabled;
  101346. /**
  101347. * Are bump textures enabled in the application.
  101348. */
  101349. static BumpTextureEnabled: boolean;
  101350. private static _LightmapTextureEnabled;
  101351. /**
  101352. * Are lightmap textures enabled in the application.
  101353. */
  101354. static LightmapTextureEnabled: boolean;
  101355. private static _RefractionTextureEnabled;
  101356. /**
  101357. * Are refraction textures enabled in the application.
  101358. */
  101359. static RefractionTextureEnabled: boolean;
  101360. private static _ColorGradingTextureEnabled;
  101361. /**
  101362. * Are color grading textures enabled in the application.
  101363. */
  101364. static ColorGradingTextureEnabled: boolean;
  101365. private static _FresnelEnabled;
  101366. /**
  101367. * Are fresnels enabled in the application.
  101368. */
  101369. static FresnelEnabled: boolean;
  101370. private static _ClearCoatTextureEnabled;
  101371. /**
  101372. * Are clear coat textures enabled in the application.
  101373. */
  101374. static ClearCoatTextureEnabled: boolean;
  101375. private static _ClearCoatBumpTextureEnabled;
  101376. /**
  101377. * Are clear coat bump textures enabled in the application.
  101378. */
  101379. static ClearCoatBumpTextureEnabled: boolean;
  101380. private static _ClearCoatTintTextureEnabled;
  101381. /**
  101382. * Are clear coat tint textures enabled in the application.
  101383. */
  101384. static ClearCoatTintTextureEnabled: boolean;
  101385. private static _SheenTextureEnabled;
  101386. /**
  101387. * Are sheen textures enabled in the application.
  101388. */
  101389. static SheenTextureEnabled: boolean;
  101390. private static _AnisotropicTextureEnabled;
  101391. /**
  101392. * Are anisotropic textures enabled in the application.
  101393. */
  101394. static AnisotropicTextureEnabled: boolean;
  101395. private static _ThicknessTextureEnabled;
  101396. /**
  101397. * Are thickness textures enabled in the application.
  101398. */
  101399. static ThicknessTextureEnabled: boolean;
  101400. }
  101401. }
  101402. declare module BABYLON {
  101403. /** @hidden */
  101404. export var defaultFragmentDeclaration: {
  101405. name: string;
  101406. shader: string;
  101407. };
  101408. }
  101409. declare module BABYLON {
  101410. /** @hidden */
  101411. export var defaultUboDeclaration: {
  101412. name: string;
  101413. shader: string;
  101414. };
  101415. }
  101416. declare module BABYLON {
  101417. /** @hidden */
  101418. export var lightFragmentDeclaration: {
  101419. name: string;
  101420. shader: string;
  101421. };
  101422. }
  101423. declare module BABYLON {
  101424. /** @hidden */
  101425. export var lightUboDeclaration: {
  101426. name: string;
  101427. shader: string;
  101428. };
  101429. }
  101430. declare module BABYLON {
  101431. /** @hidden */
  101432. export var lightsFragmentFunctions: {
  101433. name: string;
  101434. shader: string;
  101435. };
  101436. }
  101437. declare module BABYLON {
  101438. /** @hidden */
  101439. export var shadowsFragmentFunctions: {
  101440. name: string;
  101441. shader: string;
  101442. };
  101443. }
  101444. declare module BABYLON {
  101445. /** @hidden */
  101446. export var fresnelFunction: {
  101447. name: string;
  101448. shader: string;
  101449. };
  101450. }
  101451. declare module BABYLON {
  101452. /** @hidden */
  101453. export var reflectionFunction: {
  101454. name: string;
  101455. shader: string;
  101456. };
  101457. }
  101458. declare module BABYLON {
  101459. /** @hidden */
  101460. export var bumpFragmentFunctions: {
  101461. name: string;
  101462. shader: string;
  101463. };
  101464. }
  101465. declare module BABYLON {
  101466. /** @hidden */
  101467. export var logDepthDeclaration: {
  101468. name: string;
  101469. shader: string;
  101470. };
  101471. }
  101472. declare module BABYLON {
  101473. /** @hidden */
  101474. export var bumpFragment: {
  101475. name: string;
  101476. shader: string;
  101477. };
  101478. }
  101479. declare module BABYLON {
  101480. /** @hidden */
  101481. export var depthPrePass: {
  101482. name: string;
  101483. shader: string;
  101484. };
  101485. }
  101486. declare module BABYLON {
  101487. /** @hidden */
  101488. export var lightFragment: {
  101489. name: string;
  101490. shader: string;
  101491. };
  101492. }
  101493. declare module BABYLON {
  101494. /** @hidden */
  101495. export var logDepthFragment: {
  101496. name: string;
  101497. shader: string;
  101498. };
  101499. }
  101500. declare module BABYLON {
  101501. /** @hidden */
  101502. export var defaultPixelShader: {
  101503. name: string;
  101504. shader: string;
  101505. };
  101506. }
  101507. declare module BABYLON {
  101508. /** @hidden */
  101509. export var defaultVertexDeclaration: {
  101510. name: string;
  101511. shader: string;
  101512. };
  101513. }
  101514. declare module BABYLON {
  101515. /** @hidden */
  101516. export var bumpVertexDeclaration: {
  101517. name: string;
  101518. shader: string;
  101519. };
  101520. }
  101521. declare module BABYLON {
  101522. /** @hidden */
  101523. export var bumpVertex: {
  101524. name: string;
  101525. shader: string;
  101526. };
  101527. }
  101528. declare module BABYLON {
  101529. /** @hidden */
  101530. export var fogVertex: {
  101531. name: string;
  101532. shader: string;
  101533. };
  101534. }
  101535. declare module BABYLON {
  101536. /** @hidden */
  101537. export var shadowsVertex: {
  101538. name: string;
  101539. shader: string;
  101540. };
  101541. }
  101542. declare module BABYLON {
  101543. /** @hidden */
  101544. export var pointCloudVertex: {
  101545. name: string;
  101546. shader: string;
  101547. };
  101548. }
  101549. declare module BABYLON {
  101550. /** @hidden */
  101551. export var logDepthVertex: {
  101552. name: string;
  101553. shader: string;
  101554. };
  101555. }
  101556. declare module BABYLON {
  101557. /** @hidden */
  101558. export var defaultVertexShader: {
  101559. name: string;
  101560. shader: string;
  101561. };
  101562. }
  101563. declare module BABYLON {
  101564. /** @hidden */
  101565. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  101566. MAINUV1: boolean;
  101567. MAINUV2: boolean;
  101568. DIFFUSE: boolean;
  101569. DIFFUSEDIRECTUV: number;
  101570. AMBIENT: boolean;
  101571. AMBIENTDIRECTUV: number;
  101572. OPACITY: boolean;
  101573. OPACITYDIRECTUV: number;
  101574. OPACITYRGB: boolean;
  101575. REFLECTION: boolean;
  101576. EMISSIVE: boolean;
  101577. EMISSIVEDIRECTUV: number;
  101578. SPECULAR: boolean;
  101579. SPECULARDIRECTUV: number;
  101580. BUMP: boolean;
  101581. BUMPDIRECTUV: number;
  101582. PARALLAX: boolean;
  101583. PARALLAXOCCLUSION: boolean;
  101584. SPECULAROVERALPHA: boolean;
  101585. CLIPPLANE: boolean;
  101586. CLIPPLANE2: boolean;
  101587. CLIPPLANE3: boolean;
  101588. CLIPPLANE4: boolean;
  101589. ALPHATEST: boolean;
  101590. DEPTHPREPASS: boolean;
  101591. ALPHAFROMDIFFUSE: boolean;
  101592. POINTSIZE: boolean;
  101593. FOG: boolean;
  101594. SPECULARTERM: boolean;
  101595. DIFFUSEFRESNEL: boolean;
  101596. OPACITYFRESNEL: boolean;
  101597. REFLECTIONFRESNEL: boolean;
  101598. REFRACTIONFRESNEL: boolean;
  101599. EMISSIVEFRESNEL: boolean;
  101600. FRESNEL: boolean;
  101601. NORMAL: boolean;
  101602. UV1: boolean;
  101603. UV2: boolean;
  101604. VERTEXCOLOR: boolean;
  101605. VERTEXALPHA: boolean;
  101606. NUM_BONE_INFLUENCERS: number;
  101607. BonesPerMesh: number;
  101608. BONETEXTURE: boolean;
  101609. INSTANCES: boolean;
  101610. GLOSSINESS: boolean;
  101611. ROUGHNESS: boolean;
  101612. EMISSIVEASILLUMINATION: boolean;
  101613. LINKEMISSIVEWITHDIFFUSE: boolean;
  101614. REFLECTIONFRESNELFROMSPECULAR: boolean;
  101615. LIGHTMAP: boolean;
  101616. LIGHTMAPDIRECTUV: number;
  101617. OBJECTSPACE_NORMALMAP: boolean;
  101618. USELIGHTMAPASSHADOWMAP: boolean;
  101619. REFLECTIONMAP_3D: boolean;
  101620. REFLECTIONMAP_SPHERICAL: boolean;
  101621. REFLECTIONMAP_PLANAR: boolean;
  101622. REFLECTIONMAP_CUBIC: boolean;
  101623. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  101624. REFLECTIONMAP_PROJECTION: boolean;
  101625. REFLECTIONMAP_SKYBOX: boolean;
  101626. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  101627. REFLECTIONMAP_EXPLICIT: boolean;
  101628. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  101629. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  101630. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  101631. INVERTCUBICMAP: boolean;
  101632. LOGARITHMICDEPTH: boolean;
  101633. REFRACTION: boolean;
  101634. REFRACTIONMAP_3D: boolean;
  101635. REFLECTIONOVERALPHA: boolean;
  101636. TWOSIDEDLIGHTING: boolean;
  101637. SHADOWFLOAT: boolean;
  101638. MORPHTARGETS: boolean;
  101639. MORPHTARGETS_NORMAL: boolean;
  101640. MORPHTARGETS_TANGENT: boolean;
  101641. NUM_MORPH_INFLUENCERS: number;
  101642. NONUNIFORMSCALING: boolean;
  101643. PREMULTIPLYALPHA: boolean;
  101644. IMAGEPROCESSING: boolean;
  101645. VIGNETTE: boolean;
  101646. VIGNETTEBLENDMODEMULTIPLY: boolean;
  101647. VIGNETTEBLENDMODEOPAQUE: boolean;
  101648. TONEMAPPING: boolean;
  101649. TONEMAPPING_ACES: boolean;
  101650. CONTRAST: boolean;
  101651. COLORCURVES: boolean;
  101652. COLORGRADING: boolean;
  101653. COLORGRADING3D: boolean;
  101654. SAMPLER3DGREENDEPTH: boolean;
  101655. SAMPLER3DBGRMAP: boolean;
  101656. IMAGEPROCESSINGPOSTPROCESS: boolean;
  101657. MULTIVIEW: boolean;
  101658. /**
  101659. * If the reflection texture on this material is in linear color space
  101660. * @hidden
  101661. */
  101662. IS_REFLECTION_LINEAR: boolean;
  101663. /**
  101664. * If the refraction texture on this material is in linear color space
  101665. * @hidden
  101666. */
  101667. IS_REFRACTION_LINEAR: boolean;
  101668. EXPOSURE: boolean;
  101669. constructor();
  101670. setReflectionMode(modeToEnable: string): void;
  101671. }
  101672. /**
  101673. * This is the default material used in Babylon. It is the best trade off between quality
  101674. * and performances.
  101675. * @see http://doc.babylonjs.com/babylon101/materials
  101676. */
  101677. export class StandardMaterial extends PushMaterial {
  101678. private _diffuseTexture;
  101679. /**
  101680. * The basic texture of the material as viewed under a light.
  101681. */
  101682. diffuseTexture: Nullable<BaseTexture>;
  101683. private _ambientTexture;
  101684. /**
  101685. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  101686. */
  101687. ambientTexture: Nullable<BaseTexture>;
  101688. private _opacityTexture;
  101689. /**
  101690. * Define the transparency of the material from a texture.
  101691. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  101692. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  101693. */
  101694. opacityTexture: Nullable<BaseTexture>;
  101695. private _reflectionTexture;
  101696. /**
  101697. * Define the texture used to display the reflection.
  101698. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  101699. */
  101700. reflectionTexture: Nullable<BaseTexture>;
  101701. private _emissiveTexture;
  101702. /**
  101703. * Define texture of the material as if self lit.
  101704. * This will be mixed in the final result even in the absence of light.
  101705. */
  101706. emissiveTexture: Nullable<BaseTexture>;
  101707. private _specularTexture;
  101708. /**
  101709. * Define how the color and intensity of the highlight given by the light in the material.
  101710. */
  101711. specularTexture: Nullable<BaseTexture>;
  101712. private _bumpTexture;
  101713. /**
  101714. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  101715. * 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.
  101716. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  101717. */
  101718. bumpTexture: Nullable<BaseTexture>;
  101719. private _lightmapTexture;
  101720. /**
  101721. * Complex lighting can be computationally expensive to compute at runtime.
  101722. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  101723. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  101724. */
  101725. lightmapTexture: Nullable<BaseTexture>;
  101726. private _refractionTexture;
  101727. /**
  101728. * Define the texture used to display the refraction.
  101729. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  101730. */
  101731. refractionTexture: Nullable<BaseTexture>;
  101732. /**
  101733. * The color of the material lit by the environmental background lighting.
  101734. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  101735. */
  101736. ambientColor: Color3;
  101737. /**
  101738. * The basic color of the material as viewed under a light.
  101739. */
  101740. diffuseColor: Color3;
  101741. /**
  101742. * Define how the color and intensity of the highlight given by the light in the material.
  101743. */
  101744. specularColor: Color3;
  101745. /**
  101746. * Define the color of the material as if self lit.
  101747. * This will be mixed in the final result even in the absence of light.
  101748. */
  101749. emissiveColor: Color3;
  101750. /**
  101751. * Defines how sharp are the highlights in the material.
  101752. * The bigger the value the sharper giving a more glossy feeling to the result.
  101753. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  101754. */
  101755. specularPower: number;
  101756. private _useAlphaFromDiffuseTexture;
  101757. /**
  101758. * Does the transparency come from the diffuse texture alpha channel.
  101759. */
  101760. useAlphaFromDiffuseTexture: boolean;
  101761. private _useEmissiveAsIllumination;
  101762. /**
  101763. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  101764. */
  101765. useEmissiveAsIllumination: boolean;
  101766. private _linkEmissiveWithDiffuse;
  101767. /**
  101768. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  101769. * the emissive level when the final color is close to one.
  101770. */
  101771. linkEmissiveWithDiffuse: boolean;
  101772. private _useSpecularOverAlpha;
  101773. /**
  101774. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  101775. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  101776. */
  101777. useSpecularOverAlpha: boolean;
  101778. private _useReflectionOverAlpha;
  101779. /**
  101780. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  101781. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  101782. */
  101783. useReflectionOverAlpha: boolean;
  101784. private _disableLighting;
  101785. /**
  101786. * Does lights from the scene impacts this material.
  101787. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  101788. */
  101789. disableLighting: boolean;
  101790. private _useObjectSpaceNormalMap;
  101791. /**
  101792. * Allows using an object space normal map (instead of tangent space).
  101793. */
  101794. useObjectSpaceNormalMap: boolean;
  101795. private _useParallax;
  101796. /**
  101797. * Is parallax enabled or not.
  101798. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  101799. */
  101800. useParallax: boolean;
  101801. private _useParallaxOcclusion;
  101802. /**
  101803. * Is parallax occlusion enabled or not.
  101804. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  101805. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  101806. */
  101807. useParallaxOcclusion: boolean;
  101808. /**
  101809. * 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.
  101810. */
  101811. parallaxScaleBias: number;
  101812. private _roughness;
  101813. /**
  101814. * Helps to define how blurry the reflections should appears in the material.
  101815. */
  101816. roughness: number;
  101817. /**
  101818. * In case of refraction, define the value of the index of refraction.
  101819. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  101820. */
  101821. indexOfRefraction: number;
  101822. /**
  101823. * Invert the refraction texture alongside the y axis.
  101824. * It can be useful with procedural textures or probe for instance.
  101825. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  101826. */
  101827. invertRefractionY: boolean;
  101828. /**
  101829. * Defines the alpha limits in alpha test mode.
  101830. */
  101831. alphaCutOff: number;
  101832. private _useLightmapAsShadowmap;
  101833. /**
  101834. * In case of light mapping, define whether the map contains light or shadow informations.
  101835. */
  101836. useLightmapAsShadowmap: boolean;
  101837. private _diffuseFresnelParameters;
  101838. /**
  101839. * Define the diffuse fresnel parameters of the material.
  101840. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101841. */
  101842. diffuseFresnelParameters: FresnelParameters;
  101843. private _opacityFresnelParameters;
  101844. /**
  101845. * Define the opacity fresnel parameters of the material.
  101846. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101847. */
  101848. opacityFresnelParameters: FresnelParameters;
  101849. private _reflectionFresnelParameters;
  101850. /**
  101851. * Define the reflection fresnel parameters of the material.
  101852. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101853. */
  101854. reflectionFresnelParameters: FresnelParameters;
  101855. private _refractionFresnelParameters;
  101856. /**
  101857. * Define the refraction fresnel parameters of the material.
  101858. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101859. */
  101860. refractionFresnelParameters: FresnelParameters;
  101861. private _emissiveFresnelParameters;
  101862. /**
  101863. * Define the emissive fresnel parameters of the material.
  101864. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101865. */
  101866. emissiveFresnelParameters: FresnelParameters;
  101867. private _useReflectionFresnelFromSpecular;
  101868. /**
  101869. * If true automatically deducts the fresnels values from the material specularity.
  101870. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101871. */
  101872. useReflectionFresnelFromSpecular: boolean;
  101873. private _useGlossinessFromSpecularMapAlpha;
  101874. /**
  101875. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  101876. */
  101877. useGlossinessFromSpecularMapAlpha: boolean;
  101878. private _maxSimultaneousLights;
  101879. /**
  101880. * Defines the maximum number of lights that can be used in the material
  101881. */
  101882. maxSimultaneousLights: number;
  101883. private _invertNormalMapX;
  101884. /**
  101885. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  101886. */
  101887. invertNormalMapX: boolean;
  101888. private _invertNormalMapY;
  101889. /**
  101890. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  101891. */
  101892. invertNormalMapY: boolean;
  101893. private _twoSidedLighting;
  101894. /**
  101895. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  101896. */
  101897. twoSidedLighting: boolean;
  101898. /**
  101899. * Default configuration related to image processing available in the standard Material.
  101900. */
  101901. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  101902. /**
  101903. * Gets the image processing configuration used either in this material.
  101904. */
  101905. /**
  101906. * Sets the Default image processing configuration used either in the this material.
  101907. *
  101908. * If sets to null, the scene one is in use.
  101909. */
  101910. imageProcessingConfiguration: ImageProcessingConfiguration;
  101911. /**
  101912. * Keep track of the image processing observer to allow dispose and replace.
  101913. */
  101914. private _imageProcessingObserver;
  101915. /**
  101916. * Attaches a new image processing configuration to the Standard Material.
  101917. * @param configuration
  101918. */
  101919. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  101920. /**
  101921. * Gets wether the color curves effect is enabled.
  101922. */
  101923. /**
  101924. * Sets wether the color curves effect is enabled.
  101925. */
  101926. cameraColorCurvesEnabled: boolean;
  101927. /**
  101928. * Gets wether the color grading effect is enabled.
  101929. */
  101930. /**
  101931. * Gets wether the color grading effect is enabled.
  101932. */
  101933. cameraColorGradingEnabled: boolean;
  101934. /**
  101935. * Gets wether tonemapping is enabled or not.
  101936. */
  101937. /**
  101938. * Sets wether tonemapping is enabled or not
  101939. */
  101940. cameraToneMappingEnabled: boolean;
  101941. /**
  101942. * The camera exposure used on this material.
  101943. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  101944. * This corresponds to a photographic exposure.
  101945. */
  101946. /**
  101947. * The camera exposure used on this material.
  101948. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  101949. * This corresponds to a photographic exposure.
  101950. */
  101951. cameraExposure: number;
  101952. /**
  101953. * Gets The camera contrast used on this material.
  101954. */
  101955. /**
  101956. * Sets The camera contrast used on this material.
  101957. */
  101958. cameraContrast: number;
  101959. /**
  101960. * Gets the Color Grading 2D Lookup Texture.
  101961. */
  101962. /**
  101963. * Sets the Color Grading 2D Lookup Texture.
  101964. */
  101965. cameraColorGradingTexture: Nullable<BaseTexture>;
  101966. /**
  101967. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  101968. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  101969. * 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;
  101970. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  101971. */
  101972. /**
  101973. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  101974. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  101975. * 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;
  101976. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  101977. */
  101978. cameraColorCurves: Nullable<ColorCurves>;
  101979. /**
  101980. * Custom callback helping to override the default shader used in the material.
  101981. */
  101982. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  101983. protected _renderTargets: SmartArray<RenderTargetTexture>;
  101984. protected _worldViewProjectionMatrix: Matrix;
  101985. protected _globalAmbientColor: Color3;
  101986. protected _useLogarithmicDepth: boolean;
  101987. /**
  101988. * Instantiates a new standard material.
  101989. * This is the default material used in Babylon. It is the best trade off between quality
  101990. * and performances.
  101991. * @see http://doc.babylonjs.com/babylon101/materials
  101992. * @param name Define the name of the material in the scene
  101993. * @param scene Define the scene the material belong to
  101994. */
  101995. constructor(name: string, scene: Scene);
  101996. /**
  101997. * Gets a boolean indicating that current material needs to register RTT
  101998. */
  101999. readonly hasRenderTargetTextures: boolean;
  102000. /**
  102001. * Gets the current class name of the material e.g. "StandardMaterial"
  102002. * Mainly use in serialization.
  102003. * @returns the class name
  102004. */
  102005. getClassName(): string;
  102006. /**
  102007. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  102008. * You can try switching to logarithmic depth.
  102009. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  102010. */
  102011. useLogarithmicDepth: boolean;
  102012. /**
  102013. * Specifies if the material will require alpha blending
  102014. * @returns a boolean specifying if alpha blending is needed
  102015. */
  102016. needAlphaBlending(): boolean;
  102017. /**
  102018. * Specifies if this material should be rendered in alpha test mode
  102019. * @returns a boolean specifying if an alpha test is needed.
  102020. */
  102021. needAlphaTesting(): boolean;
  102022. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  102023. /**
  102024. * Get the texture used for alpha test purpose.
  102025. * @returns the diffuse texture in case of the standard material.
  102026. */
  102027. getAlphaTestTexture(): Nullable<BaseTexture>;
  102028. /**
  102029. * Get if the submesh is ready to be used and all its information available.
  102030. * Child classes can use it to update shaders
  102031. * @param mesh defines the mesh to check
  102032. * @param subMesh defines which submesh to check
  102033. * @param useInstances specifies that instances should be used
  102034. * @returns a boolean indicating that the submesh is ready or not
  102035. */
  102036. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  102037. /**
  102038. * Builds the material UBO layouts.
  102039. * Used internally during the effect preparation.
  102040. */
  102041. buildUniformLayout(): void;
  102042. /**
  102043. * Unbinds the material from the mesh
  102044. */
  102045. unbind(): void;
  102046. /**
  102047. * Binds the submesh to this material by preparing the effect and shader to draw
  102048. * @param world defines the world transformation matrix
  102049. * @param mesh defines the mesh containing the submesh
  102050. * @param subMesh defines the submesh to bind the material to
  102051. */
  102052. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  102053. /**
  102054. * Get the list of animatables in the material.
  102055. * @returns the list of animatables object used in the material
  102056. */
  102057. getAnimatables(): IAnimatable[];
  102058. /**
  102059. * Gets the active textures from the material
  102060. * @returns an array of textures
  102061. */
  102062. getActiveTextures(): BaseTexture[];
  102063. /**
  102064. * Specifies if the material uses a texture
  102065. * @param texture defines the texture to check against the material
  102066. * @returns a boolean specifying if the material uses the texture
  102067. */
  102068. hasTexture(texture: BaseTexture): boolean;
  102069. /**
  102070. * Disposes the material
  102071. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  102072. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  102073. */
  102074. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  102075. /**
  102076. * Makes a duplicate of the material, and gives it a new name
  102077. * @param name defines the new name for the duplicated material
  102078. * @returns the cloned material
  102079. */
  102080. clone(name: string): StandardMaterial;
  102081. /**
  102082. * Serializes this material in a JSON representation
  102083. * @returns the serialized material object
  102084. */
  102085. serialize(): any;
  102086. /**
  102087. * Creates a standard material from parsed material data
  102088. * @param source defines the JSON representation of the material
  102089. * @param scene defines the hosting scene
  102090. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  102091. * @returns a new standard material
  102092. */
  102093. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  102094. /**
  102095. * Are diffuse textures enabled in the application.
  102096. */
  102097. static DiffuseTextureEnabled: boolean;
  102098. /**
  102099. * Are ambient textures enabled in the application.
  102100. */
  102101. static AmbientTextureEnabled: boolean;
  102102. /**
  102103. * Are opacity textures enabled in the application.
  102104. */
  102105. static OpacityTextureEnabled: boolean;
  102106. /**
  102107. * Are reflection textures enabled in the application.
  102108. */
  102109. static ReflectionTextureEnabled: boolean;
  102110. /**
  102111. * Are emissive textures enabled in the application.
  102112. */
  102113. static EmissiveTextureEnabled: boolean;
  102114. /**
  102115. * Are specular textures enabled in the application.
  102116. */
  102117. static SpecularTextureEnabled: boolean;
  102118. /**
  102119. * Are bump textures enabled in the application.
  102120. */
  102121. static BumpTextureEnabled: boolean;
  102122. /**
  102123. * Are lightmap textures enabled in the application.
  102124. */
  102125. static LightmapTextureEnabled: boolean;
  102126. /**
  102127. * Are refraction textures enabled in the application.
  102128. */
  102129. static RefractionTextureEnabled: boolean;
  102130. /**
  102131. * Are color grading textures enabled in the application.
  102132. */
  102133. static ColorGradingTextureEnabled: boolean;
  102134. /**
  102135. * Are fresnels enabled in the application.
  102136. */
  102137. static FresnelEnabled: boolean;
  102138. }
  102139. }
  102140. declare module BABYLON {
  102141. /**
  102142. * A class extending Texture allowing drawing on a texture
  102143. * @see http://doc.babylonjs.com/how_to/dynamictexture
  102144. */
  102145. export class DynamicTexture extends Texture {
  102146. private _generateMipMaps;
  102147. private _canvas;
  102148. private _context;
  102149. private _engine;
  102150. /**
  102151. * Creates a DynamicTexture
  102152. * @param name defines the name of the texture
  102153. * @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
  102154. * @param scene defines the scene where you want the texture
  102155. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  102156. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  102157. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  102158. */
  102159. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  102160. /**
  102161. * Get the current class name of the texture useful for serialization or dynamic coding.
  102162. * @returns "DynamicTexture"
  102163. */
  102164. getClassName(): string;
  102165. /**
  102166. * Gets the current state of canRescale
  102167. */
  102168. readonly canRescale: boolean;
  102169. private _recreate;
  102170. /**
  102171. * Scales the texture
  102172. * @param ratio the scale factor to apply to both width and height
  102173. */
  102174. scale(ratio: number): void;
  102175. /**
  102176. * Resizes the texture
  102177. * @param width the new width
  102178. * @param height the new height
  102179. */
  102180. scaleTo(width: number, height: number): void;
  102181. /**
  102182. * Gets the context of the canvas used by the texture
  102183. * @returns the canvas context of the dynamic texture
  102184. */
  102185. getContext(): CanvasRenderingContext2D;
  102186. /**
  102187. * Clears the texture
  102188. */
  102189. clear(): void;
  102190. /**
  102191. * Updates the texture
  102192. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  102193. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  102194. */
  102195. update(invertY?: boolean, premulAlpha?: boolean): void;
  102196. /**
  102197. * Draws text onto the texture
  102198. * @param text defines the text to be drawn
  102199. * @param x defines the placement of the text from the left
  102200. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  102201. * @param font defines the font to be used with font-style, font-size, font-name
  102202. * @param color defines the color used for the text
  102203. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  102204. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  102205. * @param update defines whether texture is immediately update (default is true)
  102206. */
  102207. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  102208. /**
  102209. * Clones the texture
  102210. * @returns the clone of the texture.
  102211. */
  102212. clone(): DynamicTexture;
  102213. /**
  102214. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  102215. * @returns a serialized dynamic texture object
  102216. */
  102217. serialize(): any;
  102218. /** @hidden */
  102219. _rebuild(): void;
  102220. }
  102221. }
  102222. declare module BABYLON {
  102223. /** @hidden */
  102224. export var imageProcessingPixelShader: {
  102225. name: string;
  102226. shader: string;
  102227. };
  102228. }
  102229. declare module BABYLON {
  102230. /**
  102231. * ImageProcessingPostProcess
  102232. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  102233. */
  102234. export class ImageProcessingPostProcess extends PostProcess {
  102235. /**
  102236. * Default configuration related to image processing available in the PBR Material.
  102237. */
  102238. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  102239. /**
  102240. * Gets the image processing configuration used either in this material.
  102241. */
  102242. /**
  102243. * Sets the Default image processing configuration used either in the this material.
  102244. *
  102245. * If sets to null, the scene one is in use.
  102246. */
  102247. imageProcessingConfiguration: ImageProcessingConfiguration;
  102248. /**
  102249. * Keep track of the image processing observer to allow dispose and replace.
  102250. */
  102251. private _imageProcessingObserver;
  102252. /**
  102253. * Attaches a new image processing configuration to the PBR Material.
  102254. * @param configuration
  102255. */
  102256. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  102257. /**
  102258. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  102259. */
  102260. /**
  102261. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  102262. */
  102263. colorCurves: Nullable<ColorCurves>;
  102264. /**
  102265. * Gets wether the color curves effect is enabled.
  102266. */
  102267. /**
  102268. * Sets wether the color curves effect is enabled.
  102269. */
  102270. colorCurvesEnabled: boolean;
  102271. /**
  102272. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  102273. */
  102274. /**
  102275. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  102276. */
  102277. colorGradingTexture: Nullable<BaseTexture>;
  102278. /**
  102279. * Gets wether the color grading effect is enabled.
  102280. */
  102281. /**
  102282. * Gets wether the color grading effect is enabled.
  102283. */
  102284. colorGradingEnabled: boolean;
  102285. /**
  102286. * Gets exposure used in the effect.
  102287. */
  102288. /**
  102289. * Sets exposure used in the effect.
  102290. */
  102291. exposure: number;
  102292. /**
  102293. * Gets wether tonemapping is enabled or not.
  102294. */
  102295. /**
  102296. * Sets wether tonemapping is enabled or not
  102297. */
  102298. toneMappingEnabled: boolean;
  102299. /**
  102300. * Gets the type of tone mapping effect.
  102301. */
  102302. /**
  102303. * Sets the type of tone mapping effect.
  102304. */
  102305. toneMappingType: number;
  102306. /**
  102307. * Gets contrast used in the effect.
  102308. */
  102309. /**
  102310. * Sets contrast used in the effect.
  102311. */
  102312. contrast: number;
  102313. /**
  102314. * Gets Vignette stretch size.
  102315. */
  102316. /**
  102317. * Sets Vignette stretch size.
  102318. */
  102319. vignetteStretch: number;
  102320. /**
  102321. * Gets Vignette centre X Offset.
  102322. */
  102323. /**
  102324. * Sets Vignette centre X Offset.
  102325. */
  102326. vignetteCentreX: number;
  102327. /**
  102328. * Gets Vignette centre Y Offset.
  102329. */
  102330. /**
  102331. * Sets Vignette centre Y Offset.
  102332. */
  102333. vignetteCentreY: number;
  102334. /**
  102335. * Gets Vignette weight or intensity of the vignette effect.
  102336. */
  102337. /**
  102338. * Sets Vignette weight or intensity of the vignette effect.
  102339. */
  102340. vignetteWeight: number;
  102341. /**
  102342. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  102343. * if vignetteEnabled is set to true.
  102344. */
  102345. /**
  102346. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  102347. * if vignetteEnabled is set to true.
  102348. */
  102349. vignetteColor: Color4;
  102350. /**
  102351. * Gets Camera field of view used by the Vignette effect.
  102352. */
  102353. /**
  102354. * Sets Camera field of view used by the Vignette effect.
  102355. */
  102356. vignetteCameraFov: number;
  102357. /**
  102358. * Gets the vignette blend mode allowing different kind of effect.
  102359. */
  102360. /**
  102361. * Sets the vignette blend mode allowing different kind of effect.
  102362. */
  102363. vignetteBlendMode: number;
  102364. /**
  102365. * Gets wether the vignette effect is enabled.
  102366. */
  102367. /**
  102368. * Sets wether the vignette effect is enabled.
  102369. */
  102370. vignetteEnabled: boolean;
  102371. private _fromLinearSpace;
  102372. /**
  102373. * Gets wether the input of the processing is in Gamma or Linear Space.
  102374. */
  102375. /**
  102376. * Sets wether the input of the processing is in Gamma or Linear Space.
  102377. */
  102378. fromLinearSpace: boolean;
  102379. /**
  102380. * Defines cache preventing GC.
  102381. */
  102382. private _defines;
  102383. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  102384. /**
  102385. * "ImageProcessingPostProcess"
  102386. * @returns "ImageProcessingPostProcess"
  102387. */
  102388. getClassName(): string;
  102389. protected _updateParameters(): void;
  102390. dispose(camera?: Camera): void;
  102391. }
  102392. }
  102393. declare module BABYLON {
  102394. /**
  102395. * Class containing static functions to help procedurally build meshes
  102396. */
  102397. export class GroundBuilder {
  102398. /**
  102399. * Creates a ground mesh
  102400. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  102401. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  102402. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  102403. * @param name defines the name of the mesh
  102404. * @param options defines the options used to create the mesh
  102405. * @param scene defines the hosting scene
  102406. * @returns the ground mesh
  102407. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  102408. */
  102409. static CreateGround(name: string, options: {
  102410. width?: number;
  102411. height?: number;
  102412. subdivisions?: number;
  102413. subdivisionsX?: number;
  102414. subdivisionsY?: number;
  102415. updatable?: boolean;
  102416. }, scene: any): Mesh;
  102417. /**
  102418. * Creates a tiled ground mesh
  102419. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  102420. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  102421. * * 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
  102422. * * 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
  102423. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  102424. * @param name defines the name of the mesh
  102425. * @param options defines the options used to create the mesh
  102426. * @param scene defines the hosting scene
  102427. * @returns the tiled ground mesh
  102428. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  102429. */
  102430. static CreateTiledGround(name: string, options: {
  102431. xmin: number;
  102432. zmin: number;
  102433. xmax: number;
  102434. zmax: number;
  102435. subdivisions?: {
  102436. w: number;
  102437. h: number;
  102438. };
  102439. precision?: {
  102440. w: number;
  102441. h: number;
  102442. };
  102443. updatable?: boolean;
  102444. }, scene?: Nullable<Scene>): Mesh;
  102445. /**
  102446. * Creates a ground mesh from a height map
  102447. * * The parameter `url` sets the URL of the height map image resource.
  102448. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  102449. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  102450. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  102451. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  102452. * * 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.
  102453. * * 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).
  102454. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  102455. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  102456. * @param name defines the name of the mesh
  102457. * @param url defines the url to the height map
  102458. * @param options defines the options used to create the mesh
  102459. * @param scene defines the hosting scene
  102460. * @returns the ground mesh
  102461. * @see https://doc.babylonjs.com/babylon101/height_map
  102462. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  102463. */
  102464. static CreateGroundFromHeightMap(name: string, url: string, options: {
  102465. width?: number;
  102466. height?: number;
  102467. subdivisions?: number;
  102468. minHeight?: number;
  102469. maxHeight?: number;
  102470. colorFilter?: Color3;
  102471. alphaFilter?: number;
  102472. updatable?: boolean;
  102473. onReady?: (mesh: GroundMesh) => void;
  102474. }, scene?: Nullable<Scene>): GroundMesh;
  102475. }
  102476. }
  102477. declare module BABYLON {
  102478. /**
  102479. * Class containing static functions to help procedurally build meshes
  102480. */
  102481. export class TorusBuilder {
  102482. /**
  102483. * Creates a torus mesh
  102484. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  102485. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  102486. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  102487. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  102488. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  102489. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  102490. * @param name defines the name of the mesh
  102491. * @param options defines the options used to create the mesh
  102492. * @param scene defines the hosting scene
  102493. * @returns the torus mesh
  102494. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  102495. */
  102496. static CreateTorus(name: string, options: {
  102497. diameter?: number;
  102498. thickness?: number;
  102499. tessellation?: number;
  102500. updatable?: boolean;
  102501. sideOrientation?: number;
  102502. frontUVs?: Vector4;
  102503. backUVs?: Vector4;
  102504. }, scene: any): Mesh;
  102505. }
  102506. }
  102507. declare module BABYLON {
  102508. /**
  102509. * Class containing static functions to help procedurally build meshes
  102510. */
  102511. export class CylinderBuilder {
  102512. /**
  102513. * Creates a cylinder or a cone mesh
  102514. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  102515. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  102516. * * 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.
  102517. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  102518. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  102519. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  102520. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  102521. * * The parameter `cap` sets the way the cylinder is capped. Possible values : BABYLON.Mesh.NO_CAP, BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL (default).
  102522. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  102523. * * 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).
  102524. * * 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
  102525. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  102526. * * 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
  102527. * * 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.
  102528. * * If `enclose` is false, a ring surface is one element.
  102529. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  102530. * * 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
  102531. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  102532. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  102533. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  102534. * @param name defines the name of the mesh
  102535. * @param options defines the options used to create the mesh
  102536. * @param scene defines the hosting scene
  102537. * @returns the cylinder mesh
  102538. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  102539. */
  102540. static CreateCylinder(name: string, options: {
  102541. height?: number;
  102542. diameterTop?: number;
  102543. diameterBottom?: number;
  102544. diameter?: number;
  102545. tessellation?: number;
  102546. subdivisions?: number;
  102547. arc?: number;
  102548. faceColors?: Color4[];
  102549. faceUV?: Vector4[];
  102550. updatable?: boolean;
  102551. hasRings?: boolean;
  102552. enclose?: boolean;
  102553. cap?: number;
  102554. sideOrientation?: number;
  102555. frontUVs?: Vector4;
  102556. backUVs?: Vector4;
  102557. }, scene: any): Mesh;
  102558. }
  102559. }
  102560. declare module BABYLON {
  102561. /**
  102562. * Options to modify the vr teleportation behavior.
  102563. */
  102564. export interface VRTeleportationOptions {
  102565. /**
  102566. * The name of the mesh which should be used as the teleportation floor. (default: null)
  102567. */
  102568. floorMeshName?: string;
  102569. /**
  102570. * A list of meshes to be used as the teleportation floor. (default: empty)
  102571. */
  102572. floorMeshes?: Mesh[];
  102573. }
  102574. /**
  102575. * Options to modify the vr experience helper's behavior.
  102576. */
  102577. export interface VRExperienceHelperOptions extends WebVROptions {
  102578. /**
  102579. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  102580. */
  102581. createDeviceOrientationCamera?: boolean;
  102582. /**
  102583. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  102584. */
  102585. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  102586. /**
  102587. * Uses the main button on the controller to toggle the laser casted. (default: true)
  102588. */
  102589. laserToggle?: boolean;
  102590. /**
  102591. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  102592. */
  102593. floorMeshes?: Mesh[];
  102594. /**
  102595. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  102596. */
  102597. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  102598. }
  102599. /**
  102600. * Event containing information after VR has been entered
  102601. */
  102602. export class OnAfterEnteringVRObservableEvent {
  102603. /**
  102604. * If entering vr was successful
  102605. */
  102606. success: boolean;
  102607. }
  102608. /**
  102609. * Helps to quickly add VR support to an existing scene.
  102610. * See http://doc.babylonjs.com/how_to/webvr_helper
  102611. */
  102612. export class VRExperienceHelper {
  102613. /** Options to modify the vr experience helper's behavior. */
  102614. webVROptions: VRExperienceHelperOptions;
  102615. private _scene;
  102616. private _position;
  102617. private _btnVR;
  102618. private _btnVRDisplayed;
  102619. private _webVRsupported;
  102620. private _webVRready;
  102621. private _webVRrequesting;
  102622. private _webVRpresenting;
  102623. private _hasEnteredVR;
  102624. private _fullscreenVRpresenting;
  102625. private _canvas;
  102626. private _webVRCamera;
  102627. private _vrDeviceOrientationCamera;
  102628. private _deviceOrientationCamera;
  102629. private _existingCamera;
  102630. private _onKeyDown;
  102631. private _onVrDisplayPresentChange;
  102632. private _onVRDisplayChanged;
  102633. private _onVRRequestPresentStart;
  102634. private _onVRRequestPresentComplete;
  102635. /**
  102636. * Observable raised right before entering VR.
  102637. */
  102638. onEnteringVRObservable: Observable<VRExperienceHelper>;
  102639. /**
  102640. * Observable raised when entering VR has completed.
  102641. */
  102642. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  102643. /**
  102644. * Observable raised when exiting VR.
  102645. */
  102646. onExitingVRObservable: Observable<VRExperienceHelper>;
  102647. /**
  102648. * Observable raised when controller mesh is loaded.
  102649. */
  102650. onControllerMeshLoadedObservable: Observable<WebVRController>;
  102651. /** Return this.onEnteringVRObservable
  102652. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  102653. */
  102654. readonly onEnteringVR: Observable<VRExperienceHelper>;
  102655. /** Return this.onExitingVRObservable
  102656. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  102657. */
  102658. readonly onExitingVR: Observable<VRExperienceHelper>;
  102659. /** Return this.onControllerMeshLoadedObservable
  102660. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  102661. */
  102662. readonly onControllerMeshLoaded: Observable<WebVRController>;
  102663. private _rayLength;
  102664. private _useCustomVRButton;
  102665. private _teleportationRequested;
  102666. private _teleportActive;
  102667. private _floorMeshName;
  102668. private _floorMeshesCollection;
  102669. private _rotationAllowed;
  102670. private _teleportBackwardsVector;
  102671. private _teleportationTarget;
  102672. private _isDefaultTeleportationTarget;
  102673. private _postProcessMove;
  102674. private _teleportationFillColor;
  102675. private _teleportationBorderColor;
  102676. private _rotationAngle;
  102677. private _haloCenter;
  102678. private _cameraGazer;
  102679. private _padSensibilityUp;
  102680. private _padSensibilityDown;
  102681. private _leftController;
  102682. private _rightController;
  102683. /**
  102684. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  102685. */
  102686. onNewMeshSelected: Observable<AbstractMesh>;
  102687. /**
  102688. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  102689. */
  102690. onNewMeshPicked: Observable<PickingInfo>;
  102691. private _circleEase;
  102692. /**
  102693. * Observable raised before camera teleportation
  102694. */
  102695. onBeforeCameraTeleport: Observable<Vector3>;
  102696. /**
  102697. * Observable raised after camera teleportation
  102698. */
  102699. onAfterCameraTeleport: Observable<Vector3>;
  102700. /**
  102701. * Observable raised when current selected mesh gets unselected
  102702. */
  102703. onSelectedMeshUnselected: Observable<AbstractMesh>;
  102704. private _raySelectionPredicate;
  102705. /**
  102706. * To be optionaly changed by user to define custom ray selection
  102707. */
  102708. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  102709. /**
  102710. * To be optionaly changed by user to define custom selection logic (after ray selection)
  102711. */
  102712. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  102713. /**
  102714. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  102715. */
  102716. teleportationEnabled: boolean;
  102717. private _defaultHeight;
  102718. private _teleportationInitialized;
  102719. private _interactionsEnabled;
  102720. private _interactionsRequested;
  102721. private _displayGaze;
  102722. private _displayLaserPointer;
  102723. /**
  102724. * The mesh used to display where the user is going to teleport.
  102725. */
  102726. /**
  102727. * Sets the mesh to be used to display where the user is going to teleport.
  102728. */
  102729. teleportationTarget: Mesh;
  102730. /**
  102731. * 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
  102732. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  102733. * See http://doc.babylonjs.com/resources/baking_transformations
  102734. */
  102735. gazeTrackerMesh: Mesh;
  102736. /**
  102737. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  102738. */
  102739. updateGazeTrackerScale: boolean;
  102740. /**
  102741. * If the gaze trackers color should be updated when selecting meshes
  102742. */
  102743. updateGazeTrackerColor: boolean;
  102744. /**
  102745. * The gaze tracking mesh corresponding to the left controller
  102746. */
  102747. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  102748. /**
  102749. * The gaze tracking mesh corresponding to the right controller
  102750. */
  102751. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  102752. /**
  102753. * If the ray of the gaze should be displayed.
  102754. */
  102755. /**
  102756. * Sets if the ray of the gaze should be displayed.
  102757. */
  102758. displayGaze: boolean;
  102759. /**
  102760. * If the ray of the LaserPointer should be displayed.
  102761. */
  102762. /**
  102763. * Sets if the ray of the LaserPointer should be displayed.
  102764. */
  102765. displayLaserPointer: boolean;
  102766. /**
  102767. * The deviceOrientationCamera used as the camera when not in VR.
  102768. */
  102769. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  102770. /**
  102771. * Based on the current WebVR support, returns the current VR camera used.
  102772. */
  102773. readonly currentVRCamera: Nullable<Camera>;
  102774. /**
  102775. * The webVRCamera which is used when in VR.
  102776. */
  102777. readonly webVRCamera: WebVRFreeCamera;
  102778. /**
  102779. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  102780. */
  102781. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  102782. private readonly _teleportationRequestInitiated;
  102783. /**
  102784. * Defines wether or not Pointer lock should be requested when switching to
  102785. * full screen.
  102786. */
  102787. requestPointerLockOnFullScreen: boolean;
  102788. /**
  102789. * Instantiates a VRExperienceHelper.
  102790. * Helps to quickly add VR support to an existing scene.
  102791. * @param scene The scene the VRExperienceHelper belongs to.
  102792. * @param webVROptions Options to modify the vr experience helper's behavior.
  102793. */
  102794. constructor(scene: Scene,
  102795. /** Options to modify the vr experience helper's behavior. */
  102796. webVROptions?: VRExperienceHelperOptions);
  102797. private _onDefaultMeshLoaded;
  102798. private _onResize;
  102799. private _onFullscreenChange;
  102800. /**
  102801. * Gets a value indicating if we are currently in VR mode.
  102802. */
  102803. readonly isInVRMode: boolean;
  102804. private onVrDisplayPresentChange;
  102805. private onVRDisplayChanged;
  102806. private moveButtonToBottomRight;
  102807. private displayVRButton;
  102808. private updateButtonVisibility;
  102809. private _cachedAngularSensibility;
  102810. /**
  102811. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  102812. * Otherwise, will use the fullscreen API.
  102813. */
  102814. enterVR(): void;
  102815. /**
  102816. * Attempt to exit VR, or fullscreen.
  102817. */
  102818. exitVR(): void;
  102819. /**
  102820. * The position of the vr experience helper.
  102821. */
  102822. /**
  102823. * Sets the position of the vr experience helper.
  102824. */
  102825. position: Vector3;
  102826. /**
  102827. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  102828. */
  102829. enableInteractions(): void;
  102830. private readonly _noControllerIsActive;
  102831. private beforeRender;
  102832. private _isTeleportationFloor;
  102833. /**
  102834. * Adds a floor mesh to be used for teleportation.
  102835. * @param floorMesh the mesh to be used for teleportation.
  102836. */
  102837. addFloorMesh(floorMesh: Mesh): void;
  102838. /**
  102839. * Removes a floor mesh from being used for teleportation.
  102840. * @param floorMesh the mesh to be removed.
  102841. */
  102842. removeFloorMesh(floorMesh: Mesh): void;
  102843. /**
  102844. * Enables interactions and teleportation using the VR controllers and gaze.
  102845. * @param vrTeleportationOptions options to modify teleportation behavior.
  102846. */
  102847. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  102848. private _onNewGamepadConnected;
  102849. private _tryEnableInteractionOnController;
  102850. private _onNewGamepadDisconnected;
  102851. private _enableInteractionOnController;
  102852. private _checkTeleportWithRay;
  102853. private _checkRotate;
  102854. private _checkTeleportBackwards;
  102855. private _enableTeleportationOnController;
  102856. private _createTeleportationCircles;
  102857. private _displayTeleportationTarget;
  102858. private _hideTeleportationTarget;
  102859. private _rotateCamera;
  102860. private _moveTeleportationSelectorTo;
  102861. private _workingVector;
  102862. private _workingQuaternion;
  102863. private _workingMatrix;
  102864. /**
  102865. * Teleports the users feet to the desired location
  102866. * @param location The location where the user's feet should be placed
  102867. */
  102868. teleportCamera(location: Vector3): void;
  102869. private _convertNormalToDirectionOfRay;
  102870. private _castRayAndSelectObject;
  102871. private _notifySelectedMeshUnselected;
  102872. /**
  102873. * Sets the color of the laser ray from the vr controllers.
  102874. * @param color new color for the ray.
  102875. */
  102876. changeLaserColor(color: Color3): void;
  102877. /**
  102878. * Sets the color of the ray from the vr headsets gaze.
  102879. * @param color new color for the ray.
  102880. */
  102881. changeGazeColor(color: Color3): void;
  102882. /**
  102883. * Exits VR and disposes of the vr experience helper
  102884. */
  102885. dispose(): void;
  102886. /**
  102887. * Gets the name of the VRExperienceHelper class
  102888. * @returns "VRExperienceHelper"
  102889. */
  102890. getClassName(): string;
  102891. }
  102892. }
  102893. declare module BABYLON {
  102894. /**
  102895. * Manages an XRSession
  102896. * @see https://doc.babylonjs.com/how_to/webxr
  102897. */
  102898. export class WebXRSessionManager implements IDisposable {
  102899. private scene;
  102900. /**
  102901. * Fires every time a new xrFrame arrives which can be used to update the camera
  102902. */
  102903. onXRFrameObservable: Observable<any>;
  102904. /**
  102905. * Fires when the xr session is ended either by the device or manually done
  102906. */
  102907. onXRSessionEnded: Observable<any>;
  102908. /** @hidden */
  102909. _xrSession: XRSession;
  102910. /** @hidden */
  102911. _frameOfReference: XRFrameOfReference;
  102912. /** @hidden */
  102913. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  102914. /** @hidden */
  102915. _currentXRFrame: Nullable<XRFrame>;
  102916. private _xrNavigator;
  102917. private _xrDevice;
  102918. private _tmpMatrix;
  102919. /**
  102920. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  102921. * @param scene The scene which the session should be created for
  102922. */
  102923. constructor(scene: Scene);
  102924. /**
  102925. * Initializes the manager
  102926. * After initialization enterXR can be called to start an XR session
  102927. * @returns Promise which resolves after it is initialized
  102928. */
  102929. initializeAsync(): Promise<void>;
  102930. /**
  102931. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  102932. * @param sessionCreationOptions xr options to create the session with
  102933. * @param frameOfReferenceType option to configure how the xr pose is expressed
  102934. * @returns Promise which resolves after it enters XR
  102935. */
  102936. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  102937. /**
  102938. * Stops the xrSession and restores the renderloop
  102939. * @returns Promise which resolves after it exits XR
  102940. */
  102941. exitXRAsync(): Promise<void>;
  102942. /**
  102943. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  102944. * @param ray ray to cast into the environment
  102945. * @returns Promise which resolves with a collision point in the environment if it exists
  102946. */
  102947. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  102948. /**
  102949. * Checks if a session would be supported for the creation options specified
  102950. * @param options creation options to check if they are supported
  102951. * @returns true if supported
  102952. */
  102953. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  102954. /**
  102955. * @hidden
  102956. * Converts the render layer of xrSession to a render target
  102957. * @param session session to create render target for
  102958. * @param scene scene the new render target should be created for
  102959. */
  102960. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  102961. /**
  102962. * Disposes of the session manager
  102963. */
  102964. dispose(): void;
  102965. }
  102966. }
  102967. declare module BABYLON {
  102968. /**
  102969. * WebXR Camera which holds the views for the xrSession
  102970. * @see https://doc.babylonjs.com/how_to/webxr
  102971. */
  102972. export class WebXRCamera extends FreeCamera {
  102973. private static _TmpMatrix;
  102974. /**
  102975. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  102976. * @param name the name of the camera
  102977. * @param scene the scene to add the camera to
  102978. */
  102979. constructor(name: string, scene: Scene);
  102980. private _updateNumberOfRigCameras;
  102981. /** @hidden */
  102982. _updateForDualEyeDebugging(pupilDistance?: number): void;
  102983. /**
  102984. * Updates the cameras position from the current pose information of the XR session
  102985. * @param xrSessionManager the session containing pose information
  102986. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  102987. */
  102988. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  102989. }
  102990. }
  102991. declare module BABYLON {
  102992. /**
  102993. * States of the webXR experience
  102994. */
  102995. export enum WebXRState {
  102996. /**
  102997. * Transitioning to being in XR mode
  102998. */
  102999. ENTERING_XR = 0,
  103000. /**
  103001. * Transitioning to non XR mode
  103002. */
  103003. EXITING_XR = 1,
  103004. /**
  103005. * In XR mode and presenting
  103006. */
  103007. IN_XR = 2,
  103008. /**
  103009. * Not entered XR mode
  103010. */
  103011. NOT_IN_XR = 3
  103012. }
  103013. /**
  103014. * Helper class used to enable XR
  103015. * @see https://doc.babylonjs.com/how_to/webxr
  103016. */
  103017. export class WebXRExperienceHelper implements IDisposable {
  103018. private scene;
  103019. /**
  103020. * 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
  103021. */
  103022. container: AbstractMesh;
  103023. /**
  103024. * Camera used to render xr content
  103025. */
  103026. camera: WebXRCamera;
  103027. /**
  103028. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  103029. */
  103030. state: WebXRState;
  103031. private _setState;
  103032. private static _TmpVector;
  103033. /**
  103034. * Fires when the state of the experience helper has changed
  103035. */
  103036. onStateChangedObservable: Observable<WebXRState>;
  103037. /** @hidden */
  103038. _sessionManager: WebXRSessionManager;
  103039. private _nonVRCamera;
  103040. private _originalSceneAutoClear;
  103041. private _supported;
  103042. /**
  103043. * Creates the experience helper
  103044. * @param scene the scene to attach the experience helper to
  103045. * @returns a promise for the experience helper
  103046. */
  103047. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  103048. /**
  103049. * Creates a WebXRExperienceHelper
  103050. * @param scene The scene the helper should be created in
  103051. */
  103052. private constructor();
  103053. /**
  103054. * Exits XR mode and returns the scene to its original state
  103055. * @returns promise that resolves after xr mode has exited
  103056. */
  103057. exitXRAsync(): Promise<void>;
  103058. /**
  103059. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  103060. * @param sessionCreationOptions options for the XR session
  103061. * @param frameOfReference frame of reference of the XR session
  103062. * @returns promise that resolves after xr mode has entered
  103063. */
  103064. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  103065. /**
  103066. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  103067. * @param ray ray to cast into the environment
  103068. * @returns Promise which resolves with a collision point in the environment if it exists
  103069. */
  103070. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  103071. /**
  103072. * Updates the global position of the camera by moving the camera's container
  103073. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  103074. * @param position The desired global position of the camera
  103075. */
  103076. setPositionOfCameraUsingContainer(position: Vector3): void;
  103077. /**
  103078. * Rotates the xr camera by rotating the camera's container around the camera's position
  103079. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  103080. * @param rotation the desired quaternion rotation to apply to the camera
  103081. */
  103082. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  103083. /**
  103084. * Checks if the creation options are supported by the xr session
  103085. * @param options creation options
  103086. * @returns true if supported
  103087. */
  103088. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  103089. /**
  103090. * Disposes of the experience helper
  103091. */
  103092. dispose(): void;
  103093. }
  103094. }
  103095. declare module BABYLON {
  103096. /**
  103097. * Button which can be used to enter a different mode of XR
  103098. */
  103099. export class WebXREnterExitUIButton {
  103100. /** button element */
  103101. element: HTMLElement;
  103102. /** XR initialization options for the button */
  103103. initializationOptions: XRSessionCreationOptions;
  103104. /**
  103105. * Creates a WebXREnterExitUIButton
  103106. * @param element button element
  103107. * @param initializationOptions XR initialization options for the button
  103108. */
  103109. constructor(
  103110. /** button element */
  103111. element: HTMLElement,
  103112. /** XR initialization options for the button */
  103113. initializationOptions: XRSessionCreationOptions);
  103114. /**
  103115. * Overwritable function which can be used to update the button's visuals when the state changes
  103116. * @param activeButton the current active button in the UI
  103117. */
  103118. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  103119. }
  103120. /**
  103121. * Options to create the webXR UI
  103122. */
  103123. export class WebXREnterExitUIOptions {
  103124. /**
  103125. * Context to enter xr with
  103126. */
  103127. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  103128. /**
  103129. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  103130. */
  103131. customButtons?: Array<WebXREnterExitUIButton>;
  103132. }
  103133. /**
  103134. * UI to allow the user to enter/exit XR mode
  103135. */
  103136. export class WebXREnterExitUI implements IDisposable {
  103137. private scene;
  103138. private _overlay;
  103139. private _buttons;
  103140. private _activeButton;
  103141. /**
  103142. * Fired every time the active button is changed.
  103143. *
  103144. * When xr is entered via a button that launches xr that button will be the callback parameter
  103145. *
  103146. * When exiting xr the callback parameter will be null)
  103147. */
  103148. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  103149. /**
  103150. * Creates UI to allow the user to enter/exit XR mode
  103151. * @param scene the scene to add the ui to
  103152. * @param helper the xr experience helper to enter/exit xr with
  103153. * @param options options to configure the UI
  103154. * @returns the created ui
  103155. */
  103156. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  103157. private constructor();
  103158. private _updateButtons;
  103159. /**
  103160. * Disposes of the object
  103161. */
  103162. dispose(): void;
  103163. }
  103164. }
  103165. declare module BABYLON {
  103166. /**
  103167. * Represents an XR input
  103168. */
  103169. export class WebXRController {
  103170. /**
  103171. * 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
  103172. */
  103173. grip?: AbstractMesh;
  103174. /**
  103175. * Pointer which can be used to select objects or attach a visible laser to
  103176. */
  103177. pointer: AbstractMesh;
  103178. /**
  103179. * Creates the controller
  103180. * @see https://doc.babylonjs.com/how_to/webxr
  103181. * @param scene the scene which the controller should be associated to
  103182. */
  103183. constructor(scene: Scene);
  103184. /**
  103185. * Disposes of the object
  103186. */
  103187. dispose(): void;
  103188. }
  103189. /**
  103190. * XR input used to track XR inputs such as controllers/rays
  103191. */
  103192. export class WebXRInput implements IDisposable {
  103193. private helper;
  103194. /**
  103195. * XR controllers being tracked
  103196. */
  103197. controllers: Array<WebXRController>;
  103198. private _tmpMatrix;
  103199. private _frameObserver;
  103200. /**
  103201. * Initializes the WebXRInput
  103202. * @param helper experience helper which the input should be created for
  103203. */
  103204. constructor(helper: WebXRExperienceHelper);
  103205. /**
  103206. * Disposes of the object
  103207. */
  103208. dispose(): void;
  103209. }
  103210. }
  103211. declare module BABYLON {
  103212. /**
  103213. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  103214. */
  103215. export class WebXRManagedOutputCanvas implements IDisposable {
  103216. private _canvas;
  103217. /**
  103218. * xrpresent context of the canvas which can be used to display/mirror xr content
  103219. */
  103220. canvasContext: Nullable<WebGLRenderingContext>;
  103221. /**
  103222. * Initializes the canvas to be added/removed upon entering/exiting xr
  103223. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  103224. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  103225. */
  103226. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  103227. /**
  103228. * Disposes of the object
  103229. */
  103230. dispose(): void;
  103231. private _setManagedOutputCanvas;
  103232. private _addCanvas;
  103233. private _removeCanvas;
  103234. }
  103235. }
  103236. declare module BABYLON {
  103237. /**
  103238. * Contains an array of blocks representing the octree
  103239. */
  103240. export interface IOctreeContainer<T> {
  103241. /**
  103242. * Blocks within the octree
  103243. */
  103244. blocks: Array<OctreeBlock<T>>;
  103245. }
  103246. /**
  103247. * Class used to store a cell in an octree
  103248. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103249. */
  103250. export class OctreeBlock<T> {
  103251. /**
  103252. * Gets the content of the current block
  103253. */
  103254. entries: T[];
  103255. /**
  103256. * Gets the list of block children
  103257. */
  103258. blocks: Array<OctreeBlock<T>>;
  103259. private _depth;
  103260. private _maxDepth;
  103261. private _capacity;
  103262. private _minPoint;
  103263. private _maxPoint;
  103264. private _boundingVectors;
  103265. private _creationFunc;
  103266. /**
  103267. * Creates a new block
  103268. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  103269. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  103270. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  103271. * @param depth defines the current depth of this block in the octree
  103272. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  103273. * @param creationFunc defines a callback to call when an element is added to the block
  103274. */
  103275. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  103276. /**
  103277. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  103278. */
  103279. readonly capacity: number;
  103280. /**
  103281. * Gets the minimum vector (in world space) of the block's bounding box
  103282. */
  103283. readonly minPoint: Vector3;
  103284. /**
  103285. * Gets the maximum vector (in world space) of the block's bounding box
  103286. */
  103287. readonly maxPoint: Vector3;
  103288. /**
  103289. * Add a new element to this block
  103290. * @param entry defines the element to add
  103291. */
  103292. addEntry(entry: T): void;
  103293. /**
  103294. * Remove an element from this block
  103295. * @param entry defines the element to remove
  103296. */
  103297. removeEntry(entry: T): void;
  103298. /**
  103299. * Add an array of elements to this block
  103300. * @param entries defines the array of elements to add
  103301. */
  103302. addEntries(entries: T[]): void;
  103303. /**
  103304. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  103305. * @param frustumPlanes defines the frustum planes to test
  103306. * @param selection defines the array to store current content if selection is positive
  103307. * @param allowDuplicate defines if the selection array can contains duplicated entries
  103308. */
  103309. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  103310. /**
  103311. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  103312. * @param sphereCenter defines the bounding sphere center
  103313. * @param sphereRadius defines the bounding sphere radius
  103314. * @param selection defines the array to store current content if selection is positive
  103315. * @param allowDuplicate defines if the selection array can contains duplicated entries
  103316. */
  103317. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  103318. /**
  103319. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  103320. * @param ray defines the ray to test with
  103321. * @param selection defines the array to store current content if selection is positive
  103322. */
  103323. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  103324. /**
  103325. * Subdivide the content into child blocks (this block will then be empty)
  103326. */
  103327. createInnerBlocks(): void;
  103328. /**
  103329. * @hidden
  103330. */
  103331. 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;
  103332. }
  103333. }
  103334. declare module BABYLON {
  103335. /**
  103336. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  103337. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103338. */
  103339. export class Octree<T> {
  103340. /** 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.) */
  103341. maxDepth: number;
  103342. /**
  103343. * Blocks within the octree containing objects
  103344. */
  103345. blocks: Array<OctreeBlock<T>>;
  103346. /**
  103347. * Content stored in the octree
  103348. */
  103349. dynamicContent: T[];
  103350. private _maxBlockCapacity;
  103351. private _selectionContent;
  103352. private _creationFunc;
  103353. /**
  103354. * Creates a octree
  103355. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103356. * @param creationFunc function to be used to instatiate the octree
  103357. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  103358. * @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.)
  103359. */
  103360. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  103361. /** 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.) */
  103362. maxDepth?: number);
  103363. /**
  103364. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  103365. * @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);
  103366. * @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);
  103367. * @param entries meshes to be added to the octree blocks
  103368. */
  103369. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  103370. /**
  103371. * Adds a mesh to the octree
  103372. * @param entry Mesh to add to the octree
  103373. */
  103374. addMesh(entry: T): void;
  103375. /**
  103376. * Remove an element from the octree
  103377. * @param entry defines the element to remove
  103378. */
  103379. removeMesh(entry: T): void;
  103380. /**
  103381. * Selects an array of meshes within the frustum
  103382. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  103383. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  103384. * @returns array of meshes within the frustum
  103385. */
  103386. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  103387. /**
  103388. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  103389. * @param sphereCenter defines the bounding sphere center
  103390. * @param sphereRadius defines the bounding sphere radius
  103391. * @param allowDuplicate defines if the selection array can contains duplicated entries
  103392. * @returns an array of objects that intersect the sphere
  103393. */
  103394. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  103395. /**
  103396. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  103397. * @param ray defines the ray to test with
  103398. * @returns array of intersected objects
  103399. */
  103400. intersectsRay(ray: Ray): SmartArray<T>;
  103401. /**
  103402. * Adds a mesh into the octree block if it intersects the block
  103403. */
  103404. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  103405. /**
  103406. * Adds a submesh into the octree block if it intersects the block
  103407. */
  103408. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  103409. }
  103410. }
  103411. declare module BABYLON {
  103412. interface Scene {
  103413. /**
  103414. * @hidden
  103415. * Backing Filed
  103416. */
  103417. _selectionOctree: Octree<AbstractMesh>;
  103418. /**
  103419. * Gets the octree used to boost mesh selection (picking)
  103420. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103421. */
  103422. selectionOctree: Octree<AbstractMesh>;
  103423. /**
  103424. * Creates or updates the octree used to boost selection (picking)
  103425. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103426. * @param maxCapacity defines the maximum capacity per leaf
  103427. * @param maxDepth defines the maximum depth of the octree
  103428. * @returns an octree of AbstractMesh
  103429. */
  103430. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  103431. }
  103432. interface AbstractMesh {
  103433. /**
  103434. * @hidden
  103435. * Backing Field
  103436. */
  103437. _submeshesOctree: Octree<SubMesh>;
  103438. /**
  103439. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  103440. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  103441. * @param maxCapacity defines the maximum size of each block (64 by default)
  103442. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  103443. * @returns the new octree
  103444. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  103445. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103446. */
  103447. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  103448. }
  103449. /**
  103450. * Defines the octree scene component responsible to manage any octrees
  103451. * in a given scene.
  103452. */
  103453. export class OctreeSceneComponent {
  103454. /**
  103455. * The component name help to identify the component in the list of scene components.
  103456. */
  103457. readonly name: string;
  103458. /**
  103459. * The scene the component belongs to.
  103460. */
  103461. scene: Scene;
  103462. /**
  103463. * Indicates if the meshes have been checked to make sure they are isEnabled()
  103464. */
  103465. readonly checksIsEnabled: boolean;
  103466. /**
  103467. * Creates a new instance of the component for the given scene
  103468. * @param scene Defines the scene to register the component in
  103469. */
  103470. constructor(scene: Scene);
  103471. /**
  103472. * Registers the component in a given scene
  103473. */
  103474. register(): void;
  103475. /**
  103476. * Return the list of active meshes
  103477. * @returns the list of active meshes
  103478. */
  103479. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  103480. /**
  103481. * Return the list of active sub meshes
  103482. * @param mesh The mesh to get the candidates sub meshes from
  103483. * @returns the list of active sub meshes
  103484. */
  103485. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  103486. private _tempRay;
  103487. /**
  103488. * Return the list of sub meshes intersecting with a given local ray
  103489. * @param mesh defines the mesh to find the submesh for
  103490. * @param localRay defines the ray in local space
  103491. * @returns the list of intersecting sub meshes
  103492. */
  103493. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  103494. /**
  103495. * Return the list of sub meshes colliding with a collider
  103496. * @param mesh defines the mesh to find the submesh for
  103497. * @param collider defines the collider to evaluate the collision against
  103498. * @returns the list of colliding sub meshes
  103499. */
  103500. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  103501. /**
  103502. * Rebuilds the elements related to this component in case of
  103503. * context lost for instance.
  103504. */
  103505. rebuild(): void;
  103506. /**
  103507. * Disposes the component and the associated ressources.
  103508. */
  103509. dispose(): void;
  103510. }
  103511. }
  103512. declare module BABYLON {
  103513. /**
  103514. * Renders a layer on top of an existing scene
  103515. */
  103516. export class UtilityLayerRenderer implements IDisposable {
  103517. /** the original scene that will be rendered on top of */
  103518. originalScene: Scene;
  103519. private _pointerCaptures;
  103520. private _lastPointerEvents;
  103521. private static _DefaultUtilityLayer;
  103522. private static _DefaultKeepDepthUtilityLayer;
  103523. private _sharedGizmoLight;
  103524. private _renderCamera;
  103525. /**
  103526. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  103527. * @returns the camera that is used when rendering the utility layer
  103528. */
  103529. getRenderCamera(): Nullable<Camera>;
  103530. /**
  103531. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  103532. * @param cam the camera that should be used when rendering the utility layer
  103533. */
  103534. setRenderCamera(cam: Nullable<Camera>): void;
  103535. /**
  103536. * @hidden
  103537. * Light which used by gizmos to get light shading
  103538. */
  103539. _getSharedGizmoLight(): HemisphericLight;
  103540. /**
  103541. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  103542. */
  103543. pickUtilitySceneFirst: boolean;
  103544. /**
  103545. * 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)
  103546. */
  103547. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  103548. /**
  103549. * 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)
  103550. */
  103551. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  103552. /**
  103553. * The scene that is rendered on top of the original scene
  103554. */
  103555. utilityLayerScene: Scene;
  103556. /**
  103557. * If the utility layer should automatically be rendered on top of existing scene
  103558. */
  103559. shouldRender: boolean;
  103560. /**
  103561. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  103562. */
  103563. onlyCheckPointerDownEvents: boolean;
  103564. /**
  103565. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  103566. */
  103567. processAllEvents: boolean;
  103568. /**
  103569. * Observable raised when the pointer move from the utility layer scene to the main scene
  103570. */
  103571. onPointerOutObservable: Observable<number>;
  103572. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  103573. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  103574. private _afterRenderObserver;
  103575. private _sceneDisposeObserver;
  103576. private _originalPointerObserver;
  103577. /**
  103578. * Instantiates a UtilityLayerRenderer
  103579. * @param originalScene the original scene that will be rendered on top of
  103580. * @param handleEvents boolean indicating if the utility layer should handle events
  103581. */
  103582. constructor(
  103583. /** the original scene that will be rendered on top of */
  103584. originalScene: Scene, handleEvents?: boolean);
  103585. private _notifyObservers;
  103586. /**
  103587. * Renders the utility layers scene on top of the original scene
  103588. */
  103589. render(): void;
  103590. /**
  103591. * Disposes of the renderer
  103592. */
  103593. dispose(): void;
  103594. private _updateCamera;
  103595. }
  103596. }
  103597. declare module BABYLON {
  103598. /**
  103599. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  103600. */
  103601. export class Gizmo implements IDisposable {
  103602. /** The utility layer the gizmo will be added to */
  103603. gizmoLayer: UtilityLayerRenderer;
  103604. /**
  103605. * The root mesh of the gizmo
  103606. */
  103607. _rootMesh: Mesh;
  103608. private _attachedMesh;
  103609. /**
  103610. * Ratio for the scale of the gizmo (Default: 1)
  103611. */
  103612. scaleRatio: number;
  103613. /**
  103614. * If a custom mesh has been set (Default: false)
  103615. */
  103616. protected _customMeshSet: boolean;
  103617. /**
  103618. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  103619. * * When set, interactions will be enabled
  103620. */
  103621. attachedMesh: Nullable<AbstractMesh>;
  103622. /**
  103623. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  103624. * @param mesh The mesh to replace the default mesh of the gizmo
  103625. */
  103626. setCustomMesh(mesh: Mesh): void;
  103627. /**
  103628. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  103629. */
  103630. updateGizmoRotationToMatchAttachedMesh: boolean;
  103631. /**
  103632. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  103633. */
  103634. updateGizmoPositionToMatchAttachedMesh: boolean;
  103635. /**
  103636. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  103637. */
  103638. protected _updateScale: boolean;
  103639. protected _interactionsEnabled: boolean;
  103640. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  103641. private _beforeRenderObserver;
  103642. private _tempVector;
  103643. /**
  103644. * Creates a gizmo
  103645. * @param gizmoLayer The utility layer the gizmo will be added to
  103646. */
  103647. constructor(
  103648. /** The utility layer the gizmo will be added to */
  103649. gizmoLayer?: UtilityLayerRenderer);
  103650. /**
  103651. * Updates the gizmo to match the attached mesh's position/rotation
  103652. */
  103653. protected _update(): void;
  103654. /**
  103655. * Disposes of the gizmo
  103656. */
  103657. dispose(): void;
  103658. }
  103659. }
  103660. declare module BABYLON {
  103661. /**
  103662. * Single plane drag gizmo
  103663. */
  103664. export class PlaneDragGizmo extends Gizmo {
  103665. /**
  103666. * Drag behavior responsible for the gizmos dragging interactions
  103667. */
  103668. dragBehavior: PointerDragBehavior;
  103669. private _pointerObserver;
  103670. /**
  103671. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  103672. */
  103673. snapDistance: number;
  103674. /**
  103675. * Event that fires each time the gizmo snaps to a new location.
  103676. * * snapDistance is the the change in distance
  103677. */
  103678. onSnapObservable: Observable<{
  103679. snapDistance: number;
  103680. }>;
  103681. private _plane;
  103682. private _coloredMaterial;
  103683. private _hoverMaterial;
  103684. private _isEnabled;
  103685. private _parent;
  103686. /** @hidden */
  103687. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  103688. /** @hidden */
  103689. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  103690. /**
  103691. * Creates a PlaneDragGizmo
  103692. * @param gizmoLayer The utility layer the gizmo will be added to
  103693. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  103694. * @param color The color of the gizmo
  103695. */
  103696. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  103697. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  103698. /**
  103699. * If the gizmo is enabled
  103700. */
  103701. isEnabled: boolean;
  103702. /**
  103703. * Disposes of the gizmo
  103704. */
  103705. dispose(): void;
  103706. }
  103707. }
  103708. declare module BABYLON {
  103709. /**
  103710. * Gizmo that enables dragging a mesh along 3 axis
  103711. */
  103712. export class PositionGizmo extends Gizmo {
  103713. /**
  103714. * Internal gizmo used for interactions on the x axis
  103715. */
  103716. xGizmo: AxisDragGizmo;
  103717. /**
  103718. * Internal gizmo used for interactions on the y axis
  103719. */
  103720. yGizmo: AxisDragGizmo;
  103721. /**
  103722. * Internal gizmo used for interactions on the z axis
  103723. */
  103724. zGizmo: AxisDragGizmo;
  103725. /**
  103726. * Internal gizmo used for interactions on the yz plane
  103727. */
  103728. xPlaneGizmo: PlaneDragGizmo;
  103729. /**
  103730. * Internal gizmo used for interactions on the xz plane
  103731. */
  103732. yPlaneGizmo: PlaneDragGizmo;
  103733. /**
  103734. * Internal gizmo used for interactions on the xy plane
  103735. */
  103736. zPlaneGizmo: PlaneDragGizmo;
  103737. /**
  103738. * private variables
  103739. */
  103740. private _meshAttached;
  103741. private _updateGizmoRotationToMatchAttachedMesh;
  103742. private _snapDistance;
  103743. private _scaleRatio;
  103744. /** Fires an event when any of it's sub gizmos are dragged */
  103745. onDragStartObservable: Observable<{}>;
  103746. /** Fires an event when any of it's sub gizmos are released from dragging */
  103747. onDragEndObservable: Observable<{}>;
  103748. /**
  103749. * If set to true, planar drag is enabled
  103750. */
  103751. private _planarGizmoEnabled;
  103752. attachedMesh: Nullable<AbstractMesh>;
  103753. /**
  103754. * Creates a PositionGizmo
  103755. * @param gizmoLayer The utility layer the gizmo will be added to
  103756. */
  103757. constructor(gizmoLayer?: UtilityLayerRenderer);
  103758. /**
  103759. * If the planar drag gizmo is enabled
  103760. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  103761. */
  103762. planarGizmoEnabled: boolean;
  103763. updateGizmoRotationToMatchAttachedMesh: boolean;
  103764. /**
  103765. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  103766. */
  103767. snapDistance: number;
  103768. /**
  103769. * Ratio for the scale of the gizmo (Default: 1)
  103770. */
  103771. scaleRatio: number;
  103772. /**
  103773. * Disposes of the gizmo
  103774. */
  103775. dispose(): void;
  103776. /**
  103777. * CustomMeshes are not supported by this gizmo
  103778. * @param mesh The mesh to replace the default mesh of the gizmo
  103779. */
  103780. setCustomMesh(mesh: Mesh): void;
  103781. }
  103782. }
  103783. declare module BABYLON {
  103784. /**
  103785. * Single axis drag gizmo
  103786. */
  103787. export class AxisDragGizmo extends Gizmo {
  103788. /**
  103789. * Drag behavior responsible for the gizmos dragging interactions
  103790. */
  103791. dragBehavior: PointerDragBehavior;
  103792. private _pointerObserver;
  103793. /**
  103794. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  103795. */
  103796. snapDistance: number;
  103797. /**
  103798. * Event that fires each time the gizmo snaps to a new location.
  103799. * * snapDistance is the the change in distance
  103800. */
  103801. onSnapObservable: Observable<{
  103802. snapDistance: number;
  103803. }>;
  103804. private _isEnabled;
  103805. private _parent;
  103806. private _arrow;
  103807. private _coloredMaterial;
  103808. private _hoverMaterial;
  103809. /** @hidden */
  103810. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  103811. /** @hidden */
  103812. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  103813. /**
  103814. * Creates an AxisDragGizmo
  103815. * @param gizmoLayer The utility layer the gizmo will be added to
  103816. * @param dragAxis The axis which the gizmo will be able to drag on
  103817. * @param color The color of the gizmo
  103818. */
  103819. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  103820. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  103821. /**
  103822. * If the gizmo is enabled
  103823. */
  103824. isEnabled: boolean;
  103825. /**
  103826. * Disposes of the gizmo
  103827. */
  103828. dispose(): void;
  103829. }
  103830. }
  103831. declare module BABYLON.Debug {
  103832. /**
  103833. * The Axes viewer will show 3 axes in a specific point in space
  103834. */
  103835. export class AxesViewer {
  103836. private _xAxis;
  103837. private _yAxis;
  103838. private _zAxis;
  103839. private _scaleLinesFactor;
  103840. private _instanced;
  103841. /**
  103842. * Gets the hosting scene
  103843. */
  103844. scene: Scene;
  103845. /**
  103846. * Gets or sets a number used to scale line length
  103847. */
  103848. scaleLines: number;
  103849. /** Gets the node hierarchy used to render x-axis */
  103850. readonly xAxis: TransformNode;
  103851. /** Gets the node hierarchy used to render y-axis */
  103852. readonly yAxis: TransformNode;
  103853. /** Gets the node hierarchy used to render z-axis */
  103854. readonly zAxis: TransformNode;
  103855. /**
  103856. * Creates a new AxesViewer
  103857. * @param scene defines the hosting scene
  103858. * @param scaleLines defines a number used to scale line length (1 by default)
  103859. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  103860. * @param xAxis defines the node hierarchy used to render the x-axis
  103861. * @param yAxis defines the node hierarchy used to render the y-axis
  103862. * @param zAxis defines the node hierarchy used to render the z-axis
  103863. */
  103864. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  103865. /**
  103866. * Force the viewer to update
  103867. * @param position defines the position of the viewer
  103868. * @param xaxis defines the x axis of the viewer
  103869. * @param yaxis defines the y axis of the viewer
  103870. * @param zaxis defines the z axis of the viewer
  103871. */
  103872. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  103873. /**
  103874. * Creates an instance of this axes viewer.
  103875. * @returns a new axes viewer with instanced meshes
  103876. */
  103877. createInstance(): AxesViewer;
  103878. /** Releases resources */
  103879. dispose(): void;
  103880. private static _SetRenderingGroupId;
  103881. }
  103882. }
  103883. declare module BABYLON.Debug {
  103884. /**
  103885. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  103886. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  103887. */
  103888. export class BoneAxesViewer extends AxesViewer {
  103889. /**
  103890. * Gets or sets the target mesh where to display the axes viewer
  103891. */
  103892. mesh: Nullable<Mesh>;
  103893. /**
  103894. * Gets or sets the target bone where to display the axes viewer
  103895. */
  103896. bone: Nullable<Bone>;
  103897. /** Gets current position */
  103898. pos: Vector3;
  103899. /** Gets direction of X axis */
  103900. xaxis: Vector3;
  103901. /** Gets direction of Y axis */
  103902. yaxis: Vector3;
  103903. /** Gets direction of Z axis */
  103904. zaxis: Vector3;
  103905. /**
  103906. * Creates a new BoneAxesViewer
  103907. * @param scene defines the hosting scene
  103908. * @param bone defines the target bone
  103909. * @param mesh defines the target mesh
  103910. * @param scaleLines defines a scaling factor for line length (1 by default)
  103911. */
  103912. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  103913. /**
  103914. * Force the viewer to update
  103915. */
  103916. update(): void;
  103917. /** Releases resources */
  103918. dispose(): void;
  103919. }
  103920. }
  103921. declare module BABYLON {
  103922. /**
  103923. * Interface used to define scene explorer extensibility option
  103924. */
  103925. export interface IExplorerExtensibilityOption {
  103926. /**
  103927. * Define the option label
  103928. */
  103929. label: string;
  103930. /**
  103931. * Defines the action to execute on click
  103932. */
  103933. action: (entity: any) => void;
  103934. }
  103935. /**
  103936. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  103937. */
  103938. export interface IExplorerExtensibilityGroup {
  103939. /**
  103940. * Defines a predicate to test if a given type mut be extended
  103941. */
  103942. predicate: (entity: any) => boolean;
  103943. /**
  103944. * Gets the list of options added to a type
  103945. */
  103946. entries: IExplorerExtensibilityOption[];
  103947. }
  103948. /**
  103949. * Interface used to define the options to use to create the Inspector
  103950. */
  103951. export interface IInspectorOptions {
  103952. /**
  103953. * Display in overlay mode (default: false)
  103954. */
  103955. overlay?: boolean;
  103956. /**
  103957. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  103958. */
  103959. globalRoot?: HTMLElement;
  103960. /**
  103961. * Display the Scene explorer
  103962. */
  103963. showExplorer?: boolean;
  103964. /**
  103965. * Display the property inspector
  103966. */
  103967. showInspector?: boolean;
  103968. /**
  103969. * Display in embed mode (both panes on the right)
  103970. */
  103971. embedMode?: boolean;
  103972. /**
  103973. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  103974. */
  103975. handleResize?: boolean;
  103976. /**
  103977. * Allow the panes to popup (default: true)
  103978. */
  103979. enablePopup?: boolean;
  103980. /**
  103981. * Allow the panes to be closed by users (default: true)
  103982. */
  103983. enableClose?: boolean;
  103984. /**
  103985. * Optional list of extensibility entries
  103986. */
  103987. explorerExtensibility?: IExplorerExtensibilityGroup[];
  103988. /**
  103989. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  103990. */
  103991. inspectorURL?: string;
  103992. }
  103993. interface Scene {
  103994. /**
  103995. * @hidden
  103996. * Backing field
  103997. */
  103998. _debugLayer: DebugLayer;
  103999. /**
  104000. * Gets the debug layer (aka Inspector) associated with the scene
  104001. * @see http://doc.babylonjs.com/features/playground_debuglayer
  104002. */
  104003. debugLayer: DebugLayer;
  104004. }
  104005. /**
  104006. * The debug layer (aka Inspector) is the go to tool in order to better understand
  104007. * what is happening in your scene
  104008. * @see http://doc.babylonjs.com/features/playground_debuglayer
  104009. */
  104010. export class DebugLayer {
  104011. /**
  104012. * Define the url to get the inspector script from.
  104013. * By default it uses the babylonjs CDN.
  104014. * @ignoreNaming
  104015. */
  104016. static InspectorURL: string;
  104017. private _scene;
  104018. private BJSINSPECTOR;
  104019. /**
  104020. * Observable triggered when a property is changed through the inspector.
  104021. */
  104022. onPropertyChangedObservable: Observable<{
  104023. object: any;
  104024. property: string;
  104025. value: any;
  104026. initialValue: any;
  104027. }>;
  104028. /**
  104029. * Instantiates a new debug layer.
  104030. * The debug layer (aka Inspector) is the go to tool in order to better understand
  104031. * what is happening in your scene
  104032. * @see http://doc.babylonjs.com/features/playground_debuglayer
  104033. * @param scene Defines the scene to inspect
  104034. */
  104035. constructor(scene: Scene);
  104036. /** Creates the inspector window. */
  104037. private _createInspector;
  104038. /**
  104039. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  104040. * @param entity defines the entity to select
  104041. * @param lineContainerTitle defines the specific block to highlight
  104042. */
  104043. select(entity: any, lineContainerTitle?: string): void;
  104044. /** Get the inspector from bundle or global */
  104045. private _getGlobalInspector;
  104046. /**
  104047. * Get if the inspector is visible or not.
  104048. * @returns true if visible otherwise, false
  104049. */
  104050. isVisible(): boolean;
  104051. /**
  104052. * Hide the inspector and close its window.
  104053. */
  104054. hide(): void;
  104055. /**
  104056. * Launch the debugLayer.
  104057. * @param config Define the configuration of the inspector
  104058. * @return a promise fulfilled when the debug layer is visible
  104059. */
  104060. show(config?: IInspectorOptions): Promise<DebugLayer>;
  104061. }
  104062. }
  104063. declare module BABYLON {
  104064. /**
  104065. * Class containing static functions to help procedurally build meshes
  104066. */
  104067. export class BoxBuilder {
  104068. /**
  104069. * Creates a box mesh
  104070. * * The parameter `size` sets the size (float) of each box side (default 1)
  104071. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  104072. * * 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)
  104073. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  104074. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104075. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104076. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104077. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  104078. * @param name defines the name of the mesh
  104079. * @param options defines the options used to create the mesh
  104080. * @param scene defines the hosting scene
  104081. * @returns the box mesh
  104082. */
  104083. static CreateBox(name: string, options: {
  104084. size?: number;
  104085. width?: number;
  104086. height?: number;
  104087. depth?: number;
  104088. faceUV?: Vector4[];
  104089. faceColors?: Color4[];
  104090. sideOrientation?: number;
  104091. frontUVs?: Vector4;
  104092. backUVs?: Vector4;
  104093. wrap?: boolean;
  104094. topBaseAt?: number;
  104095. bottomBaseAt?: number;
  104096. updatable?: boolean;
  104097. }, scene?: Nullable<Scene>): Mesh;
  104098. }
  104099. }
  104100. declare module BABYLON {
  104101. /**
  104102. * Class containing static functions to help procedurally build meshes
  104103. */
  104104. export class SphereBuilder {
  104105. /**
  104106. * Creates a sphere mesh
  104107. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  104108. * * 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`)
  104109. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  104110. * * 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
  104111. * * 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)
  104112. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104113. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104114. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104115. * @param name defines the name of the mesh
  104116. * @param options defines the options used to create the mesh
  104117. * @param scene defines the hosting scene
  104118. * @returns the sphere mesh
  104119. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  104120. */
  104121. static CreateSphere(name: string, options: {
  104122. segments?: number;
  104123. diameter?: number;
  104124. diameterX?: number;
  104125. diameterY?: number;
  104126. diameterZ?: number;
  104127. arc?: number;
  104128. slice?: number;
  104129. sideOrientation?: number;
  104130. frontUVs?: Vector4;
  104131. backUVs?: Vector4;
  104132. updatable?: boolean;
  104133. }, scene: any): Mesh;
  104134. }
  104135. }
  104136. declare module BABYLON.Debug {
  104137. /**
  104138. * Used to show the physics impostor around the specific mesh
  104139. */
  104140. export class PhysicsViewer {
  104141. /** @hidden */
  104142. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  104143. /** @hidden */
  104144. protected _meshes: Array<Nullable<AbstractMesh>>;
  104145. /** @hidden */
  104146. protected _scene: Nullable<Scene>;
  104147. /** @hidden */
  104148. protected _numMeshes: number;
  104149. /** @hidden */
  104150. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  104151. private _renderFunction;
  104152. private _utilityLayer;
  104153. private _debugBoxMesh;
  104154. private _debugSphereMesh;
  104155. private _debugCylinderMesh;
  104156. private _debugMaterial;
  104157. private _debugMeshMeshes;
  104158. /**
  104159. * Creates a new PhysicsViewer
  104160. * @param scene defines the hosting scene
  104161. */
  104162. constructor(scene: Scene);
  104163. /** @hidden */
  104164. protected _updateDebugMeshes(): void;
  104165. /**
  104166. * Renders a specified physic impostor
  104167. * @param impostor defines the impostor to render
  104168. * @param targetMesh defines the mesh represented by the impostor
  104169. * @returns the new debug mesh used to render the impostor
  104170. */
  104171. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  104172. /**
  104173. * Hides a specified physic impostor
  104174. * @param impostor defines the impostor to hide
  104175. */
  104176. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  104177. private _getDebugMaterial;
  104178. private _getDebugBoxMesh;
  104179. private _getDebugSphereMesh;
  104180. private _getDebugCylinderMesh;
  104181. private _getDebugMeshMesh;
  104182. private _getDebugMesh;
  104183. /** Releases all resources */
  104184. dispose(): void;
  104185. }
  104186. }
  104187. declare module BABYLON {
  104188. /**
  104189. * Class containing static functions to help procedurally build meshes
  104190. */
  104191. export class LinesBuilder {
  104192. /**
  104193. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  104194. * * 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
  104195. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  104196. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  104197. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  104198. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  104199. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  104200. * * 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
  104201. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  104202. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104203. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  104204. * @param name defines the name of the new line system
  104205. * @param options defines the options used to create the line system
  104206. * @param scene defines the hosting scene
  104207. * @returns a new line system mesh
  104208. */
  104209. static CreateLineSystem(name: string, options: {
  104210. lines: Vector3[][];
  104211. updatable?: boolean;
  104212. instance?: Nullable<LinesMesh>;
  104213. colors?: Nullable<Color4[][]>;
  104214. useVertexAlpha?: boolean;
  104215. }, scene: Nullable<Scene>): LinesMesh;
  104216. /**
  104217. * Creates a line mesh
  104218. * 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
  104219. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  104220. * * The parameter `points` is an array successive Vector3
  104221. * * 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
  104222. * * The optional parameter `colors` is an array of successive Color4, one per line point
  104223. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  104224. * * When updating an instance, remember that only point positions can change, not the number of points
  104225. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104226. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  104227. * @param name defines the name of the new line system
  104228. * @param options defines the options used to create the line system
  104229. * @param scene defines the hosting scene
  104230. * @returns a new line mesh
  104231. */
  104232. static CreateLines(name: string, options: {
  104233. points: Vector3[];
  104234. updatable?: boolean;
  104235. instance?: Nullable<LinesMesh>;
  104236. colors?: Color4[];
  104237. useVertexAlpha?: boolean;
  104238. }, scene?: Nullable<Scene>): LinesMesh;
  104239. /**
  104240. * Creates a dashed line mesh
  104241. * * 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
  104242. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  104243. * * The parameter `points` is an array successive Vector3
  104244. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  104245. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  104246. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  104247. * * 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
  104248. * * When updating an instance, remember that only point positions can change, not the number of points
  104249. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104250. * @param name defines the name of the mesh
  104251. * @param options defines the options used to create the mesh
  104252. * @param scene defines the hosting scene
  104253. * @returns the dashed line mesh
  104254. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  104255. */
  104256. static CreateDashedLines(name: string, options: {
  104257. points: Vector3[];
  104258. dashSize?: number;
  104259. gapSize?: number;
  104260. dashNb?: number;
  104261. updatable?: boolean;
  104262. instance?: LinesMesh;
  104263. }, scene?: Nullable<Scene>): LinesMesh;
  104264. }
  104265. }
  104266. declare module BABYLON {
  104267. /**
  104268. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  104269. * in order to better appreciate the issue one might have.
  104270. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  104271. */
  104272. export class RayHelper {
  104273. /**
  104274. * Defines the ray we are currently tryin to visualize.
  104275. */
  104276. ray: Nullable<Ray>;
  104277. private _renderPoints;
  104278. private _renderLine;
  104279. private _renderFunction;
  104280. private _scene;
  104281. private _updateToMeshFunction;
  104282. private _attachedToMesh;
  104283. private _meshSpaceDirection;
  104284. private _meshSpaceOrigin;
  104285. /**
  104286. * Helper function to create a colored helper in a scene in one line.
  104287. * @param ray Defines the ray we are currently tryin to visualize
  104288. * @param scene Defines the scene the ray is used in
  104289. * @param color Defines the color we want to see the ray in
  104290. * @returns The newly created ray helper.
  104291. */
  104292. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  104293. /**
  104294. * Instantiate a new ray helper.
  104295. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  104296. * in order to better appreciate the issue one might have.
  104297. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  104298. * @param ray Defines the ray we are currently tryin to visualize
  104299. */
  104300. constructor(ray: Ray);
  104301. /**
  104302. * Shows the ray we are willing to debug.
  104303. * @param scene Defines the scene the ray needs to be rendered in
  104304. * @param color Defines the color the ray needs to be rendered in
  104305. */
  104306. show(scene: Scene, color?: Color3): void;
  104307. /**
  104308. * Hides the ray we are debugging.
  104309. */
  104310. hide(): void;
  104311. private _render;
  104312. /**
  104313. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  104314. * @param mesh Defines the mesh we want the helper attached to
  104315. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  104316. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  104317. * @param length Defines the length of the ray
  104318. */
  104319. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  104320. /**
  104321. * Detach the ray helper from the mesh it has previously been attached to.
  104322. */
  104323. detachFromMesh(): void;
  104324. private _updateToMesh;
  104325. /**
  104326. * Dispose the helper and release its associated resources.
  104327. */
  104328. dispose(): void;
  104329. }
  104330. }
  104331. declare module BABYLON.Debug {
  104332. /**
  104333. * Class used to render a debug view of a given skeleton
  104334. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  104335. */
  104336. export class SkeletonViewer {
  104337. /** defines the skeleton to render */
  104338. skeleton: Skeleton;
  104339. /** defines the mesh attached to the skeleton */
  104340. mesh: AbstractMesh;
  104341. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  104342. autoUpdateBonesMatrices: boolean;
  104343. /** defines the rendering group id to use with the viewer */
  104344. renderingGroupId: number;
  104345. /** Gets or sets the color used to render the skeleton */
  104346. color: Color3;
  104347. private _scene;
  104348. private _debugLines;
  104349. private _debugMesh;
  104350. private _isEnabled;
  104351. private _renderFunction;
  104352. private _utilityLayer;
  104353. /**
  104354. * Returns the mesh used to render the bones
  104355. */
  104356. readonly debugMesh: Nullable<LinesMesh>;
  104357. /**
  104358. * Creates a new SkeletonViewer
  104359. * @param skeleton defines the skeleton to render
  104360. * @param mesh defines the mesh attached to the skeleton
  104361. * @param scene defines the hosting scene
  104362. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  104363. * @param renderingGroupId defines the rendering group id to use with the viewer
  104364. */
  104365. constructor(
  104366. /** defines the skeleton to render */
  104367. skeleton: Skeleton,
  104368. /** defines the mesh attached to the skeleton */
  104369. mesh: AbstractMesh, scene: Scene,
  104370. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  104371. autoUpdateBonesMatrices?: boolean,
  104372. /** defines the rendering group id to use with the viewer */
  104373. renderingGroupId?: number);
  104374. /** Gets or sets a boolean indicating if the viewer is enabled */
  104375. isEnabled: boolean;
  104376. private _getBonePosition;
  104377. private _getLinesForBonesWithLength;
  104378. private _getLinesForBonesNoLength;
  104379. /** Update the viewer to sync with current skeleton state */
  104380. update(): void;
  104381. /** Release associated resources */
  104382. dispose(): void;
  104383. }
  104384. }
  104385. declare module BABYLON {
  104386. /**
  104387. * Options to create the null engine
  104388. */
  104389. export class NullEngineOptions {
  104390. /**
  104391. * Render width (Default: 512)
  104392. */
  104393. renderWidth: number;
  104394. /**
  104395. * Render height (Default: 256)
  104396. */
  104397. renderHeight: number;
  104398. /**
  104399. * Texture size (Default: 512)
  104400. */
  104401. textureSize: number;
  104402. /**
  104403. * If delta time between frames should be constant
  104404. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  104405. */
  104406. deterministicLockstep: boolean;
  104407. /**
  104408. * Maximum about of steps between frames (Default: 4)
  104409. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  104410. */
  104411. lockstepMaxSteps: number;
  104412. }
  104413. /**
  104414. * The null engine class provides support for headless version of babylon.js.
  104415. * This can be used in server side scenario or for testing purposes
  104416. */
  104417. export class NullEngine extends Engine {
  104418. private _options;
  104419. /**
  104420. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  104421. */
  104422. isDeterministicLockStep(): boolean;
  104423. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  104424. getLockstepMaxSteps(): number;
  104425. /**
  104426. * Sets hardware scaling, used to save performance if needed
  104427. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  104428. */
  104429. getHardwareScalingLevel(): number;
  104430. constructor(options?: NullEngineOptions);
  104431. createVertexBuffer(vertices: FloatArray): DataBuffer;
  104432. createIndexBuffer(indices: IndicesArray): DataBuffer;
  104433. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  104434. getRenderWidth(useScreen?: boolean): number;
  104435. getRenderHeight(useScreen?: boolean): number;
  104436. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  104437. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  104438. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  104439. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  104440. bindSamplers(effect: Effect): void;
  104441. enableEffect(effect: Effect): void;
  104442. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  104443. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  104444. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  104445. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  104446. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  104447. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  104448. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  104449. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  104450. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  104451. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  104452. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  104453. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  104454. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  104455. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  104456. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  104457. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  104458. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  104459. setFloat(uniform: WebGLUniformLocation, value: number): void;
  104460. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  104461. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  104462. setBool(uniform: WebGLUniformLocation, bool: number): void;
  104463. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  104464. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  104465. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  104466. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  104467. bindBuffers(vertexBuffers: {
  104468. [key: string]: VertexBuffer;
  104469. }, indexBuffer: DataBuffer, effect: Effect): void;
  104470. wipeCaches(bruteForce?: boolean): void;
  104471. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  104472. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  104473. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  104474. /** @hidden */
  104475. _createTexture(): WebGLTexture;
  104476. /** @hidden */
  104477. _releaseTexture(texture: InternalTexture): void;
  104478. 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;
  104479. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  104480. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  104481. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  104482. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  104483. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  104484. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  104485. areAllEffectsReady(): boolean;
  104486. /**
  104487. * @hidden
  104488. * Get the current error code of the webGL context
  104489. * @returns the error code
  104490. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  104491. */
  104492. getError(): number;
  104493. /** @hidden */
  104494. _getUnpackAlignement(): number;
  104495. /** @hidden */
  104496. _unpackFlipY(value: boolean): void;
  104497. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  104498. /**
  104499. * Updates a dynamic vertex buffer.
  104500. * @param vertexBuffer the vertex buffer to update
  104501. * @param data the data used to update the vertex buffer
  104502. * @param byteOffset the byte offset of the data (optional)
  104503. * @param byteLength the byte length of the data (optional)
  104504. */
  104505. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  104506. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  104507. /** @hidden */
  104508. _bindTexture(channel: number, texture: InternalTexture): void;
  104509. /** @hidden */
  104510. _releaseBuffer(buffer: DataBuffer): boolean;
  104511. releaseEffects(): void;
  104512. displayLoadingUI(): void;
  104513. hideLoadingUI(): void;
  104514. /** @hidden */
  104515. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  104516. /** @hidden */
  104517. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  104518. /** @hidden */
  104519. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  104520. /** @hidden */
  104521. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  104522. }
  104523. }
  104524. declare module BABYLON {
  104525. /** @hidden */
  104526. export class _OcclusionDataStorage {
  104527. /** @hidden */
  104528. occlusionInternalRetryCounter: number;
  104529. /** @hidden */
  104530. isOcclusionQueryInProgress: boolean;
  104531. /** @hidden */
  104532. isOccluded: boolean;
  104533. /** @hidden */
  104534. occlusionRetryCount: number;
  104535. /** @hidden */
  104536. occlusionType: number;
  104537. /** @hidden */
  104538. occlusionQueryAlgorithmType: number;
  104539. }
  104540. interface Engine {
  104541. /**
  104542. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  104543. * @return the new query
  104544. */
  104545. createQuery(): WebGLQuery;
  104546. /**
  104547. * Delete and release a webGL query
  104548. * @param query defines the query to delete
  104549. * @return the current engine
  104550. */
  104551. deleteQuery(query: WebGLQuery): Engine;
  104552. /**
  104553. * Check if a given query has resolved and got its value
  104554. * @param query defines the query to check
  104555. * @returns true if the query got its value
  104556. */
  104557. isQueryResultAvailable(query: WebGLQuery): boolean;
  104558. /**
  104559. * Gets the value of a given query
  104560. * @param query defines the query to check
  104561. * @returns the value of the query
  104562. */
  104563. getQueryResult(query: WebGLQuery): number;
  104564. /**
  104565. * Initiates an occlusion query
  104566. * @param algorithmType defines the algorithm to use
  104567. * @param query defines the query to use
  104568. * @returns the current engine
  104569. * @see http://doc.babylonjs.com/features/occlusionquery
  104570. */
  104571. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  104572. /**
  104573. * Ends an occlusion query
  104574. * @see http://doc.babylonjs.com/features/occlusionquery
  104575. * @param algorithmType defines the algorithm to use
  104576. * @returns the current engine
  104577. */
  104578. endOcclusionQuery(algorithmType: number): Engine;
  104579. /**
  104580. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  104581. * Please note that only one query can be issued at a time
  104582. * @returns a time token used to track the time span
  104583. */
  104584. startTimeQuery(): Nullable<_TimeToken>;
  104585. /**
  104586. * Ends a time query
  104587. * @param token defines the token used to measure the time span
  104588. * @returns the time spent (in ns)
  104589. */
  104590. endTimeQuery(token: _TimeToken): int;
  104591. /** @hidden */
  104592. _currentNonTimestampToken: Nullable<_TimeToken>;
  104593. /** @hidden */
  104594. _createTimeQuery(): WebGLQuery;
  104595. /** @hidden */
  104596. _deleteTimeQuery(query: WebGLQuery): void;
  104597. /** @hidden */
  104598. _getGlAlgorithmType(algorithmType: number): number;
  104599. /** @hidden */
  104600. _getTimeQueryResult(query: WebGLQuery): any;
  104601. /** @hidden */
  104602. _getTimeQueryAvailability(query: WebGLQuery): any;
  104603. }
  104604. interface AbstractMesh {
  104605. /**
  104606. * Backing filed
  104607. * @hidden
  104608. */
  104609. __occlusionDataStorage: _OcclusionDataStorage;
  104610. /**
  104611. * Access property
  104612. * @hidden
  104613. */
  104614. _occlusionDataStorage: _OcclusionDataStorage;
  104615. /**
  104616. * 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.
  104617. * The default value is -1 which means don't break the query and wait till the result
  104618. * @see http://doc.babylonjs.com/features/occlusionquery
  104619. */
  104620. occlusionRetryCount: number;
  104621. /**
  104622. * 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:
  104623. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  104624. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  104625. * * 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.
  104626. * @see http://doc.babylonjs.com/features/occlusionquery
  104627. */
  104628. occlusionType: number;
  104629. /**
  104630. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  104631. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  104632. * * 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.
  104633. * @see http://doc.babylonjs.com/features/occlusionquery
  104634. */
  104635. occlusionQueryAlgorithmType: number;
  104636. /**
  104637. * 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
  104638. * @see http://doc.babylonjs.com/features/occlusionquery
  104639. */
  104640. isOccluded: boolean;
  104641. /**
  104642. * Flag to check the progress status of the query
  104643. * @see http://doc.babylonjs.com/features/occlusionquery
  104644. */
  104645. isOcclusionQueryInProgress: boolean;
  104646. }
  104647. }
  104648. declare module BABYLON {
  104649. /** @hidden */
  104650. export var _forceTransformFeedbackToBundle: boolean;
  104651. interface Engine {
  104652. /**
  104653. * Creates a webGL transform feedback object
  104654. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  104655. * @returns the webGL transform feedback object
  104656. */
  104657. createTransformFeedback(): WebGLTransformFeedback;
  104658. /**
  104659. * Delete a webGL transform feedback object
  104660. * @param value defines the webGL transform feedback object to delete
  104661. */
  104662. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  104663. /**
  104664. * Bind a webGL transform feedback object to the webgl context
  104665. * @param value defines the webGL transform feedback object to bind
  104666. */
  104667. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  104668. /**
  104669. * Begins a transform feedback operation
  104670. * @param usePoints defines if points or triangles must be used
  104671. */
  104672. beginTransformFeedback(usePoints: boolean): void;
  104673. /**
  104674. * Ends a transform feedback operation
  104675. */
  104676. endTransformFeedback(): void;
  104677. /**
  104678. * Specify the varyings to use with transform feedback
  104679. * @param program defines the associated webGL program
  104680. * @param value defines the list of strings representing the varying names
  104681. */
  104682. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  104683. /**
  104684. * Bind a webGL buffer for a transform feedback operation
  104685. * @param value defines the webGL buffer to bind
  104686. */
  104687. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  104688. }
  104689. }
  104690. declare module BABYLON {
  104691. /**
  104692. * Creation options of the multi render target texture.
  104693. */
  104694. export interface IMultiRenderTargetOptions {
  104695. /**
  104696. * Define if the texture needs to create mip maps after render.
  104697. */
  104698. generateMipMaps?: boolean;
  104699. /**
  104700. * Define the types of all the draw buffers we want to create
  104701. */
  104702. types?: number[];
  104703. /**
  104704. * Define the sampling modes of all the draw buffers we want to create
  104705. */
  104706. samplingModes?: number[];
  104707. /**
  104708. * Define if a depth buffer is required
  104709. */
  104710. generateDepthBuffer?: boolean;
  104711. /**
  104712. * Define if a stencil buffer is required
  104713. */
  104714. generateStencilBuffer?: boolean;
  104715. /**
  104716. * Define if a depth texture is required instead of a depth buffer
  104717. */
  104718. generateDepthTexture?: boolean;
  104719. /**
  104720. * Define the number of desired draw buffers
  104721. */
  104722. textureCount?: number;
  104723. /**
  104724. * Define if aspect ratio should be adapted to the texture or stay the scene one
  104725. */
  104726. doNotChangeAspectRatio?: boolean;
  104727. /**
  104728. * Define the default type of the buffers we are creating
  104729. */
  104730. defaultType?: number;
  104731. }
  104732. /**
  104733. * A multi render target, like a render target provides the ability to render to a texture.
  104734. * Unlike the render target, it can render to several draw buffers in one draw.
  104735. * This is specially interesting in deferred rendering or for any effects requiring more than
  104736. * just one color from a single pass.
  104737. */
  104738. export class MultiRenderTarget extends RenderTargetTexture {
  104739. private _internalTextures;
  104740. private _textures;
  104741. private _multiRenderTargetOptions;
  104742. /**
  104743. * Get if draw buffers are currently supported by the used hardware and browser.
  104744. */
  104745. readonly isSupported: boolean;
  104746. /**
  104747. * Get the list of textures generated by the multi render target.
  104748. */
  104749. readonly textures: Texture[];
  104750. /**
  104751. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  104752. */
  104753. readonly depthTexture: Texture;
  104754. /**
  104755. * Set the wrapping mode on U of all the textures we are rendering to.
  104756. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  104757. */
  104758. wrapU: number;
  104759. /**
  104760. * Set the wrapping mode on V of all the textures we are rendering to.
  104761. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  104762. */
  104763. wrapV: number;
  104764. /**
  104765. * Instantiate a new multi render target texture.
  104766. * A multi render target, like a render target provides the ability to render to a texture.
  104767. * Unlike the render target, it can render to several draw buffers in one draw.
  104768. * This is specially interesting in deferred rendering or for any effects requiring more than
  104769. * just one color from a single pass.
  104770. * @param name Define the name of the texture
  104771. * @param size Define the size of the buffers to render to
  104772. * @param count Define the number of target we are rendering into
  104773. * @param scene Define the scene the texture belongs to
  104774. * @param options Define the options used to create the multi render target
  104775. */
  104776. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  104777. /** @hidden */
  104778. _rebuild(): void;
  104779. private _createInternalTextures;
  104780. private _createTextures;
  104781. /**
  104782. * Define the number of samples used if MSAA is enabled.
  104783. */
  104784. samples: number;
  104785. /**
  104786. * Resize all the textures in the multi render target.
  104787. * Be carrefull as it will recreate all the data in the new texture.
  104788. * @param size Define the new size
  104789. */
  104790. resize(size: any): void;
  104791. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  104792. /**
  104793. * Dispose the render targets and their associated resources
  104794. */
  104795. dispose(): void;
  104796. /**
  104797. * Release all the underlying texture used as draw buffers.
  104798. */
  104799. releaseInternalTextures(): void;
  104800. }
  104801. }
  104802. declare module BABYLON {
  104803. interface Engine {
  104804. /**
  104805. * Unbind a list of render target textures from the webGL context
  104806. * This is used only when drawBuffer extension or webGL2 are active
  104807. * @param textures defines the render target textures to unbind
  104808. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  104809. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  104810. */
  104811. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  104812. /**
  104813. * Create a multi render target texture
  104814. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  104815. * @param size defines the size of the texture
  104816. * @param options defines the creation options
  104817. * @returns the cube texture as an InternalTexture
  104818. */
  104819. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  104820. /**
  104821. * Update the sample count for a given multiple render target texture
  104822. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  104823. * @param textures defines the textures to update
  104824. * @param samples defines the sample count to set
  104825. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  104826. */
  104827. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  104828. }
  104829. }
  104830. declare module BABYLON {
  104831. /**
  104832. * Gather the list of clipboard event types as constants.
  104833. */
  104834. export class ClipboardEventTypes {
  104835. /**
  104836. * The clipboard event is fired when a copy command is active (pressed).
  104837. */
  104838. static readonly COPY: number;
  104839. /**
  104840. * The clipboard event is fired when a cut command is active (pressed).
  104841. */
  104842. static readonly CUT: number;
  104843. /**
  104844. * The clipboard event is fired when a paste command is active (pressed).
  104845. */
  104846. static readonly PASTE: number;
  104847. }
  104848. /**
  104849. * This class is used to store clipboard related info for the onClipboardObservable event.
  104850. */
  104851. export class ClipboardInfo {
  104852. /**
  104853. * Defines the type of event (BABYLON.ClipboardEventTypes)
  104854. */
  104855. type: number;
  104856. /**
  104857. * Defines the related dom event
  104858. */
  104859. event: ClipboardEvent;
  104860. /**
  104861. *Creates an instance of ClipboardInfo.
  104862. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  104863. * @param event Defines the related dom event
  104864. */
  104865. constructor(
  104866. /**
  104867. * Defines the type of event (BABYLON.ClipboardEventTypes)
  104868. */
  104869. type: number,
  104870. /**
  104871. * Defines the related dom event
  104872. */
  104873. event: ClipboardEvent);
  104874. /**
  104875. * Get the clipboard event's type from the keycode.
  104876. * @param keyCode Defines the keyCode for the current keyboard event.
  104877. * @return {number}
  104878. */
  104879. static GetTypeFromCharacter(keyCode: number): number;
  104880. }
  104881. }
  104882. declare module BABYLON {
  104883. /**
  104884. * Class used to represent data loading progression
  104885. */
  104886. export class SceneLoaderProgressEvent {
  104887. /** defines if data length to load can be evaluated */
  104888. readonly lengthComputable: boolean;
  104889. /** defines the loaded data length */
  104890. readonly loaded: number;
  104891. /** defines the data length to load */
  104892. readonly total: number;
  104893. /**
  104894. * Create a new progress event
  104895. * @param lengthComputable defines if data length to load can be evaluated
  104896. * @param loaded defines the loaded data length
  104897. * @param total defines the data length to load
  104898. */
  104899. constructor(
  104900. /** defines if data length to load can be evaluated */
  104901. lengthComputable: boolean,
  104902. /** defines the loaded data length */
  104903. loaded: number,
  104904. /** defines the data length to load */
  104905. total: number);
  104906. /**
  104907. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  104908. * @param event defines the source event
  104909. * @returns a new SceneLoaderProgressEvent
  104910. */
  104911. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  104912. }
  104913. /**
  104914. * Interface used by SceneLoader plugins to define supported file extensions
  104915. */
  104916. export interface ISceneLoaderPluginExtensions {
  104917. /**
  104918. * Defines the list of supported extensions
  104919. */
  104920. [extension: string]: {
  104921. isBinary: boolean;
  104922. };
  104923. }
  104924. /**
  104925. * Interface used by SceneLoader plugin factory
  104926. */
  104927. export interface ISceneLoaderPluginFactory {
  104928. /**
  104929. * Defines the name of the factory
  104930. */
  104931. name: string;
  104932. /**
  104933. * Function called to create a new plugin
  104934. * @return the new plugin
  104935. */
  104936. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  104937. /**
  104938. * Boolean indicating if the plugin can direct load specific data
  104939. */
  104940. canDirectLoad?: (data: string) => boolean;
  104941. }
  104942. /**
  104943. * Interface used to define a SceneLoader plugin
  104944. */
  104945. export interface ISceneLoaderPlugin {
  104946. /**
  104947. * The friendly name of this plugin.
  104948. */
  104949. name: string;
  104950. /**
  104951. * The file extensions supported by this plugin.
  104952. */
  104953. extensions: string | ISceneLoaderPluginExtensions;
  104954. /**
  104955. * Import meshes into a scene.
  104956. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  104957. * @param scene The scene to import into
  104958. * @param data The data to import
  104959. * @param rootUrl The root url for scene and resources
  104960. * @param meshes The meshes array to import into
  104961. * @param particleSystems The particle systems array to import into
  104962. * @param skeletons The skeletons array to import into
  104963. * @param onError The callback when import fails
  104964. * @returns True if successful or false otherwise
  104965. */
  104966. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  104967. /**
  104968. * Load into a scene.
  104969. * @param scene The scene to load into
  104970. * @param data The data to import
  104971. * @param rootUrl The root url for scene and resources
  104972. * @param onError The callback when import fails
  104973. * @returns true if successful or false otherwise
  104974. */
  104975. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  104976. /**
  104977. * The callback that returns true if the data can be directly loaded.
  104978. */
  104979. canDirectLoad?: (data: string) => boolean;
  104980. /**
  104981. * The callback that allows custom handling of the root url based on the response url.
  104982. */
  104983. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  104984. /**
  104985. * Load into an asset container.
  104986. * @param scene The scene to load into
  104987. * @param data The data to import
  104988. * @param rootUrl The root url for scene and resources
  104989. * @param onError The callback when import fails
  104990. * @returns The loaded asset container
  104991. */
  104992. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  104993. }
  104994. /**
  104995. * Interface used to define an async SceneLoader plugin
  104996. */
  104997. export interface ISceneLoaderPluginAsync {
  104998. /**
  104999. * The friendly name of this plugin.
  105000. */
  105001. name: string;
  105002. /**
  105003. * The file extensions supported by this plugin.
  105004. */
  105005. extensions: string | ISceneLoaderPluginExtensions;
  105006. /**
  105007. * Import meshes into a scene.
  105008. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  105009. * @param scene The scene to import into
  105010. * @param data The data to import
  105011. * @param rootUrl The root url for scene and resources
  105012. * @param onProgress The callback when the load progresses
  105013. * @param fileName Defines the name of the file to load
  105014. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  105015. */
  105016. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  105017. meshes: AbstractMesh[];
  105018. particleSystems: IParticleSystem[];
  105019. skeletons: Skeleton[];
  105020. animationGroups: AnimationGroup[];
  105021. }>;
  105022. /**
  105023. * Load into a scene.
  105024. * @param scene The scene to load into
  105025. * @param data The data to import
  105026. * @param rootUrl The root url for scene and resources
  105027. * @param onProgress The callback when the load progresses
  105028. * @param fileName Defines the name of the file to load
  105029. * @returns Nothing
  105030. */
  105031. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  105032. /**
  105033. * The callback that returns true if the data can be directly loaded.
  105034. */
  105035. canDirectLoad?: (data: string) => boolean;
  105036. /**
  105037. * The callback that allows custom handling of the root url based on the response url.
  105038. */
  105039. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  105040. /**
  105041. * Load into an asset container.
  105042. * @param scene The scene to load into
  105043. * @param data The data to import
  105044. * @param rootUrl The root url for scene and resources
  105045. * @param onProgress The callback when the load progresses
  105046. * @param fileName Defines the name of the file to load
  105047. * @returns The loaded asset container
  105048. */
  105049. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  105050. }
  105051. /**
  105052. * Class used to load scene from various file formats using registered plugins
  105053. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  105054. */
  105055. export class SceneLoader {
  105056. /**
  105057. * No logging while loading
  105058. */
  105059. static readonly NO_LOGGING: number;
  105060. /**
  105061. * Minimal logging while loading
  105062. */
  105063. static readonly MINIMAL_LOGGING: number;
  105064. /**
  105065. * Summary logging while loading
  105066. */
  105067. static readonly SUMMARY_LOGGING: number;
  105068. /**
  105069. * Detailled logging while loading
  105070. */
  105071. static readonly DETAILED_LOGGING: number;
  105072. /**
  105073. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  105074. */
  105075. static ForceFullSceneLoadingForIncremental: boolean;
  105076. /**
  105077. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  105078. */
  105079. static ShowLoadingScreen: boolean;
  105080. /**
  105081. * Defines the current logging level (while loading the scene)
  105082. * @ignorenaming
  105083. */
  105084. static loggingLevel: number;
  105085. /**
  105086. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  105087. */
  105088. static CleanBoneMatrixWeights: boolean;
  105089. /**
  105090. * Event raised when a plugin is used to load a scene
  105091. */
  105092. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  105093. private static _registeredPlugins;
  105094. private static _getDefaultPlugin;
  105095. private static _getPluginForExtension;
  105096. private static _getPluginForDirectLoad;
  105097. private static _getPluginForFilename;
  105098. private static _getDirectLoad;
  105099. private static _loadData;
  105100. private static _getFileInfo;
  105101. /**
  105102. * Gets a plugin that can load the given extension
  105103. * @param extension defines the extension to load
  105104. * @returns a plugin or null if none works
  105105. */
  105106. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  105107. /**
  105108. * Gets a boolean indicating that the given extension can be loaded
  105109. * @param extension defines the extension to load
  105110. * @returns true if the extension is supported
  105111. */
  105112. static IsPluginForExtensionAvailable(extension: string): boolean;
  105113. /**
  105114. * Adds a new plugin to the list of registered plugins
  105115. * @param plugin defines the plugin to add
  105116. */
  105117. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  105118. /**
  105119. * Import meshes into a scene
  105120. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  105121. * @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)
  105122. * @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)
  105123. * @param scene the instance of BABYLON.Scene to append to
  105124. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  105125. * @param onProgress a callback with a progress event for each file being loaded
  105126. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  105127. * @param pluginExtension the extension used to determine the plugin
  105128. * @returns The loaded plugin
  105129. */
  105130. 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>;
  105131. /**
  105132. * Import meshes into a scene
  105133. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  105134. * @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)
  105135. * @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)
  105136. * @param scene the instance of BABYLON.Scene to append to
  105137. * @param onProgress a callback with a progress event for each file being loaded
  105138. * @param pluginExtension the extension used to determine the plugin
  105139. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  105140. */
  105141. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  105142. meshes: AbstractMesh[];
  105143. particleSystems: IParticleSystem[];
  105144. skeletons: Skeleton[];
  105145. animationGroups: AnimationGroup[];
  105146. }>;
  105147. /**
  105148. * Load a scene
  105149. * @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)
  105150. * @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)
  105151. * @param engine is the instance of BABYLON.Engine to use to create the scene
  105152. * @param onSuccess a callback with the scene when import succeeds
  105153. * @param onProgress a callback with a progress event for each file being loaded
  105154. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  105155. * @param pluginExtension the extension used to determine the plugin
  105156. * @returns The loaded plugin
  105157. */
  105158. 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>;
  105159. /**
  105160. * Load a scene
  105161. * @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)
  105162. * @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)
  105163. * @param engine is the instance of BABYLON.Engine to use to create the scene
  105164. * @param onProgress a callback with a progress event for each file being loaded
  105165. * @param pluginExtension the extension used to determine the plugin
  105166. * @returns The loaded scene
  105167. */
  105168. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  105169. /**
  105170. * Append a scene
  105171. * @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)
  105172. * @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)
  105173. * @param scene is the instance of BABYLON.Scene to append to
  105174. * @param onSuccess a callback with the scene when import succeeds
  105175. * @param onProgress a callback with a progress event for each file being loaded
  105176. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  105177. * @param pluginExtension the extension used to determine the plugin
  105178. * @returns The loaded plugin
  105179. */
  105180. 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>;
  105181. /**
  105182. * Append a scene
  105183. * @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)
  105184. * @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)
  105185. * @param scene is the instance of BABYLON.Scene to append to
  105186. * @param onProgress a callback with a progress event for each file being loaded
  105187. * @param pluginExtension the extension used to determine the plugin
  105188. * @returns The given scene
  105189. */
  105190. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  105191. /**
  105192. * Load a scene into an asset container
  105193. * @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)
  105194. * @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)
  105195. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  105196. * @param onSuccess a callback with the scene when import succeeds
  105197. * @param onProgress a callback with a progress event for each file being loaded
  105198. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  105199. * @param pluginExtension the extension used to determine the plugin
  105200. * @returns The loaded plugin
  105201. */
  105202. 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>;
  105203. /**
  105204. * Load a scene into an asset container
  105205. * @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)
  105206. * @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)
  105207. * @param scene is the instance of Scene to append to
  105208. * @param onProgress a callback with a progress event for each file being loaded
  105209. * @param pluginExtension the extension used to determine the plugin
  105210. * @returns The loaded asset container
  105211. */
  105212. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  105213. }
  105214. }
  105215. declare module BABYLON {
  105216. /**
  105217. * Google Daydream controller
  105218. */
  105219. export class DaydreamController extends WebVRController {
  105220. /**
  105221. * Base Url for the controller model.
  105222. */
  105223. static MODEL_BASE_URL: string;
  105224. /**
  105225. * File name for the controller model.
  105226. */
  105227. static MODEL_FILENAME: string;
  105228. /**
  105229. * Gamepad Id prefix used to identify Daydream Controller.
  105230. */
  105231. static readonly GAMEPAD_ID_PREFIX: string;
  105232. /**
  105233. * Creates a new DaydreamController from a gamepad
  105234. * @param vrGamepad the gamepad that the controller should be created from
  105235. */
  105236. constructor(vrGamepad: any);
  105237. /**
  105238. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105239. * @param scene scene in which to add meshes
  105240. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105241. */
  105242. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105243. /**
  105244. * Called once for each button that changed state since the last frame
  105245. * @param buttonIdx Which button index changed
  105246. * @param state New state of the button
  105247. * @param changes Which properties on the state changed since last frame
  105248. */
  105249. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105250. }
  105251. }
  105252. declare module BABYLON {
  105253. /**
  105254. * Gear VR Controller
  105255. */
  105256. export class GearVRController extends WebVRController {
  105257. /**
  105258. * Base Url for the controller model.
  105259. */
  105260. static MODEL_BASE_URL: string;
  105261. /**
  105262. * File name for the controller model.
  105263. */
  105264. static MODEL_FILENAME: string;
  105265. /**
  105266. * Gamepad Id prefix used to identify this controller.
  105267. */
  105268. static readonly GAMEPAD_ID_PREFIX: string;
  105269. private readonly _buttonIndexToObservableNameMap;
  105270. /**
  105271. * Creates a new GearVRController from a gamepad
  105272. * @param vrGamepad the gamepad that the controller should be created from
  105273. */
  105274. constructor(vrGamepad: any);
  105275. /**
  105276. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105277. * @param scene scene in which to add meshes
  105278. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105279. */
  105280. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105281. /**
  105282. * Called once for each button that changed state since the last frame
  105283. * @param buttonIdx Which button index changed
  105284. * @param state New state of the button
  105285. * @param changes Which properties on the state changed since last frame
  105286. */
  105287. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105288. }
  105289. }
  105290. declare module BABYLON {
  105291. /**
  105292. * Generic Controller
  105293. */
  105294. export class GenericController extends WebVRController {
  105295. /**
  105296. * Base Url for the controller model.
  105297. */
  105298. static readonly MODEL_BASE_URL: string;
  105299. /**
  105300. * File name for the controller model.
  105301. */
  105302. static readonly MODEL_FILENAME: string;
  105303. /**
  105304. * Creates a new GenericController from a gamepad
  105305. * @param vrGamepad the gamepad that the controller should be created from
  105306. */
  105307. constructor(vrGamepad: any);
  105308. /**
  105309. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105310. * @param scene scene in which to add meshes
  105311. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105312. */
  105313. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105314. /**
  105315. * Called once for each button that changed state since the last frame
  105316. * @param buttonIdx Which button index changed
  105317. * @param state New state of the button
  105318. * @param changes Which properties on the state changed since last frame
  105319. */
  105320. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105321. }
  105322. }
  105323. declare module BABYLON {
  105324. /**
  105325. * Oculus Touch Controller
  105326. */
  105327. export class OculusTouchController extends WebVRController {
  105328. /**
  105329. * Base Url for the controller model.
  105330. */
  105331. static MODEL_BASE_URL: string;
  105332. /**
  105333. * File name for the left controller model.
  105334. */
  105335. static MODEL_LEFT_FILENAME: string;
  105336. /**
  105337. * File name for the right controller model.
  105338. */
  105339. static MODEL_RIGHT_FILENAME: string;
  105340. /**
  105341. * Fired when the secondary trigger on this controller is modified
  105342. */
  105343. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  105344. /**
  105345. * Fired when the thumb rest on this controller is modified
  105346. */
  105347. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  105348. /**
  105349. * Creates a new OculusTouchController from a gamepad
  105350. * @param vrGamepad the gamepad that the controller should be created from
  105351. */
  105352. constructor(vrGamepad: any);
  105353. /**
  105354. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105355. * @param scene scene in which to add meshes
  105356. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105357. */
  105358. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105359. /**
  105360. * Fired when the A button on this controller is modified
  105361. */
  105362. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105363. /**
  105364. * Fired when the B button on this controller is modified
  105365. */
  105366. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105367. /**
  105368. * Fired when the X button on this controller is modified
  105369. */
  105370. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105371. /**
  105372. * Fired when the Y button on this controller is modified
  105373. */
  105374. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105375. /**
  105376. * Called once for each button that changed state since the last frame
  105377. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  105378. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  105379. * 2) secondary trigger (same)
  105380. * 3) A (right) X (left), touch, pressed = value
  105381. * 4) B / Y
  105382. * 5) thumb rest
  105383. * @param buttonIdx Which button index changed
  105384. * @param state New state of the button
  105385. * @param changes Which properties on the state changed since last frame
  105386. */
  105387. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105388. }
  105389. }
  105390. declare module BABYLON {
  105391. /**
  105392. * Vive Controller
  105393. */
  105394. export class ViveController extends WebVRController {
  105395. /**
  105396. * Base Url for the controller model.
  105397. */
  105398. static MODEL_BASE_URL: string;
  105399. /**
  105400. * File name for the controller model.
  105401. */
  105402. static MODEL_FILENAME: string;
  105403. /**
  105404. * Creates a new ViveController from a gamepad
  105405. * @param vrGamepad the gamepad that the controller should be created from
  105406. */
  105407. constructor(vrGamepad: any);
  105408. /**
  105409. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105410. * @param scene scene in which to add meshes
  105411. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105412. */
  105413. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105414. /**
  105415. * Fired when the left button on this controller is modified
  105416. */
  105417. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105418. /**
  105419. * Fired when the right button on this controller is modified
  105420. */
  105421. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105422. /**
  105423. * Fired when the menu button on this controller is modified
  105424. */
  105425. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105426. /**
  105427. * Called once for each button that changed state since the last frame
  105428. * Vive mapping:
  105429. * 0: touchpad
  105430. * 1: trigger
  105431. * 2: left AND right buttons
  105432. * 3: menu button
  105433. * @param buttonIdx Which button index changed
  105434. * @param state New state of the button
  105435. * @param changes Which properties on the state changed since last frame
  105436. */
  105437. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105438. }
  105439. }
  105440. declare module BABYLON {
  105441. /**
  105442. * Defines the WindowsMotionController object that the state of the windows motion controller
  105443. */
  105444. export class WindowsMotionController extends WebVRController {
  105445. /**
  105446. * The base url used to load the left and right controller models
  105447. */
  105448. static MODEL_BASE_URL: string;
  105449. /**
  105450. * The name of the left controller model file
  105451. */
  105452. static MODEL_LEFT_FILENAME: string;
  105453. /**
  105454. * The name of the right controller model file
  105455. */
  105456. static MODEL_RIGHT_FILENAME: string;
  105457. /**
  105458. * The controller name prefix for this controller type
  105459. */
  105460. static readonly GAMEPAD_ID_PREFIX: string;
  105461. /**
  105462. * The controller id pattern for this controller type
  105463. */
  105464. private static readonly GAMEPAD_ID_PATTERN;
  105465. private _loadedMeshInfo;
  105466. private readonly _mapping;
  105467. /**
  105468. * Fired when the trackpad on this controller is clicked
  105469. */
  105470. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  105471. /**
  105472. * Fired when the trackpad on this controller is modified
  105473. */
  105474. onTrackpadValuesChangedObservable: Observable<StickValues>;
  105475. /**
  105476. * The current x and y values of this controller's trackpad
  105477. */
  105478. trackpad: StickValues;
  105479. /**
  105480. * Creates a new WindowsMotionController from a gamepad
  105481. * @param vrGamepad the gamepad that the controller should be created from
  105482. */
  105483. constructor(vrGamepad: any);
  105484. /**
  105485. * Fired when the trigger on this controller is modified
  105486. */
  105487. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105488. /**
  105489. * Fired when the menu button on this controller is modified
  105490. */
  105491. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105492. /**
  105493. * Fired when the grip button on this controller is modified
  105494. */
  105495. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105496. /**
  105497. * Fired when the thumbstick button on this controller is modified
  105498. */
  105499. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105500. /**
  105501. * Fired when the touchpad button on this controller is modified
  105502. */
  105503. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105504. /**
  105505. * Fired when the touchpad values on this controller are modified
  105506. */
  105507. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  105508. private _updateTrackpad;
  105509. /**
  105510. * Called once per frame by the engine.
  105511. */
  105512. update(): void;
  105513. /**
  105514. * Called once for each button that changed state since the last frame
  105515. * @param buttonIdx Which button index changed
  105516. * @param state New state of the button
  105517. * @param changes Which properties on the state changed since last frame
  105518. */
  105519. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105520. /**
  105521. * Moves the buttons on the controller mesh based on their current state
  105522. * @param buttonName the name of the button to move
  105523. * @param buttonValue the value of the button which determines the buttons new position
  105524. */
  105525. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  105526. /**
  105527. * Moves the axis on the controller mesh based on its current state
  105528. * @param axis the index of the axis
  105529. * @param axisValue the value of the axis which determines the meshes new position
  105530. * @hidden
  105531. */
  105532. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  105533. /**
  105534. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105535. * @param scene scene in which to add meshes
  105536. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105537. */
  105538. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  105539. /**
  105540. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  105541. * can be transformed by button presses and axes values, based on this._mapping.
  105542. *
  105543. * @param scene scene in which the meshes exist
  105544. * @param meshes list of meshes that make up the controller model to process
  105545. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  105546. */
  105547. private processModel;
  105548. private createMeshInfo;
  105549. /**
  105550. * Gets the ray of the controller in the direction the controller is pointing
  105551. * @param length the length the resulting ray should be
  105552. * @returns a ray in the direction the controller is pointing
  105553. */
  105554. getForwardRay(length?: number): Ray;
  105555. /**
  105556. * Disposes of the controller
  105557. */
  105558. dispose(): void;
  105559. }
  105560. }
  105561. declare module BABYLON {
  105562. /**
  105563. * Class containing static functions to help procedurally build meshes
  105564. */
  105565. export class PolyhedronBuilder {
  105566. /**
  105567. * Creates a polyhedron mesh
  105568. * * 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
  105569. * * The parameter `size` (positive float, default 1) sets the polygon size
  105570. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  105571. * * 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`
  105572. * * 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
  105573. * * 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)`)
  105574. * * 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
  105575. * * 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
  105576. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105577. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105578. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105579. * @param name defines the name of the mesh
  105580. * @param options defines the options used to create the mesh
  105581. * @param scene defines the hosting scene
  105582. * @returns the polyhedron mesh
  105583. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  105584. */
  105585. static CreatePolyhedron(name: string, options: {
  105586. type?: number;
  105587. size?: number;
  105588. sizeX?: number;
  105589. sizeY?: number;
  105590. sizeZ?: number;
  105591. custom?: any;
  105592. faceUV?: Vector4[];
  105593. faceColors?: Color4[];
  105594. flat?: boolean;
  105595. updatable?: boolean;
  105596. sideOrientation?: number;
  105597. frontUVs?: Vector4;
  105598. backUVs?: Vector4;
  105599. }, scene?: Nullable<Scene>): Mesh;
  105600. }
  105601. }
  105602. declare module BABYLON {
  105603. /**
  105604. * Gizmo that enables scaling a mesh along 3 axis
  105605. */
  105606. export class ScaleGizmo extends Gizmo {
  105607. /**
  105608. * Internal gizmo used for interactions on the x axis
  105609. */
  105610. xGizmo: AxisScaleGizmo;
  105611. /**
  105612. * Internal gizmo used for interactions on the y axis
  105613. */
  105614. yGizmo: AxisScaleGizmo;
  105615. /**
  105616. * Internal gizmo used for interactions on the z axis
  105617. */
  105618. zGizmo: AxisScaleGizmo;
  105619. /**
  105620. * Internal gizmo used to scale all axis equally
  105621. */
  105622. uniformScaleGizmo: AxisScaleGizmo;
  105623. private _meshAttached;
  105624. private _updateGizmoRotationToMatchAttachedMesh;
  105625. private _snapDistance;
  105626. private _scaleRatio;
  105627. private _uniformScalingMesh;
  105628. private _octahedron;
  105629. /** Fires an event when any of it's sub gizmos are dragged */
  105630. onDragStartObservable: Observable<{}>;
  105631. /** Fires an event when any of it's sub gizmos are released from dragging */
  105632. onDragEndObservable: Observable<{}>;
  105633. attachedMesh: Nullable<AbstractMesh>;
  105634. /**
  105635. * Creates a ScaleGizmo
  105636. * @param gizmoLayer The utility layer the gizmo will be added to
  105637. */
  105638. constructor(gizmoLayer?: UtilityLayerRenderer);
  105639. updateGizmoRotationToMatchAttachedMesh: boolean;
  105640. /**
  105641. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  105642. */
  105643. snapDistance: number;
  105644. /**
  105645. * Ratio for the scale of the gizmo (Default: 1)
  105646. */
  105647. scaleRatio: number;
  105648. /**
  105649. * Disposes of the gizmo
  105650. */
  105651. dispose(): void;
  105652. }
  105653. }
  105654. declare module BABYLON {
  105655. /**
  105656. * Single axis scale gizmo
  105657. */
  105658. export class AxisScaleGizmo extends Gizmo {
  105659. /**
  105660. * Drag behavior responsible for the gizmos dragging interactions
  105661. */
  105662. dragBehavior: PointerDragBehavior;
  105663. private _pointerObserver;
  105664. /**
  105665. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  105666. */
  105667. snapDistance: number;
  105668. /**
  105669. * Event that fires each time the gizmo snaps to a new location.
  105670. * * snapDistance is the the change in distance
  105671. */
  105672. onSnapObservable: Observable<{
  105673. snapDistance: number;
  105674. }>;
  105675. /**
  105676. * If the scaling operation should be done on all axis (default: false)
  105677. */
  105678. uniformScaling: boolean;
  105679. private _isEnabled;
  105680. private _parent;
  105681. private _arrow;
  105682. private _coloredMaterial;
  105683. private _hoverMaterial;
  105684. /**
  105685. * Creates an AxisScaleGizmo
  105686. * @param gizmoLayer The utility layer the gizmo will be added to
  105687. * @param dragAxis The axis which the gizmo will be able to scale on
  105688. * @param color The color of the gizmo
  105689. */
  105690. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  105691. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  105692. /**
  105693. * If the gizmo is enabled
  105694. */
  105695. isEnabled: boolean;
  105696. /**
  105697. * Disposes of the gizmo
  105698. */
  105699. dispose(): void;
  105700. /**
  105701. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  105702. * @param mesh The mesh to replace the default mesh of the gizmo
  105703. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  105704. */
  105705. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  105706. }
  105707. }
  105708. declare module BABYLON {
  105709. /**
  105710. * Bounding box gizmo
  105711. */
  105712. export class BoundingBoxGizmo extends Gizmo {
  105713. private _lineBoundingBox;
  105714. private _rotateSpheresParent;
  105715. private _scaleBoxesParent;
  105716. private _boundingDimensions;
  105717. private _renderObserver;
  105718. private _pointerObserver;
  105719. private _scaleDragSpeed;
  105720. private _tmpQuaternion;
  105721. private _tmpVector;
  105722. private _tmpRotationMatrix;
  105723. /**
  105724. * 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)
  105725. */
  105726. ignoreChildren: boolean;
  105727. /**
  105728. * 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)
  105729. */
  105730. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  105731. /**
  105732. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  105733. */
  105734. rotationSphereSize: number;
  105735. /**
  105736. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  105737. */
  105738. scaleBoxSize: number;
  105739. /**
  105740. * 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)
  105741. */
  105742. fixedDragMeshScreenSize: boolean;
  105743. /**
  105744. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  105745. */
  105746. fixedDragMeshScreenSizeDistanceFactor: number;
  105747. /**
  105748. * Fired when a rotation sphere or scale box is dragged
  105749. */
  105750. onDragStartObservable: Observable<{}>;
  105751. /**
  105752. * Fired when a scale box is dragged
  105753. */
  105754. onScaleBoxDragObservable: Observable<{}>;
  105755. /**
  105756. * Fired when a scale box drag is ended
  105757. */
  105758. onScaleBoxDragEndObservable: Observable<{}>;
  105759. /**
  105760. * Fired when a rotation sphere is dragged
  105761. */
  105762. onRotationSphereDragObservable: Observable<{}>;
  105763. /**
  105764. * Fired when a rotation sphere drag is ended
  105765. */
  105766. onRotationSphereDragEndObservable: Observable<{}>;
  105767. /**
  105768. * 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)
  105769. */
  105770. scalePivot: Nullable<Vector3>;
  105771. /**
  105772. * Mesh used as a pivot to rotate the attached mesh
  105773. */
  105774. private _anchorMesh;
  105775. private _existingMeshScale;
  105776. private _dragMesh;
  105777. private pointerDragBehavior;
  105778. private coloredMaterial;
  105779. private hoverColoredMaterial;
  105780. /**
  105781. * Sets the color of the bounding box gizmo
  105782. * @param color the color to set
  105783. */
  105784. setColor(color: Color3): void;
  105785. /**
  105786. * Creates an BoundingBoxGizmo
  105787. * @param gizmoLayer The utility layer the gizmo will be added to
  105788. * @param color The color of the gizmo
  105789. */
  105790. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  105791. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  105792. private _selectNode;
  105793. /**
  105794. * Updates the bounding box information for the Gizmo
  105795. */
  105796. updateBoundingBox(): void;
  105797. private _updateRotationSpheres;
  105798. private _updateScaleBoxes;
  105799. /**
  105800. * Enables rotation on the specified axis and disables rotation on the others
  105801. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  105802. */
  105803. setEnabledRotationAxis(axis: string): void;
  105804. /**
  105805. * Enables/disables scaling
  105806. * @param enable if scaling should be enabled
  105807. */
  105808. setEnabledScaling(enable: boolean): void;
  105809. private _updateDummy;
  105810. /**
  105811. * Enables a pointer drag behavior on the bounding box of the gizmo
  105812. */
  105813. enableDragBehavior(): void;
  105814. /**
  105815. * Disposes of the gizmo
  105816. */
  105817. dispose(): void;
  105818. /**
  105819. * 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)
  105820. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  105821. * @returns the bounding box mesh with the passed in mesh as a child
  105822. */
  105823. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  105824. /**
  105825. * CustomMeshes are not supported by this gizmo
  105826. * @param mesh The mesh to replace the default mesh of the gizmo
  105827. */
  105828. setCustomMesh(mesh: Mesh): void;
  105829. }
  105830. }
  105831. declare module BABYLON {
  105832. /**
  105833. * Single plane rotation gizmo
  105834. */
  105835. export class PlaneRotationGizmo extends Gizmo {
  105836. /**
  105837. * Drag behavior responsible for the gizmos dragging interactions
  105838. */
  105839. dragBehavior: PointerDragBehavior;
  105840. private _pointerObserver;
  105841. /**
  105842. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  105843. */
  105844. snapDistance: number;
  105845. /**
  105846. * Event that fires each time the gizmo snaps to a new location.
  105847. * * snapDistance is the the change in distance
  105848. */
  105849. onSnapObservable: Observable<{
  105850. snapDistance: number;
  105851. }>;
  105852. private _isEnabled;
  105853. private _parent;
  105854. /**
  105855. * Creates a PlaneRotationGizmo
  105856. * @param gizmoLayer The utility layer the gizmo will be added to
  105857. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  105858. * @param color The color of the gizmo
  105859. * @param tessellation Amount of tessellation to be used when creating rotation circles
  105860. */
  105861. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>);
  105862. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  105863. /**
  105864. * If the gizmo is enabled
  105865. */
  105866. isEnabled: boolean;
  105867. /**
  105868. * Disposes of the gizmo
  105869. */
  105870. dispose(): void;
  105871. }
  105872. }
  105873. declare module BABYLON {
  105874. /**
  105875. * Gizmo that enables rotating a mesh along 3 axis
  105876. */
  105877. export class RotationGizmo extends Gizmo {
  105878. /**
  105879. * Internal gizmo used for interactions on the x axis
  105880. */
  105881. xGizmo: PlaneRotationGizmo;
  105882. /**
  105883. * Internal gizmo used for interactions on the y axis
  105884. */
  105885. yGizmo: PlaneRotationGizmo;
  105886. /**
  105887. * Internal gizmo used for interactions on the z axis
  105888. */
  105889. zGizmo: PlaneRotationGizmo;
  105890. /** Fires an event when any of it's sub gizmos are dragged */
  105891. onDragStartObservable: Observable<{}>;
  105892. /** Fires an event when any of it's sub gizmos are released from dragging */
  105893. onDragEndObservable: Observable<{}>;
  105894. private _meshAttached;
  105895. attachedMesh: Nullable<AbstractMesh>;
  105896. /**
  105897. * Creates a RotationGizmo
  105898. * @param gizmoLayer The utility layer the gizmo will be added to
  105899. * @param tessellation Amount of tessellation to be used when creating rotation circles
  105900. */
  105901. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  105902. updateGizmoRotationToMatchAttachedMesh: boolean;
  105903. /**
  105904. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  105905. */
  105906. snapDistance: number;
  105907. /**
  105908. * Ratio for the scale of the gizmo (Default: 1)
  105909. */
  105910. scaleRatio: number;
  105911. /**
  105912. * Disposes of the gizmo
  105913. */
  105914. dispose(): void;
  105915. /**
  105916. * CustomMeshes are not supported by this gizmo
  105917. * @param mesh The mesh to replace the default mesh of the gizmo
  105918. */
  105919. setCustomMesh(mesh: Mesh): void;
  105920. }
  105921. }
  105922. declare module BABYLON {
  105923. /**
  105924. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  105925. */
  105926. export class GizmoManager implements IDisposable {
  105927. private scene;
  105928. /**
  105929. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  105930. */
  105931. gizmos: {
  105932. positionGizmo: Nullable<PositionGizmo>;
  105933. rotationGizmo: Nullable<RotationGizmo>;
  105934. scaleGizmo: Nullable<ScaleGizmo>;
  105935. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  105936. };
  105937. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  105938. clearGizmoOnEmptyPointerEvent: boolean;
  105939. /** Fires an event when the manager is attached to a mesh */
  105940. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  105941. private _gizmosEnabled;
  105942. private _pointerObserver;
  105943. private _attachedMesh;
  105944. private _boundingBoxColor;
  105945. private _defaultUtilityLayer;
  105946. private _defaultKeepDepthUtilityLayer;
  105947. /**
  105948. * When bounding box gizmo is enabled, this can be used to track drag/end events
  105949. */
  105950. boundingBoxDragBehavior: SixDofDragBehavior;
  105951. /**
  105952. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  105953. */
  105954. attachableMeshes: Nullable<Array<AbstractMesh>>;
  105955. /**
  105956. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  105957. */
  105958. usePointerToAttachGizmos: boolean;
  105959. /**
  105960. * Utility layer that the bounding box gizmo belongs to
  105961. */
  105962. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  105963. /**
  105964. * Utility layer that all gizmos besides bounding box belong to
  105965. */
  105966. readonly utilityLayer: UtilityLayerRenderer;
  105967. /**
  105968. * Instatiates a gizmo manager
  105969. * @param scene the scene to overlay the gizmos on top of
  105970. */
  105971. constructor(scene: Scene);
  105972. /**
  105973. * Attaches a set of gizmos to the specified mesh
  105974. * @param mesh The mesh the gizmo's should be attached to
  105975. */
  105976. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  105977. /**
  105978. * If the position gizmo is enabled
  105979. */
  105980. positionGizmoEnabled: boolean;
  105981. /**
  105982. * If the rotation gizmo is enabled
  105983. */
  105984. rotationGizmoEnabled: boolean;
  105985. /**
  105986. * If the scale gizmo is enabled
  105987. */
  105988. scaleGizmoEnabled: boolean;
  105989. /**
  105990. * If the boundingBox gizmo is enabled
  105991. */
  105992. boundingBoxGizmoEnabled: boolean;
  105993. /**
  105994. * Disposes of the gizmo manager
  105995. */
  105996. dispose(): void;
  105997. }
  105998. }
  105999. declare module BABYLON {
  106000. /**
  106001. * A directional light is defined by a direction (what a surprise!).
  106002. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  106003. * 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.
  106004. * Documentation: https://doc.babylonjs.com/babylon101/lights
  106005. */
  106006. export class DirectionalLight extends ShadowLight {
  106007. private _shadowFrustumSize;
  106008. /**
  106009. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  106010. */
  106011. /**
  106012. * Specifies a fix frustum size for the shadow generation.
  106013. */
  106014. shadowFrustumSize: number;
  106015. private _shadowOrthoScale;
  106016. /**
  106017. * Gets the shadow projection scale against the optimal computed one.
  106018. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  106019. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  106020. */
  106021. /**
  106022. * Sets the shadow projection scale against the optimal computed one.
  106023. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  106024. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  106025. */
  106026. shadowOrthoScale: number;
  106027. /**
  106028. * Automatically compute the projection matrix to best fit (including all the casters)
  106029. * on each frame.
  106030. */
  106031. autoUpdateExtends: boolean;
  106032. private _orthoLeft;
  106033. private _orthoRight;
  106034. private _orthoTop;
  106035. private _orthoBottom;
  106036. /**
  106037. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  106038. * The directional light is emitted from everywhere in the given direction.
  106039. * It can cast shadows.
  106040. * Documentation : https://doc.babylonjs.com/babylon101/lights
  106041. * @param name The friendly name of the light
  106042. * @param direction The direction of the light
  106043. * @param scene The scene the light belongs to
  106044. */
  106045. constructor(name: string, direction: Vector3, scene: Scene);
  106046. /**
  106047. * Returns the string "DirectionalLight".
  106048. * @return The class name
  106049. */
  106050. getClassName(): string;
  106051. /**
  106052. * Returns the integer 1.
  106053. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  106054. */
  106055. getTypeID(): number;
  106056. /**
  106057. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  106058. * Returns the DirectionalLight Shadow projection matrix.
  106059. */
  106060. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  106061. /**
  106062. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  106063. * Returns the DirectionalLight Shadow projection matrix.
  106064. */
  106065. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  106066. /**
  106067. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  106068. * Returns the DirectionalLight Shadow projection matrix.
  106069. */
  106070. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  106071. protected _buildUniformLayout(): void;
  106072. /**
  106073. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  106074. * @param effect The effect to update
  106075. * @param lightIndex The index of the light in the effect to update
  106076. * @returns The directional light
  106077. */
  106078. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  106079. /**
  106080. * Gets the minZ used for shadow according to both the scene and the light.
  106081. *
  106082. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  106083. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  106084. * @param activeCamera The camera we are returning the min for
  106085. * @returns the depth min z
  106086. */
  106087. getDepthMinZ(activeCamera: Camera): number;
  106088. /**
  106089. * Gets the maxZ used for shadow according to both the scene and the light.
  106090. *
  106091. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  106092. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  106093. * @param activeCamera The camera we are returning the max for
  106094. * @returns the depth max z
  106095. */
  106096. getDepthMaxZ(activeCamera: Camera): number;
  106097. /**
  106098. * Prepares the list of defines specific to the light type.
  106099. * @param defines the list of defines
  106100. * @param lightIndex defines the index of the light for the effect
  106101. */
  106102. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  106103. }
  106104. }
  106105. declare module BABYLON {
  106106. /**
  106107. * Class containing static functions to help procedurally build meshes
  106108. */
  106109. export class HemisphereBuilder {
  106110. /**
  106111. * Creates a hemisphere mesh
  106112. * @param name defines the name of the mesh
  106113. * @param options defines the options used to create the mesh
  106114. * @param scene defines the hosting scene
  106115. * @returns the hemisphere mesh
  106116. */
  106117. static CreateHemisphere(name: string, options: {
  106118. segments?: number;
  106119. diameter?: number;
  106120. sideOrientation?: number;
  106121. }, scene: any): Mesh;
  106122. }
  106123. }
  106124. declare module BABYLON {
  106125. /**
  106126. * A spot light is defined by a position, a direction, an angle, and an exponent.
  106127. * These values define a cone of light starting from the position, emitting toward the direction.
  106128. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  106129. * and the exponent defines the speed of the decay of the light with distance (reach).
  106130. * Documentation: https://doc.babylonjs.com/babylon101/lights
  106131. */
  106132. export class SpotLight extends ShadowLight {
  106133. private _angle;
  106134. private _innerAngle;
  106135. private _cosHalfAngle;
  106136. private _lightAngleScale;
  106137. private _lightAngleOffset;
  106138. /**
  106139. * Gets the cone angle of the spot light in Radians.
  106140. */
  106141. /**
  106142. * Sets the cone angle of the spot light in Radians.
  106143. */
  106144. angle: number;
  106145. /**
  106146. * Only used in gltf falloff mode, this defines the angle where
  106147. * the directional falloff will start before cutting at angle which could be seen
  106148. * as outer angle.
  106149. */
  106150. /**
  106151. * Only used in gltf falloff mode, this defines the angle where
  106152. * the directional falloff will start before cutting at angle which could be seen
  106153. * as outer angle.
  106154. */
  106155. innerAngle: number;
  106156. private _shadowAngleScale;
  106157. /**
  106158. * Allows scaling the angle of the light for shadow generation only.
  106159. */
  106160. /**
  106161. * Allows scaling the angle of the light for shadow generation only.
  106162. */
  106163. shadowAngleScale: number;
  106164. /**
  106165. * The light decay speed with the distance from the emission spot.
  106166. */
  106167. exponent: number;
  106168. private _projectionTextureMatrix;
  106169. /**
  106170. * Allows reading the projecton texture
  106171. */
  106172. readonly projectionTextureMatrix: Matrix;
  106173. protected _projectionTextureLightNear: number;
  106174. /**
  106175. * Gets the near clip of the Spotlight for texture projection.
  106176. */
  106177. /**
  106178. * Sets the near clip of the Spotlight for texture projection.
  106179. */
  106180. projectionTextureLightNear: number;
  106181. protected _projectionTextureLightFar: number;
  106182. /**
  106183. * Gets the far clip of the Spotlight for texture projection.
  106184. */
  106185. /**
  106186. * Sets the far clip of the Spotlight for texture projection.
  106187. */
  106188. projectionTextureLightFar: number;
  106189. protected _projectionTextureUpDirection: Vector3;
  106190. /**
  106191. * Gets the Up vector of the Spotlight for texture projection.
  106192. */
  106193. /**
  106194. * Sets the Up vector of the Spotlight for texture projection.
  106195. */
  106196. projectionTextureUpDirection: Vector3;
  106197. private _projectionTexture;
  106198. /**
  106199. * Gets the projection texture of the light.
  106200. */
  106201. /**
  106202. * Sets the projection texture of the light.
  106203. */
  106204. projectionTexture: Nullable<BaseTexture>;
  106205. private _projectionTextureViewLightDirty;
  106206. private _projectionTextureProjectionLightDirty;
  106207. private _projectionTextureDirty;
  106208. private _projectionTextureViewTargetVector;
  106209. private _projectionTextureViewLightMatrix;
  106210. private _projectionTextureProjectionLightMatrix;
  106211. private _projectionTextureScalingMatrix;
  106212. /**
  106213. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  106214. * It can cast shadows.
  106215. * Documentation : https://doc.babylonjs.com/babylon101/lights
  106216. * @param name The light friendly name
  106217. * @param position The position of the spot light in the scene
  106218. * @param direction The direction of the light in the scene
  106219. * @param angle The cone angle of the light in Radians
  106220. * @param exponent The light decay speed with the distance from the emission spot
  106221. * @param scene The scene the lights belongs to
  106222. */
  106223. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  106224. /**
  106225. * Returns the string "SpotLight".
  106226. * @returns the class name
  106227. */
  106228. getClassName(): string;
  106229. /**
  106230. * Returns the integer 2.
  106231. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  106232. */
  106233. getTypeID(): number;
  106234. /**
  106235. * Overrides the direction setter to recompute the projection texture view light Matrix.
  106236. */
  106237. protected _setDirection(value: Vector3): void;
  106238. /**
  106239. * Overrides the position setter to recompute the projection texture view light Matrix.
  106240. */
  106241. protected _setPosition(value: Vector3): void;
  106242. /**
  106243. * 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.
  106244. * Returns the SpotLight.
  106245. */
  106246. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  106247. protected _computeProjectionTextureViewLightMatrix(): void;
  106248. protected _computeProjectionTextureProjectionLightMatrix(): void;
  106249. /**
  106250. * Main function for light texture projection matrix computing.
  106251. */
  106252. protected _computeProjectionTextureMatrix(): void;
  106253. protected _buildUniformLayout(): void;
  106254. private _computeAngleValues;
  106255. /**
  106256. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  106257. * @param effect The effect to update
  106258. * @param lightIndex The index of the light in the effect to update
  106259. * @returns The spot light
  106260. */
  106261. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  106262. /**
  106263. * Disposes the light and the associated resources.
  106264. */
  106265. dispose(): void;
  106266. /**
  106267. * Prepares the list of defines specific to the light type.
  106268. * @param defines the list of defines
  106269. * @param lightIndex defines the index of the light for the effect
  106270. */
  106271. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  106272. }
  106273. }
  106274. declare module BABYLON {
  106275. /**
  106276. * Gizmo that enables viewing a light
  106277. */
  106278. export class LightGizmo extends Gizmo {
  106279. private _lightMesh;
  106280. private _material;
  106281. private cachedPosition;
  106282. private cachedForward;
  106283. /**
  106284. * Creates a LightGizmo
  106285. * @param gizmoLayer The utility layer the gizmo will be added to
  106286. */
  106287. constructor(gizmoLayer?: UtilityLayerRenderer);
  106288. private _light;
  106289. /**
  106290. * The light that the gizmo is attached to
  106291. */
  106292. light: Nullable<Light>;
  106293. /**
  106294. * @hidden
  106295. * Updates the gizmo to match the attached mesh's position/rotation
  106296. */
  106297. protected _update(): void;
  106298. private static _Scale;
  106299. /**
  106300. * Creates the lines for a light mesh
  106301. */
  106302. private static _createLightLines;
  106303. /**
  106304. * Disposes of the light gizmo
  106305. */
  106306. dispose(): void;
  106307. private static _CreateHemisphericLightMesh;
  106308. private static _CreatePointLightMesh;
  106309. private static _CreateSpotLightMesh;
  106310. private static _CreateDirectionalLightMesh;
  106311. }
  106312. }
  106313. declare module BABYLON {
  106314. /** @hidden */
  106315. export var backgroundFragmentDeclaration: {
  106316. name: string;
  106317. shader: string;
  106318. };
  106319. }
  106320. declare module BABYLON {
  106321. /** @hidden */
  106322. export var backgroundUboDeclaration: {
  106323. name: string;
  106324. shader: string;
  106325. };
  106326. }
  106327. declare module BABYLON {
  106328. /** @hidden */
  106329. export var backgroundPixelShader: {
  106330. name: string;
  106331. shader: string;
  106332. };
  106333. }
  106334. declare module BABYLON {
  106335. /** @hidden */
  106336. export var backgroundVertexDeclaration: {
  106337. name: string;
  106338. shader: string;
  106339. };
  106340. }
  106341. declare module BABYLON {
  106342. /** @hidden */
  106343. export var backgroundVertexShader: {
  106344. name: string;
  106345. shader: string;
  106346. };
  106347. }
  106348. declare module BABYLON {
  106349. /**
  106350. * Background material used to create an efficient environement around your scene.
  106351. */
  106352. export class BackgroundMaterial extends PushMaterial {
  106353. /**
  106354. * Standard reflectance value at parallel view angle.
  106355. */
  106356. static StandardReflectance0: number;
  106357. /**
  106358. * Standard reflectance value at grazing angle.
  106359. */
  106360. static StandardReflectance90: number;
  106361. protected _primaryColor: Color3;
  106362. /**
  106363. * Key light Color (multiply against the environement texture)
  106364. */
  106365. primaryColor: Color3;
  106366. protected __perceptualColor: Nullable<Color3>;
  106367. /**
  106368. * Experimental Internal Use Only.
  106369. *
  106370. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  106371. * This acts as a helper to set the primary color to a more "human friendly" value.
  106372. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  106373. * output color as close as possible from the chosen value.
  106374. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  106375. * part of lighting setup.)
  106376. */
  106377. _perceptualColor: Nullable<Color3>;
  106378. protected _primaryColorShadowLevel: float;
  106379. /**
  106380. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  106381. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  106382. */
  106383. primaryColorShadowLevel: float;
  106384. protected _primaryColorHighlightLevel: float;
  106385. /**
  106386. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  106387. * The primary color is used at the level chosen to define what the white area would look.
  106388. */
  106389. primaryColorHighlightLevel: float;
  106390. protected _reflectionTexture: Nullable<BaseTexture>;
  106391. /**
  106392. * Reflection Texture used in the material.
  106393. * Should be author in a specific way for the best result (refer to the documentation).
  106394. */
  106395. reflectionTexture: Nullable<BaseTexture>;
  106396. protected _reflectionBlur: float;
  106397. /**
  106398. * Reflection Texture level of blur.
  106399. *
  106400. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  106401. * texture twice.
  106402. */
  106403. reflectionBlur: float;
  106404. protected _diffuseTexture: Nullable<BaseTexture>;
  106405. /**
  106406. * Diffuse Texture used in the material.
  106407. * Should be author in a specific way for the best result (refer to the documentation).
  106408. */
  106409. diffuseTexture: Nullable<BaseTexture>;
  106410. protected _shadowLights: Nullable<IShadowLight[]>;
  106411. /**
  106412. * Specify the list of lights casting shadow on the material.
  106413. * All scene shadow lights will be included if null.
  106414. */
  106415. shadowLights: Nullable<IShadowLight[]>;
  106416. protected _shadowLevel: float;
  106417. /**
  106418. * Helps adjusting the shadow to a softer level if required.
  106419. * 0 means black shadows and 1 means no shadows.
  106420. */
  106421. shadowLevel: float;
  106422. protected _sceneCenter: Vector3;
  106423. /**
  106424. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  106425. * It is usually zero but might be interesting to modify according to your setup.
  106426. */
  106427. sceneCenter: Vector3;
  106428. protected _opacityFresnel: boolean;
  106429. /**
  106430. * This helps specifying that the material is falling off to the sky box at grazing angle.
  106431. * This helps ensuring a nice transition when the camera goes under the ground.
  106432. */
  106433. opacityFresnel: boolean;
  106434. protected _reflectionFresnel: boolean;
  106435. /**
  106436. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  106437. * This helps adding a mirror texture on the ground.
  106438. */
  106439. reflectionFresnel: boolean;
  106440. protected _reflectionFalloffDistance: number;
  106441. /**
  106442. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  106443. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  106444. */
  106445. reflectionFalloffDistance: number;
  106446. protected _reflectionAmount: number;
  106447. /**
  106448. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  106449. */
  106450. reflectionAmount: number;
  106451. protected _reflectionReflectance0: number;
  106452. /**
  106453. * This specifies the weight of the reflection at grazing angle.
  106454. */
  106455. reflectionReflectance0: number;
  106456. protected _reflectionReflectance90: number;
  106457. /**
  106458. * This specifies the weight of the reflection at a perpendicular point of view.
  106459. */
  106460. reflectionReflectance90: number;
  106461. /**
  106462. * Sets the reflection reflectance fresnel values according to the default standard
  106463. * empirically know to work well :-)
  106464. */
  106465. reflectionStandardFresnelWeight: number;
  106466. protected _useRGBColor: boolean;
  106467. /**
  106468. * Helps to directly use the maps channels instead of their level.
  106469. */
  106470. useRGBColor: boolean;
  106471. protected _enableNoise: boolean;
  106472. /**
  106473. * This helps reducing the banding effect that could occur on the background.
  106474. */
  106475. enableNoise: boolean;
  106476. /**
  106477. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  106478. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  106479. * Recommended to be keep at 1.0 except for special cases.
  106480. */
  106481. fovMultiplier: number;
  106482. private _fovMultiplier;
  106483. /**
  106484. * Enable the FOV adjustment feature controlled by fovMultiplier.
  106485. */
  106486. useEquirectangularFOV: boolean;
  106487. private _maxSimultaneousLights;
  106488. /**
  106489. * Number of Simultaneous lights allowed on the material.
  106490. */
  106491. maxSimultaneousLights: int;
  106492. /**
  106493. * Default configuration related to image processing available in the Background Material.
  106494. */
  106495. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  106496. /**
  106497. * Keep track of the image processing observer to allow dispose and replace.
  106498. */
  106499. private _imageProcessingObserver;
  106500. /**
  106501. * Attaches a new image processing configuration to the PBR Material.
  106502. * @param configuration (if null the scene configuration will be use)
  106503. */
  106504. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  106505. /**
  106506. * Gets the image processing configuration used either in this material.
  106507. */
  106508. /**
  106509. * Sets the Default image processing configuration used either in the this material.
  106510. *
  106511. * If sets to null, the scene one is in use.
  106512. */
  106513. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  106514. /**
  106515. * Gets wether the color curves effect is enabled.
  106516. */
  106517. /**
  106518. * Sets wether the color curves effect is enabled.
  106519. */
  106520. cameraColorCurvesEnabled: boolean;
  106521. /**
  106522. * Gets wether the color grading effect is enabled.
  106523. */
  106524. /**
  106525. * Gets wether the color grading effect is enabled.
  106526. */
  106527. cameraColorGradingEnabled: boolean;
  106528. /**
  106529. * Gets wether tonemapping is enabled or not.
  106530. */
  106531. /**
  106532. * Sets wether tonemapping is enabled or not
  106533. */
  106534. cameraToneMappingEnabled: boolean;
  106535. /**
  106536. * The camera exposure used on this material.
  106537. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  106538. * This corresponds to a photographic exposure.
  106539. */
  106540. /**
  106541. * The camera exposure used on this material.
  106542. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  106543. * This corresponds to a photographic exposure.
  106544. */
  106545. cameraExposure: float;
  106546. /**
  106547. * Gets The camera contrast used on this material.
  106548. */
  106549. /**
  106550. * Sets The camera contrast used on this material.
  106551. */
  106552. cameraContrast: float;
  106553. /**
  106554. * Gets the Color Grading 2D Lookup Texture.
  106555. */
  106556. /**
  106557. * Sets the Color Grading 2D Lookup Texture.
  106558. */
  106559. cameraColorGradingTexture: Nullable<BaseTexture>;
  106560. /**
  106561. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  106562. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  106563. * 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;
  106564. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  106565. */
  106566. /**
  106567. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  106568. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  106569. * 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;
  106570. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  106571. */
  106572. cameraColorCurves: Nullable<ColorCurves>;
  106573. /**
  106574. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  106575. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  106576. */
  106577. switchToBGR: boolean;
  106578. private _renderTargets;
  106579. private _reflectionControls;
  106580. private _white;
  106581. private _primaryShadowColor;
  106582. private _primaryHighlightColor;
  106583. /**
  106584. * Instantiates a Background Material in the given scene
  106585. * @param name The friendly name of the material
  106586. * @param scene The scene to add the material to
  106587. */
  106588. constructor(name: string, scene: Scene);
  106589. /**
  106590. * Gets a boolean indicating that current material needs to register RTT
  106591. */
  106592. readonly hasRenderTargetTextures: boolean;
  106593. /**
  106594. * The entire material has been created in order to prevent overdraw.
  106595. * @returns false
  106596. */
  106597. needAlphaTesting(): boolean;
  106598. /**
  106599. * The entire material has been created in order to prevent overdraw.
  106600. * @returns true if blending is enable
  106601. */
  106602. needAlphaBlending(): boolean;
  106603. /**
  106604. * Checks wether the material is ready to be rendered for a given mesh.
  106605. * @param mesh The mesh to render
  106606. * @param subMesh The submesh to check against
  106607. * @param useInstances Specify wether or not the material is used with instances
  106608. * @returns true if all the dependencies are ready (Textures, Effects...)
  106609. */
  106610. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  106611. /**
  106612. * Compute the primary color according to the chosen perceptual color.
  106613. */
  106614. private _computePrimaryColorFromPerceptualColor;
  106615. /**
  106616. * Compute the highlights and shadow colors according to their chosen levels.
  106617. */
  106618. private _computePrimaryColors;
  106619. /**
  106620. * Build the uniform buffer used in the material.
  106621. */
  106622. buildUniformLayout(): void;
  106623. /**
  106624. * Unbind the material.
  106625. */
  106626. unbind(): void;
  106627. /**
  106628. * Bind only the world matrix to the material.
  106629. * @param world The world matrix to bind.
  106630. */
  106631. bindOnlyWorldMatrix(world: Matrix): void;
  106632. /**
  106633. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  106634. * @param world The world matrix to bind.
  106635. * @param subMesh The submesh to bind for.
  106636. */
  106637. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  106638. /**
  106639. * Dispose the material.
  106640. * @param forceDisposeEffect Force disposal of the associated effect.
  106641. * @param forceDisposeTextures Force disposal of the associated textures.
  106642. */
  106643. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  106644. /**
  106645. * Clones the material.
  106646. * @param name The cloned name.
  106647. * @returns The cloned material.
  106648. */
  106649. clone(name: string): BackgroundMaterial;
  106650. /**
  106651. * Serializes the current material to its JSON representation.
  106652. * @returns The JSON representation.
  106653. */
  106654. serialize(): any;
  106655. /**
  106656. * Gets the class name of the material
  106657. * @returns "BackgroundMaterial"
  106658. */
  106659. getClassName(): string;
  106660. /**
  106661. * Parse a JSON input to create back a background material.
  106662. * @param source The JSON data to parse
  106663. * @param scene The scene to create the parsed material in
  106664. * @param rootUrl The root url of the assets the material depends upon
  106665. * @returns the instantiated BackgroundMaterial.
  106666. */
  106667. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  106668. }
  106669. }
  106670. declare module BABYLON {
  106671. /**
  106672. * Represents the different options available during the creation of
  106673. * a Environment helper.
  106674. *
  106675. * This can control the default ground, skybox and image processing setup of your scene.
  106676. */
  106677. export interface IEnvironmentHelperOptions {
  106678. /**
  106679. * Specifies wether or not to create a ground.
  106680. * True by default.
  106681. */
  106682. createGround: boolean;
  106683. /**
  106684. * Specifies the ground size.
  106685. * 15 by default.
  106686. */
  106687. groundSize: number;
  106688. /**
  106689. * The texture used on the ground for the main color.
  106690. * Comes from the BabylonJS CDN by default.
  106691. *
  106692. * Remarks: Can be either a texture or a url.
  106693. */
  106694. groundTexture: string | BaseTexture;
  106695. /**
  106696. * The color mixed in the ground texture by default.
  106697. * BabylonJS clearColor by default.
  106698. */
  106699. groundColor: Color3;
  106700. /**
  106701. * Specifies the ground opacity.
  106702. * 1 by default.
  106703. */
  106704. groundOpacity: number;
  106705. /**
  106706. * Enables the ground to receive shadows.
  106707. * True by default.
  106708. */
  106709. enableGroundShadow: boolean;
  106710. /**
  106711. * Helps preventing the shadow to be fully black on the ground.
  106712. * 0.5 by default.
  106713. */
  106714. groundShadowLevel: number;
  106715. /**
  106716. * Creates a mirror texture attach to the ground.
  106717. * false by default.
  106718. */
  106719. enableGroundMirror: boolean;
  106720. /**
  106721. * Specifies the ground mirror size ratio.
  106722. * 0.3 by default as the default kernel is 64.
  106723. */
  106724. groundMirrorSizeRatio: number;
  106725. /**
  106726. * Specifies the ground mirror blur kernel size.
  106727. * 64 by default.
  106728. */
  106729. groundMirrorBlurKernel: number;
  106730. /**
  106731. * Specifies the ground mirror visibility amount.
  106732. * 1 by default
  106733. */
  106734. groundMirrorAmount: number;
  106735. /**
  106736. * Specifies the ground mirror reflectance weight.
  106737. * This uses the standard weight of the background material to setup the fresnel effect
  106738. * of the mirror.
  106739. * 1 by default.
  106740. */
  106741. groundMirrorFresnelWeight: number;
  106742. /**
  106743. * Specifies the ground mirror Falloff distance.
  106744. * This can helps reducing the size of the reflection.
  106745. * 0 by Default.
  106746. */
  106747. groundMirrorFallOffDistance: number;
  106748. /**
  106749. * Specifies the ground mirror texture type.
  106750. * Unsigned Int by Default.
  106751. */
  106752. groundMirrorTextureType: number;
  106753. /**
  106754. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  106755. * the shown objects.
  106756. */
  106757. groundYBias: number;
  106758. /**
  106759. * Specifies wether or not to create a skybox.
  106760. * True by default.
  106761. */
  106762. createSkybox: boolean;
  106763. /**
  106764. * Specifies the skybox size.
  106765. * 20 by default.
  106766. */
  106767. skyboxSize: number;
  106768. /**
  106769. * The texture used on the skybox for the main color.
  106770. * Comes from the BabylonJS CDN by default.
  106771. *
  106772. * Remarks: Can be either a texture or a url.
  106773. */
  106774. skyboxTexture: string | BaseTexture;
  106775. /**
  106776. * The color mixed in the skybox texture by default.
  106777. * BabylonJS clearColor by default.
  106778. */
  106779. skyboxColor: Color3;
  106780. /**
  106781. * The background rotation around the Y axis of the scene.
  106782. * This helps aligning the key lights of your scene with the background.
  106783. * 0 by default.
  106784. */
  106785. backgroundYRotation: number;
  106786. /**
  106787. * Compute automatically the size of the elements to best fit with the scene.
  106788. */
  106789. sizeAuto: boolean;
  106790. /**
  106791. * Default position of the rootMesh if autoSize is not true.
  106792. */
  106793. rootPosition: Vector3;
  106794. /**
  106795. * Sets up the image processing in the scene.
  106796. * true by default.
  106797. */
  106798. setupImageProcessing: boolean;
  106799. /**
  106800. * The texture used as your environment texture in the scene.
  106801. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  106802. *
  106803. * Remarks: Can be either a texture or a url.
  106804. */
  106805. environmentTexture: string | BaseTexture;
  106806. /**
  106807. * The value of the exposure to apply to the scene.
  106808. * 0.6 by default if setupImageProcessing is true.
  106809. */
  106810. cameraExposure: number;
  106811. /**
  106812. * The value of the contrast to apply to the scene.
  106813. * 1.6 by default if setupImageProcessing is true.
  106814. */
  106815. cameraContrast: number;
  106816. /**
  106817. * Specifies wether or not tonemapping should be enabled in the scene.
  106818. * true by default if setupImageProcessing is true.
  106819. */
  106820. toneMappingEnabled: boolean;
  106821. }
  106822. /**
  106823. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  106824. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  106825. * It also helps with the default setup of your imageProcessing configuration.
  106826. */
  106827. export class EnvironmentHelper {
  106828. /**
  106829. * Default ground texture URL.
  106830. */
  106831. private static _groundTextureCDNUrl;
  106832. /**
  106833. * Default skybox texture URL.
  106834. */
  106835. private static _skyboxTextureCDNUrl;
  106836. /**
  106837. * Default environment texture URL.
  106838. */
  106839. private static _environmentTextureCDNUrl;
  106840. /**
  106841. * Creates the default options for the helper.
  106842. */
  106843. private static _getDefaultOptions;
  106844. private _rootMesh;
  106845. /**
  106846. * Gets the root mesh created by the helper.
  106847. */
  106848. readonly rootMesh: Mesh;
  106849. private _skybox;
  106850. /**
  106851. * Gets the skybox created by the helper.
  106852. */
  106853. readonly skybox: Nullable<Mesh>;
  106854. private _skyboxTexture;
  106855. /**
  106856. * Gets the skybox texture created by the helper.
  106857. */
  106858. readonly skyboxTexture: Nullable<BaseTexture>;
  106859. private _skyboxMaterial;
  106860. /**
  106861. * Gets the skybox material created by the helper.
  106862. */
  106863. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  106864. private _ground;
  106865. /**
  106866. * Gets the ground mesh created by the helper.
  106867. */
  106868. readonly ground: Nullable<Mesh>;
  106869. private _groundTexture;
  106870. /**
  106871. * Gets the ground texture created by the helper.
  106872. */
  106873. readonly groundTexture: Nullable<BaseTexture>;
  106874. private _groundMirror;
  106875. /**
  106876. * Gets the ground mirror created by the helper.
  106877. */
  106878. readonly groundMirror: Nullable<MirrorTexture>;
  106879. /**
  106880. * Gets the ground mirror render list to helps pushing the meshes
  106881. * you wish in the ground reflection.
  106882. */
  106883. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  106884. private _groundMaterial;
  106885. /**
  106886. * Gets the ground material created by the helper.
  106887. */
  106888. readonly groundMaterial: Nullable<BackgroundMaterial>;
  106889. /**
  106890. * Stores the creation options.
  106891. */
  106892. private readonly _scene;
  106893. private _options;
  106894. /**
  106895. * This observable will be notified with any error during the creation of the environment,
  106896. * mainly texture creation errors.
  106897. */
  106898. onErrorObservable: Observable<{
  106899. message?: string;
  106900. exception?: any;
  106901. }>;
  106902. /**
  106903. * constructor
  106904. * @param options Defines the options we want to customize the helper
  106905. * @param scene The scene to add the material to
  106906. */
  106907. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  106908. /**
  106909. * Updates the background according to the new options
  106910. * @param options
  106911. */
  106912. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  106913. /**
  106914. * Sets the primary color of all the available elements.
  106915. * @param color the main color to affect to the ground and the background
  106916. */
  106917. setMainColor(color: Color3): void;
  106918. /**
  106919. * Setup the image processing according to the specified options.
  106920. */
  106921. private _setupImageProcessing;
  106922. /**
  106923. * Setup the environment texture according to the specified options.
  106924. */
  106925. private _setupEnvironmentTexture;
  106926. /**
  106927. * Setup the background according to the specified options.
  106928. */
  106929. private _setupBackground;
  106930. /**
  106931. * Get the scene sizes according to the setup.
  106932. */
  106933. private _getSceneSize;
  106934. /**
  106935. * Setup the ground according to the specified options.
  106936. */
  106937. private _setupGround;
  106938. /**
  106939. * Setup the ground material according to the specified options.
  106940. */
  106941. private _setupGroundMaterial;
  106942. /**
  106943. * Setup the ground diffuse texture according to the specified options.
  106944. */
  106945. private _setupGroundDiffuseTexture;
  106946. /**
  106947. * Setup the ground mirror texture according to the specified options.
  106948. */
  106949. private _setupGroundMirrorTexture;
  106950. /**
  106951. * Setup the ground to receive the mirror texture.
  106952. */
  106953. private _setupMirrorInGroundMaterial;
  106954. /**
  106955. * Setup the skybox according to the specified options.
  106956. */
  106957. private _setupSkybox;
  106958. /**
  106959. * Setup the skybox material according to the specified options.
  106960. */
  106961. private _setupSkyboxMaterial;
  106962. /**
  106963. * Setup the skybox reflection texture according to the specified options.
  106964. */
  106965. private _setupSkyboxReflectionTexture;
  106966. private _errorHandler;
  106967. /**
  106968. * Dispose all the elements created by the Helper.
  106969. */
  106970. dispose(): void;
  106971. }
  106972. }
  106973. declare module BABYLON {
  106974. /**
  106975. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  106976. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  106977. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  106978. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  106979. */
  106980. export class PhotoDome extends TransformNode {
  106981. /**
  106982. * Define the image as a Monoscopic panoramic 360 image.
  106983. */
  106984. static readonly MODE_MONOSCOPIC: number;
  106985. /**
  106986. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  106987. */
  106988. static readonly MODE_TOPBOTTOM: number;
  106989. /**
  106990. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  106991. */
  106992. static readonly MODE_SIDEBYSIDE: number;
  106993. private _useDirectMapping;
  106994. /**
  106995. * The texture being displayed on the sphere
  106996. */
  106997. protected _photoTexture: Texture;
  106998. /**
  106999. * Gets or sets the texture being displayed on the sphere
  107000. */
  107001. photoTexture: Texture;
  107002. /**
  107003. * Observable raised when an error occured while loading the 360 image
  107004. */
  107005. onLoadErrorObservable: Observable<string>;
  107006. /**
  107007. * The skybox material
  107008. */
  107009. protected _material: BackgroundMaterial;
  107010. /**
  107011. * The surface used for the skybox
  107012. */
  107013. protected _mesh: Mesh;
  107014. /**
  107015. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  107016. * Also see the options.resolution property.
  107017. */
  107018. fovMultiplier: number;
  107019. private _imageMode;
  107020. /**
  107021. * Gets or set the current video mode for the video. It can be:
  107022. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  107023. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  107024. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  107025. */
  107026. imageMode: number;
  107027. /**
  107028. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  107029. * @param name Element's name, child elements will append suffixes for their own names.
  107030. * @param urlsOfPhoto defines the url of the photo to display
  107031. * @param options defines an object containing optional or exposed sub element properties
  107032. * @param onError defines a callback called when an error occured while loading the texture
  107033. */
  107034. constructor(name: string, urlOfPhoto: string, options: {
  107035. resolution?: number;
  107036. size?: number;
  107037. useDirectMapping?: boolean;
  107038. faceForward?: boolean;
  107039. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  107040. private _onBeforeCameraRenderObserver;
  107041. private _changeImageMode;
  107042. /**
  107043. * Releases resources associated with this node.
  107044. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  107045. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  107046. */
  107047. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  107048. }
  107049. }
  107050. declare module BABYLON {
  107051. /** @hidden */
  107052. export var rgbdDecodePixelShader: {
  107053. name: string;
  107054. shader: string;
  107055. };
  107056. }
  107057. declare module BABYLON {
  107058. /**
  107059. * Class used to host texture specific utilities
  107060. */
  107061. export class BRDFTextureTools {
  107062. /**
  107063. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  107064. * @param texture the texture to expand.
  107065. */
  107066. private static _ExpandDefaultBRDFTexture;
  107067. /**
  107068. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  107069. * @param scene defines the hosting scene
  107070. * @returns the environment BRDF texture
  107071. */
  107072. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  107073. private static _environmentBRDFBase64Texture;
  107074. }
  107075. }
  107076. declare module BABYLON {
  107077. /**
  107078. * @hidden
  107079. */
  107080. export interface IMaterialClearCoatDefines {
  107081. CLEARCOAT: boolean;
  107082. CLEARCOAT_DEFAULTIOR: boolean;
  107083. CLEARCOAT_TEXTURE: boolean;
  107084. CLEARCOAT_TEXTUREDIRECTUV: number;
  107085. CLEARCOAT_BUMP: boolean;
  107086. CLEARCOAT_BUMPDIRECTUV: number;
  107087. CLEARCOAT_TINT: boolean;
  107088. CLEARCOAT_TINT_TEXTURE: boolean;
  107089. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  107090. /** @hidden */
  107091. _areTexturesDirty: boolean;
  107092. }
  107093. /**
  107094. * Define the code related to the clear coat parameters of the pbr material.
  107095. */
  107096. export class PBRClearCoatConfiguration {
  107097. /**
  107098. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  107099. * The default fits with a polyurethane material.
  107100. */
  107101. private static readonly _DefaultIndexOfRefraction;
  107102. private _isEnabled;
  107103. /**
  107104. * Defines if the clear coat is enabled in the material.
  107105. */
  107106. isEnabled: boolean;
  107107. /**
  107108. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  107109. */
  107110. intensity: number;
  107111. /**
  107112. * Defines the clear coat layer roughness.
  107113. */
  107114. roughness: number;
  107115. private _indexOfRefraction;
  107116. /**
  107117. * Defines the index of refraction of the clear coat.
  107118. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  107119. * The default fits with a polyurethane material.
  107120. * Changing the default value is more performance intensive.
  107121. */
  107122. indexOfRefraction: number;
  107123. private _texture;
  107124. /**
  107125. * Stores the clear coat values in a texture.
  107126. */
  107127. texture: Nullable<BaseTexture>;
  107128. private _bumpTexture;
  107129. /**
  107130. * Define the clear coat specific bump texture.
  107131. */
  107132. bumpTexture: Nullable<BaseTexture>;
  107133. private _isTintEnabled;
  107134. /**
  107135. * Defines if the clear coat tint is enabled in the material.
  107136. */
  107137. isTintEnabled: boolean;
  107138. /**
  107139. * Defines the clear coat tint of the material.
  107140. * This is only use if tint is enabled
  107141. */
  107142. tintColor: Color3;
  107143. /**
  107144. * Defines the distance at which the tint color should be found in the
  107145. * clear coat media.
  107146. * This is only use if tint is enabled
  107147. */
  107148. tintColorAtDistance: number;
  107149. /**
  107150. * Defines the clear coat layer thickness.
  107151. * This is only use if tint is enabled
  107152. */
  107153. tintThickness: number;
  107154. private _tintTexture;
  107155. /**
  107156. * Stores the clear tint values in a texture.
  107157. * rgb is tint
  107158. * a is a thickness factor
  107159. */
  107160. tintTexture: Nullable<BaseTexture>;
  107161. /** @hidden */
  107162. private _internalMarkAllSubMeshesAsTexturesDirty;
  107163. /** @hidden */
  107164. _markAllSubMeshesAsTexturesDirty(): void;
  107165. /**
  107166. * Instantiate a new istance of clear coat configuration.
  107167. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  107168. */
  107169. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  107170. /**
  107171. * Gets wehter the submesh is ready to be used or not.
  107172. * @param defines the list of "defines" to update.
  107173. * @param scene defines the scene the material belongs to.
  107174. * @param engine defines the engine the material belongs to.
  107175. * @param disableBumpMap defines wether the material disables bump or not.
  107176. * @returns - boolean indicating that the submesh is ready or not.
  107177. */
  107178. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  107179. /**
  107180. * Checks to see if a texture is used in the material.
  107181. * @param defines the list of "defines" to update.
  107182. * @param scene defines the scene to the material belongs to.
  107183. */
  107184. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  107185. /**
  107186. * Binds the material data.
  107187. * @param uniformBuffer defines the Uniform buffer to fill in.
  107188. * @param scene defines the scene the material belongs to.
  107189. * @param engine defines the engine the material belongs to.
  107190. * @param disableBumpMap defines wether the material disables bump or not.
  107191. * @param isFrozen defines wether the material is frozen or not.
  107192. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  107193. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  107194. */
  107195. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  107196. /**
  107197. * Checks to see if a texture is used in the material.
  107198. * @param texture - Base texture to use.
  107199. * @returns - Boolean specifying if a texture is used in the material.
  107200. */
  107201. hasTexture(texture: BaseTexture): boolean;
  107202. /**
  107203. * Returns an array of the actively used textures.
  107204. * @param activeTextures Array of BaseTextures
  107205. */
  107206. getActiveTextures(activeTextures: BaseTexture[]): void;
  107207. /**
  107208. * Returns the animatable textures.
  107209. * @param animatables Array of animatable textures.
  107210. */
  107211. getAnimatables(animatables: IAnimatable[]): void;
  107212. /**
  107213. * Disposes the resources of the material.
  107214. * @param forceDisposeTextures - Forces the disposal of all textures.
  107215. */
  107216. dispose(forceDisposeTextures?: boolean): void;
  107217. /**
  107218. * Get the current class name of the texture useful for serialization or dynamic coding.
  107219. * @returns "PBRClearCoatConfiguration"
  107220. */
  107221. getClassName(): string;
  107222. /**
  107223. * Add fallbacks to the effect fallbacks list.
  107224. * @param defines defines the Base texture to use.
  107225. * @param fallbacks defines the current fallback list.
  107226. * @param currentRank defines the current fallback rank.
  107227. * @returns the new fallback rank.
  107228. */
  107229. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  107230. /**
  107231. * Add the required uniforms to the current list.
  107232. * @param uniforms defines the current uniform list.
  107233. */
  107234. static AddUniforms(uniforms: string[]): void;
  107235. /**
  107236. * Add the required samplers to the current list.
  107237. * @param samplers defines the current sampler list.
  107238. */
  107239. static AddSamplers(samplers: string[]): void;
  107240. /**
  107241. * Add the required uniforms to the current buffer.
  107242. * @param uniformBuffer defines the current uniform buffer.
  107243. */
  107244. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  107245. /**
  107246. * Makes a duplicate of the current configuration into another one.
  107247. * @param clearCoatConfiguration define the config where to copy the info
  107248. */
  107249. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  107250. /**
  107251. * Serializes this clear coat configuration.
  107252. * @returns - An object with the serialized config.
  107253. */
  107254. serialize(): any;
  107255. /**
  107256. * Parses a Clear Coat Configuration from a serialized object.
  107257. * @param source - Serialized object.
  107258. */
  107259. parse(source: any): void;
  107260. }
  107261. }
  107262. declare module BABYLON {
  107263. /**
  107264. * @hidden
  107265. */
  107266. export interface IMaterialAnisotropicDefines {
  107267. ANISOTROPIC: boolean;
  107268. ANISOTROPIC_TEXTURE: boolean;
  107269. ANISOTROPIC_TEXTUREDIRECTUV: number;
  107270. MAINUV1: boolean;
  107271. _areTexturesDirty: boolean;
  107272. _needUVs: boolean;
  107273. }
  107274. /**
  107275. * Define the code related to the anisotropic parameters of the pbr material.
  107276. */
  107277. export class PBRAnisotropicConfiguration {
  107278. private _isEnabled;
  107279. /**
  107280. * Defines if the anisotropy is enabled in the material.
  107281. */
  107282. isEnabled: boolean;
  107283. /**
  107284. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  107285. */
  107286. intensity: number;
  107287. /**
  107288. * Defines if the effect is along the tangents, bitangents or in between.
  107289. * By default, the effect is "strectching" the highlights along the tangents.
  107290. */
  107291. direction: Vector2;
  107292. private _texture;
  107293. /**
  107294. * Stores the anisotropy values in a texture.
  107295. * rg is direction (like normal from -1 to 1)
  107296. * b is a intensity
  107297. */
  107298. texture: Nullable<BaseTexture>;
  107299. /** @hidden */
  107300. private _internalMarkAllSubMeshesAsTexturesDirty;
  107301. /** @hidden */
  107302. _markAllSubMeshesAsTexturesDirty(): void;
  107303. /**
  107304. * Instantiate a new istance of anisotropy configuration.
  107305. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  107306. */
  107307. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  107308. /**
  107309. * Specifies that the submesh is ready to be used.
  107310. * @param defines the list of "defines" to update.
  107311. * @param scene defines the scene the material belongs to.
  107312. * @returns - boolean indicating that the submesh is ready or not.
  107313. */
  107314. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  107315. /**
  107316. * Checks to see if a texture is used in the material.
  107317. * @param defines the list of "defines" to update.
  107318. * @param mesh the mesh we are preparing the defines for.
  107319. * @param scene defines the scene the material belongs to.
  107320. */
  107321. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  107322. /**
  107323. * Binds the material data.
  107324. * @param uniformBuffer defines the Uniform buffer to fill in.
  107325. * @param scene defines the scene the material belongs to.
  107326. * @param isFrozen defines wether the material is frozen or not.
  107327. */
  107328. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  107329. /**
  107330. * Checks to see if a texture is used in the material.
  107331. * @param texture - Base texture to use.
  107332. * @returns - Boolean specifying if a texture is used in the material.
  107333. */
  107334. hasTexture(texture: BaseTexture): boolean;
  107335. /**
  107336. * Returns an array of the actively used textures.
  107337. * @param activeTextures Array of BaseTextures
  107338. */
  107339. getActiveTextures(activeTextures: BaseTexture[]): void;
  107340. /**
  107341. * Returns the animatable textures.
  107342. * @param animatables Array of animatable textures.
  107343. */
  107344. getAnimatables(animatables: IAnimatable[]): void;
  107345. /**
  107346. * Disposes the resources of the material.
  107347. * @param forceDisposeTextures - Forces the disposal of all textures.
  107348. */
  107349. dispose(forceDisposeTextures?: boolean): void;
  107350. /**
  107351. * Get the current class name of the texture useful for serialization or dynamic coding.
  107352. * @returns "PBRAnisotropicConfiguration"
  107353. */
  107354. getClassName(): string;
  107355. /**
  107356. * Add fallbacks to the effect fallbacks list.
  107357. * @param defines defines the Base texture to use.
  107358. * @param fallbacks defines the current fallback list.
  107359. * @param currentRank defines the current fallback rank.
  107360. * @returns the new fallback rank.
  107361. */
  107362. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  107363. /**
  107364. * Add the required uniforms to the current list.
  107365. * @param uniforms defines the current uniform list.
  107366. */
  107367. static AddUniforms(uniforms: string[]): void;
  107368. /**
  107369. * Add the required uniforms to the current buffer.
  107370. * @param uniformBuffer defines the current uniform buffer.
  107371. */
  107372. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  107373. /**
  107374. * Add the required samplers to the current list.
  107375. * @param samplers defines the current sampler list.
  107376. */
  107377. static AddSamplers(samplers: string[]): void;
  107378. /**
  107379. * Makes a duplicate of the current configuration into another one.
  107380. * @param anisotropicConfiguration define the config where to copy the info
  107381. */
  107382. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  107383. /**
  107384. * Serializes this anisotropy configuration.
  107385. * @returns - An object with the serialized config.
  107386. */
  107387. serialize(): any;
  107388. /**
  107389. * Parses a anisotropy Configuration from a serialized object.
  107390. * @param source - Serialized object.
  107391. */
  107392. parse(source: any): void;
  107393. }
  107394. }
  107395. declare module BABYLON {
  107396. /**
  107397. * @hidden
  107398. */
  107399. export interface IMaterialBRDFDefines {
  107400. BRDF_V_HEIGHT_CORRELATED: boolean;
  107401. MS_BRDF_ENERGY_CONSERVATION: boolean;
  107402. SPHERICAL_HARMONICS: boolean;
  107403. /** @hidden */
  107404. _areMiscDirty: boolean;
  107405. }
  107406. /**
  107407. * Define the code related to the BRDF parameters of the pbr material.
  107408. */
  107409. export class PBRBRDFConfiguration {
  107410. /**
  107411. * Default value used for the energy conservation.
  107412. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  107413. */
  107414. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  107415. /**
  107416. * Default value used for the Smith Visibility Height Correlated mode.
  107417. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  107418. */
  107419. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  107420. /**
  107421. * Default value used for the IBL diffuse part.
  107422. * This can help switching back to the polynomials mode globally which is a tiny bit
  107423. * less GPU intensive at the drawback of a lower quality.
  107424. */
  107425. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  107426. private _useEnergyConservation;
  107427. /**
  107428. * Defines if the material uses energy conservation.
  107429. */
  107430. useEnergyConservation: boolean;
  107431. private _useSmithVisibilityHeightCorrelated;
  107432. /**
  107433. * LEGACY Mode set to false
  107434. * Defines if the material uses height smith correlated visibility term.
  107435. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  107436. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  107437. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  107438. * Not relying on height correlated will also disable energy conservation.
  107439. */
  107440. useSmithVisibilityHeightCorrelated: boolean;
  107441. private _useSphericalHarmonics;
  107442. /**
  107443. * LEGACY Mode set to false
  107444. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  107445. * diffuse part of the IBL.
  107446. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  107447. * to the ground truth.
  107448. */
  107449. useSphericalHarmonics: boolean;
  107450. /** @hidden */
  107451. private _internalMarkAllSubMeshesAsMiscDirty;
  107452. /** @hidden */
  107453. _markAllSubMeshesAsMiscDirty(): void;
  107454. /**
  107455. * Instantiate a new istance of clear coat configuration.
  107456. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  107457. */
  107458. constructor(markAllSubMeshesAsMiscDirty: () => void);
  107459. /**
  107460. * Checks to see if a texture is used in the material.
  107461. * @param defines the list of "defines" to update.
  107462. */
  107463. prepareDefines(defines: IMaterialBRDFDefines): void;
  107464. /**
  107465. * Get the current class name of the texture useful for serialization or dynamic coding.
  107466. * @returns "PBRClearCoatConfiguration"
  107467. */
  107468. getClassName(): string;
  107469. /**
  107470. * Makes a duplicate of the current configuration into another one.
  107471. * @param brdfConfiguration define the config where to copy the info
  107472. */
  107473. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  107474. /**
  107475. * Serializes this BRDF configuration.
  107476. * @returns - An object with the serialized config.
  107477. */
  107478. serialize(): any;
  107479. /**
  107480. * Parses a BRDF Configuration from a serialized object.
  107481. * @param source - Serialized object.
  107482. */
  107483. parse(source: any): void;
  107484. }
  107485. }
  107486. declare module BABYLON {
  107487. /**
  107488. * @hidden
  107489. */
  107490. export interface IMaterialSheenDefines {
  107491. SHEEN: boolean;
  107492. SHEEN_TEXTURE: boolean;
  107493. SHEEN_TEXTUREDIRECTUV: number;
  107494. SHEEN_LINKWITHALBEDO: boolean;
  107495. /** @hidden */
  107496. _areTexturesDirty: boolean;
  107497. }
  107498. /**
  107499. * Define the code related to the Sheen parameters of the pbr material.
  107500. */
  107501. export class PBRSheenConfiguration {
  107502. private _isEnabled;
  107503. /**
  107504. * Defines if the material uses sheen.
  107505. */
  107506. isEnabled: boolean;
  107507. private _linkSheenWithAlbedo;
  107508. /**
  107509. * Defines if the sheen is linked to the sheen color.
  107510. */
  107511. linkSheenWithAlbedo: boolean;
  107512. /**
  107513. * Defines the sheen intensity.
  107514. */
  107515. intensity: number;
  107516. /**
  107517. * Defines the sheen color.
  107518. */
  107519. color: Color3;
  107520. private _texture;
  107521. /**
  107522. * Stores the sheen tint values in a texture.
  107523. * rgb is tint
  107524. * a is a intensity
  107525. */
  107526. texture: Nullable<BaseTexture>;
  107527. /** @hidden */
  107528. private _internalMarkAllSubMeshesAsTexturesDirty;
  107529. /** @hidden */
  107530. _markAllSubMeshesAsTexturesDirty(): void;
  107531. /**
  107532. * Instantiate a new istance of clear coat configuration.
  107533. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  107534. */
  107535. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  107536. /**
  107537. * Specifies that the submesh is ready to be used.
  107538. * @param defines the list of "defines" to update.
  107539. * @param scene defines the scene the material belongs to.
  107540. * @returns - boolean indicating that the submesh is ready or not.
  107541. */
  107542. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  107543. /**
  107544. * Checks to see if a texture is used in the material.
  107545. * @param defines the list of "defines" to update.
  107546. * @param scene defines the scene the material belongs to.
  107547. */
  107548. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  107549. /**
  107550. * Binds the material data.
  107551. * @param uniformBuffer defines the Uniform buffer to fill in.
  107552. * @param scene defines the scene the material belongs to.
  107553. * @param isFrozen defines wether the material is frozen or not.
  107554. */
  107555. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  107556. /**
  107557. * Checks to see if a texture is used in the material.
  107558. * @param texture - Base texture to use.
  107559. * @returns - Boolean specifying if a texture is used in the material.
  107560. */
  107561. hasTexture(texture: BaseTexture): boolean;
  107562. /**
  107563. * Returns an array of the actively used textures.
  107564. * @param activeTextures Array of BaseTextures
  107565. */
  107566. getActiveTextures(activeTextures: BaseTexture[]): void;
  107567. /**
  107568. * Returns the animatable textures.
  107569. * @param animatables Array of animatable textures.
  107570. */
  107571. getAnimatables(animatables: IAnimatable[]): void;
  107572. /**
  107573. * Disposes the resources of the material.
  107574. * @param forceDisposeTextures - Forces the disposal of all textures.
  107575. */
  107576. dispose(forceDisposeTextures?: boolean): void;
  107577. /**
  107578. * Get the current class name of the texture useful for serialization or dynamic coding.
  107579. * @returns "PBRSheenConfiguration"
  107580. */
  107581. getClassName(): string;
  107582. /**
  107583. * Add fallbacks to the effect fallbacks list.
  107584. * @param defines defines the Base texture to use.
  107585. * @param fallbacks defines the current fallback list.
  107586. * @param currentRank defines the current fallback rank.
  107587. * @returns the new fallback rank.
  107588. */
  107589. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  107590. /**
  107591. * Add the required uniforms to the current list.
  107592. * @param uniforms defines the current uniform list.
  107593. */
  107594. static AddUniforms(uniforms: string[]): void;
  107595. /**
  107596. * Add the required uniforms to the current buffer.
  107597. * @param uniformBuffer defines the current uniform buffer.
  107598. */
  107599. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  107600. /**
  107601. * Add the required samplers to the current list.
  107602. * @param samplers defines the current sampler list.
  107603. */
  107604. static AddSamplers(samplers: string[]): void;
  107605. /**
  107606. * Makes a duplicate of the current configuration into another one.
  107607. * @param sheenConfiguration define the config where to copy the info
  107608. */
  107609. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  107610. /**
  107611. * Serializes this BRDF configuration.
  107612. * @returns - An object with the serialized config.
  107613. */
  107614. serialize(): any;
  107615. /**
  107616. * Parses a Sheen Configuration from a serialized object.
  107617. * @param source - Serialized object.
  107618. */
  107619. parse(source: any): void;
  107620. }
  107621. }
  107622. declare module BABYLON {
  107623. /**
  107624. * @hidden
  107625. */
  107626. export interface IMaterialSubSurfaceDefines {
  107627. SUBSURFACE: boolean;
  107628. SS_REFRACTION: boolean;
  107629. SS_TRANSLUCENCY: boolean;
  107630. SS_SCATERRING: boolean;
  107631. SS_THICKNESSANDMASK_TEXTURE: boolean;
  107632. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  107633. SS_REFRACTIONMAP_3D: boolean;
  107634. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  107635. SS_LODINREFRACTIONALPHA: boolean;
  107636. SS_GAMMAREFRACTION: boolean;
  107637. SS_RGBDREFRACTION: boolean;
  107638. SS_LINEARSPECULARREFRACTION: boolean;
  107639. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  107640. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  107641. /** @hidden */
  107642. _areTexturesDirty: boolean;
  107643. }
  107644. /**
  107645. * Define the code related to the sub surface parameters of the pbr material.
  107646. */
  107647. export class PBRSubSurfaceConfiguration {
  107648. private _isRefractionEnabled;
  107649. /**
  107650. * Defines if the refraction is enabled in the material.
  107651. */
  107652. isRefractionEnabled: boolean;
  107653. private _isTranslucencyEnabled;
  107654. /**
  107655. * Defines if the translucency is enabled in the material.
  107656. */
  107657. isTranslucencyEnabled: boolean;
  107658. private _isScatteringEnabled;
  107659. /**
  107660. * Defines the refraction intensity of the material.
  107661. * The refraction when enabled replaces the Diffuse part of the material.
  107662. * The intensity helps transitionning between diffuse and refraction.
  107663. */
  107664. refractionIntensity: number;
  107665. /**
  107666. * Defines the translucency intensity of the material.
  107667. * When translucency has been enabled, this defines how much of the "translucency"
  107668. * is addded to the diffuse part of the material.
  107669. */
  107670. translucencyIntensity: number;
  107671. /**
  107672. * Defines the scattering intensity of the material.
  107673. * When scattering has been enabled, this defines how much of the "scattered light"
  107674. * is addded to the diffuse part of the material.
  107675. */
  107676. scatteringIntensity: number;
  107677. private _thicknessTexture;
  107678. /**
  107679. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  107680. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  107681. * 0 would mean minimumThickness
  107682. * 1 would mean maximumThickness
  107683. * The other channels might be use as a mask to vary the different effects intensity.
  107684. */
  107685. thicknessTexture: Nullable<BaseTexture>;
  107686. private _refractionTexture;
  107687. /**
  107688. * Defines the texture to use for refraction.
  107689. */
  107690. refractionTexture: Nullable<BaseTexture>;
  107691. private _indexOfRefraction;
  107692. /**
  107693. * Defines the index of refraction used in the material.
  107694. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  107695. */
  107696. indexOfRefraction: number;
  107697. private _invertRefractionY;
  107698. /**
  107699. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  107700. */
  107701. invertRefractionY: boolean;
  107702. private _linkRefractionWithTransparency;
  107703. /**
  107704. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  107705. * Materials half opaque for instance using refraction could benefit from this control.
  107706. */
  107707. linkRefractionWithTransparency: boolean;
  107708. /**
  107709. * Defines the minimum thickness stored in the thickness map.
  107710. * If no thickness map is defined, this value will be used to simulate thickness.
  107711. */
  107712. minimumThickness: number;
  107713. /**
  107714. * Defines the maximum thickness stored in the thickness map.
  107715. */
  107716. maximumThickness: number;
  107717. /**
  107718. * Defines the volume tint of the material.
  107719. * This is used for both translucency and scattering.
  107720. */
  107721. tintColor: Color3;
  107722. /**
  107723. * Defines the distance at which the tint color should be found in the media.
  107724. * This is used for refraction only.
  107725. */
  107726. tintColorAtDistance: number;
  107727. /**
  107728. * Defines how far each channel transmit through the media.
  107729. * It is defined as a color to simplify it selection.
  107730. */
  107731. diffusionDistance: Color3;
  107732. private _useMaskFromThicknessTexture;
  107733. /**
  107734. * Stores the intensity of the different subsurface effects in the thickness texture.
  107735. * * the green channel is the translucency intensity.
  107736. * * the blue channel is the scattering intensity.
  107737. * * the alpha channel is the refraction intensity.
  107738. */
  107739. useMaskFromThicknessTexture: boolean;
  107740. /** @hidden */
  107741. private _internalMarkAllSubMeshesAsTexturesDirty;
  107742. /** @hidden */
  107743. _markAllSubMeshesAsTexturesDirty(): void;
  107744. /**
  107745. * Instantiate a new istance of sub surface configuration.
  107746. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  107747. */
  107748. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  107749. /**
  107750. * Gets wehter the submesh is ready to be used or not.
  107751. * @param defines the list of "defines" to update.
  107752. * @param scene defines the scene the material belongs to.
  107753. * @returns - boolean indicating that the submesh is ready or not.
  107754. */
  107755. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  107756. /**
  107757. * Checks to see if a texture is used in the material.
  107758. * @param defines the list of "defines" to update.
  107759. * @param scene defines the scene to the material belongs to.
  107760. */
  107761. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  107762. /**
  107763. * Binds the material data.
  107764. * @param uniformBuffer defines the Uniform buffer to fill in.
  107765. * @param scene defines the scene the material belongs to.
  107766. * @param engine defines the engine the material belongs to.
  107767. * @param isFrozen defines wether the material is frozen or not.
  107768. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  107769. */
  107770. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  107771. /**
  107772. * Unbinds the material from the mesh.
  107773. * @param activeEffect defines the effect that should be unbound from.
  107774. * @returns true if unbound, otherwise false
  107775. */
  107776. unbind(activeEffect: Effect): boolean;
  107777. /**
  107778. * Returns the texture used for refraction or null if none is used.
  107779. * @param scene defines the scene the material belongs to.
  107780. * @returns - Refraction texture if present. If no refraction texture and refraction
  107781. * is linked with transparency, returns environment texture. Otherwise, returns null.
  107782. */
  107783. private _getRefractionTexture;
  107784. /**
  107785. * Returns true if alpha blending should be disabled.
  107786. */
  107787. readonly disableAlphaBlending: boolean;
  107788. /**
  107789. * Fills the list of render target textures.
  107790. * @param renderTargets the list of render targets to update
  107791. */
  107792. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  107793. /**
  107794. * Checks to see if a texture is used in the material.
  107795. * @param texture - Base texture to use.
  107796. * @returns - Boolean specifying if a texture is used in the material.
  107797. */
  107798. hasTexture(texture: BaseTexture): boolean;
  107799. /**
  107800. * Gets a boolean indicating that current material needs to register RTT
  107801. * @returns true if this uses a render target otherwise false.
  107802. */
  107803. hasRenderTargetTextures(): boolean;
  107804. /**
  107805. * Returns an array of the actively used textures.
  107806. * @param activeTextures Array of BaseTextures
  107807. */
  107808. getActiveTextures(activeTextures: BaseTexture[]): void;
  107809. /**
  107810. * Returns the animatable textures.
  107811. * @param animatables Array of animatable textures.
  107812. */
  107813. getAnimatables(animatables: IAnimatable[]): void;
  107814. /**
  107815. * Disposes the resources of the material.
  107816. * @param forceDisposeTextures - Forces the disposal of all textures.
  107817. */
  107818. dispose(forceDisposeTextures?: boolean): void;
  107819. /**
  107820. * Get the current class name of the texture useful for serialization or dynamic coding.
  107821. * @returns "PBRSubSurfaceConfiguration"
  107822. */
  107823. getClassName(): string;
  107824. /**
  107825. * Add fallbacks to the effect fallbacks list.
  107826. * @param defines defines the Base texture to use.
  107827. * @param fallbacks defines the current fallback list.
  107828. * @param currentRank defines the current fallback rank.
  107829. * @returns the new fallback rank.
  107830. */
  107831. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  107832. /**
  107833. * Add the required uniforms to the current list.
  107834. * @param uniforms defines the current uniform list.
  107835. */
  107836. static AddUniforms(uniforms: string[]): void;
  107837. /**
  107838. * Add the required samplers to the current list.
  107839. * @param samplers defines the current sampler list.
  107840. */
  107841. static AddSamplers(samplers: string[]): void;
  107842. /**
  107843. * Add the required uniforms to the current buffer.
  107844. * @param uniformBuffer defines the current uniform buffer.
  107845. */
  107846. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  107847. /**
  107848. * Makes a duplicate of the current configuration into another one.
  107849. * @param configuration define the config where to copy the info
  107850. */
  107851. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  107852. /**
  107853. * Serializes this Sub Surface configuration.
  107854. * @returns - An object with the serialized config.
  107855. */
  107856. serialize(): any;
  107857. /**
  107858. * Parses a Sub Surface Configuration from a serialized object.
  107859. * @param source - Serialized object.
  107860. */
  107861. parse(source: any): void;
  107862. }
  107863. }
  107864. declare module BABYLON {
  107865. /** @hidden */
  107866. export var pbrFragmentDeclaration: {
  107867. name: string;
  107868. shader: string;
  107869. };
  107870. }
  107871. declare module BABYLON {
  107872. /** @hidden */
  107873. export var pbrUboDeclaration: {
  107874. name: string;
  107875. shader: string;
  107876. };
  107877. }
  107878. declare module BABYLON {
  107879. /** @hidden */
  107880. export var pbrFragmentExtraDeclaration: {
  107881. name: string;
  107882. shader: string;
  107883. };
  107884. }
  107885. declare module BABYLON {
  107886. /** @hidden */
  107887. export var pbrFragmentSamplersDeclaration: {
  107888. name: string;
  107889. shader: string;
  107890. };
  107891. }
  107892. declare module BABYLON {
  107893. /** @hidden */
  107894. export var pbrHelperFunctions: {
  107895. name: string;
  107896. shader: string;
  107897. };
  107898. }
  107899. declare module BABYLON {
  107900. /** @hidden */
  107901. export var harmonicsFunctions: {
  107902. name: string;
  107903. shader: string;
  107904. };
  107905. }
  107906. declare module BABYLON {
  107907. /** @hidden */
  107908. export var pbrDirectLightingSetupFunctions: {
  107909. name: string;
  107910. shader: string;
  107911. };
  107912. }
  107913. declare module BABYLON {
  107914. /** @hidden */
  107915. export var pbrDirectLightingFalloffFunctions: {
  107916. name: string;
  107917. shader: string;
  107918. };
  107919. }
  107920. declare module BABYLON {
  107921. /** @hidden */
  107922. export var pbrBRDFFunctions: {
  107923. name: string;
  107924. shader: string;
  107925. };
  107926. }
  107927. declare module BABYLON {
  107928. /** @hidden */
  107929. export var pbrDirectLightingFunctions: {
  107930. name: string;
  107931. shader: string;
  107932. };
  107933. }
  107934. declare module BABYLON {
  107935. /** @hidden */
  107936. export var pbrIBLFunctions: {
  107937. name: string;
  107938. shader: string;
  107939. };
  107940. }
  107941. declare module BABYLON {
  107942. /** @hidden */
  107943. export var pbrDebug: {
  107944. name: string;
  107945. shader: string;
  107946. };
  107947. }
  107948. declare module BABYLON {
  107949. /** @hidden */
  107950. export var pbrPixelShader: {
  107951. name: string;
  107952. shader: string;
  107953. };
  107954. }
  107955. declare module BABYLON {
  107956. /** @hidden */
  107957. export var pbrVertexDeclaration: {
  107958. name: string;
  107959. shader: string;
  107960. };
  107961. }
  107962. declare module BABYLON {
  107963. /** @hidden */
  107964. export var pbrVertexShader: {
  107965. name: string;
  107966. shader: string;
  107967. };
  107968. }
  107969. declare module BABYLON {
  107970. /**
  107971. * Manages the defines for the PBR Material.
  107972. * @hidden
  107973. */
  107974. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  107975. PBR: boolean;
  107976. MAINUV1: boolean;
  107977. MAINUV2: boolean;
  107978. UV1: boolean;
  107979. UV2: boolean;
  107980. ALBEDO: boolean;
  107981. ALBEDODIRECTUV: number;
  107982. VERTEXCOLOR: boolean;
  107983. AMBIENT: boolean;
  107984. AMBIENTDIRECTUV: number;
  107985. AMBIENTINGRAYSCALE: boolean;
  107986. OPACITY: boolean;
  107987. VERTEXALPHA: boolean;
  107988. OPACITYDIRECTUV: number;
  107989. OPACITYRGB: boolean;
  107990. ALPHATEST: boolean;
  107991. DEPTHPREPASS: boolean;
  107992. ALPHABLEND: boolean;
  107993. ALPHAFROMALBEDO: boolean;
  107994. ALPHATESTVALUE: string;
  107995. SPECULAROVERALPHA: boolean;
  107996. RADIANCEOVERALPHA: boolean;
  107997. ALPHAFRESNEL: boolean;
  107998. LINEARALPHAFRESNEL: boolean;
  107999. PREMULTIPLYALPHA: boolean;
  108000. EMISSIVE: boolean;
  108001. EMISSIVEDIRECTUV: number;
  108002. REFLECTIVITY: boolean;
  108003. REFLECTIVITYDIRECTUV: number;
  108004. SPECULARTERM: boolean;
  108005. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  108006. MICROSURFACEAUTOMATIC: boolean;
  108007. LODBASEDMICROSFURACE: boolean;
  108008. MICROSURFACEMAP: boolean;
  108009. MICROSURFACEMAPDIRECTUV: number;
  108010. METALLICWORKFLOW: boolean;
  108011. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  108012. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  108013. METALLNESSSTOREINMETALMAPBLUE: boolean;
  108014. AOSTOREINMETALMAPRED: boolean;
  108015. ENVIRONMENTBRDF: boolean;
  108016. ENVIRONMENTBRDF_RGBD: boolean;
  108017. NORMAL: boolean;
  108018. TANGENT: boolean;
  108019. BUMP: boolean;
  108020. BUMPDIRECTUV: number;
  108021. OBJECTSPACE_NORMALMAP: boolean;
  108022. PARALLAX: boolean;
  108023. PARALLAXOCCLUSION: boolean;
  108024. NORMALXYSCALE: boolean;
  108025. LIGHTMAP: boolean;
  108026. LIGHTMAPDIRECTUV: number;
  108027. USELIGHTMAPASSHADOWMAP: boolean;
  108028. GAMMALIGHTMAP: boolean;
  108029. REFLECTION: boolean;
  108030. REFLECTIONMAP_3D: boolean;
  108031. REFLECTIONMAP_SPHERICAL: boolean;
  108032. REFLECTIONMAP_PLANAR: boolean;
  108033. REFLECTIONMAP_CUBIC: boolean;
  108034. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  108035. REFLECTIONMAP_PROJECTION: boolean;
  108036. REFLECTIONMAP_SKYBOX: boolean;
  108037. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  108038. REFLECTIONMAP_EXPLICIT: boolean;
  108039. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  108040. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  108041. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  108042. INVERTCUBICMAP: boolean;
  108043. USESPHERICALFROMREFLECTIONMAP: boolean;
  108044. USEIRRADIANCEMAP: boolean;
  108045. SPHERICAL_HARMONICS: boolean;
  108046. USESPHERICALINVERTEX: boolean;
  108047. REFLECTIONMAP_OPPOSITEZ: boolean;
  108048. LODINREFLECTIONALPHA: boolean;
  108049. GAMMAREFLECTION: boolean;
  108050. RGBDREFLECTION: boolean;
  108051. LINEARSPECULARREFLECTION: boolean;
  108052. RADIANCEOCCLUSION: boolean;
  108053. HORIZONOCCLUSION: boolean;
  108054. INSTANCES: boolean;
  108055. NUM_BONE_INFLUENCERS: number;
  108056. BonesPerMesh: number;
  108057. BONETEXTURE: boolean;
  108058. NONUNIFORMSCALING: boolean;
  108059. MORPHTARGETS: boolean;
  108060. MORPHTARGETS_NORMAL: boolean;
  108061. MORPHTARGETS_TANGENT: boolean;
  108062. NUM_MORPH_INFLUENCERS: number;
  108063. IMAGEPROCESSING: boolean;
  108064. VIGNETTE: boolean;
  108065. VIGNETTEBLENDMODEMULTIPLY: boolean;
  108066. VIGNETTEBLENDMODEOPAQUE: boolean;
  108067. TONEMAPPING: boolean;
  108068. TONEMAPPING_ACES: boolean;
  108069. CONTRAST: boolean;
  108070. COLORCURVES: boolean;
  108071. COLORGRADING: boolean;
  108072. COLORGRADING3D: boolean;
  108073. SAMPLER3DGREENDEPTH: boolean;
  108074. SAMPLER3DBGRMAP: boolean;
  108075. IMAGEPROCESSINGPOSTPROCESS: boolean;
  108076. EXPOSURE: boolean;
  108077. MULTIVIEW: boolean;
  108078. USEPHYSICALLIGHTFALLOFF: boolean;
  108079. USEGLTFLIGHTFALLOFF: boolean;
  108080. TWOSIDEDLIGHTING: boolean;
  108081. SHADOWFLOAT: boolean;
  108082. CLIPPLANE: boolean;
  108083. CLIPPLANE2: boolean;
  108084. CLIPPLANE3: boolean;
  108085. CLIPPLANE4: boolean;
  108086. POINTSIZE: boolean;
  108087. FOG: boolean;
  108088. LOGARITHMICDEPTH: boolean;
  108089. FORCENORMALFORWARD: boolean;
  108090. SPECULARAA: boolean;
  108091. CLEARCOAT: boolean;
  108092. CLEARCOAT_DEFAULTIOR: boolean;
  108093. CLEARCOAT_TEXTURE: boolean;
  108094. CLEARCOAT_TEXTUREDIRECTUV: number;
  108095. CLEARCOAT_BUMP: boolean;
  108096. CLEARCOAT_BUMPDIRECTUV: number;
  108097. CLEARCOAT_TINT: boolean;
  108098. CLEARCOAT_TINT_TEXTURE: boolean;
  108099. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  108100. ANISOTROPIC: boolean;
  108101. ANISOTROPIC_TEXTURE: boolean;
  108102. ANISOTROPIC_TEXTUREDIRECTUV: number;
  108103. BRDF_V_HEIGHT_CORRELATED: boolean;
  108104. MS_BRDF_ENERGY_CONSERVATION: boolean;
  108105. SHEEN: boolean;
  108106. SHEEN_TEXTURE: boolean;
  108107. SHEEN_TEXTUREDIRECTUV: number;
  108108. SHEEN_LINKWITHALBEDO: boolean;
  108109. SUBSURFACE: boolean;
  108110. SS_REFRACTION: boolean;
  108111. SS_TRANSLUCENCY: boolean;
  108112. SS_SCATERRING: boolean;
  108113. SS_THICKNESSANDMASK_TEXTURE: boolean;
  108114. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  108115. SS_REFRACTIONMAP_3D: boolean;
  108116. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  108117. SS_LODINREFRACTIONALPHA: boolean;
  108118. SS_GAMMAREFRACTION: boolean;
  108119. SS_RGBDREFRACTION: boolean;
  108120. SS_LINEARSPECULARREFRACTION: boolean;
  108121. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  108122. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  108123. UNLIT: boolean;
  108124. DEBUGMODE: number;
  108125. /**
  108126. * Initializes the PBR Material defines.
  108127. */
  108128. constructor();
  108129. /**
  108130. * Resets the PBR Material defines.
  108131. */
  108132. reset(): void;
  108133. }
  108134. /**
  108135. * The Physically based material base class of BJS.
  108136. *
  108137. * This offers the main features of a standard PBR material.
  108138. * For more information, please refer to the documentation :
  108139. * https://doc.babylonjs.com/how_to/physically_based_rendering
  108140. */
  108141. export abstract class PBRBaseMaterial extends PushMaterial {
  108142. /**
  108143. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  108144. */
  108145. static readonly PBRMATERIAL_OPAQUE: number;
  108146. /**
  108147. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  108148. */
  108149. static readonly PBRMATERIAL_ALPHATEST: number;
  108150. /**
  108151. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  108152. */
  108153. static readonly PBRMATERIAL_ALPHABLEND: number;
  108154. /**
  108155. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  108156. * They are also discarded below the alpha cutoff threshold to improve performances.
  108157. */
  108158. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  108159. /**
  108160. * Defines the default value of how much AO map is occluding the analytical lights
  108161. * (point spot...).
  108162. */
  108163. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  108164. /**
  108165. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  108166. */
  108167. static readonly LIGHTFALLOFF_PHYSICAL: number;
  108168. /**
  108169. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  108170. * to enhance interoperability with other engines.
  108171. */
  108172. static readonly LIGHTFALLOFF_GLTF: number;
  108173. /**
  108174. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  108175. * to enhance interoperability with other materials.
  108176. */
  108177. static readonly LIGHTFALLOFF_STANDARD: number;
  108178. /**
  108179. * Intensity of the direct lights e.g. the four lights available in your scene.
  108180. * This impacts both the direct diffuse and specular highlights.
  108181. */
  108182. protected _directIntensity: number;
  108183. /**
  108184. * Intensity of the emissive part of the material.
  108185. * This helps controlling the emissive effect without modifying the emissive color.
  108186. */
  108187. protected _emissiveIntensity: number;
  108188. /**
  108189. * Intensity of the environment e.g. how much the environment will light the object
  108190. * either through harmonics for rough material or through the refelction for shiny ones.
  108191. */
  108192. protected _environmentIntensity: number;
  108193. /**
  108194. * This is a special control allowing the reduction of the specular highlights coming from the
  108195. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  108196. */
  108197. protected _specularIntensity: number;
  108198. /**
  108199. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  108200. */
  108201. private _lightingInfos;
  108202. /**
  108203. * Debug Control allowing disabling the bump map on this material.
  108204. */
  108205. protected _disableBumpMap: boolean;
  108206. /**
  108207. * AKA Diffuse Texture in standard nomenclature.
  108208. */
  108209. protected _albedoTexture: Nullable<BaseTexture>;
  108210. /**
  108211. * AKA Occlusion Texture in other nomenclature.
  108212. */
  108213. protected _ambientTexture: Nullable<BaseTexture>;
  108214. /**
  108215. * AKA Occlusion Texture Intensity in other nomenclature.
  108216. */
  108217. protected _ambientTextureStrength: number;
  108218. /**
  108219. * Defines how much the AO map is occluding the analytical lights (point spot...).
  108220. * 1 means it completely occludes it
  108221. * 0 mean it has no impact
  108222. */
  108223. protected _ambientTextureImpactOnAnalyticalLights: number;
  108224. /**
  108225. * Stores the alpha values in a texture.
  108226. */
  108227. protected _opacityTexture: Nullable<BaseTexture>;
  108228. /**
  108229. * Stores the reflection values in a texture.
  108230. */
  108231. protected _reflectionTexture: Nullable<BaseTexture>;
  108232. /**
  108233. * Stores the emissive values in a texture.
  108234. */
  108235. protected _emissiveTexture: Nullable<BaseTexture>;
  108236. /**
  108237. * AKA Specular texture in other nomenclature.
  108238. */
  108239. protected _reflectivityTexture: Nullable<BaseTexture>;
  108240. /**
  108241. * Used to switch from specular/glossiness to metallic/roughness workflow.
  108242. */
  108243. protected _metallicTexture: Nullable<BaseTexture>;
  108244. /**
  108245. * Specifies the metallic scalar of the metallic/roughness workflow.
  108246. * Can also be used to scale the metalness values of the metallic texture.
  108247. */
  108248. protected _metallic: Nullable<number>;
  108249. /**
  108250. * Specifies the roughness scalar of the metallic/roughness workflow.
  108251. * Can also be used to scale the roughness values of the metallic texture.
  108252. */
  108253. protected _roughness: Nullable<number>;
  108254. /**
  108255. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  108256. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  108257. */
  108258. protected _microSurfaceTexture: Nullable<BaseTexture>;
  108259. /**
  108260. * Stores surface normal data used to displace a mesh in a texture.
  108261. */
  108262. protected _bumpTexture: Nullable<BaseTexture>;
  108263. /**
  108264. * Stores the pre-calculated light information of a mesh in a texture.
  108265. */
  108266. protected _lightmapTexture: Nullable<BaseTexture>;
  108267. /**
  108268. * The color of a material in ambient lighting.
  108269. */
  108270. protected _ambientColor: Color3;
  108271. /**
  108272. * AKA Diffuse Color in other nomenclature.
  108273. */
  108274. protected _albedoColor: Color3;
  108275. /**
  108276. * AKA Specular Color in other nomenclature.
  108277. */
  108278. protected _reflectivityColor: Color3;
  108279. /**
  108280. * The color applied when light is reflected from a material.
  108281. */
  108282. protected _reflectionColor: Color3;
  108283. /**
  108284. * The color applied when light is emitted from a material.
  108285. */
  108286. protected _emissiveColor: Color3;
  108287. /**
  108288. * AKA Glossiness in other nomenclature.
  108289. */
  108290. protected _microSurface: number;
  108291. /**
  108292. * Specifies that the material will use the light map as a show map.
  108293. */
  108294. protected _useLightmapAsShadowmap: boolean;
  108295. /**
  108296. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  108297. * makes the reflect vector face the model (under horizon).
  108298. */
  108299. protected _useHorizonOcclusion: boolean;
  108300. /**
  108301. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  108302. * too much the area relying on ambient texture to define their ambient occlusion.
  108303. */
  108304. protected _useRadianceOcclusion: boolean;
  108305. /**
  108306. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  108307. */
  108308. protected _useAlphaFromAlbedoTexture: boolean;
  108309. /**
  108310. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  108311. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  108312. */
  108313. protected _useSpecularOverAlpha: boolean;
  108314. /**
  108315. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  108316. */
  108317. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  108318. /**
  108319. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  108320. */
  108321. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  108322. /**
  108323. * Specifies if the metallic texture contains the roughness information in its green channel.
  108324. */
  108325. protected _useRoughnessFromMetallicTextureGreen: boolean;
  108326. /**
  108327. * Specifies if the metallic texture contains the metallness information in its blue channel.
  108328. */
  108329. protected _useMetallnessFromMetallicTextureBlue: boolean;
  108330. /**
  108331. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  108332. */
  108333. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  108334. /**
  108335. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  108336. */
  108337. protected _useAmbientInGrayScale: boolean;
  108338. /**
  108339. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  108340. * The material will try to infer what glossiness each pixel should be.
  108341. */
  108342. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  108343. /**
  108344. * Defines the falloff type used in this material.
  108345. * It by default is Physical.
  108346. */
  108347. protected _lightFalloff: number;
  108348. /**
  108349. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  108350. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  108351. */
  108352. protected _useRadianceOverAlpha: boolean;
  108353. /**
  108354. * Allows using an object space normal map (instead of tangent space).
  108355. */
  108356. protected _useObjectSpaceNormalMap: boolean;
  108357. /**
  108358. * Allows using the bump map in parallax mode.
  108359. */
  108360. protected _useParallax: boolean;
  108361. /**
  108362. * Allows using the bump map in parallax occlusion mode.
  108363. */
  108364. protected _useParallaxOcclusion: boolean;
  108365. /**
  108366. * Controls the scale bias of the parallax mode.
  108367. */
  108368. protected _parallaxScaleBias: number;
  108369. /**
  108370. * If sets to true, disables all the lights affecting the material.
  108371. */
  108372. protected _disableLighting: boolean;
  108373. /**
  108374. * Number of Simultaneous lights allowed on the material.
  108375. */
  108376. protected _maxSimultaneousLights: number;
  108377. /**
  108378. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  108379. */
  108380. protected _invertNormalMapX: boolean;
  108381. /**
  108382. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  108383. */
  108384. protected _invertNormalMapY: boolean;
  108385. /**
  108386. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  108387. */
  108388. protected _twoSidedLighting: boolean;
  108389. /**
  108390. * Defines the alpha limits in alpha test mode.
  108391. */
  108392. protected _alphaCutOff: number;
  108393. /**
  108394. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  108395. */
  108396. protected _forceAlphaTest: boolean;
  108397. /**
  108398. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  108399. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  108400. */
  108401. protected _useAlphaFresnel: boolean;
  108402. /**
  108403. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  108404. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  108405. */
  108406. protected _useLinearAlphaFresnel: boolean;
  108407. /**
  108408. * The transparency mode of the material.
  108409. */
  108410. protected _transparencyMode: Nullable<number>;
  108411. /**
  108412. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  108413. * from cos thetav and roughness:
  108414. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  108415. */
  108416. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  108417. /**
  108418. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  108419. */
  108420. protected _forceIrradianceInFragment: boolean;
  108421. /**
  108422. * Force normal to face away from face.
  108423. */
  108424. protected _forceNormalForward: boolean;
  108425. /**
  108426. * Enables specular anti aliasing in the PBR shader.
  108427. * It will both interacts on the Geometry for analytical and IBL lighting.
  108428. * It also prefilter the roughness map based on the bump values.
  108429. */
  108430. protected _enableSpecularAntiAliasing: boolean;
  108431. /**
  108432. * Default configuration related to image processing available in the PBR Material.
  108433. */
  108434. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  108435. /**
  108436. * Keep track of the image processing observer to allow dispose and replace.
  108437. */
  108438. private _imageProcessingObserver;
  108439. /**
  108440. * Attaches a new image processing configuration to the PBR Material.
  108441. * @param configuration
  108442. */
  108443. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  108444. /**
  108445. * Stores the available render targets.
  108446. */
  108447. private _renderTargets;
  108448. /**
  108449. * Sets the global ambient color for the material used in lighting calculations.
  108450. */
  108451. private _globalAmbientColor;
  108452. /**
  108453. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  108454. */
  108455. private _useLogarithmicDepth;
  108456. /**
  108457. * If set to true, no lighting calculations will be applied.
  108458. */
  108459. private _unlit;
  108460. private _debugMode;
  108461. /**
  108462. * @hidden
  108463. * This is reserved for the inspector.
  108464. * Defines the material debug mode.
  108465. * It helps seeing only some components of the material while troubleshooting.
  108466. */
  108467. debugMode: number;
  108468. /**
  108469. * @hidden
  108470. * This is reserved for the inspector.
  108471. * Specify from where on screen the debug mode should start.
  108472. * The value goes from -1 (full screen) to 1 (not visible)
  108473. * It helps with side by side comparison against the final render
  108474. * This defaults to -1
  108475. */
  108476. private debugLimit;
  108477. /**
  108478. * @hidden
  108479. * This is reserved for the inspector.
  108480. * As the default viewing range might not be enough (if the ambient is really small for instance)
  108481. * You can use the factor to better multiply the final value.
  108482. */
  108483. private debugFactor;
  108484. /**
  108485. * Defines the clear coat layer parameters for the material.
  108486. */
  108487. readonly clearCoat: PBRClearCoatConfiguration;
  108488. /**
  108489. * Defines the anisotropic parameters for the material.
  108490. */
  108491. readonly anisotropy: PBRAnisotropicConfiguration;
  108492. /**
  108493. * Defines the BRDF parameters for the material.
  108494. */
  108495. readonly brdf: PBRBRDFConfiguration;
  108496. /**
  108497. * Defines the Sheen parameters for the material.
  108498. */
  108499. readonly sheen: PBRSheenConfiguration;
  108500. /**
  108501. * Defines the SubSurface parameters for the material.
  108502. */
  108503. readonly subSurface: PBRSubSurfaceConfiguration;
  108504. /**
  108505. * Custom callback helping to override the default shader used in the material.
  108506. */
  108507. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  108508. /**
  108509. * Instantiates a new PBRMaterial instance.
  108510. *
  108511. * @param name The material name
  108512. * @param scene The scene the material will be use in.
  108513. */
  108514. constructor(name: string, scene: Scene);
  108515. /**
  108516. * Gets a boolean indicating that current material needs to register RTT
  108517. */
  108518. readonly hasRenderTargetTextures: boolean;
  108519. /**
  108520. * Gets the name of the material class.
  108521. */
  108522. getClassName(): string;
  108523. /**
  108524. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  108525. */
  108526. /**
  108527. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  108528. */
  108529. useLogarithmicDepth: boolean;
  108530. /**
  108531. * Gets the current transparency mode.
  108532. */
  108533. /**
  108534. * Sets the transparency mode of the material.
  108535. *
  108536. * | Value | Type | Description |
  108537. * | ----- | ----------------------------------- | ----------- |
  108538. * | 0 | OPAQUE | |
  108539. * | 1 | ALPHATEST | |
  108540. * | 2 | ALPHABLEND | |
  108541. * | 3 | ALPHATESTANDBLEND | |
  108542. *
  108543. */
  108544. transparencyMode: Nullable<number>;
  108545. /**
  108546. * Returns true if alpha blending should be disabled.
  108547. */
  108548. private readonly _disableAlphaBlending;
  108549. /**
  108550. * Specifies whether or not this material should be rendered in alpha blend mode.
  108551. */
  108552. needAlphaBlending(): boolean;
  108553. /**
  108554. * Specifies if the mesh will require alpha blending.
  108555. * @param mesh - BJS mesh.
  108556. */
  108557. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  108558. /**
  108559. * Specifies whether or not this material should be rendered in alpha test mode.
  108560. */
  108561. needAlphaTesting(): boolean;
  108562. /**
  108563. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  108564. */
  108565. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  108566. /**
  108567. * Gets the texture used for the alpha test.
  108568. */
  108569. getAlphaTestTexture(): Nullable<BaseTexture>;
  108570. /**
  108571. * Specifies that the submesh is ready to be used.
  108572. * @param mesh - BJS mesh.
  108573. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  108574. * @param useInstances - Specifies that instances should be used.
  108575. * @returns - boolean indicating that the submesh is ready or not.
  108576. */
  108577. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  108578. /**
  108579. * Specifies if the material uses metallic roughness workflow.
  108580. * @returns boolean specifiying if the material uses metallic roughness workflow.
  108581. */
  108582. isMetallicWorkflow(): boolean;
  108583. private _prepareEffect;
  108584. private _prepareDefines;
  108585. /**
  108586. * Force shader compilation
  108587. */
  108588. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  108589. clipPlane: boolean;
  108590. }>): void;
  108591. /**
  108592. * Initializes the uniform buffer layout for the shader.
  108593. */
  108594. buildUniformLayout(): void;
  108595. /**
  108596. * Unbinds the material from the mesh
  108597. */
  108598. unbind(): void;
  108599. /**
  108600. * Binds the submesh data.
  108601. * @param world - The world matrix.
  108602. * @param mesh - The BJS mesh.
  108603. * @param subMesh - A submesh of the BJS mesh.
  108604. */
  108605. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  108606. /**
  108607. * Returns the animatable textures.
  108608. * @returns - Array of animatable textures.
  108609. */
  108610. getAnimatables(): IAnimatable[];
  108611. /**
  108612. * Returns the texture used for reflections.
  108613. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  108614. */
  108615. private _getReflectionTexture;
  108616. /**
  108617. * Returns an array of the actively used textures.
  108618. * @returns - Array of BaseTextures
  108619. */
  108620. getActiveTextures(): BaseTexture[];
  108621. /**
  108622. * Checks to see if a texture is used in the material.
  108623. * @param texture - Base texture to use.
  108624. * @returns - Boolean specifying if a texture is used in the material.
  108625. */
  108626. hasTexture(texture: BaseTexture): boolean;
  108627. /**
  108628. * Disposes the resources of the material.
  108629. * @param forceDisposeEffect - Forces the disposal of effects.
  108630. * @param forceDisposeTextures - Forces the disposal of all textures.
  108631. */
  108632. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  108633. }
  108634. }
  108635. declare module BABYLON {
  108636. /**
  108637. * The Physically based material of BJS.
  108638. *
  108639. * This offers the main features of a standard PBR material.
  108640. * For more information, please refer to the documentation :
  108641. * https://doc.babylonjs.com/how_to/physically_based_rendering
  108642. */
  108643. export class PBRMaterial extends PBRBaseMaterial {
  108644. /**
  108645. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  108646. */
  108647. static readonly PBRMATERIAL_OPAQUE: number;
  108648. /**
  108649. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  108650. */
  108651. static readonly PBRMATERIAL_ALPHATEST: number;
  108652. /**
  108653. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  108654. */
  108655. static readonly PBRMATERIAL_ALPHABLEND: number;
  108656. /**
  108657. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  108658. * They are also discarded below the alpha cutoff threshold to improve performances.
  108659. */
  108660. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  108661. /**
  108662. * Defines the default value of how much AO map is occluding the analytical lights
  108663. * (point spot...).
  108664. */
  108665. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  108666. /**
  108667. * Intensity of the direct lights e.g. the four lights available in your scene.
  108668. * This impacts both the direct diffuse and specular highlights.
  108669. */
  108670. directIntensity: number;
  108671. /**
  108672. * Intensity of the emissive part of the material.
  108673. * This helps controlling the emissive effect without modifying the emissive color.
  108674. */
  108675. emissiveIntensity: number;
  108676. /**
  108677. * Intensity of the environment e.g. how much the environment will light the object
  108678. * either through harmonics for rough material or through the refelction for shiny ones.
  108679. */
  108680. environmentIntensity: number;
  108681. /**
  108682. * This is a special control allowing the reduction of the specular highlights coming from the
  108683. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  108684. */
  108685. specularIntensity: number;
  108686. /**
  108687. * Debug Control allowing disabling the bump map on this material.
  108688. */
  108689. disableBumpMap: boolean;
  108690. /**
  108691. * AKA Diffuse Texture in standard nomenclature.
  108692. */
  108693. albedoTexture: BaseTexture;
  108694. /**
  108695. * AKA Occlusion Texture in other nomenclature.
  108696. */
  108697. ambientTexture: BaseTexture;
  108698. /**
  108699. * AKA Occlusion Texture Intensity in other nomenclature.
  108700. */
  108701. ambientTextureStrength: number;
  108702. /**
  108703. * Defines how much the AO map is occluding the analytical lights (point spot...).
  108704. * 1 means it completely occludes it
  108705. * 0 mean it has no impact
  108706. */
  108707. ambientTextureImpactOnAnalyticalLights: number;
  108708. /**
  108709. * Stores the alpha values in a texture.
  108710. */
  108711. opacityTexture: BaseTexture;
  108712. /**
  108713. * Stores the reflection values in a texture.
  108714. */
  108715. reflectionTexture: Nullable<BaseTexture>;
  108716. /**
  108717. * Stores the emissive values in a texture.
  108718. */
  108719. emissiveTexture: BaseTexture;
  108720. /**
  108721. * AKA Specular texture in other nomenclature.
  108722. */
  108723. reflectivityTexture: BaseTexture;
  108724. /**
  108725. * Used to switch from specular/glossiness to metallic/roughness workflow.
  108726. */
  108727. metallicTexture: BaseTexture;
  108728. /**
  108729. * Specifies the metallic scalar of the metallic/roughness workflow.
  108730. * Can also be used to scale the metalness values of the metallic texture.
  108731. */
  108732. metallic: Nullable<number>;
  108733. /**
  108734. * Specifies the roughness scalar of the metallic/roughness workflow.
  108735. * Can also be used to scale the roughness values of the metallic texture.
  108736. */
  108737. roughness: Nullable<number>;
  108738. /**
  108739. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  108740. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  108741. */
  108742. microSurfaceTexture: BaseTexture;
  108743. /**
  108744. * Stores surface normal data used to displace a mesh in a texture.
  108745. */
  108746. bumpTexture: BaseTexture;
  108747. /**
  108748. * Stores the pre-calculated light information of a mesh in a texture.
  108749. */
  108750. lightmapTexture: BaseTexture;
  108751. /**
  108752. * Stores the refracted light information in a texture.
  108753. */
  108754. refractionTexture: Nullable<BaseTexture>;
  108755. /**
  108756. * The color of a material in ambient lighting.
  108757. */
  108758. ambientColor: Color3;
  108759. /**
  108760. * AKA Diffuse Color in other nomenclature.
  108761. */
  108762. albedoColor: Color3;
  108763. /**
  108764. * AKA Specular Color in other nomenclature.
  108765. */
  108766. reflectivityColor: Color3;
  108767. /**
  108768. * The color reflected from the material.
  108769. */
  108770. reflectionColor: Color3;
  108771. /**
  108772. * The color emitted from the material.
  108773. */
  108774. emissiveColor: Color3;
  108775. /**
  108776. * AKA Glossiness in other nomenclature.
  108777. */
  108778. microSurface: number;
  108779. /**
  108780. * source material index of refraction (IOR)' / 'destination material IOR.
  108781. */
  108782. indexOfRefraction: number;
  108783. /**
  108784. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  108785. */
  108786. invertRefractionY: boolean;
  108787. /**
  108788. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  108789. * Materials half opaque for instance using refraction could benefit from this control.
  108790. */
  108791. linkRefractionWithTransparency: boolean;
  108792. /**
  108793. * If true, the light map contains occlusion information instead of lighting info.
  108794. */
  108795. useLightmapAsShadowmap: boolean;
  108796. /**
  108797. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  108798. */
  108799. useAlphaFromAlbedoTexture: boolean;
  108800. /**
  108801. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  108802. */
  108803. forceAlphaTest: boolean;
  108804. /**
  108805. * Defines the alpha limits in alpha test mode.
  108806. */
  108807. alphaCutOff: number;
  108808. /**
  108809. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  108810. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  108811. */
  108812. useSpecularOverAlpha: boolean;
  108813. /**
  108814. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  108815. */
  108816. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  108817. /**
  108818. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  108819. */
  108820. useRoughnessFromMetallicTextureAlpha: boolean;
  108821. /**
  108822. * Specifies if the metallic texture contains the roughness information in its green channel.
  108823. */
  108824. useRoughnessFromMetallicTextureGreen: boolean;
  108825. /**
  108826. * Specifies if the metallic texture contains the metallness information in its blue channel.
  108827. */
  108828. useMetallnessFromMetallicTextureBlue: boolean;
  108829. /**
  108830. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  108831. */
  108832. useAmbientOcclusionFromMetallicTextureRed: boolean;
  108833. /**
  108834. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  108835. */
  108836. useAmbientInGrayScale: boolean;
  108837. /**
  108838. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  108839. * The material will try to infer what glossiness each pixel should be.
  108840. */
  108841. useAutoMicroSurfaceFromReflectivityMap: boolean;
  108842. /**
  108843. * BJS is using an harcoded light falloff based on a manually sets up range.
  108844. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  108845. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  108846. */
  108847. /**
  108848. * BJS is using an harcoded light falloff based on a manually sets up range.
  108849. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  108850. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  108851. */
  108852. usePhysicalLightFalloff: boolean;
  108853. /**
  108854. * In order to support the falloff compatibility with gltf, a special mode has been added
  108855. * to reproduce the gltf light falloff.
  108856. */
  108857. /**
  108858. * In order to support the falloff compatibility with gltf, a special mode has been added
  108859. * to reproduce the gltf light falloff.
  108860. */
  108861. useGLTFLightFalloff: boolean;
  108862. /**
  108863. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  108864. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  108865. */
  108866. useRadianceOverAlpha: boolean;
  108867. /**
  108868. * Allows using an object space normal map (instead of tangent space).
  108869. */
  108870. useObjectSpaceNormalMap: boolean;
  108871. /**
  108872. * Allows using the bump map in parallax mode.
  108873. */
  108874. useParallax: boolean;
  108875. /**
  108876. * Allows using the bump map in parallax occlusion mode.
  108877. */
  108878. useParallaxOcclusion: boolean;
  108879. /**
  108880. * Controls the scale bias of the parallax mode.
  108881. */
  108882. parallaxScaleBias: number;
  108883. /**
  108884. * If sets to true, disables all the lights affecting the material.
  108885. */
  108886. disableLighting: boolean;
  108887. /**
  108888. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  108889. */
  108890. forceIrradianceInFragment: boolean;
  108891. /**
  108892. * Number of Simultaneous lights allowed on the material.
  108893. */
  108894. maxSimultaneousLights: number;
  108895. /**
  108896. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  108897. */
  108898. invertNormalMapX: boolean;
  108899. /**
  108900. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  108901. */
  108902. invertNormalMapY: boolean;
  108903. /**
  108904. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  108905. */
  108906. twoSidedLighting: boolean;
  108907. /**
  108908. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  108909. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  108910. */
  108911. useAlphaFresnel: boolean;
  108912. /**
  108913. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  108914. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  108915. */
  108916. useLinearAlphaFresnel: boolean;
  108917. /**
  108918. * Let user defines the brdf lookup texture used for IBL.
  108919. * A default 8bit version is embedded but you could point at :
  108920. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  108921. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  108922. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  108923. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  108924. */
  108925. environmentBRDFTexture: Nullable<BaseTexture>;
  108926. /**
  108927. * Force normal to face away from face.
  108928. */
  108929. forceNormalForward: boolean;
  108930. /**
  108931. * Enables specular anti aliasing in the PBR shader.
  108932. * It will both interacts on the Geometry for analytical and IBL lighting.
  108933. * It also prefilter the roughness map based on the bump values.
  108934. */
  108935. enableSpecularAntiAliasing: boolean;
  108936. /**
  108937. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  108938. * makes the reflect vector face the model (under horizon).
  108939. */
  108940. useHorizonOcclusion: boolean;
  108941. /**
  108942. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  108943. * too much the area relying on ambient texture to define their ambient occlusion.
  108944. */
  108945. useRadianceOcclusion: boolean;
  108946. /**
  108947. * If set to true, no lighting calculations will be applied.
  108948. */
  108949. unlit: boolean;
  108950. /**
  108951. * Gets the image processing configuration used either in this material.
  108952. */
  108953. /**
  108954. * Sets the Default image processing configuration used either in the this material.
  108955. *
  108956. * If sets to null, the scene one is in use.
  108957. */
  108958. imageProcessingConfiguration: ImageProcessingConfiguration;
  108959. /**
  108960. * Gets wether the color curves effect is enabled.
  108961. */
  108962. /**
  108963. * Sets wether the color curves effect is enabled.
  108964. */
  108965. cameraColorCurvesEnabled: boolean;
  108966. /**
  108967. * Gets wether the color grading effect is enabled.
  108968. */
  108969. /**
  108970. * Gets wether the color grading effect is enabled.
  108971. */
  108972. cameraColorGradingEnabled: boolean;
  108973. /**
  108974. * Gets wether tonemapping is enabled or not.
  108975. */
  108976. /**
  108977. * Sets wether tonemapping is enabled or not
  108978. */
  108979. cameraToneMappingEnabled: boolean;
  108980. /**
  108981. * The camera exposure used on this material.
  108982. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  108983. * This corresponds to a photographic exposure.
  108984. */
  108985. /**
  108986. * The camera exposure used on this material.
  108987. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  108988. * This corresponds to a photographic exposure.
  108989. */
  108990. cameraExposure: number;
  108991. /**
  108992. * Gets The camera contrast used on this material.
  108993. */
  108994. /**
  108995. * Sets The camera contrast used on this material.
  108996. */
  108997. cameraContrast: number;
  108998. /**
  108999. * Gets the Color Grading 2D Lookup Texture.
  109000. */
  109001. /**
  109002. * Sets the Color Grading 2D Lookup Texture.
  109003. */
  109004. cameraColorGradingTexture: Nullable<BaseTexture>;
  109005. /**
  109006. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  109007. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  109008. * 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;
  109009. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  109010. */
  109011. /**
  109012. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  109013. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  109014. * 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;
  109015. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  109016. */
  109017. cameraColorCurves: Nullable<ColorCurves>;
  109018. /**
  109019. * Instantiates a new PBRMaterial instance.
  109020. *
  109021. * @param name The material name
  109022. * @param scene The scene the material will be use in.
  109023. */
  109024. constructor(name: string, scene: Scene);
  109025. /**
  109026. * Returns the name of this material class.
  109027. */
  109028. getClassName(): string;
  109029. /**
  109030. * Makes a duplicate of the current material.
  109031. * @param name - name to use for the new material.
  109032. */
  109033. clone(name: string): PBRMaterial;
  109034. /**
  109035. * Serializes this PBR Material.
  109036. * @returns - An object with the serialized material.
  109037. */
  109038. serialize(): any;
  109039. /**
  109040. * Parses a PBR Material from a serialized object.
  109041. * @param source - Serialized object.
  109042. * @param scene - BJS scene instance.
  109043. * @param rootUrl - url for the scene object
  109044. * @returns - PBRMaterial
  109045. */
  109046. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  109047. }
  109048. }
  109049. declare module BABYLON {
  109050. /**
  109051. * Direct draw surface info
  109052. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  109053. */
  109054. export interface DDSInfo {
  109055. /**
  109056. * Width of the texture
  109057. */
  109058. width: number;
  109059. /**
  109060. * Width of the texture
  109061. */
  109062. height: number;
  109063. /**
  109064. * Number of Mipmaps for the texture
  109065. * @see https://en.wikipedia.org/wiki/Mipmap
  109066. */
  109067. mipmapCount: number;
  109068. /**
  109069. * If the textures format is a known fourCC format
  109070. * @see https://www.fourcc.org/
  109071. */
  109072. isFourCC: boolean;
  109073. /**
  109074. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  109075. */
  109076. isRGB: boolean;
  109077. /**
  109078. * If the texture is a lumincance format
  109079. */
  109080. isLuminance: boolean;
  109081. /**
  109082. * If this is a cube texture
  109083. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  109084. */
  109085. isCube: boolean;
  109086. /**
  109087. * If the texture is a compressed format eg. FOURCC_DXT1
  109088. */
  109089. isCompressed: boolean;
  109090. /**
  109091. * The dxgiFormat of the texture
  109092. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  109093. */
  109094. dxgiFormat: number;
  109095. /**
  109096. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  109097. */
  109098. textureType: number;
  109099. /**
  109100. * Sphericle polynomial created for the dds texture
  109101. */
  109102. sphericalPolynomial?: SphericalPolynomial;
  109103. }
  109104. /**
  109105. * Class used to provide DDS decompression tools
  109106. */
  109107. export class DDSTools {
  109108. /**
  109109. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  109110. */
  109111. static StoreLODInAlphaChannel: boolean;
  109112. /**
  109113. * Gets DDS information from an array buffer
  109114. * @param arrayBuffer defines the array buffer to read data from
  109115. * @returns the DDS information
  109116. */
  109117. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  109118. private static _FloatView;
  109119. private static _Int32View;
  109120. private static _ToHalfFloat;
  109121. private static _FromHalfFloat;
  109122. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  109123. private static _GetHalfFloatRGBAArrayBuffer;
  109124. private static _GetFloatRGBAArrayBuffer;
  109125. private static _GetFloatAsUIntRGBAArrayBuffer;
  109126. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  109127. private static _GetRGBAArrayBuffer;
  109128. private static _ExtractLongWordOrder;
  109129. private static _GetRGBArrayBuffer;
  109130. private static _GetLuminanceArrayBuffer;
  109131. /**
  109132. * Uploads DDS Levels to a Babylon Texture
  109133. * @hidden
  109134. */
  109135. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  109136. }
  109137. interface Engine {
  109138. /**
  109139. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  109140. * @param rootUrl defines the url where the file to load is located
  109141. * @param scene defines the current scene
  109142. * @param lodScale defines scale to apply to the mip map selection
  109143. * @param lodOffset defines offset to apply to the mip map selection
  109144. * @param onLoad defines an optional callback raised when the texture is loaded
  109145. * @param onError defines an optional callback raised if there is an issue to load the texture
  109146. * @param format defines the format of the data
  109147. * @param forcedExtension defines the extension to use to pick the right loader
  109148. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  109149. * @returns the cube texture as an InternalTexture
  109150. */
  109151. 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;
  109152. }
  109153. }
  109154. declare module BABYLON {
  109155. /**
  109156. * Implementation of the DDS Texture Loader.
  109157. * @hidden
  109158. */
  109159. export class _DDSTextureLoader implements IInternalTextureLoader {
  109160. /**
  109161. * Defines wether the loader supports cascade loading the different faces.
  109162. */
  109163. readonly supportCascades: boolean;
  109164. /**
  109165. * This returns if the loader support the current file information.
  109166. * @param extension defines the file extension of the file being loaded
  109167. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109168. * @param fallback defines the fallback internal texture if any
  109169. * @param isBase64 defines whether the texture is encoded as a base64
  109170. * @param isBuffer defines whether the texture data are stored as a buffer
  109171. * @returns true if the loader can load the specified file
  109172. */
  109173. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  109174. /**
  109175. * Transform the url before loading if required.
  109176. * @param rootUrl the url of the texture
  109177. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109178. * @returns the transformed texture
  109179. */
  109180. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  109181. /**
  109182. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  109183. * @param rootUrl the url of the texture
  109184. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109185. * @returns the fallback texture
  109186. */
  109187. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  109188. /**
  109189. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  109190. * @param data contains the texture data
  109191. * @param texture defines the BabylonJS internal texture
  109192. * @param createPolynomials will be true if polynomials have been requested
  109193. * @param onLoad defines the callback to trigger once the texture is ready
  109194. * @param onError defines the callback to trigger in case of error
  109195. */
  109196. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  109197. /**
  109198. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  109199. * @param data contains the texture data
  109200. * @param texture defines the BabylonJS internal texture
  109201. * @param callback defines the method to call once ready to upload
  109202. */
  109203. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  109204. }
  109205. }
  109206. declare module BABYLON {
  109207. /** @hidden */
  109208. export var rgbdEncodePixelShader: {
  109209. name: string;
  109210. shader: string;
  109211. };
  109212. }
  109213. declare module BABYLON {
  109214. /**
  109215. * Raw texture data and descriptor sufficient for WebGL texture upload
  109216. */
  109217. export interface EnvironmentTextureInfo {
  109218. /**
  109219. * Version of the environment map
  109220. */
  109221. version: number;
  109222. /**
  109223. * Width of image
  109224. */
  109225. width: number;
  109226. /**
  109227. * Irradiance information stored in the file.
  109228. */
  109229. irradiance: any;
  109230. /**
  109231. * Specular information stored in the file.
  109232. */
  109233. specular: any;
  109234. }
  109235. /**
  109236. * Sets of helpers addressing the serialization and deserialization of environment texture
  109237. * stored in a BabylonJS env file.
  109238. * Those files are usually stored as .env files.
  109239. */
  109240. export class EnvironmentTextureTools {
  109241. /**
  109242. * Magic number identifying the env file.
  109243. */
  109244. private static _MagicBytes;
  109245. /**
  109246. * Gets the environment info from an env file.
  109247. * @param data The array buffer containing the .env bytes.
  109248. * @returns the environment file info (the json header) if successfully parsed.
  109249. */
  109250. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  109251. /**
  109252. * Creates an environment texture from a loaded cube texture.
  109253. * @param texture defines the cube texture to convert in env file
  109254. * @return a promise containing the environment data if succesfull.
  109255. */
  109256. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  109257. /**
  109258. * Creates a JSON representation of the spherical data.
  109259. * @param texture defines the texture containing the polynomials
  109260. * @return the JSON representation of the spherical info
  109261. */
  109262. private static _CreateEnvTextureIrradiance;
  109263. /**
  109264. * Uploads the texture info contained in the env file to the GPU.
  109265. * @param texture defines the internal texture to upload to
  109266. * @param arrayBuffer defines the buffer cotaining the data to load
  109267. * @param info defines the texture info retrieved through the GetEnvInfo method
  109268. * @returns a promise
  109269. */
  109270. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  109271. /**
  109272. * Uploads the levels of image data to the GPU.
  109273. * @param texture defines the internal texture to upload to
  109274. * @param imageData defines the array buffer views of image data [mipmap][face]
  109275. * @returns a promise
  109276. */
  109277. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  109278. /**
  109279. * Uploads spherical polynomials information to the texture.
  109280. * @param texture defines the texture we are trying to upload the information to
  109281. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  109282. */
  109283. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  109284. /** @hidden */
  109285. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  109286. }
  109287. }
  109288. declare module BABYLON {
  109289. /**
  109290. * Implementation of the ENV Texture Loader.
  109291. * @hidden
  109292. */
  109293. export class _ENVTextureLoader implements IInternalTextureLoader {
  109294. /**
  109295. * Defines wether the loader supports cascade loading the different faces.
  109296. */
  109297. readonly supportCascades: boolean;
  109298. /**
  109299. * This returns if the loader support the current file information.
  109300. * @param extension defines the file extension of the file being loaded
  109301. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109302. * @param fallback defines the fallback internal texture if any
  109303. * @param isBase64 defines whether the texture is encoded as a base64
  109304. * @param isBuffer defines whether the texture data are stored as a buffer
  109305. * @returns true if the loader can load the specified file
  109306. */
  109307. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  109308. /**
  109309. * Transform the url before loading if required.
  109310. * @param rootUrl the url of the texture
  109311. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109312. * @returns the transformed texture
  109313. */
  109314. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  109315. /**
  109316. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  109317. * @param rootUrl the url of the texture
  109318. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109319. * @returns the fallback texture
  109320. */
  109321. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  109322. /**
  109323. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  109324. * @param data contains the texture data
  109325. * @param texture defines the BabylonJS internal texture
  109326. * @param createPolynomials will be true if polynomials have been requested
  109327. * @param onLoad defines the callback to trigger once the texture is ready
  109328. * @param onError defines the callback to trigger in case of error
  109329. */
  109330. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  109331. /**
  109332. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  109333. * @param data contains the texture data
  109334. * @param texture defines the BabylonJS internal texture
  109335. * @param callback defines the method to call once ready to upload
  109336. */
  109337. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  109338. }
  109339. }
  109340. declare module BABYLON {
  109341. /**
  109342. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  109343. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  109344. */
  109345. export class KhronosTextureContainer {
  109346. /** contents of the KTX container file */
  109347. arrayBuffer: any;
  109348. private static HEADER_LEN;
  109349. private static COMPRESSED_2D;
  109350. private static COMPRESSED_3D;
  109351. private static TEX_2D;
  109352. private static TEX_3D;
  109353. /**
  109354. * Gets the openGL type
  109355. */
  109356. glType: number;
  109357. /**
  109358. * Gets the openGL type size
  109359. */
  109360. glTypeSize: number;
  109361. /**
  109362. * Gets the openGL format
  109363. */
  109364. glFormat: number;
  109365. /**
  109366. * Gets the openGL internal format
  109367. */
  109368. glInternalFormat: number;
  109369. /**
  109370. * Gets the base internal format
  109371. */
  109372. glBaseInternalFormat: number;
  109373. /**
  109374. * Gets image width in pixel
  109375. */
  109376. pixelWidth: number;
  109377. /**
  109378. * Gets image height in pixel
  109379. */
  109380. pixelHeight: number;
  109381. /**
  109382. * Gets image depth in pixels
  109383. */
  109384. pixelDepth: number;
  109385. /**
  109386. * Gets the number of array elements
  109387. */
  109388. numberOfArrayElements: number;
  109389. /**
  109390. * Gets the number of faces
  109391. */
  109392. numberOfFaces: number;
  109393. /**
  109394. * Gets the number of mipmap levels
  109395. */
  109396. numberOfMipmapLevels: number;
  109397. /**
  109398. * Gets the bytes of key value data
  109399. */
  109400. bytesOfKeyValueData: number;
  109401. /**
  109402. * Gets the load type
  109403. */
  109404. loadType: number;
  109405. /**
  109406. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  109407. */
  109408. isInvalid: boolean;
  109409. /**
  109410. * Creates a new KhronosTextureContainer
  109411. * @param arrayBuffer contents of the KTX container file
  109412. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  109413. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  109414. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  109415. */
  109416. constructor(
  109417. /** contents of the KTX container file */
  109418. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  109419. /**
  109420. * Uploads KTX content to a Babylon Texture.
  109421. * It is assumed that the texture has already been created & is currently bound
  109422. * @hidden
  109423. */
  109424. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  109425. private _upload2DCompressedLevels;
  109426. }
  109427. }
  109428. declare module BABYLON {
  109429. /**
  109430. * Implementation of the KTX Texture Loader.
  109431. * @hidden
  109432. */
  109433. export class _KTXTextureLoader implements IInternalTextureLoader {
  109434. /**
  109435. * Defines wether the loader supports cascade loading the different faces.
  109436. */
  109437. readonly supportCascades: boolean;
  109438. /**
  109439. * This returns if the loader support the current file information.
  109440. * @param extension defines the file extension of the file being loaded
  109441. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109442. * @param fallback defines the fallback internal texture if any
  109443. * @param isBase64 defines whether the texture is encoded as a base64
  109444. * @param isBuffer defines whether the texture data are stored as a buffer
  109445. * @returns true if the loader can load the specified file
  109446. */
  109447. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  109448. /**
  109449. * Transform the url before loading if required.
  109450. * @param rootUrl the url of the texture
  109451. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109452. * @returns the transformed texture
  109453. */
  109454. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  109455. /**
  109456. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  109457. * @param rootUrl the url of the texture
  109458. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109459. * @returns the fallback texture
  109460. */
  109461. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  109462. /**
  109463. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  109464. * @param data contains the texture data
  109465. * @param texture defines the BabylonJS internal texture
  109466. * @param createPolynomials will be true if polynomials have been requested
  109467. * @param onLoad defines the callback to trigger once the texture is ready
  109468. * @param onError defines the callback to trigger in case of error
  109469. */
  109470. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  109471. /**
  109472. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  109473. * @param data contains the texture data
  109474. * @param texture defines the BabylonJS internal texture
  109475. * @param callback defines the method to call once ready to upload
  109476. */
  109477. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  109478. }
  109479. }
  109480. declare module BABYLON {
  109481. /** @hidden */
  109482. export var _forceSceneHelpersToBundle: boolean;
  109483. interface Scene {
  109484. /**
  109485. * Creates a default light for the scene.
  109486. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  109487. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  109488. */
  109489. createDefaultLight(replace?: boolean): void;
  109490. /**
  109491. * Creates a default camera for the scene.
  109492. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  109493. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  109494. * @param replace has default false, when true replaces the active camera in the scene
  109495. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  109496. */
  109497. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  109498. /**
  109499. * Creates a default camera and a default light.
  109500. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  109501. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  109502. * @param replace has the default false, when true replaces the active camera/light in the scene
  109503. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  109504. */
  109505. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  109506. /**
  109507. * Creates a new sky box
  109508. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  109509. * @param environmentTexture defines the texture to use as environment texture
  109510. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  109511. * @param scale defines the overall scale of the skybox
  109512. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  109513. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  109514. * @returns a new mesh holding the sky box
  109515. */
  109516. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  109517. /**
  109518. * Creates a new environment
  109519. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  109520. * @param options defines the options you can use to configure the environment
  109521. * @returns the new EnvironmentHelper
  109522. */
  109523. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  109524. /**
  109525. * Creates a new VREXperienceHelper
  109526. * @see http://doc.babylonjs.com/how_to/webvr_helper
  109527. * @param webVROptions defines the options used to create the new VREXperienceHelper
  109528. * @returns a new VREXperienceHelper
  109529. */
  109530. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  109531. /**
  109532. * Creates a new XREXperienceHelper
  109533. * @see http://doc.babylonjs.com/how_to/webxr
  109534. * @returns a promise for a new XREXperienceHelper
  109535. */
  109536. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  109537. }
  109538. }
  109539. declare module BABYLON {
  109540. /**
  109541. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  109542. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  109543. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  109544. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  109545. */
  109546. export class VideoDome extends TransformNode {
  109547. /**
  109548. * Define the video source as a Monoscopic panoramic 360 video.
  109549. */
  109550. static readonly MODE_MONOSCOPIC: number;
  109551. /**
  109552. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  109553. */
  109554. static readonly MODE_TOPBOTTOM: number;
  109555. /**
  109556. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  109557. */
  109558. static readonly MODE_SIDEBYSIDE: number;
  109559. private _useDirectMapping;
  109560. /**
  109561. * The video texture being displayed on the sphere
  109562. */
  109563. protected _videoTexture: VideoTexture;
  109564. /**
  109565. * Gets the video texture being displayed on the sphere
  109566. */
  109567. readonly videoTexture: VideoTexture;
  109568. /**
  109569. * The skybox material
  109570. */
  109571. protected _material: BackgroundMaterial;
  109572. /**
  109573. * The surface used for the skybox
  109574. */
  109575. protected _mesh: Mesh;
  109576. /**
  109577. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  109578. * Also see the options.resolution property.
  109579. */
  109580. fovMultiplier: number;
  109581. private _videoMode;
  109582. /**
  109583. * Gets or set the current video mode for the video. It can be:
  109584. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  109585. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  109586. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  109587. */
  109588. videoMode: number;
  109589. /**
  109590. * Oberserver used in Stereoscopic VR Mode.
  109591. */
  109592. private _onBeforeCameraRenderObserver;
  109593. /**
  109594. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  109595. * @param name Element's name, child elements will append suffixes for their own names.
  109596. * @param urlsOrVideo defines the url(s) or the video element to use
  109597. * @param options An object containing optional or exposed sub element properties
  109598. */
  109599. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  109600. resolution?: number;
  109601. clickToPlay?: boolean;
  109602. autoPlay?: boolean;
  109603. loop?: boolean;
  109604. size?: number;
  109605. poster?: string;
  109606. faceForward?: boolean;
  109607. useDirectMapping?: boolean;
  109608. }, scene: Scene);
  109609. private _changeVideoMode;
  109610. /**
  109611. * Releases resources associated with this node.
  109612. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  109613. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  109614. */
  109615. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  109616. }
  109617. }
  109618. declare module BABYLON {
  109619. /**
  109620. * This class can be used to get instrumentation data from a Babylon engine
  109621. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  109622. */
  109623. export class EngineInstrumentation implements IDisposable {
  109624. /**
  109625. * Define the instrumented engine.
  109626. */
  109627. engine: Engine;
  109628. private _captureGPUFrameTime;
  109629. private _gpuFrameTimeToken;
  109630. private _gpuFrameTime;
  109631. private _captureShaderCompilationTime;
  109632. private _shaderCompilationTime;
  109633. private _onBeginFrameObserver;
  109634. private _onEndFrameObserver;
  109635. private _onBeforeShaderCompilationObserver;
  109636. private _onAfterShaderCompilationObserver;
  109637. /**
  109638. * Gets the perf counter used for GPU frame time
  109639. */
  109640. readonly gpuFrameTimeCounter: PerfCounter;
  109641. /**
  109642. * Gets the GPU frame time capture status
  109643. */
  109644. /**
  109645. * Enable or disable the GPU frame time capture
  109646. */
  109647. captureGPUFrameTime: boolean;
  109648. /**
  109649. * Gets the perf counter used for shader compilation time
  109650. */
  109651. readonly shaderCompilationTimeCounter: PerfCounter;
  109652. /**
  109653. * Gets the shader compilation time capture status
  109654. */
  109655. /**
  109656. * Enable or disable the shader compilation time capture
  109657. */
  109658. captureShaderCompilationTime: boolean;
  109659. /**
  109660. * Instantiates a new engine instrumentation.
  109661. * This class can be used to get instrumentation data from a Babylon engine
  109662. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  109663. * @param engine Defines the engine to instrument
  109664. */
  109665. constructor(
  109666. /**
  109667. * Define the instrumented engine.
  109668. */
  109669. engine: Engine);
  109670. /**
  109671. * Dispose and release associated resources.
  109672. */
  109673. dispose(): void;
  109674. }
  109675. }
  109676. declare module BABYLON {
  109677. /**
  109678. * This class can be used to get instrumentation data from a Babylon engine
  109679. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  109680. */
  109681. export class SceneInstrumentation implements IDisposable {
  109682. /**
  109683. * Defines the scene to instrument
  109684. */
  109685. scene: Scene;
  109686. private _captureActiveMeshesEvaluationTime;
  109687. private _activeMeshesEvaluationTime;
  109688. private _captureRenderTargetsRenderTime;
  109689. private _renderTargetsRenderTime;
  109690. private _captureFrameTime;
  109691. private _frameTime;
  109692. private _captureRenderTime;
  109693. private _renderTime;
  109694. private _captureInterFrameTime;
  109695. private _interFrameTime;
  109696. private _captureParticlesRenderTime;
  109697. private _particlesRenderTime;
  109698. private _captureSpritesRenderTime;
  109699. private _spritesRenderTime;
  109700. private _capturePhysicsTime;
  109701. private _physicsTime;
  109702. private _captureAnimationsTime;
  109703. private _animationsTime;
  109704. private _captureCameraRenderTime;
  109705. private _cameraRenderTime;
  109706. private _onBeforeActiveMeshesEvaluationObserver;
  109707. private _onAfterActiveMeshesEvaluationObserver;
  109708. private _onBeforeRenderTargetsRenderObserver;
  109709. private _onAfterRenderTargetsRenderObserver;
  109710. private _onAfterRenderObserver;
  109711. private _onBeforeDrawPhaseObserver;
  109712. private _onAfterDrawPhaseObserver;
  109713. private _onBeforeAnimationsObserver;
  109714. private _onBeforeParticlesRenderingObserver;
  109715. private _onAfterParticlesRenderingObserver;
  109716. private _onBeforeSpritesRenderingObserver;
  109717. private _onAfterSpritesRenderingObserver;
  109718. private _onBeforePhysicsObserver;
  109719. private _onAfterPhysicsObserver;
  109720. private _onAfterAnimationsObserver;
  109721. private _onBeforeCameraRenderObserver;
  109722. private _onAfterCameraRenderObserver;
  109723. /**
  109724. * Gets the perf counter used for active meshes evaluation time
  109725. */
  109726. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  109727. /**
  109728. * Gets the active meshes evaluation time capture status
  109729. */
  109730. /**
  109731. * Enable or disable the active meshes evaluation time capture
  109732. */
  109733. captureActiveMeshesEvaluationTime: boolean;
  109734. /**
  109735. * Gets the perf counter used for render targets render time
  109736. */
  109737. readonly renderTargetsRenderTimeCounter: PerfCounter;
  109738. /**
  109739. * Gets the render targets render time capture status
  109740. */
  109741. /**
  109742. * Enable or disable the render targets render time capture
  109743. */
  109744. captureRenderTargetsRenderTime: boolean;
  109745. /**
  109746. * Gets the perf counter used for particles render time
  109747. */
  109748. readonly particlesRenderTimeCounter: PerfCounter;
  109749. /**
  109750. * Gets the particles render time capture status
  109751. */
  109752. /**
  109753. * Enable or disable the particles render time capture
  109754. */
  109755. captureParticlesRenderTime: boolean;
  109756. /**
  109757. * Gets the perf counter used for sprites render time
  109758. */
  109759. readonly spritesRenderTimeCounter: PerfCounter;
  109760. /**
  109761. * Gets the sprites render time capture status
  109762. */
  109763. /**
  109764. * Enable or disable the sprites render time capture
  109765. */
  109766. captureSpritesRenderTime: boolean;
  109767. /**
  109768. * Gets the perf counter used for physics time
  109769. */
  109770. readonly physicsTimeCounter: PerfCounter;
  109771. /**
  109772. * Gets the physics time capture status
  109773. */
  109774. /**
  109775. * Enable or disable the physics time capture
  109776. */
  109777. capturePhysicsTime: boolean;
  109778. /**
  109779. * Gets the perf counter used for animations time
  109780. */
  109781. readonly animationsTimeCounter: PerfCounter;
  109782. /**
  109783. * Gets the animations time capture status
  109784. */
  109785. /**
  109786. * Enable or disable the animations time capture
  109787. */
  109788. captureAnimationsTime: boolean;
  109789. /**
  109790. * Gets the perf counter used for frame time capture
  109791. */
  109792. readonly frameTimeCounter: PerfCounter;
  109793. /**
  109794. * Gets the frame time capture status
  109795. */
  109796. /**
  109797. * Enable or disable the frame time capture
  109798. */
  109799. captureFrameTime: boolean;
  109800. /**
  109801. * Gets the perf counter used for inter-frames time capture
  109802. */
  109803. readonly interFrameTimeCounter: PerfCounter;
  109804. /**
  109805. * Gets the inter-frames time capture status
  109806. */
  109807. /**
  109808. * Enable or disable the inter-frames time capture
  109809. */
  109810. captureInterFrameTime: boolean;
  109811. /**
  109812. * Gets the perf counter used for render time capture
  109813. */
  109814. readonly renderTimeCounter: PerfCounter;
  109815. /**
  109816. * Gets the render time capture status
  109817. */
  109818. /**
  109819. * Enable or disable the render time capture
  109820. */
  109821. captureRenderTime: boolean;
  109822. /**
  109823. * Gets the perf counter used for camera render time capture
  109824. */
  109825. readonly cameraRenderTimeCounter: PerfCounter;
  109826. /**
  109827. * Gets the camera render time capture status
  109828. */
  109829. /**
  109830. * Enable or disable the camera render time capture
  109831. */
  109832. captureCameraRenderTime: boolean;
  109833. /**
  109834. * Gets the perf counter used for draw calls
  109835. */
  109836. readonly drawCallsCounter: PerfCounter;
  109837. /**
  109838. * Instantiates a new scene instrumentation.
  109839. * This class can be used to get instrumentation data from a Babylon engine
  109840. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  109841. * @param scene Defines the scene to instrument
  109842. */
  109843. constructor(
  109844. /**
  109845. * Defines the scene to instrument
  109846. */
  109847. scene: Scene);
  109848. /**
  109849. * Dispose and release associated resources.
  109850. */
  109851. dispose(): void;
  109852. }
  109853. }
  109854. declare module BABYLON {
  109855. /** @hidden */
  109856. export var glowMapGenerationPixelShader: {
  109857. name: string;
  109858. shader: string;
  109859. };
  109860. }
  109861. declare module BABYLON {
  109862. /** @hidden */
  109863. export var glowMapGenerationVertexShader: {
  109864. name: string;
  109865. shader: string;
  109866. };
  109867. }
  109868. declare module BABYLON {
  109869. /**
  109870. * Effect layer options. This helps customizing the behaviour
  109871. * of the effect layer.
  109872. */
  109873. export interface IEffectLayerOptions {
  109874. /**
  109875. * Multiplication factor apply to the canvas size to compute the render target size
  109876. * used to generated the objects (the smaller the faster).
  109877. */
  109878. mainTextureRatio: number;
  109879. /**
  109880. * Enforces a fixed size texture to ensure effect stability across devices.
  109881. */
  109882. mainTextureFixedSize?: number;
  109883. /**
  109884. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  109885. */
  109886. alphaBlendingMode: number;
  109887. /**
  109888. * The camera attached to the layer.
  109889. */
  109890. camera: Nullable<Camera>;
  109891. /**
  109892. * The rendering group to draw the layer in.
  109893. */
  109894. renderingGroupId: number;
  109895. }
  109896. /**
  109897. * The effect layer Helps adding post process effect blended with the main pass.
  109898. *
  109899. * This can be for instance use to generate glow or higlight effects on the scene.
  109900. *
  109901. * The effect layer class can not be used directly and is intented to inherited from to be
  109902. * customized per effects.
  109903. */
  109904. export abstract class EffectLayer {
  109905. private _vertexBuffers;
  109906. private _indexBuffer;
  109907. private _cachedDefines;
  109908. private _effectLayerMapGenerationEffect;
  109909. private _effectLayerOptions;
  109910. private _mergeEffect;
  109911. protected _scene: Scene;
  109912. protected _engine: Engine;
  109913. protected _maxSize: number;
  109914. protected _mainTextureDesiredSize: ISize;
  109915. protected _mainTexture: RenderTargetTexture;
  109916. protected _shouldRender: boolean;
  109917. protected _postProcesses: PostProcess[];
  109918. protected _textures: BaseTexture[];
  109919. protected _emissiveTextureAndColor: {
  109920. texture: Nullable<BaseTexture>;
  109921. color: Color4;
  109922. };
  109923. /**
  109924. * The name of the layer
  109925. */
  109926. name: string;
  109927. /**
  109928. * The clear color of the texture used to generate the glow map.
  109929. */
  109930. neutralColor: Color4;
  109931. /**
  109932. * Specifies wether the highlight layer is enabled or not.
  109933. */
  109934. isEnabled: boolean;
  109935. /**
  109936. * Gets the camera attached to the layer.
  109937. */
  109938. readonly camera: Nullable<Camera>;
  109939. /**
  109940. * Gets the rendering group id the layer should render in.
  109941. */
  109942. readonly renderingGroupId: number;
  109943. /**
  109944. * An event triggered when the effect layer has been disposed.
  109945. */
  109946. onDisposeObservable: Observable<EffectLayer>;
  109947. /**
  109948. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  109949. */
  109950. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  109951. /**
  109952. * An event triggered when the generated texture is being merged in the scene.
  109953. */
  109954. onBeforeComposeObservable: Observable<EffectLayer>;
  109955. /**
  109956. * An event triggered when the generated texture has been merged in the scene.
  109957. */
  109958. onAfterComposeObservable: Observable<EffectLayer>;
  109959. /**
  109960. * An event triggered when the efffect layer changes its size.
  109961. */
  109962. onSizeChangedObservable: Observable<EffectLayer>;
  109963. /** @hidden */
  109964. static _SceneComponentInitialization: (scene: Scene) => void;
  109965. /**
  109966. * Instantiates a new effect Layer and references it in the scene.
  109967. * @param name The name of the layer
  109968. * @param scene The scene to use the layer in
  109969. */
  109970. constructor(
  109971. /** The Friendly of the effect in the scene */
  109972. name: string, scene: Scene);
  109973. /**
  109974. * Get the effect name of the layer.
  109975. * @return The effect name
  109976. */
  109977. abstract getEffectName(): string;
  109978. /**
  109979. * Checks for the readiness of the element composing the layer.
  109980. * @param subMesh the mesh to check for
  109981. * @param useInstances specify wether or not to use instances to render the mesh
  109982. * @return true if ready otherwise, false
  109983. */
  109984. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  109985. /**
  109986. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  109987. * @returns true if the effect requires stencil during the main canvas render pass.
  109988. */
  109989. abstract needStencil(): boolean;
  109990. /**
  109991. * Create the merge effect. This is the shader use to blit the information back
  109992. * to the main canvas at the end of the scene rendering.
  109993. * @returns The effect containing the shader used to merge the effect on the main canvas
  109994. */
  109995. protected abstract _createMergeEffect(): Effect;
  109996. /**
  109997. * Creates the render target textures and post processes used in the effect layer.
  109998. */
  109999. protected abstract _createTextureAndPostProcesses(): void;
  110000. /**
  110001. * Implementation specific of rendering the generating effect on the main canvas.
  110002. * @param effect The effect used to render through
  110003. */
  110004. protected abstract _internalRender(effect: Effect): void;
  110005. /**
  110006. * Sets the required values for both the emissive texture and and the main color.
  110007. */
  110008. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  110009. /**
  110010. * Free any resources and references associated to a mesh.
  110011. * Internal use
  110012. * @param mesh The mesh to free.
  110013. */
  110014. abstract _disposeMesh(mesh: Mesh): void;
  110015. /**
  110016. * Serializes this layer (Glow or Highlight for example)
  110017. * @returns a serialized layer object
  110018. */
  110019. abstract serialize?(): any;
  110020. /**
  110021. * Initializes the effect layer with the required options.
  110022. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  110023. */
  110024. protected _init(options: Partial<IEffectLayerOptions>): void;
  110025. /**
  110026. * Generates the index buffer of the full screen quad blending to the main canvas.
  110027. */
  110028. private _generateIndexBuffer;
  110029. /**
  110030. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  110031. */
  110032. private _generateVertexBuffer;
  110033. /**
  110034. * Sets the main texture desired size which is the closest power of two
  110035. * of the engine canvas size.
  110036. */
  110037. private _setMainTextureSize;
  110038. /**
  110039. * Creates the main texture for the effect layer.
  110040. */
  110041. protected _createMainTexture(): void;
  110042. /**
  110043. * Adds specific effects defines.
  110044. * @param defines The defines to add specifics to.
  110045. */
  110046. protected _addCustomEffectDefines(defines: string[]): void;
  110047. /**
  110048. * Checks for the readiness of the element composing the layer.
  110049. * @param subMesh the mesh to check for
  110050. * @param useInstances specify wether or not to use instances to render the mesh
  110051. * @param emissiveTexture the associated emissive texture used to generate the glow
  110052. * @return true if ready otherwise, false
  110053. */
  110054. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  110055. /**
  110056. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  110057. */
  110058. render(): void;
  110059. /**
  110060. * Determine if a given mesh will be used in the current effect.
  110061. * @param mesh mesh to test
  110062. * @returns true if the mesh will be used
  110063. */
  110064. hasMesh(mesh: AbstractMesh): boolean;
  110065. /**
  110066. * Returns true if the layer contains information to display, otherwise false.
  110067. * @returns true if the glow layer should be rendered
  110068. */
  110069. shouldRender(): boolean;
  110070. /**
  110071. * Returns true if the mesh should render, otherwise false.
  110072. * @param mesh The mesh to render
  110073. * @returns true if it should render otherwise false
  110074. */
  110075. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  110076. /**
  110077. * Returns true if the mesh can be rendered, otherwise false.
  110078. * @param mesh The mesh to render
  110079. * @param material The material used on the mesh
  110080. * @returns true if it can be rendered otherwise false
  110081. */
  110082. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  110083. /**
  110084. * Returns true if the mesh should render, otherwise false.
  110085. * @param mesh The mesh to render
  110086. * @returns true if it should render otherwise false
  110087. */
  110088. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  110089. /**
  110090. * Renders the submesh passed in parameter to the generation map.
  110091. */
  110092. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  110093. /**
  110094. * Rebuild the required buffers.
  110095. * @hidden Internal use only.
  110096. */
  110097. _rebuild(): void;
  110098. /**
  110099. * Dispose only the render target textures and post process.
  110100. */
  110101. private _disposeTextureAndPostProcesses;
  110102. /**
  110103. * Dispose the highlight layer and free resources.
  110104. */
  110105. dispose(): void;
  110106. /**
  110107. * Gets the class name of the effect layer
  110108. * @returns the string with the class name of the effect layer
  110109. */
  110110. getClassName(): string;
  110111. /**
  110112. * Creates an effect layer from parsed effect layer data
  110113. * @param parsedEffectLayer defines effect layer data
  110114. * @param scene defines the current scene
  110115. * @param rootUrl defines the root URL containing the effect layer information
  110116. * @returns a parsed effect Layer
  110117. */
  110118. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  110119. }
  110120. }
  110121. declare module BABYLON {
  110122. interface AbstractScene {
  110123. /**
  110124. * The list of effect layers (highlights/glow) added to the scene
  110125. * @see http://doc.babylonjs.com/how_to/highlight_layer
  110126. * @see http://doc.babylonjs.com/how_to/glow_layer
  110127. */
  110128. effectLayers: Array<EffectLayer>;
  110129. /**
  110130. * Removes the given effect layer from this scene.
  110131. * @param toRemove defines the effect layer to remove
  110132. * @returns the index of the removed effect layer
  110133. */
  110134. removeEffectLayer(toRemove: EffectLayer): number;
  110135. /**
  110136. * Adds the given effect layer to this scene
  110137. * @param newEffectLayer defines the effect layer to add
  110138. */
  110139. addEffectLayer(newEffectLayer: EffectLayer): void;
  110140. }
  110141. /**
  110142. * Defines the layer scene component responsible to manage any effect layers
  110143. * in a given scene.
  110144. */
  110145. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  110146. /**
  110147. * The component name helpfull to identify the component in the list of scene components.
  110148. */
  110149. readonly name: string;
  110150. /**
  110151. * The scene the component belongs to.
  110152. */
  110153. scene: Scene;
  110154. private _engine;
  110155. private _renderEffects;
  110156. private _needStencil;
  110157. private _previousStencilState;
  110158. /**
  110159. * Creates a new instance of the component for the given scene
  110160. * @param scene Defines the scene to register the component in
  110161. */
  110162. constructor(scene: Scene);
  110163. /**
  110164. * Registers the component in a given scene
  110165. */
  110166. register(): void;
  110167. /**
  110168. * Rebuilds the elements related to this component in case of
  110169. * context lost for instance.
  110170. */
  110171. rebuild(): void;
  110172. /**
  110173. * Serializes the component data to the specified json object
  110174. * @param serializationObject The object to serialize to
  110175. */
  110176. serialize(serializationObject: any): void;
  110177. /**
  110178. * Adds all the elements from the container to the scene
  110179. * @param container the container holding the elements
  110180. */
  110181. addFromContainer(container: AbstractScene): void;
  110182. /**
  110183. * Removes all the elements in the container from the scene
  110184. * @param container contains the elements to remove
  110185. * @param dispose if the removed element should be disposed (default: false)
  110186. */
  110187. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  110188. /**
  110189. * Disposes the component and the associated ressources.
  110190. */
  110191. dispose(): void;
  110192. private _isReadyForMesh;
  110193. private _renderMainTexture;
  110194. private _setStencil;
  110195. private _setStencilBack;
  110196. private _draw;
  110197. private _drawCamera;
  110198. private _drawRenderingGroup;
  110199. }
  110200. }
  110201. declare module BABYLON {
  110202. /** @hidden */
  110203. export var glowMapMergePixelShader: {
  110204. name: string;
  110205. shader: string;
  110206. };
  110207. }
  110208. declare module BABYLON {
  110209. /** @hidden */
  110210. export var glowMapMergeVertexShader: {
  110211. name: string;
  110212. shader: string;
  110213. };
  110214. }
  110215. declare module BABYLON {
  110216. interface AbstractScene {
  110217. /**
  110218. * Return a the first highlight layer of the scene with a given name.
  110219. * @param name The name of the highlight layer to look for.
  110220. * @return The highlight layer if found otherwise null.
  110221. */
  110222. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  110223. }
  110224. /**
  110225. * Glow layer options. This helps customizing the behaviour
  110226. * of the glow layer.
  110227. */
  110228. export interface IGlowLayerOptions {
  110229. /**
  110230. * Multiplication factor apply to the canvas size to compute the render target size
  110231. * used to generated the glowing objects (the smaller the faster).
  110232. */
  110233. mainTextureRatio: number;
  110234. /**
  110235. * Enforces a fixed size texture to ensure resize independant blur.
  110236. */
  110237. mainTextureFixedSize?: number;
  110238. /**
  110239. * How big is the kernel of the blur texture.
  110240. */
  110241. blurKernelSize: number;
  110242. /**
  110243. * The camera attached to the layer.
  110244. */
  110245. camera: Nullable<Camera>;
  110246. /**
  110247. * Enable MSAA by chosing the number of samples.
  110248. */
  110249. mainTextureSamples?: number;
  110250. /**
  110251. * The rendering group to draw the layer in.
  110252. */
  110253. renderingGroupId: number;
  110254. }
  110255. /**
  110256. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  110257. *
  110258. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  110259. * glowy meshes to your scene.
  110260. *
  110261. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  110262. */
  110263. export class GlowLayer extends EffectLayer {
  110264. /**
  110265. * Effect Name of the layer.
  110266. */
  110267. static readonly EffectName: string;
  110268. /**
  110269. * The default blur kernel size used for the glow.
  110270. */
  110271. static DefaultBlurKernelSize: number;
  110272. /**
  110273. * The default texture size ratio used for the glow.
  110274. */
  110275. static DefaultTextureRatio: number;
  110276. /**
  110277. * Sets the kernel size of the blur.
  110278. */
  110279. /**
  110280. * Gets the kernel size of the blur.
  110281. */
  110282. blurKernelSize: number;
  110283. /**
  110284. * Sets the glow intensity.
  110285. */
  110286. /**
  110287. * Gets the glow intensity.
  110288. */
  110289. intensity: number;
  110290. private _options;
  110291. private _intensity;
  110292. private _horizontalBlurPostprocess1;
  110293. private _verticalBlurPostprocess1;
  110294. private _horizontalBlurPostprocess2;
  110295. private _verticalBlurPostprocess2;
  110296. private _blurTexture1;
  110297. private _blurTexture2;
  110298. private _postProcesses1;
  110299. private _postProcesses2;
  110300. private _includedOnlyMeshes;
  110301. private _excludedMeshes;
  110302. /**
  110303. * Callback used to let the user override the color selection on a per mesh basis
  110304. */
  110305. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  110306. /**
  110307. * Callback used to let the user override the texture selection on a per mesh basis
  110308. */
  110309. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  110310. /**
  110311. * Instantiates a new glow Layer and references it to the scene.
  110312. * @param name The name of the layer
  110313. * @param scene The scene to use the layer in
  110314. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  110315. */
  110316. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  110317. /**
  110318. * Get the effect name of the layer.
  110319. * @return The effect name
  110320. */
  110321. getEffectName(): string;
  110322. /**
  110323. * Create the merge effect. This is the shader use to blit the information back
  110324. * to the main canvas at the end of the scene rendering.
  110325. */
  110326. protected _createMergeEffect(): Effect;
  110327. /**
  110328. * Creates the render target textures and post processes used in the glow layer.
  110329. */
  110330. protected _createTextureAndPostProcesses(): void;
  110331. /**
  110332. * Checks for the readiness of the element composing the layer.
  110333. * @param subMesh the mesh to check for
  110334. * @param useInstances specify wether or not to use instances to render the mesh
  110335. * @param emissiveTexture the associated emissive texture used to generate the glow
  110336. * @return true if ready otherwise, false
  110337. */
  110338. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  110339. /**
  110340. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  110341. */
  110342. needStencil(): boolean;
  110343. /**
  110344. * Returns true if the mesh can be rendered, otherwise false.
  110345. * @param mesh The mesh to render
  110346. * @param material The material used on the mesh
  110347. * @returns true if it can be rendered otherwise false
  110348. */
  110349. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  110350. /**
  110351. * Implementation specific of rendering the generating effect on the main canvas.
  110352. * @param effect The effect used to render through
  110353. */
  110354. protected _internalRender(effect: Effect): void;
  110355. /**
  110356. * Sets the required values for both the emissive texture and and the main color.
  110357. */
  110358. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  110359. /**
  110360. * Returns true if the mesh should render, otherwise false.
  110361. * @param mesh The mesh to render
  110362. * @returns true if it should render otherwise false
  110363. */
  110364. protected _shouldRenderMesh(mesh: Mesh): boolean;
  110365. /**
  110366. * Adds specific effects defines.
  110367. * @param defines The defines to add specifics to.
  110368. */
  110369. protected _addCustomEffectDefines(defines: string[]): void;
  110370. /**
  110371. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  110372. * @param mesh The mesh to exclude from the glow layer
  110373. */
  110374. addExcludedMesh(mesh: Mesh): void;
  110375. /**
  110376. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  110377. * @param mesh The mesh to remove
  110378. */
  110379. removeExcludedMesh(mesh: Mesh): void;
  110380. /**
  110381. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  110382. * @param mesh The mesh to include in the glow layer
  110383. */
  110384. addIncludedOnlyMesh(mesh: Mesh): void;
  110385. /**
  110386. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  110387. * @param mesh The mesh to remove
  110388. */
  110389. removeIncludedOnlyMesh(mesh: Mesh): void;
  110390. /**
  110391. * Determine if a given mesh will be used in the glow layer
  110392. * @param mesh The mesh to test
  110393. * @returns true if the mesh will be highlighted by the current glow layer
  110394. */
  110395. hasMesh(mesh: AbstractMesh): boolean;
  110396. /**
  110397. * Free any resources and references associated to a mesh.
  110398. * Internal use
  110399. * @param mesh The mesh to free.
  110400. * @hidden
  110401. */
  110402. _disposeMesh(mesh: Mesh): void;
  110403. /**
  110404. * Gets the class name of the effect layer
  110405. * @returns the string with the class name of the effect layer
  110406. */
  110407. getClassName(): string;
  110408. /**
  110409. * Serializes this glow layer
  110410. * @returns a serialized glow layer object
  110411. */
  110412. serialize(): any;
  110413. /**
  110414. * Creates a Glow Layer from parsed glow layer data
  110415. * @param parsedGlowLayer defines glow layer data
  110416. * @param scene defines the current scene
  110417. * @param rootUrl defines the root URL containing the glow layer information
  110418. * @returns a parsed Glow Layer
  110419. */
  110420. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  110421. }
  110422. }
  110423. declare module BABYLON {
  110424. /** @hidden */
  110425. export var glowBlurPostProcessPixelShader: {
  110426. name: string;
  110427. shader: string;
  110428. };
  110429. }
  110430. declare module BABYLON {
  110431. interface AbstractScene {
  110432. /**
  110433. * Return a the first highlight layer of the scene with a given name.
  110434. * @param name The name of the highlight layer to look for.
  110435. * @return The highlight layer if found otherwise null.
  110436. */
  110437. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  110438. }
  110439. /**
  110440. * Highlight layer options. This helps customizing the behaviour
  110441. * of the highlight layer.
  110442. */
  110443. export interface IHighlightLayerOptions {
  110444. /**
  110445. * Multiplication factor apply to the canvas size to compute the render target size
  110446. * used to generated the glowing objects (the smaller the faster).
  110447. */
  110448. mainTextureRatio: number;
  110449. /**
  110450. * Enforces a fixed size texture to ensure resize independant blur.
  110451. */
  110452. mainTextureFixedSize?: number;
  110453. /**
  110454. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  110455. * of the picture to blur (the smaller the faster).
  110456. */
  110457. blurTextureSizeRatio: number;
  110458. /**
  110459. * How big in texel of the blur texture is the vertical blur.
  110460. */
  110461. blurVerticalSize: number;
  110462. /**
  110463. * How big in texel of the blur texture is the horizontal blur.
  110464. */
  110465. blurHorizontalSize: number;
  110466. /**
  110467. * Alpha blending mode used to apply the blur. Default is combine.
  110468. */
  110469. alphaBlendingMode: number;
  110470. /**
  110471. * The camera attached to the layer.
  110472. */
  110473. camera: Nullable<Camera>;
  110474. /**
  110475. * Should we display highlight as a solid stroke?
  110476. */
  110477. isStroke?: boolean;
  110478. /**
  110479. * The rendering group to draw the layer in.
  110480. */
  110481. renderingGroupId: number;
  110482. }
  110483. /**
  110484. * The highlight layer Helps adding a glow effect around a mesh.
  110485. *
  110486. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  110487. * glowy meshes to your scene.
  110488. *
  110489. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  110490. */
  110491. export class HighlightLayer extends EffectLayer {
  110492. name: string;
  110493. /**
  110494. * Effect Name of the highlight layer.
  110495. */
  110496. static readonly EffectName: string;
  110497. /**
  110498. * The neutral color used during the preparation of the glow effect.
  110499. * This is black by default as the blend operation is a blend operation.
  110500. */
  110501. static NeutralColor: Color4;
  110502. /**
  110503. * Stencil value used for glowing meshes.
  110504. */
  110505. static GlowingMeshStencilReference: number;
  110506. /**
  110507. * Stencil value used for the other meshes in the scene.
  110508. */
  110509. static NormalMeshStencilReference: number;
  110510. /**
  110511. * Specifies whether or not the inner glow is ACTIVE in the layer.
  110512. */
  110513. innerGlow: boolean;
  110514. /**
  110515. * Specifies whether or not the outer glow is ACTIVE in the layer.
  110516. */
  110517. outerGlow: boolean;
  110518. /**
  110519. * Specifies the horizontal size of the blur.
  110520. */
  110521. /**
  110522. * Gets the horizontal size of the blur.
  110523. */
  110524. blurHorizontalSize: number;
  110525. /**
  110526. * Specifies the vertical size of the blur.
  110527. */
  110528. /**
  110529. * Gets the vertical size of the blur.
  110530. */
  110531. blurVerticalSize: number;
  110532. /**
  110533. * An event triggered when the highlight layer is being blurred.
  110534. */
  110535. onBeforeBlurObservable: Observable<HighlightLayer>;
  110536. /**
  110537. * An event triggered when the highlight layer has been blurred.
  110538. */
  110539. onAfterBlurObservable: Observable<HighlightLayer>;
  110540. private _instanceGlowingMeshStencilReference;
  110541. private _options;
  110542. private _downSamplePostprocess;
  110543. private _horizontalBlurPostprocess;
  110544. private _verticalBlurPostprocess;
  110545. private _blurTexture;
  110546. private _meshes;
  110547. private _excludedMeshes;
  110548. /**
  110549. * Instantiates a new highlight Layer and references it to the scene..
  110550. * @param name The name of the layer
  110551. * @param scene The scene to use the layer in
  110552. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  110553. */
  110554. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  110555. /**
  110556. * Get the effect name of the layer.
  110557. * @return The effect name
  110558. */
  110559. getEffectName(): string;
  110560. /**
  110561. * Create the merge effect. This is the shader use to blit the information back
  110562. * to the main canvas at the end of the scene rendering.
  110563. */
  110564. protected _createMergeEffect(): Effect;
  110565. /**
  110566. * Creates the render target textures and post processes used in the highlight layer.
  110567. */
  110568. protected _createTextureAndPostProcesses(): void;
  110569. /**
  110570. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  110571. */
  110572. needStencil(): boolean;
  110573. /**
  110574. * Checks for the readiness of the element composing the layer.
  110575. * @param subMesh the mesh to check for
  110576. * @param useInstances specify wether or not to use instances to render the mesh
  110577. * @param emissiveTexture the associated emissive texture used to generate the glow
  110578. * @return true if ready otherwise, false
  110579. */
  110580. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  110581. /**
  110582. * Implementation specific of rendering the generating effect on the main canvas.
  110583. * @param effect The effect used to render through
  110584. */
  110585. protected _internalRender(effect: Effect): void;
  110586. /**
  110587. * Returns true if the layer contains information to display, otherwise false.
  110588. */
  110589. shouldRender(): boolean;
  110590. /**
  110591. * Returns true if the mesh should render, otherwise false.
  110592. * @param mesh The mesh to render
  110593. * @returns true if it should render otherwise false
  110594. */
  110595. protected _shouldRenderMesh(mesh: Mesh): boolean;
  110596. /**
  110597. * Sets the required values for both the emissive texture and and the main color.
  110598. */
  110599. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  110600. /**
  110601. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  110602. * @param mesh The mesh to exclude from the highlight layer
  110603. */
  110604. addExcludedMesh(mesh: Mesh): void;
  110605. /**
  110606. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  110607. * @param mesh The mesh to highlight
  110608. */
  110609. removeExcludedMesh(mesh: Mesh): void;
  110610. /**
  110611. * Determine if a given mesh will be highlighted by the current HighlightLayer
  110612. * @param mesh mesh to test
  110613. * @returns true if the mesh will be highlighted by the current HighlightLayer
  110614. */
  110615. hasMesh(mesh: AbstractMesh): boolean;
  110616. /**
  110617. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  110618. * @param mesh The mesh to highlight
  110619. * @param color The color of the highlight
  110620. * @param glowEmissiveOnly Extract the glow from the emissive texture
  110621. */
  110622. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  110623. /**
  110624. * Remove a mesh from the highlight layer in order to make it stop glowing.
  110625. * @param mesh The mesh to highlight
  110626. */
  110627. removeMesh(mesh: Mesh): void;
  110628. /**
  110629. * Force the stencil to the normal expected value for none glowing parts
  110630. */
  110631. private _defaultStencilReference;
  110632. /**
  110633. * Free any resources and references associated to a mesh.
  110634. * Internal use
  110635. * @param mesh The mesh to free.
  110636. * @hidden
  110637. */
  110638. _disposeMesh(mesh: Mesh): void;
  110639. /**
  110640. * Dispose the highlight layer and free resources.
  110641. */
  110642. dispose(): void;
  110643. /**
  110644. * Gets the class name of the effect layer
  110645. * @returns the string with the class name of the effect layer
  110646. */
  110647. getClassName(): string;
  110648. /**
  110649. * Serializes this Highlight layer
  110650. * @returns a serialized Highlight layer object
  110651. */
  110652. serialize(): any;
  110653. /**
  110654. * Creates a Highlight layer from parsed Highlight layer data
  110655. * @param parsedHightlightLayer defines the Highlight layer data
  110656. * @param scene defines the current scene
  110657. * @param rootUrl defines the root URL containing the Highlight layer information
  110658. * @returns a parsed Highlight layer
  110659. */
  110660. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  110661. }
  110662. }
  110663. declare module BABYLON {
  110664. interface AbstractScene {
  110665. /**
  110666. * The list of layers (background and foreground) of the scene
  110667. */
  110668. layers: Array<Layer>;
  110669. }
  110670. /**
  110671. * Defines the layer scene component responsible to manage any layers
  110672. * in a given scene.
  110673. */
  110674. export class LayerSceneComponent implements ISceneComponent {
  110675. /**
  110676. * The component name helpfull to identify the component in the list of scene components.
  110677. */
  110678. readonly name: string;
  110679. /**
  110680. * The scene the component belongs to.
  110681. */
  110682. scene: Scene;
  110683. private _engine;
  110684. /**
  110685. * Creates a new instance of the component for the given scene
  110686. * @param scene Defines the scene to register the component in
  110687. */
  110688. constructor(scene: Scene);
  110689. /**
  110690. * Registers the component in a given scene
  110691. */
  110692. register(): void;
  110693. /**
  110694. * Rebuilds the elements related to this component in case of
  110695. * context lost for instance.
  110696. */
  110697. rebuild(): void;
  110698. /**
  110699. * Disposes the component and the associated ressources.
  110700. */
  110701. dispose(): void;
  110702. private _draw;
  110703. private _drawCameraPredicate;
  110704. private _drawCameraBackground;
  110705. private _drawCameraForeground;
  110706. private _drawRenderTargetPredicate;
  110707. private _drawRenderTargetBackground;
  110708. private _drawRenderTargetForeground;
  110709. /**
  110710. * Adds all the elements from the container to the scene
  110711. * @param container the container holding the elements
  110712. */
  110713. addFromContainer(container: AbstractScene): void;
  110714. /**
  110715. * Removes all the elements in the container from the scene
  110716. * @param container contains the elements to remove
  110717. * @param dispose if the removed element should be disposed (default: false)
  110718. */
  110719. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  110720. }
  110721. }
  110722. declare module BABYLON {
  110723. /** @hidden */
  110724. export var layerPixelShader: {
  110725. name: string;
  110726. shader: string;
  110727. };
  110728. }
  110729. declare module BABYLON {
  110730. /** @hidden */
  110731. export var layerVertexShader: {
  110732. name: string;
  110733. shader: string;
  110734. };
  110735. }
  110736. declare module BABYLON {
  110737. /**
  110738. * This represents a full screen 2d layer.
  110739. * This can be useful to display a picture in the background of your scene for instance.
  110740. * @see https://www.babylonjs-playground.com/#08A2BS#1
  110741. */
  110742. export class Layer {
  110743. /**
  110744. * Define the name of the layer.
  110745. */
  110746. name: string;
  110747. /**
  110748. * Define the texture the layer should display.
  110749. */
  110750. texture: Nullable<Texture>;
  110751. /**
  110752. * Is the layer in background or foreground.
  110753. */
  110754. isBackground: boolean;
  110755. /**
  110756. * Define the color of the layer (instead of texture).
  110757. */
  110758. color: Color4;
  110759. /**
  110760. * Define the scale of the layer in order to zoom in out of the texture.
  110761. */
  110762. scale: Vector2;
  110763. /**
  110764. * Define an offset for the layer in order to shift the texture.
  110765. */
  110766. offset: Vector2;
  110767. /**
  110768. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  110769. */
  110770. alphaBlendingMode: number;
  110771. /**
  110772. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  110773. * Alpha test will not mix with the background color in case of transparency.
  110774. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  110775. */
  110776. alphaTest: boolean;
  110777. /**
  110778. * Define a mask to restrict the layer to only some of the scene cameras.
  110779. */
  110780. layerMask: number;
  110781. /**
  110782. * Define the list of render target the layer is visible into.
  110783. */
  110784. renderTargetTextures: RenderTargetTexture[];
  110785. /**
  110786. * Define if the layer is only used in renderTarget or if it also
  110787. * renders in the main frame buffer of the canvas.
  110788. */
  110789. renderOnlyInRenderTargetTextures: boolean;
  110790. private _scene;
  110791. private _vertexBuffers;
  110792. private _indexBuffer;
  110793. private _effect;
  110794. private _alphaTestEffect;
  110795. /**
  110796. * An event triggered when the layer is disposed.
  110797. */
  110798. onDisposeObservable: Observable<Layer>;
  110799. private _onDisposeObserver;
  110800. /**
  110801. * Back compatibility with callback before the onDisposeObservable existed.
  110802. * The set callback will be triggered when the layer has been disposed.
  110803. */
  110804. onDispose: () => void;
  110805. /**
  110806. * An event triggered before rendering the scene
  110807. */
  110808. onBeforeRenderObservable: Observable<Layer>;
  110809. private _onBeforeRenderObserver;
  110810. /**
  110811. * Back compatibility with callback before the onBeforeRenderObservable existed.
  110812. * The set callback will be triggered just before rendering the layer.
  110813. */
  110814. onBeforeRender: () => void;
  110815. /**
  110816. * An event triggered after rendering the scene
  110817. */
  110818. onAfterRenderObservable: Observable<Layer>;
  110819. private _onAfterRenderObserver;
  110820. /**
  110821. * Back compatibility with callback before the onAfterRenderObservable existed.
  110822. * The set callback will be triggered just after rendering the layer.
  110823. */
  110824. onAfterRender: () => void;
  110825. /**
  110826. * Instantiates a new layer.
  110827. * This represents a full screen 2d layer.
  110828. * This can be useful to display a picture in the background of your scene for instance.
  110829. * @see https://www.babylonjs-playground.com/#08A2BS#1
  110830. * @param name Define the name of the layer in the scene
  110831. * @param imgUrl Define the url of the texture to display in the layer
  110832. * @param scene Define the scene the layer belongs to
  110833. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  110834. * @param color Defines a color for the layer
  110835. */
  110836. constructor(
  110837. /**
  110838. * Define the name of the layer.
  110839. */
  110840. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  110841. private _createIndexBuffer;
  110842. /** @hidden */
  110843. _rebuild(): void;
  110844. /**
  110845. * Renders the layer in the scene.
  110846. */
  110847. render(): void;
  110848. /**
  110849. * Disposes and releases the associated ressources.
  110850. */
  110851. dispose(): void;
  110852. }
  110853. }
  110854. declare module BABYLON {
  110855. /** @hidden */
  110856. export var lensFlarePixelShader: {
  110857. name: string;
  110858. shader: string;
  110859. };
  110860. }
  110861. declare module BABYLON {
  110862. /** @hidden */
  110863. export var lensFlareVertexShader: {
  110864. name: string;
  110865. shader: string;
  110866. };
  110867. }
  110868. declare module BABYLON {
  110869. /**
  110870. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  110871. * It is usually composed of several `lensFlare`.
  110872. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  110873. */
  110874. export class LensFlareSystem {
  110875. /**
  110876. * Define the name of the lens flare system
  110877. */
  110878. name: string;
  110879. /**
  110880. * List of lens flares used in this system.
  110881. */
  110882. lensFlares: LensFlare[];
  110883. /**
  110884. * Define a limit from the border the lens flare can be visible.
  110885. */
  110886. borderLimit: number;
  110887. /**
  110888. * Define a viewport border we do not want to see the lens flare in.
  110889. */
  110890. viewportBorder: number;
  110891. /**
  110892. * Define a predicate which could limit the list of meshes able to occlude the effect.
  110893. */
  110894. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  110895. /**
  110896. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  110897. */
  110898. layerMask: number;
  110899. /**
  110900. * Define the id of the lens flare system in the scene.
  110901. * (equal to name by default)
  110902. */
  110903. id: string;
  110904. private _scene;
  110905. private _emitter;
  110906. private _vertexBuffers;
  110907. private _indexBuffer;
  110908. private _effect;
  110909. private _positionX;
  110910. private _positionY;
  110911. private _isEnabled;
  110912. /** @hidden */
  110913. static _SceneComponentInitialization: (scene: Scene) => void;
  110914. /**
  110915. * Instantiates a lens flare system.
  110916. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  110917. * It is usually composed of several `lensFlare`.
  110918. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  110919. * @param name Define the name of the lens flare system in the scene
  110920. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  110921. * @param scene Define the scene the lens flare system belongs to
  110922. */
  110923. constructor(
  110924. /**
  110925. * Define the name of the lens flare system
  110926. */
  110927. name: string, emitter: any, scene: Scene);
  110928. /**
  110929. * Define if the lens flare system is enabled.
  110930. */
  110931. isEnabled: boolean;
  110932. /**
  110933. * Get the scene the effects belongs to.
  110934. * @returns the scene holding the lens flare system
  110935. */
  110936. getScene(): Scene;
  110937. /**
  110938. * Get the emitter of the lens flare system.
  110939. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  110940. * @returns the emitter of the lens flare system
  110941. */
  110942. getEmitter(): any;
  110943. /**
  110944. * Set the emitter of the lens flare system.
  110945. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  110946. * @param newEmitter Define the new emitter of the system
  110947. */
  110948. setEmitter(newEmitter: any): void;
  110949. /**
  110950. * Get the lens flare system emitter position.
  110951. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  110952. * @returns the position
  110953. */
  110954. getEmitterPosition(): Vector3;
  110955. /**
  110956. * @hidden
  110957. */
  110958. computeEffectivePosition(globalViewport: Viewport): boolean;
  110959. /** @hidden */
  110960. _isVisible(): boolean;
  110961. /**
  110962. * @hidden
  110963. */
  110964. render(): boolean;
  110965. /**
  110966. * Dispose and release the lens flare with its associated resources.
  110967. */
  110968. dispose(): void;
  110969. /**
  110970. * Parse a lens flare system from a JSON repressentation
  110971. * @param parsedLensFlareSystem Define the JSON to parse
  110972. * @param scene Define the scene the parsed system should be instantiated in
  110973. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  110974. * @returns the parsed system
  110975. */
  110976. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  110977. /**
  110978. * Serialize the current Lens Flare System into a JSON representation.
  110979. * @returns the serialized JSON
  110980. */
  110981. serialize(): any;
  110982. }
  110983. }
  110984. declare module BABYLON {
  110985. /**
  110986. * This represents one of the lens effect in a `lensFlareSystem`.
  110987. * It controls one of the indiviual texture used in the effect.
  110988. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  110989. */
  110990. export class LensFlare {
  110991. /**
  110992. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  110993. */
  110994. size: number;
  110995. /**
  110996. * 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.
  110997. */
  110998. position: number;
  110999. /**
  111000. * Define the lens color.
  111001. */
  111002. color: Color3;
  111003. /**
  111004. * Define the lens texture.
  111005. */
  111006. texture: Nullable<Texture>;
  111007. /**
  111008. * Define the alpha mode to render this particular lens.
  111009. */
  111010. alphaMode: number;
  111011. private _system;
  111012. /**
  111013. * Creates a new Lens Flare.
  111014. * This represents one of the lens effect in a `lensFlareSystem`.
  111015. * It controls one of the indiviual texture used in the effect.
  111016. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  111017. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  111018. * @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.
  111019. * @param color Define the lens color
  111020. * @param imgUrl Define the lens texture url
  111021. * @param system Define the `lensFlareSystem` this flare is part of
  111022. * @returns The newly created Lens Flare
  111023. */
  111024. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  111025. /**
  111026. * Instantiates a new Lens Flare.
  111027. * This represents one of the lens effect in a `lensFlareSystem`.
  111028. * It controls one of the indiviual texture used in the effect.
  111029. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  111030. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  111031. * @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.
  111032. * @param color Define the lens color
  111033. * @param imgUrl Define the lens texture url
  111034. * @param system Define the `lensFlareSystem` this flare is part of
  111035. */
  111036. constructor(
  111037. /**
  111038. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  111039. */
  111040. size: number,
  111041. /**
  111042. * 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.
  111043. */
  111044. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  111045. /**
  111046. * Dispose and release the lens flare with its associated resources.
  111047. */
  111048. dispose(): void;
  111049. }
  111050. }
  111051. declare module BABYLON {
  111052. interface AbstractScene {
  111053. /**
  111054. * The list of lens flare system added to the scene
  111055. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  111056. */
  111057. lensFlareSystems: Array<LensFlareSystem>;
  111058. /**
  111059. * Removes the given lens flare system from this scene.
  111060. * @param toRemove The lens flare system to remove
  111061. * @returns The index of the removed lens flare system
  111062. */
  111063. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  111064. /**
  111065. * Adds the given lens flare system to this scene
  111066. * @param newLensFlareSystem The lens flare system to add
  111067. */
  111068. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  111069. /**
  111070. * Gets a lens flare system using its name
  111071. * @param name defines the name to look for
  111072. * @returns the lens flare system or null if not found
  111073. */
  111074. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  111075. /**
  111076. * Gets a lens flare system using its id
  111077. * @param id defines the id to look for
  111078. * @returns the lens flare system or null if not found
  111079. */
  111080. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  111081. }
  111082. /**
  111083. * Defines the lens flare scene component responsible to manage any lens flares
  111084. * in a given scene.
  111085. */
  111086. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  111087. /**
  111088. * The component name helpfull to identify the component in the list of scene components.
  111089. */
  111090. readonly name: string;
  111091. /**
  111092. * The scene the component belongs to.
  111093. */
  111094. scene: Scene;
  111095. /**
  111096. * Creates a new instance of the component for the given scene
  111097. * @param scene Defines the scene to register the component in
  111098. */
  111099. constructor(scene: Scene);
  111100. /**
  111101. * Registers the component in a given scene
  111102. */
  111103. register(): void;
  111104. /**
  111105. * Rebuilds the elements related to this component in case of
  111106. * context lost for instance.
  111107. */
  111108. rebuild(): void;
  111109. /**
  111110. * Adds all the elements from the container to the scene
  111111. * @param container the container holding the elements
  111112. */
  111113. addFromContainer(container: AbstractScene): void;
  111114. /**
  111115. * Removes all the elements in the container from the scene
  111116. * @param container contains the elements to remove
  111117. * @param dispose if the removed element should be disposed (default: false)
  111118. */
  111119. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  111120. /**
  111121. * Serializes the component data to the specified json object
  111122. * @param serializationObject The object to serialize to
  111123. */
  111124. serialize(serializationObject: any): void;
  111125. /**
  111126. * Disposes the component and the associated ressources.
  111127. */
  111128. dispose(): void;
  111129. private _draw;
  111130. }
  111131. }
  111132. declare module BABYLON {
  111133. /**
  111134. * Defines the shadow generator component responsible to manage any shadow generators
  111135. * in a given scene.
  111136. */
  111137. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  111138. /**
  111139. * The component name helpfull to identify the component in the list of scene components.
  111140. */
  111141. readonly name: string;
  111142. /**
  111143. * The scene the component belongs to.
  111144. */
  111145. scene: Scene;
  111146. /**
  111147. * Creates a new instance of the component for the given scene
  111148. * @param scene Defines the scene to register the component in
  111149. */
  111150. constructor(scene: Scene);
  111151. /**
  111152. * Registers the component in a given scene
  111153. */
  111154. register(): void;
  111155. /**
  111156. * Rebuilds the elements related to this component in case of
  111157. * context lost for instance.
  111158. */
  111159. rebuild(): void;
  111160. /**
  111161. * Serializes the component data to the specified json object
  111162. * @param serializationObject The object to serialize to
  111163. */
  111164. serialize(serializationObject: any): void;
  111165. /**
  111166. * Adds all the elements from the container to the scene
  111167. * @param container the container holding the elements
  111168. */
  111169. addFromContainer(container: AbstractScene): void;
  111170. /**
  111171. * Removes all the elements in the container from the scene
  111172. * @param container contains the elements to remove
  111173. * @param dispose if the removed element should be disposed (default: false)
  111174. */
  111175. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  111176. /**
  111177. * Rebuilds the elements related to this component in case of
  111178. * context lost for instance.
  111179. */
  111180. dispose(): void;
  111181. private _gatherRenderTargets;
  111182. }
  111183. }
  111184. declare module BABYLON {
  111185. /**
  111186. * A point light is a light defined by an unique point in world space.
  111187. * The light is emitted in every direction from this point.
  111188. * A good example of a point light is a standard light bulb.
  111189. * Documentation: https://doc.babylonjs.com/babylon101/lights
  111190. */
  111191. export class PointLight extends ShadowLight {
  111192. private _shadowAngle;
  111193. /**
  111194. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  111195. * This specifies what angle the shadow will use to be created.
  111196. *
  111197. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  111198. */
  111199. /**
  111200. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  111201. * This specifies what angle the shadow will use to be created.
  111202. *
  111203. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  111204. */
  111205. shadowAngle: number;
  111206. /**
  111207. * Gets the direction if it has been set.
  111208. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  111209. */
  111210. /**
  111211. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  111212. */
  111213. direction: Vector3;
  111214. /**
  111215. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  111216. * A PointLight emits the light in every direction.
  111217. * It can cast shadows.
  111218. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  111219. * ```javascript
  111220. * var pointLight = new PointLight("pl", camera.position, scene);
  111221. * ```
  111222. * Documentation : https://doc.babylonjs.com/babylon101/lights
  111223. * @param name The light friendly name
  111224. * @param position The position of the point light in the scene
  111225. * @param scene The scene the lights belongs to
  111226. */
  111227. constructor(name: string, position: Vector3, scene: Scene);
  111228. /**
  111229. * Returns the string "PointLight"
  111230. * @returns the class name
  111231. */
  111232. getClassName(): string;
  111233. /**
  111234. * Returns the integer 0.
  111235. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  111236. */
  111237. getTypeID(): number;
  111238. /**
  111239. * Specifies wether or not the shadowmap should be a cube texture.
  111240. * @returns true if the shadowmap needs to be a cube texture.
  111241. */
  111242. needCube(): boolean;
  111243. /**
  111244. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  111245. * @param faceIndex The index of the face we are computed the direction to generate shadow
  111246. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  111247. */
  111248. getShadowDirection(faceIndex?: number): Vector3;
  111249. /**
  111250. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  111251. * - fov = PI / 2
  111252. * - aspect ratio : 1.0
  111253. * - z-near and far equal to the active camera minZ and maxZ.
  111254. * Returns the PointLight.
  111255. */
  111256. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  111257. protected _buildUniformLayout(): void;
  111258. /**
  111259. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  111260. * @param effect The effect to update
  111261. * @param lightIndex The index of the light in the effect to update
  111262. * @returns The point light
  111263. */
  111264. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  111265. /**
  111266. * Prepares the list of defines specific to the light type.
  111267. * @param defines the list of defines
  111268. * @param lightIndex defines the index of the light for the effect
  111269. */
  111270. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  111271. }
  111272. }
  111273. declare module BABYLON {
  111274. /**
  111275. * Header information of HDR texture files.
  111276. */
  111277. export interface HDRInfo {
  111278. /**
  111279. * The height of the texture in pixels.
  111280. */
  111281. height: number;
  111282. /**
  111283. * The width of the texture in pixels.
  111284. */
  111285. width: number;
  111286. /**
  111287. * The index of the beginning of the data in the binary file.
  111288. */
  111289. dataPosition: number;
  111290. }
  111291. /**
  111292. * This groups tools to convert HDR texture to native colors array.
  111293. */
  111294. export class HDRTools {
  111295. private static Ldexp;
  111296. private static Rgbe2float;
  111297. private static readStringLine;
  111298. /**
  111299. * Reads header information from an RGBE texture stored in a native array.
  111300. * More information on this format are available here:
  111301. * https://en.wikipedia.org/wiki/RGBE_image_format
  111302. *
  111303. * @param uint8array The binary file stored in native array.
  111304. * @return The header information.
  111305. */
  111306. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  111307. /**
  111308. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  111309. * This RGBE texture needs to store the information as a panorama.
  111310. *
  111311. * More information on this format are available here:
  111312. * https://en.wikipedia.org/wiki/RGBE_image_format
  111313. *
  111314. * @param buffer The binary file stored in an array buffer.
  111315. * @param size The expected size of the extracted cubemap.
  111316. * @return The Cube Map information.
  111317. */
  111318. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  111319. /**
  111320. * Returns the pixels data extracted from an RGBE texture.
  111321. * This pixels will be stored left to right up to down in the R G B order in one array.
  111322. *
  111323. * More information on this format are available here:
  111324. * https://en.wikipedia.org/wiki/RGBE_image_format
  111325. *
  111326. * @param uint8array The binary file stored in an array buffer.
  111327. * @param hdrInfo The header information of the file.
  111328. * @return The pixels data in RGB right to left up to down order.
  111329. */
  111330. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  111331. private static RGBE_ReadPixels_RLE;
  111332. }
  111333. }
  111334. declare module BABYLON {
  111335. /**
  111336. * This represents a texture coming from an HDR input.
  111337. *
  111338. * The only supported format is currently panorama picture stored in RGBE format.
  111339. * Example of such files can be found on HDRLib: http://hdrlib.com/
  111340. */
  111341. export class HDRCubeTexture extends BaseTexture {
  111342. private static _facesMapping;
  111343. private _generateHarmonics;
  111344. private _noMipmap;
  111345. private _textureMatrix;
  111346. private _size;
  111347. private _onLoad;
  111348. private _onError;
  111349. /**
  111350. * The texture URL.
  111351. */
  111352. url: string;
  111353. /**
  111354. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  111355. */
  111356. coordinatesMode: number;
  111357. protected _isBlocking: boolean;
  111358. /**
  111359. * Sets wether or not the texture is blocking during loading.
  111360. */
  111361. /**
  111362. * Gets wether or not the texture is blocking during loading.
  111363. */
  111364. isBlocking: boolean;
  111365. protected _rotationY: number;
  111366. /**
  111367. * Sets texture matrix rotation angle around Y axis in radians.
  111368. */
  111369. /**
  111370. * Gets texture matrix rotation angle around Y axis radians.
  111371. */
  111372. rotationY: number;
  111373. /**
  111374. * Gets or sets the center of the bounding box associated with the cube texture
  111375. * It must define where the camera used to render the texture was set
  111376. */
  111377. boundingBoxPosition: Vector3;
  111378. private _boundingBoxSize;
  111379. /**
  111380. * Gets or sets the size of the bounding box associated with the cube texture
  111381. * When defined, the cubemap will switch to local mode
  111382. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  111383. * @example https://www.babylonjs-playground.com/#RNASML
  111384. */
  111385. boundingBoxSize: Vector3;
  111386. /**
  111387. * Instantiates an HDRTexture from the following parameters.
  111388. *
  111389. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  111390. * @param scene The scene the texture will be used in
  111391. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  111392. * @param noMipmap Forces to not generate the mipmap if true
  111393. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  111394. * @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)
  111395. * @param reserved Reserved flag for internal use.
  111396. */
  111397. 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>);
  111398. /**
  111399. * Get the current class name of the texture useful for serialization or dynamic coding.
  111400. * @returns "HDRCubeTexture"
  111401. */
  111402. getClassName(): string;
  111403. /**
  111404. * Occurs when the file is raw .hdr file.
  111405. */
  111406. private loadTexture;
  111407. clone(): HDRCubeTexture;
  111408. delayLoad(): void;
  111409. /**
  111410. * Get the texture reflection matrix used to rotate/transform the reflection.
  111411. * @returns the reflection matrix
  111412. */
  111413. getReflectionTextureMatrix(): Matrix;
  111414. /**
  111415. * Set the texture reflection matrix used to rotate/transform the reflection.
  111416. * @param value Define the reflection matrix to set
  111417. */
  111418. setReflectionTextureMatrix(value: Matrix): void;
  111419. /**
  111420. * Parses a JSON representation of an HDR Texture in order to create the texture
  111421. * @param parsedTexture Define the JSON representation
  111422. * @param scene Define the scene the texture should be created in
  111423. * @param rootUrl Define the root url in case we need to load relative dependencies
  111424. * @returns the newly created texture after parsing
  111425. */
  111426. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  111427. serialize(): any;
  111428. }
  111429. }
  111430. declare module BABYLON {
  111431. /**
  111432. * Class used to control physics engine
  111433. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  111434. */
  111435. export class PhysicsEngine implements IPhysicsEngine {
  111436. private _physicsPlugin;
  111437. /**
  111438. * Global value used to control the smallest number supported by the simulation
  111439. */
  111440. static Epsilon: number;
  111441. private _impostors;
  111442. private _joints;
  111443. /**
  111444. * Gets the gravity vector used by the simulation
  111445. */
  111446. gravity: Vector3;
  111447. /**
  111448. * Factory used to create the default physics plugin.
  111449. * @returns The default physics plugin
  111450. */
  111451. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  111452. /**
  111453. * Creates a new Physics Engine
  111454. * @param gravity defines the gravity vector used by the simulation
  111455. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  111456. */
  111457. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  111458. /**
  111459. * Sets the gravity vector used by the simulation
  111460. * @param gravity defines the gravity vector to use
  111461. */
  111462. setGravity(gravity: Vector3): void;
  111463. /**
  111464. * Set the time step of the physics engine.
  111465. * Default is 1/60.
  111466. * To slow it down, enter 1/600 for example.
  111467. * To speed it up, 1/30
  111468. * @param newTimeStep defines the new timestep to apply to this world.
  111469. */
  111470. setTimeStep(newTimeStep?: number): void;
  111471. /**
  111472. * Get the time step of the physics engine.
  111473. * @returns the current time step
  111474. */
  111475. getTimeStep(): number;
  111476. /**
  111477. * Release all resources
  111478. */
  111479. dispose(): void;
  111480. /**
  111481. * Gets the name of the current physics plugin
  111482. * @returns the name of the plugin
  111483. */
  111484. getPhysicsPluginName(): string;
  111485. /**
  111486. * Adding a new impostor for the impostor tracking.
  111487. * This will be done by the impostor itself.
  111488. * @param impostor the impostor to add
  111489. */
  111490. addImpostor(impostor: PhysicsImpostor): void;
  111491. /**
  111492. * Remove an impostor from the engine.
  111493. * This impostor and its mesh will not longer be updated by the physics engine.
  111494. * @param impostor the impostor to remove
  111495. */
  111496. removeImpostor(impostor: PhysicsImpostor): void;
  111497. /**
  111498. * Add a joint to the physics engine
  111499. * @param mainImpostor defines the main impostor to which the joint is added.
  111500. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  111501. * @param joint defines the joint that will connect both impostors.
  111502. */
  111503. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  111504. /**
  111505. * Removes a joint from the simulation
  111506. * @param mainImpostor defines the impostor used with the joint
  111507. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  111508. * @param joint defines the joint to remove
  111509. */
  111510. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  111511. /**
  111512. * Called by the scene. No need to call it.
  111513. * @param delta defines the timespam between frames
  111514. */
  111515. _step(delta: number): void;
  111516. /**
  111517. * Gets the current plugin used to run the simulation
  111518. * @returns current plugin
  111519. */
  111520. getPhysicsPlugin(): IPhysicsEnginePlugin;
  111521. /**
  111522. * Gets the list of physic impostors
  111523. * @returns an array of PhysicsImpostor
  111524. */
  111525. getImpostors(): Array<PhysicsImpostor>;
  111526. /**
  111527. * Gets the impostor for a physics enabled object
  111528. * @param object defines the object impersonated by the impostor
  111529. * @returns the PhysicsImpostor or null if not found
  111530. */
  111531. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  111532. /**
  111533. * Gets the impostor for a physics body object
  111534. * @param body defines physics body used by the impostor
  111535. * @returns the PhysicsImpostor or null if not found
  111536. */
  111537. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  111538. /**
  111539. * Does a raycast in the physics world
  111540. * @param from when should the ray start?
  111541. * @param to when should the ray end?
  111542. * @returns PhysicsRaycastResult
  111543. */
  111544. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  111545. }
  111546. }
  111547. declare module BABYLON {
  111548. /** @hidden */
  111549. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  111550. private _useDeltaForWorldStep;
  111551. world: any;
  111552. name: string;
  111553. private _physicsMaterials;
  111554. private _fixedTimeStep;
  111555. private _cannonRaycastResult;
  111556. private _raycastResult;
  111557. private _removeAfterStep;
  111558. BJSCANNON: any;
  111559. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  111560. setGravity(gravity: Vector3): void;
  111561. setTimeStep(timeStep: number): void;
  111562. getTimeStep(): number;
  111563. executeStep(delta: number): void;
  111564. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  111565. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  111566. generatePhysicsBody(impostor: PhysicsImpostor): void;
  111567. private _processChildMeshes;
  111568. removePhysicsBody(impostor: PhysicsImpostor): void;
  111569. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  111570. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  111571. private _addMaterial;
  111572. private _checkWithEpsilon;
  111573. private _createShape;
  111574. private _createHeightmap;
  111575. private _minus90X;
  111576. private _plus90X;
  111577. private _tmpPosition;
  111578. private _tmpDeltaPosition;
  111579. private _tmpUnityRotation;
  111580. private _updatePhysicsBodyTransformation;
  111581. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  111582. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  111583. isSupported(): boolean;
  111584. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  111585. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  111586. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  111587. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  111588. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  111589. getBodyMass(impostor: PhysicsImpostor): number;
  111590. getBodyFriction(impostor: PhysicsImpostor): number;
  111591. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  111592. getBodyRestitution(impostor: PhysicsImpostor): number;
  111593. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  111594. sleepBody(impostor: PhysicsImpostor): void;
  111595. wakeUpBody(impostor: PhysicsImpostor): void;
  111596. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  111597. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  111598. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  111599. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  111600. getRadius(impostor: PhysicsImpostor): number;
  111601. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  111602. dispose(): void;
  111603. private _extendNamespace;
  111604. /**
  111605. * Does a raycast in the physics world
  111606. * @param from when should the ray start?
  111607. * @param to when should the ray end?
  111608. * @returns PhysicsRaycastResult
  111609. */
  111610. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  111611. }
  111612. }
  111613. declare module BABYLON {
  111614. /** @hidden */
  111615. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  111616. world: any;
  111617. name: string;
  111618. BJSOIMO: any;
  111619. private _raycastResult;
  111620. constructor(iterations?: number, oimoInjection?: any);
  111621. setGravity(gravity: Vector3): void;
  111622. setTimeStep(timeStep: number): void;
  111623. getTimeStep(): number;
  111624. private _tmpImpostorsArray;
  111625. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  111626. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  111627. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  111628. generatePhysicsBody(impostor: PhysicsImpostor): void;
  111629. private _tmpPositionVector;
  111630. removePhysicsBody(impostor: PhysicsImpostor): void;
  111631. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  111632. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  111633. isSupported(): boolean;
  111634. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  111635. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  111636. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  111637. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  111638. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  111639. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  111640. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  111641. getBodyMass(impostor: PhysicsImpostor): number;
  111642. getBodyFriction(impostor: PhysicsImpostor): number;
  111643. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  111644. getBodyRestitution(impostor: PhysicsImpostor): number;
  111645. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  111646. sleepBody(impostor: PhysicsImpostor): void;
  111647. wakeUpBody(impostor: PhysicsImpostor): void;
  111648. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  111649. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  111650. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  111651. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  111652. getRadius(impostor: PhysicsImpostor): number;
  111653. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  111654. dispose(): void;
  111655. /**
  111656. * Does a raycast in the physics world
  111657. * @param from when should the ray start?
  111658. * @param to when should the ray end?
  111659. * @returns PhysicsRaycastResult
  111660. */
  111661. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  111662. }
  111663. }
  111664. declare module BABYLON {
  111665. /**
  111666. * Class containing static functions to help procedurally build meshes
  111667. */
  111668. export class RibbonBuilder {
  111669. /**
  111670. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  111671. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  111672. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  111673. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  111674. * * 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
  111675. * * 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
  111676. * * 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
  111677. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  111678. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  111679. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  111680. * * 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
  111681. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  111682. * * 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
  111683. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  111684. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  111685. * @param name defines the name of the mesh
  111686. * @param options defines the options used to create the mesh
  111687. * @param scene defines the hosting scene
  111688. * @returns the ribbon mesh
  111689. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  111690. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  111691. */
  111692. static CreateRibbon(name: string, options: {
  111693. pathArray: Vector3[][];
  111694. closeArray?: boolean;
  111695. closePath?: boolean;
  111696. offset?: number;
  111697. updatable?: boolean;
  111698. sideOrientation?: number;
  111699. frontUVs?: Vector4;
  111700. backUVs?: Vector4;
  111701. instance?: Mesh;
  111702. invertUV?: boolean;
  111703. uvs?: Vector2[];
  111704. colors?: Color4[];
  111705. }, scene?: Nullable<Scene>): Mesh;
  111706. }
  111707. }
  111708. declare module BABYLON {
  111709. /**
  111710. * Class containing static functions to help procedurally build meshes
  111711. */
  111712. export class ShapeBuilder {
  111713. /**
  111714. * 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.
  111715. * * 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.
  111716. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  111717. * * 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.
  111718. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  111719. * * 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
  111720. * * 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
  111721. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  111722. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  111723. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  111724. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  111725. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  111726. * @param name defines the name of the mesh
  111727. * @param options defines the options used to create the mesh
  111728. * @param scene defines the hosting scene
  111729. * @returns the extruded shape mesh
  111730. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  111731. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  111732. */
  111733. static ExtrudeShape(name: string, options: {
  111734. shape: Vector3[];
  111735. path: Vector3[];
  111736. scale?: number;
  111737. rotation?: number;
  111738. cap?: number;
  111739. updatable?: boolean;
  111740. sideOrientation?: number;
  111741. frontUVs?: Vector4;
  111742. backUVs?: Vector4;
  111743. instance?: Mesh;
  111744. invertUV?: boolean;
  111745. }, scene?: Nullable<Scene>): Mesh;
  111746. /**
  111747. * Creates an custom extruded shape mesh.
  111748. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  111749. * * 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.
  111750. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  111751. * * 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
  111752. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  111753. * * 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
  111754. * * It must returns a float value that will be the scale value applied to the shape on each path point
  111755. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  111756. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  111757. * * 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
  111758. * * 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
  111759. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  111760. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  111761. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  111762. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  111763. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  111764. * @param name defines the name of the mesh
  111765. * @param options defines the options used to create the mesh
  111766. * @param scene defines the hosting scene
  111767. * @returns the custom extruded shape mesh
  111768. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  111769. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  111770. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  111771. */
  111772. static ExtrudeShapeCustom(name: string, options: {
  111773. shape: Vector3[];
  111774. path: Vector3[];
  111775. scaleFunction?: any;
  111776. rotationFunction?: any;
  111777. ribbonCloseArray?: boolean;
  111778. ribbonClosePath?: boolean;
  111779. cap?: number;
  111780. updatable?: boolean;
  111781. sideOrientation?: number;
  111782. frontUVs?: Vector4;
  111783. backUVs?: Vector4;
  111784. instance?: Mesh;
  111785. invertUV?: boolean;
  111786. }, scene?: Nullable<Scene>): Mesh;
  111787. private static _ExtrudeShapeGeneric;
  111788. }
  111789. }
  111790. declare module BABYLON {
  111791. /**
  111792. * AmmoJS Physics plugin
  111793. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  111794. * @see https://github.com/kripken/ammo.js/
  111795. */
  111796. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  111797. private _useDeltaForWorldStep;
  111798. /**
  111799. * Reference to the Ammo library
  111800. */
  111801. bjsAMMO: any;
  111802. /**
  111803. * Created ammoJS world which physics bodies are added to
  111804. */
  111805. world: any;
  111806. /**
  111807. * Name of the plugin
  111808. */
  111809. name: string;
  111810. private _timeStep;
  111811. private _fixedTimeStep;
  111812. private _maxSteps;
  111813. private _tmpQuaternion;
  111814. private _tmpAmmoTransform;
  111815. private _tmpAmmoQuaternion;
  111816. private _tmpAmmoConcreteContactResultCallback;
  111817. private _collisionConfiguration;
  111818. private _dispatcher;
  111819. private _overlappingPairCache;
  111820. private _solver;
  111821. private _softBodySolver;
  111822. private _tmpAmmoVectorA;
  111823. private _tmpAmmoVectorB;
  111824. private _tmpAmmoVectorC;
  111825. private _tmpAmmoVectorD;
  111826. private _tmpContactCallbackResult;
  111827. private _tmpAmmoVectorRCA;
  111828. private _tmpAmmoVectorRCB;
  111829. private _raycastResult;
  111830. private static readonly DISABLE_COLLISION_FLAG;
  111831. private static readonly KINEMATIC_FLAG;
  111832. private static readonly DISABLE_DEACTIVATION_FLAG;
  111833. /**
  111834. * Initializes the ammoJS plugin
  111835. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  111836. * @param ammoInjection can be used to inject your own ammo reference
  111837. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  111838. */
  111839. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  111840. /**
  111841. * Sets the gravity of the physics world (m/(s^2))
  111842. * @param gravity Gravity to set
  111843. */
  111844. setGravity(gravity: Vector3): void;
  111845. /**
  111846. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  111847. * @param timeStep timestep to use in seconds
  111848. */
  111849. setTimeStep(timeStep: number): void;
  111850. /**
  111851. * 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)
  111852. * @param fixedTimeStep fixedTimeStep to use in seconds
  111853. */
  111854. setFixedTimeStep(fixedTimeStep: number): void;
  111855. /**
  111856. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  111857. * @param maxSteps the maximum number of steps by the physics engine per frame
  111858. */
  111859. setMaxSteps(maxSteps: number): void;
  111860. /**
  111861. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  111862. * @returns the current timestep in seconds
  111863. */
  111864. getTimeStep(): number;
  111865. private _isImpostorInContact;
  111866. private _isImpostorPairInContact;
  111867. private _stepSimulation;
  111868. /**
  111869. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  111870. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  111871. * After the step the babylon meshes are set to the position of the physics imposters
  111872. * @param delta amount of time to step forward
  111873. * @param impostors array of imposters to update before/after the step
  111874. */
  111875. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  111876. /**
  111877. * Update babylon mesh to match physics world object
  111878. * @param impostor imposter to match
  111879. */
  111880. private _afterSoftStep;
  111881. /**
  111882. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  111883. * @param impostor imposter to match
  111884. */
  111885. private _ropeStep;
  111886. /**
  111887. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  111888. * @param impostor imposter to match
  111889. */
  111890. private _softbodyOrClothStep;
  111891. private _tmpVector;
  111892. private _tmpMatrix;
  111893. /**
  111894. * Applies an impulse on the imposter
  111895. * @param impostor imposter to apply impulse to
  111896. * @param force amount of force to be applied to the imposter
  111897. * @param contactPoint the location to apply the impulse on the imposter
  111898. */
  111899. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  111900. /**
  111901. * Applies a force on the imposter
  111902. * @param impostor imposter to apply force
  111903. * @param force amount of force to be applied to the imposter
  111904. * @param contactPoint the location to apply the force on the imposter
  111905. */
  111906. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  111907. /**
  111908. * Creates a physics body using the plugin
  111909. * @param impostor the imposter to create the physics body on
  111910. */
  111911. generatePhysicsBody(impostor: PhysicsImpostor): void;
  111912. /**
  111913. * Removes the physics body from the imposter and disposes of the body's memory
  111914. * @param impostor imposter to remove the physics body from
  111915. */
  111916. removePhysicsBody(impostor: PhysicsImpostor): void;
  111917. /**
  111918. * Generates a joint
  111919. * @param impostorJoint the imposter joint to create the joint with
  111920. */
  111921. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  111922. /**
  111923. * Removes a joint
  111924. * @param impostorJoint the imposter joint to remove the joint from
  111925. */
  111926. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  111927. private _addMeshVerts;
  111928. /**
  111929. * Initialise the soft body vertices to match its object's (mesh) vertices
  111930. * Softbody vertices (nodes) are in world space and to match this
  111931. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  111932. * @param impostor to create the softbody for
  111933. */
  111934. private _softVertexData;
  111935. /**
  111936. * Create an impostor's soft body
  111937. * @param impostor to create the softbody for
  111938. */
  111939. private _createSoftbody;
  111940. /**
  111941. * Create cloth for an impostor
  111942. * @param impostor to create the softbody for
  111943. */
  111944. private _createCloth;
  111945. /**
  111946. * Create rope for an impostor
  111947. * @param impostor to create the softbody for
  111948. */
  111949. private _createRope;
  111950. private _addHullVerts;
  111951. private _createShape;
  111952. /**
  111953. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  111954. * @param impostor imposter containing the physics body and babylon object
  111955. */
  111956. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  111957. /**
  111958. * Sets the babylon object's position/rotation from the physics body's position/rotation
  111959. * @param impostor imposter containing the physics body and babylon object
  111960. * @param newPosition new position
  111961. * @param newRotation new rotation
  111962. */
  111963. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  111964. /**
  111965. * If this plugin is supported
  111966. * @returns true if its supported
  111967. */
  111968. isSupported(): boolean;
  111969. /**
  111970. * Sets the linear velocity of the physics body
  111971. * @param impostor imposter to set the velocity on
  111972. * @param velocity velocity to set
  111973. */
  111974. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  111975. /**
  111976. * Sets the angular velocity of the physics body
  111977. * @param impostor imposter to set the velocity on
  111978. * @param velocity velocity to set
  111979. */
  111980. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  111981. /**
  111982. * gets the linear velocity
  111983. * @param impostor imposter to get linear velocity from
  111984. * @returns linear velocity
  111985. */
  111986. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  111987. /**
  111988. * gets the angular velocity
  111989. * @param impostor imposter to get angular velocity from
  111990. * @returns angular velocity
  111991. */
  111992. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  111993. /**
  111994. * Sets the mass of physics body
  111995. * @param impostor imposter to set the mass on
  111996. * @param mass mass to set
  111997. */
  111998. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  111999. /**
  112000. * Gets the mass of the physics body
  112001. * @param impostor imposter to get the mass from
  112002. * @returns mass
  112003. */
  112004. getBodyMass(impostor: PhysicsImpostor): number;
  112005. /**
  112006. * Gets friction of the impostor
  112007. * @param impostor impostor to get friction from
  112008. * @returns friction value
  112009. */
  112010. getBodyFriction(impostor: PhysicsImpostor): number;
  112011. /**
  112012. * Sets friction of the impostor
  112013. * @param impostor impostor to set friction on
  112014. * @param friction friction value
  112015. */
  112016. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  112017. /**
  112018. * Gets restitution of the impostor
  112019. * @param impostor impostor to get restitution from
  112020. * @returns restitution value
  112021. */
  112022. getBodyRestitution(impostor: PhysicsImpostor): number;
  112023. /**
  112024. * Sets resitution of the impostor
  112025. * @param impostor impostor to set resitution on
  112026. * @param restitution resitution value
  112027. */
  112028. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  112029. /**
  112030. * Gets pressure inside the impostor
  112031. * @param impostor impostor to get pressure from
  112032. * @returns pressure value
  112033. */
  112034. getBodyPressure(impostor: PhysicsImpostor): number;
  112035. /**
  112036. * Sets pressure inside a soft body impostor
  112037. * Cloth and rope must remain 0 pressure
  112038. * @param impostor impostor to set pressure on
  112039. * @param pressure pressure value
  112040. */
  112041. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  112042. /**
  112043. * Gets stiffness of the impostor
  112044. * @param impostor impostor to get stiffness from
  112045. * @returns pressure value
  112046. */
  112047. getBodyStiffness(impostor: PhysicsImpostor): number;
  112048. /**
  112049. * Sets stiffness of the impostor
  112050. * @param impostor impostor to set stiffness on
  112051. * @param stiffness stiffness value from 0 to 1
  112052. */
  112053. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  112054. /**
  112055. * Gets velocityIterations of the impostor
  112056. * @param impostor impostor to get velocity iterations from
  112057. * @returns velocityIterations value
  112058. */
  112059. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  112060. /**
  112061. * Sets velocityIterations of the impostor
  112062. * @param impostor impostor to set velocity iterations on
  112063. * @param velocityIterations velocityIterations value
  112064. */
  112065. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  112066. /**
  112067. * Gets positionIterations of the impostor
  112068. * @param impostor impostor to get position iterations from
  112069. * @returns positionIterations value
  112070. */
  112071. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  112072. /**
  112073. * Sets positionIterations of the impostor
  112074. * @param impostor impostor to set position on
  112075. * @param positionIterations positionIterations value
  112076. */
  112077. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  112078. /**
  112079. * Append an anchor to a cloth object
  112080. * @param impostor is the cloth impostor to add anchor to
  112081. * @param otherImpostor is the rigid impostor to anchor to
  112082. * @param width ratio across width from 0 to 1
  112083. * @param height ratio up height from 0 to 1
  112084. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  112085. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  112086. */
  112087. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  112088. /**
  112089. * Append an hook to a rope object
  112090. * @param impostor is the rope impostor to add hook to
  112091. * @param otherImpostor is the rigid impostor to hook to
  112092. * @param length ratio along the rope from 0 to 1
  112093. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  112094. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  112095. */
  112096. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  112097. /**
  112098. * Sleeps the physics body and stops it from being active
  112099. * @param impostor impostor to sleep
  112100. */
  112101. sleepBody(impostor: PhysicsImpostor): void;
  112102. /**
  112103. * Activates the physics body
  112104. * @param impostor impostor to activate
  112105. */
  112106. wakeUpBody(impostor: PhysicsImpostor): void;
  112107. /**
  112108. * Updates the distance parameters of the joint
  112109. * @param joint joint to update
  112110. * @param maxDistance maximum distance of the joint
  112111. * @param minDistance minimum distance of the joint
  112112. */
  112113. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  112114. /**
  112115. * Sets a motor on the joint
  112116. * @param joint joint to set motor on
  112117. * @param speed speed of the motor
  112118. * @param maxForce maximum force of the motor
  112119. * @param motorIndex index of the motor
  112120. */
  112121. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  112122. /**
  112123. * Sets the motors limit
  112124. * @param joint joint to set limit on
  112125. * @param upperLimit upper limit
  112126. * @param lowerLimit lower limit
  112127. */
  112128. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  112129. /**
  112130. * Syncs the position and rotation of a mesh with the impostor
  112131. * @param mesh mesh to sync
  112132. * @param impostor impostor to update the mesh with
  112133. */
  112134. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  112135. /**
  112136. * Gets the radius of the impostor
  112137. * @param impostor impostor to get radius from
  112138. * @returns the radius
  112139. */
  112140. getRadius(impostor: PhysicsImpostor): number;
  112141. /**
  112142. * Gets the box size of the impostor
  112143. * @param impostor impostor to get box size from
  112144. * @param result the resulting box size
  112145. */
  112146. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  112147. /**
  112148. * Disposes of the impostor
  112149. */
  112150. dispose(): void;
  112151. /**
  112152. * Does a raycast in the physics world
  112153. * @param from when should the ray start?
  112154. * @param to when should the ray end?
  112155. * @returns PhysicsRaycastResult
  112156. */
  112157. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  112158. }
  112159. }
  112160. declare module BABYLON {
  112161. interface AbstractScene {
  112162. /**
  112163. * The list of reflection probes added to the scene
  112164. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  112165. */
  112166. reflectionProbes: Array<ReflectionProbe>;
  112167. /**
  112168. * Removes the given reflection probe from this scene.
  112169. * @param toRemove The reflection probe to remove
  112170. * @returns The index of the removed reflection probe
  112171. */
  112172. removeReflectionProbe(toRemove: ReflectionProbe): number;
  112173. /**
  112174. * Adds the given reflection probe to this scene.
  112175. * @param newReflectionProbe The reflection probe to add
  112176. */
  112177. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  112178. }
  112179. /**
  112180. * Class used to generate realtime reflection / refraction cube textures
  112181. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  112182. */
  112183. export class ReflectionProbe {
  112184. /** defines the name of the probe */
  112185. name: string;
  112186. private _scene;
  112187. private _renderTargetTexture;
  112188. private _projectionMatrix;
  112189. private _viewMatrix;
  112190. private _target;
  112191. private _add;
  112192. private _attachedMesh;
  112193. private _invertYAxis;
  112194. /** Gets or sets probe position (center of the cube map) */
  112195. position: Vector3;
  112196. /**
  112197. * Creates a new reflection probe
  112198. * @param name defines the name of the probe
  112199. * @param size defines the texture resolution (for each face)
  112200. * @param scene defines the hosting scene
  112201. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  112202. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  112203. */
  112204. constructor(
  112205. /** defines the name of the probe */
  112206. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  112207. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  112208. samples: number;
  112209. /** Gets or sets the refresh rate to use (on every frame by default) */
  112210. refreshRate: number;
  112211. /**
  112212. * Gets the hosting scene
  112213. * @returns a Scene
  112214. */
  112215. getScene(): Scene;
  112216. /** Gets the internal CubeTexture used to render to */
  112217. readonly cubeTexture: RenderTargetTexture;
  112218. /** Gets the list of meshes to render */
  112219. readonly renderList: Nullable<AbstractMesh[]>;
  112220. /**
  112221. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  112222. * @param mesh defines the mesh to attach to
  112223. */
  112224. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  112225. /**
  112226. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  112227. * @param renderingGroupId The rendering group id corresponding to its index
  112228. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  112229. */
  112230. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  112231. /**
  112232. * Clean all associated resources
  112233. */
  112234. dispose(): void;
  112235. /**
  112236. * Converts the reflection probe information to a readable string for debug purpose.
  112237. * @param fullDetails Supports for multiple levels of logging within scene loading
  112238. * @returns the human readable reflection probe info
  112239. */
  112240. toString(fullDetails?: boolean): string;
  112241. /**
  112242. * Get the class name of the relfection probe.
  112243. * @returns "ReflectionProbe"
  112244. */
  112245. getClassName(): string;
  112246. /**
  112247. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  112248. * @returns The JSON representation of the texture
  112249. */
  112250. serialize(): any;
  112251. /**
  112252. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  112253. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  112254. * @param scene Define the scene the parsed reflection probe should be instantiated in
  112255. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  112256. * @returns The parsed reflection probe if successful
  112257. */
  112258. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  112259. }
  112260. }
  112261. declare module BABYLON {
  112262. /** @hidden */
  112263. export var _BabylonLoaderRegistered: boolean;
  112264. }
  112265. declare module BABYLON {
  112266. /**
  112267. * The Physically based simple base material of BJS.
  112268. *
  112269. * This enables better naming and convention enforcements on top of the pbrMaterial.
  112270. * It is used as the base class for both the specGloss and metalRough conventions.
  112271. */
  112272. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  112273. /**
  112274. * Number of Simultaneous lights allowed on the material.
  112275. */
  112276. maxSimultaneousLights: number;
  112277. /**
  112278. * If sets to true, disables all the lights affecting the material.
  112279. */
  112280. disableLighting: boolean;
  112281. /**
  112282. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  112283. */
  112284. environmentTexture: BaseTexture;
  112285. /**
  112286. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  112287. */
  112288. invertNormalMapX: boolean;
  112289. /**
  112290. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  112291. */
  112292. invertNormalMapY: boolean;
  112293. /**
  112294. * Normal map used in the model.
  112295. */
  112296. normalTexture: BaseTexture;
  112297. /**
  112298. * Emissivie color used to self-illuminate the model.
  112299. */
  112300. emissiveColor: Color3;
  112301. /**
  112302. * Emissivie texture used to self-illuminate the model.
  112303. */
  112304. emissiveTexture: BaseTexture;
  112305. /**
  112306. * Occlusion Channel Strenght.
  112307. */
  112308. occlusionStrength: number;
  112309. /**
  112310. * Occlusion Texture of the material (adding extra occlusion effects).
  112311. */
  112312. occlusionTexture: BaseTexture;
  112313. /**
  112314. * Defines the alpha limits in alpha test mode.
  112315. */
  112316. alphaCutOff: number;
  112317. /**
  112318. * Gets the current double sided mode.
  112319. */
  112320. /**
  112321. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  112322. */
  112323. doubleSided: boolean;
  112324. /**
  112325. * Stores the pre-calculated light information of a mesh in a texture.
  112326. */
  112327. lightmapTexture: BaseTexture;
  112328. /**
  112329. * If true, the light map contains occlusion information instead of lighting info.
  112330. */
  112331. useLightmapAsShadowmap: boolean;
  112332. /**
  112333. * Instantiates a new PBRMaterial instance.
  112334. *
  112335. * @param name The material name
  112336. * @param scene The scene the material will be use in.
  112337. */
  112338. constructor(name: string, scene: Scene);
  112339. getClassName(): string;
  112340. }
  112341. }
  112342. declare module BABYLON {
  112343. /**
  112344. * The PBR material of BJS following the metal roughness convention.
  112345. *
  112346. * This fits to the PBR convention in the GLTF definition:
  112347. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  112348. */
  112349. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  112350. /**
  112351. * The base color has two different interpretations depending on the value of metalness.
  112352. * When the material is a metal, the base color is the specific measured reflectance value
  112353. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  112354. * of the material.
  112355. */
  112356. baseColor: Color3;
  112357. /**
  112358. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  112359. * well as opacity information in the alpha channel.
  112360. */
  112361. baseTexture: BaseTexture;
  112362. /**
  112363. * Specifies the metallic scalar value of the material.
  112364. * Can also be used to scale the metalness values of the metallic texture.
  112365. */
  112366. metallic: number;
  112367. /**
  112368. * Specifies the roughness scalar value of the material.
  112369. * Can also be used to scale the roughness values of the metallic texture.
  112370. */
  112371. roughness: number;
  112372. /**
  112373. * Texture containing both the metallic value in the B channel and the
  112374. * roughness value in the G channel to keep better precision.
  112375. */
  112376. metallicRoughnessTexture: BaseTexture;
  112377. /**
  112378. * Instantiates a new PBRMetalRoughnessMaterial instance.
  112379. *
  112380. * @param name The material name
  112381. * @param scene The scene the material will be use in.
  112382. */
  112383. constructor(name: string, scene: Scene);
  112384. /**
  112385. * Return the currrent class name of the material.
  112386. */
  112387. getClassName(): string;
  112388. /**
  112389. * Makes a duplicate of the current material.
  112390. * @param name - name to use for the new material.
  112391. */
  112392. clone(name: string): PBRMetallicRoughnessMaterial;
  112393. /**
  112394. * Serialize the material to a parsable JSON object.
  112395. */
  112396. serialize(): any;
  112397. /**
  112398. * Parses a JSON object correponding to the serialize function.
  112399. */
  112400. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  112401. }
  112402. }
  112403. declare module BABYLON {
  112404. /**
  112405. * The PBR material of BJS following the specular glossiness convention.
  112406. *
  112407. * This fits to the PBR convention in the GLTF definition:
  112408. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  112409. */
  112410. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  112411. /**
  112412. * Specifies the diffuse color of the material.
  112413. */
  112414. diffuseColor: Color3;
  112415. /**
  112416. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  112417. * channel.
  112418. */
  112419. diffuseTexture: BaseTexture;
  112420. /**
  112421. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  112422. */
  112423. specularColor: Color3;
  112424. /**
  112425. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  112426. */
  112427. glossiness: number;
  112428. /**
  112429. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  112430. */
  112431. specularGlossinessTexture: BaseTexture;
  112432. /**
  112433. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  112434. *
  112435. * @param name The material name
  112436. * @param scene The scene the material will be use in.
  112437. */
  112438. constructor(name: string, scene: Scene);
  112439. /**
  112440. * Return the currrent class name of the material.
  112441. */
  112442. getClassName(): string;
  112443. /**
  112444. * Makes a duplicate of the current material.
  112445. * @param name - name to use for the new material.
  112446. */
  112447. clone(name: string): PBRSpecularGlossinessMaterial;
  112448. /**
  112449. * Serialize the material to a parsable JSON object.
  112450. */
  112451. serialize(): any;
  112452. /**
  112453. * Parses a JSON object correponding to the serialize function.
  112454. */
  112455. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  112456. }
  112457. }
  112458. declare module BABYLON {
  112459. /**
  112460. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  112461. * It can help converting any input color in a desired output one. This can then be used to create effects
  112462. * from sepia, black and white to sixties or futuristic rendering...
  112463. *
  112464. * The only supported format is currently 3dl.
  112465. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  112466. */
  112467. export class ColorGradingTexture extends BaseTexture {
  112468. /**
  112469. * The current texture matrix. (will always be identity in color grading texture)
  112470. */
  112471. private _textureMatrix;
  112472. /**
  112473. * The texture URL.
  112474. */
  112475. url: string;
  112476. /**
  112477. * Empty line regex stored for GC.
  112478. */
  112479. private static _noneEmptyLineRegex;
  112480. private _engine;
  112481. /**
  112482. * Instantiates a ColorGradingTexture from the following parameters.
  112483. *
  112484. * @param url The location of the color gradind data (currently only supporting 3dl)
  112485. * @param scene The scene the texture will be used in
  112486. */
  112487. constructor(url: string, scene: Scene);
  112488. /**
  112489. * Returns the texture matrix used in most of the material.
  112490. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  112491. */
  112492. getTextureMatrix(): Matrix;
  112493. /**
  112494. * Occurs when the file being loaded is a .3dl LUT file.
  112495. */
  112496. private load3dlTexture;
  112497. /**
  112498. * Starts the loading process of the texture.
  112499. */
  112500. private loadTexture;
  112501. /**
  112502. * Clones the color gradind texture.
  112503. */
  112504. clone(): ColorGradingTexture;
  112505. /**
  112506. * Called during delayed load for textures.
  112507. */
  112508. delayLoad(): void;
  112509. /**
  112510. * Parses a color grading texture serialized by Babylon.
  112511. * @param parsedTexture The texture information being parsedTexture
  112512. * @param scene The scene to load the texture in
  112513. * @param rootUrl The root url of the data assets to load
  112514. * @return A color gradind texture
  112515. */
  112516. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  112517. /**
  112518. * Serializes the LUT texture to json format.
  112519. */
  112520. serialize(): any;
  112521. }
  112522. }
  112523. declare module BABYLON {
  112524. /**
  112525. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  112526. */
  112527. export class EquiRectangularCubeTexture extends BaseTexture {
  112528. /** The six faces of the cube. */
  112529. private static _FacesMapping;
  112530. private _noMipmap;
  112531. private _onLoad;
  112532. private _onError;
  112533. /** The size of the cubemap. */
  112534. private _size;
  112535. /** The buffer of the image. */
  112536. private _buffer;
  112537. /** The width of the input image. */
  112538. private _width;
  112539. /** The height of the input image. */
  112540. private _height;
  112541. /** The URL to the image. */
  112542. url: string;
  112543. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  112544. coordinatesMode: number;
  112545. /**
  112546. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  112547. * @param url The location of the image
  112548. * @param scene The scene the texture will be used in
  112549. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  112550. * @param noMipmap Forces to not generate the mipmap if true
  112551. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  112552. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  112553. * @param onLoad — defines a callback called when texture is loaded
  112554. * @param onError — defines a callback called if there is an error
  112555. */
  112556. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  112557. /**
  112558. * Load the image data, by putting the image on a canvas and extracting its buffer.
  112559. */
  112560. private loadImage;
  112561. /**
  112562. * Convert the image buffer into a cubemap and create a CubeTexture.
  112563. */
  112564. private loadTexture;
  112565. /**
  112566. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  112567. * @param buffer The ArrayBuffer that should be converted.
  112568. * @returns The buffer as Float32Array.
  112569. */
  112570. private getFloat32ArrayFromArrayBuffer;
  112571. /**
  112572. * Get the current class name of the texture useful for serialization or dynamic coding.
  112573. * @returns "EquiRectangularCubeTexture"
  112574. */
  112575. getClassName(): string;
  112576. /**
  112577. * Create a clone of the current EquiRectangularCubeTexture and return it.
  112578. * @returns A clone of the current EquiRectangularCubeTexture.
  112579. */
  112580. clone(): EquiRectangularCubeTexture;
  112581. }
  112582. }
  112583. declare module BABYLON {
  112584. /**
  112585. * Based on jsTGALoader - Javascript loader for TGA file
  112586. * By Vincent Thibault
  112587. * @see http://blog.robrowser.com/javascript-tga-loader.html
  112588. */
  112589. export class TGATools {
  112590. private static _TYPE_INDEXED;
  112591. private static _TYPE_RGB;
  112592. private static _TYPE_GREY;
  112593. private static _TYPE_RLE_INDEXED;
  112594. private static _TYPE_RLE_RGB;
  112595. private static _TYPE_RLE_GREY;
  112596. private static _ORIGIN_MASK;
  112597. private static _ORIGIN_SHIFT;
  112598. private static _ORIGIN_BL;
  112599. private static _ORIGIN_BR;
  112600. private static _ORIGIN_UL;
  112601. private static _ORIGIN_UR;
  112602. /**
  112603. * Gets the header of a TGA file
  112604. * @param data defines the TGA data
  112605. * @returns the header
  112606. */
  112607. static GetTGAHeader(data: Uint8Array): any;
  112608. /**
  112609. * Uploads TGA content to a Babylon Texture
  112610. * @hidden
  112611. */
  112612. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  112613. /** @hidden */
  112614. 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;
  112615. /** @hidden */
  112616. 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;
  112617. /** @hidden */
  112618. 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;
  112619. /** @hidden */
  112620. 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;
  112621. /** @hidden */
  112622. 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;
  112623. /** @hidden */
  112624. 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;
  112625. }
  112626. }
  112627. declare module BABYLON {
  112628. /**
  112629. * Implementation of the TGA Texture Loader.
  112630. * @hidden
  112631. */
  112632. export class _TGATextureLoader implements IInternalTextureLoader {
  112633. /**
  112634. * Defines wether the loader supports cascade loading the different faces.
  112635. */
  112636. readonly supportCascades: boolean;
  112637. /**
  112638. * This returns if the loader support the current file information.
  112639. * @param extension defines the file extension of the file being loaded
  112640. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112641. * @param fallback defines the fallback internal texture if any
  112642. * @param isBase64 defines whether the texture is encoded as a base64
  112643. * @param isBuffer defines whether the texture data are stored as a buffer
  112644. * @returns true if the loader can load the specified file
  112645. */
  112646. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  112647. /**
  112648. * Transform the url before loading if required.
  112649. * @param rootUrl the url of the texture
  112650. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112651. * @returns the transformed texture
  112652. */
  112653. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  112654. /**
  112655. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  112656. * @param rootUrl the url of the texture
  112657. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112658. * @returns the fallback texture
  112659. */
  112660. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  112661. /**
  112662. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  112663. * @param data contains the texture data
  112664. * @param texture defines the BabylonJS internal texture
  112665. * @param createPolynomials will be true if polynomials have been requested
  112666. * @param onLoad defines the callback to trigger once the texture is ready
  112667. * @param onError defines the callback to trigger in case of error
  112668. */
  112669. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  112670. /**
  112671. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  112672. * @param data contains the texture data
  112673. * @param texture defines the BabylonJS internal texture
  112674. * @param callback defines the method to call once ready to upload
  112675. */
  112676. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  112677. }
  112678. }
  112679. declare module BABYLON {
  112680. /**
  112681. * Info about the .basis files
  112682. */
  112683. class BasisFileInfo {
  112684. /**
  112685. * If the file has alpha
  112686. */
  112687. hasAlpha: boolean;
  112688. /**
  112689. * Width of the image
  112690. */
  112691. width: number;
  112692. /**
  112693. * Height of the image
  112694. */
  112695. height: number;
  112696. /**
  112697. * Aligned width used when falling back to Rgb565 ((width + 3) & ~3)
  112698. */
  112699. alignedWidth: number;
  112700. /**
  112701. * Aligned height used when falling back to Rgb565 ((height + 3) & ~3)
  112702. */
  112703. alignedHeight: number;
  112704. }
  112705. /**
  112706. * Used to load .Basis files
  112707. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  112708. */
  112709. export class BasisTools {
  112710. private static _IgnoreSupportedFormats;
  112711. private static _LoadScriptPromise;
  112712. private static _FallbackURL;
  112713. private static _BASIS_FORMAT;
  112714. /**
  112715. * Basis module can be aquired from https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  112716. * This should be set prior to loading a .basis texture
  112717. */
  112718. static BasisModule: Nullable<any>;
  112719. /**
  112720. * Verifies that the BasisModule has been populated and falls back to loading from the web if not availible
  112721. * @returns promise which will resolve if the basis module was loaded
  112722. */
  112723. static VerifyBasisModuleAsync(): any;
  112724. /**
  112725. * Verifies that the basis module has been populated and creates a bsis file from the image data
  112726. * @param data array buffer of the .basis file
  112727. * @returns the Basis file
  112728. */
  112729. static LoadBasisFile(data: ArrayBuffer): any;
  112730. /**
  112731. * Detects the supported transcode format for the file
  112732. * @param engine Babylon engine
  112733. * @param fileInfo info about the file
  112734. * @returns the chosed format or null if none are supported
  112735. */
  112736. static GetSupportedTranscodeFormat(engine: Engine, fileInfo: BasisFileInfo): Nullable<number>;
  112737. /**
  112738. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  112739. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  112740. * @returns internal format corresponding to the Basis format
  112741. */
  112742. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  112743. /**
  112744. * Retreives information about the basis file eg. dimensions
  112745. * @param basisFile the basis file to get the info from
  112746. * @returns information about the basis file
  112747. */
  112748. static GetFileInfo(basisFile: any): BasisFileInfo;
  112749. /**
  112750. * Transcodes the basis file to the requested format to be transferred to the gpu
  112751. * @param format fromat to be transferred to
  112752. * @param fileInfo information about the loaded file
  112753. * @param loadedFile the loaded basis file
  112754. * @returns the resulting pixels and if the transcode fell back to using Rgb565
  112755. */
  112756. static TranscodeFile(format: Nullable<number>, fileInfo: BasisFileInfo, loadedFile: any): {
  112757. fallbackToRgb565: boolean;
  112758. pixels: Uint8Array;
  112759. };
  112760. /**
  112761. * From https://github.com/BinomialLLC/basis_universal/blob/master/webgl/texture/dxt-to-rgb565.js
  112762. * An unoptimized version of dxtToRgb565. Also, the floating
  112763. * point math used to compute the colors actually results in
  112764. * slightly different colors compared to hardware DXT decoders.
  112765. * @param src dxt src pixels
  112766. * @param srcByteOffset offset for the start of src
  112767. * @param width aligned width of the image
  112768. * @param height aligned height of the image
  112769. * @return the converted pixels
  112770. */
  112771. static ConvertDxtToRgb565(src: Uint16Array, srcByteOffset: number, width: number, height: number): Uint16Array;
  112772. }
  112773. }
  112774. declare module BABYLON {
  112775. /**
  112776. * Loader for .basis file format
  112777. */
  112778. export class _BasisTextureLoader implements IInternalTextureLoader {
  112779. /**
  112780. * Defines whether the loader supports cascade loading the different faces.
  112781. */
  112782. readonly supportCascades: boolean;
  112783. /**
  112784. * This returns if the loader support the current file information.
  112785. * @param extension defines the file extension of the file being loaded
  112786. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112787. * @param fallback defines the fallback internal texture if any
  112788. * @param isBase64 defines whether the texture is encoded as a base64
  112789. * @param isBuffer defines whether the texture data are stored as a buffer
  112790. * @returns true if the loader can load the specified file
  112791. */
  112792. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  112793. /**
  112794. * Transform the url before loading if required.
  112795. * @param rootUrl the url of the texture
  112796. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112797. * @returns the transformed texture
  112798. */
  112799. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  112800. /**
  112801. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  112802. * @param rootUrl the url of the texture
  112803. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112804. * @returns the fallback texture
  112805. */
  112806. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  112807. /**
  112808. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  112809. * @param data contains the texture data
  112810. * @param texture defines the BabylonJS internal texture
  112811. * @param createPolynomials will be true if polynomials have been requested
  112812. * @param onLoad defines the callback to trigger once the texture is ready
  112813. * @param onError defines the callback to trigger in case of error
  112814. */
  112815. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  112816. /**
  112817. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  112818. * @param data contains the texture data
  112819. * @param texture defines the BabylonJS internal texture
  112820. * @param callback defines the method to call once ready to upload
  112821. */
  112822. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  112823. }
  112824. }
  112825. declare module BABYLON {
  112826. /**
  112827. * 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.
  112828. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  112829. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  112830. */
  112831. export class CustomProceduralTexture extends ProceduralTexture {
  112832. private _animate;
  112833. private _time;
  112834. private _config;
  112835. private _texturePath;
  112836. /**
  112837. * Instantiates a new Custom Procedural Texture.
  112838. * 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.
  112839. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  112840. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  112841. * @param name Define the name of the texture
  112842. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  112843. * @param size Define the size of the texture to create
  112844. * @param scene Define the scene the texture belongs to
  112845. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  112846. * @param generateMipMaps Define if the texture should creates mip maps or not
  112847. */
  112848. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  112849. private _loadJson;
  112850. /**
  112851. * Is the texture ready to be used ? (rendered at least once)
  112852. * @returns true if ready, otherwise, false.
  112853. */
  112854. isReady(): boolean;
  112855. /**
  112856. * Render the texture to its associated render target.
  112857. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  112858. */
  112859. render(useCameraPostProcess?: boolean): void;
  112860. /**
  112861. * Update the list of dependant textures samplers in the shader.
  112862. */
  112863. updateTextures(): void;
  112864. /**
  112865. * Update the uniform values of the procedural texture in the shader.
  112866. */
  112867. updateShaderUniforms(): void;
  112868. /**
  112869. * Define if the texture animates or not.
  112870. */
  112871. animate: boolean;
  112872. }
  112873. }
  112874. declare module BABYLON {
  112875. /** @hidden */
  112876. export var noisePixelShader: {
  112877. name: string;
  112878. shader: string;
  112879. };
  112880. }
  112881. declare module BABYLON {
  112882. /**
  112883. * Class used to generate noise procedural textures
  112884. */
  112885. export class NoiseProceduralTexture extends ProceduralTexture {
  112886. private _time;
  112887. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  112888. brightness: number;
  112889. /** Defines the number of octaves to process */
  112890. octaves: number;
  112891. /** Defines the level of persistence (0.8 by default) */
  112892. persistence: number;
  112893. /** Gets or sets animation speed factor (default is 1) */
  112894. animationSpeedFactor: number;
  112895. /**
  112896. * Creates a new NoiseProceduralTexture
  112897. * @param name defines the name fo the texture
  112898. * @param size defines the size of the texture (default is 256)
  112899. * @param scene defines the hosting scene
  112900. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  112901. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  112902. */
  112903. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  112904. private _updateShaderUniforms;
  112905. protected _getDefines(): string;
  112906. /** Generate the current state of the procedural texture */
  112907. render(useCameraPostProcess?: boolean): void;
  112908. /**
  112909. * Serializes this noise procedural texture
  112910. * @returns a serialized noise procedural texture object
  112911. */
  112912. serialize(): any;
  112913. /**
  112914. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  112915. * @param parsedTexture defines parsed texture data
  112916. * @param scene defines the current scene
  112917. * @param rootUrl defines the root URL containing noise procedural texture information
  112918. * @returns a parsed NoiseProceduralTexture
  112919. */
  112920. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  112921. }
  112922. }
  112923. declare module BABYLON {
  112924. /**
  112925. * Raw cube texture where the raw buffers are passed in
  112926. */
  112927. export class RawCubeTexture extends CubeTexture {
  112928. /**
  112929. * Creates a cube texture where the raw buffers are passed in.
  112930. * @param scene defines the scene the texture is attached to
  112931. * @param data defines the array of data to use to create each face
  112932. * @param size defines the size of the textures
  112933. * @param format defines the format of the data
  112934. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  112935. * @param generateMipMaps defines if the engine should generate the mip levels
  112936. * @param invertY defines if data must be stored with Y axis inverted
  112937. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  112938. * @param compression defines the compression used (null by default)
  112939. */
  112940. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  112941. /**
  112942. * Updates the raw cube texture.
  112943. * @param data defines the data to store
  112944. * @param format defines the data format
  112945. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  112946. * @param invertY defines if data must be stored with Y axis inverted
  112947. * @param compression defines the compression used (null by default)
  112948. * @param level defines which level of the texture to update
  112949. */
  112950. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  112951. /**
  112952. * Updates a raw cube texture with RGBD encoded data.
  112953. * @param data defines the array of data [mipmap][face] to use to create each face
  112954. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  112955. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  112956. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  112957. * @returns a promsie that resolves when the operation is complete
  112958. */
  112959. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  112960. /**
  112961. * Clones the raw cube texture.
  112962. * @return a new cube texture
  112963. */
  112964. clone(): CubeTexture;
  112965. /** @hidden */
  112966. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  112967. }
  112968. }
  112969. declare module BABYLON {
  112970. /**
  112971. * Class used to store 3D textures containing user data
  112972. */
  112973. export class RawTexture3D extends Texture {
  112974. /** Gets or sets the texture format to use */
  112975. format: number;
  112976. private _engine;
  112977. /**
  112978. * Create a new RawTexture3D
  112979. * @param data defines the data of the texture
  112980. * @param width defines the width of the texture
  112981. * @param height defines the height of the texture
  112982. * @param depth defines the depth of the texture
  112983. * @param format defines the texture format to use
  112984. * @param scene defines the hosting scene
  112985. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  112986. * @param invertY defines if texture must be stored with Y axis inverted
  112987. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  112988. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  112989. */
  112990. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  112991. /** Gets or sets the texture format to use */
  112992. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  112993. /**
  112994. * Update the texture with new data
  112995. * @param data defines the data to store in the texture
  112996. */
  112997. update(data: ArrayBufferView): void;
  112998. }
  112999. }
  113000. declare module BABYLON {
  113001. /**
  113002. * Creates a refraction texture used by refraction channel of the standard material.
  113003. * It is like a mirror but to see through a material.
  113004. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  113005. */
  113006. export class RefractionTexture extends RenderTargetTexture {
  113007. /**
  113008. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  113009. * 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.
  113010. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  113011. */
  113012. refractionPlane: Plane;
  113013. /**
  113014. * Define how deep under the surface we should see.
  113015. */
  113016. depth: number;
  113017. /**
  113018. * Creates a refraction texture used by refraction channel of the standard material.
  113019. * It is like a mirror but to see through a material.
  113020. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  113021. * @param name Define the texture name
  113022. * @param size Define the size of the underlying texture
  113023. * @param scene Define the scene the refraction belongs to
  113024. * @param generateMipMaps Define if we need to generate mips level for the refraction
  113025. */
  113026. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  113027. /**
  113028. * Clone the refraction texture.
  113029. * @returns the cloned texture
  113030. */
  113031. clone(): RefractionTexture;
  113032. /**
  113033. * Serialize the texture to a JSON representation you could use in Parse later on
  113034. * @returns the serialized JSON representation
  113035. */
  113036. serialize(): any;
  113037. }
  113038. }
  113039. declare module BABYLON {
  113040. /**
  113041. * Defines the options related to the creation of an HtmlElementTexture
  113042. */
  113043. export interface IHtmlElementTextureOptions {
  113044. /**
  113045. * Defines wether mip maps should be created or not.
  113046. */
  113047. generateMipMaps?: boolean;
  113048. /**
  113049. * Defines the sampling mode of the texture.
  113050. */
  113051. samplingMode?: number;
  113052. /**
  113053. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  113054. */
  113055. engine: Nullable<Engine>;
  113056. /**
  113057. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  113058. */
  113059. scene: Nullable<Scene>;
  113060. }
  113061. /**
  113062. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  113063. * To be as efficient as possible depending on your constraints nothing aside the first upload
  113064. * is automatically managed.
  113065. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  113066. * in your application.
  113067. *
  113068. * As the update is not automatic, you need to call them manually.
  113069. */
  113070. export class HtmlElementTexture extends BaseTexture {
  113071. /**
  113072. * The texture URL.
  113073. */
  113074. element: HTMLVideoElement | HTMLCanvasElement;
  113075. private static readonly DefaultOptions;
  113076. private _textureMatrix;
  113077. private _engine;
  113078. private _isVideo;
  113079. private _generateMipMaps;
  113080. private _samplingMode;
  113081. /**
  113082. * Instantiates a HtmlElementTexture from the following parameters.
  113083. *
  113084. * @param name Defines the name of the texture
  113085. * @param element Defines the video or canvas the texture is filled with
  113086. * @param options Defines the other none mandatory texture creation options
  113087. */
  113088. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  113089. private _createInternalTexture;
  113090. /**
  113091. * Returns the texture matrix used in most of the material.
  113092. */
  113093. getTextureMatrix(): Matrix;
  113094. /**
  113095. * Updates the content of the texture.
  113096. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  113097. */
  113098. update(invertY?: Nullable<boolean>): void;
  113099. }
  113100. }
  113101. declare module BABYLON {
  113102. /**
  113103. * Enum used to define the target of a block
  113104. */
  113105. export enum NodeMaterialBlockTargets {
  113106. /** Vertex shader */
  113107. Vertex = 1,
  113108. /** Fragment shader */
  113109. Fragment = 2,
  113110. /** Vertex and Fragment */
  113111. VertexAndFragment = 3
  113112. }
  113113. }
  113114. declare module BABYLON {
  113115. /**
  113116. * Defines the kind of connection point for node based material
  113117. */
  113118. export enum NodeMaterialBlockConnectionPointTypes {
  113119. /** Float */
  113120. Float = 1,
  113121. /** Int */
  113122. Int = 2,
  113123. /** Vector2 */
  113124. Vector2 = 4,
  113125. /** Vector3 */
  113126. Vector3 = 8,
  113127. /** Vector4 */
  113128. Vector4 = 16,
  113129. /** Color3 */
  113130. Color3 = 32,
  113131. /** Color4 */
  113132. Color4 = 64,
  113133. /** Matrix */
  113134. Matrix = 128,
  113135. /** Texture */
  113136. Texture = 256,
  113137. /** Texture3D */
  113138. Texture3D = 512,
  113139. /** Vector3 or Color3 */
  113140. Vector3OrColor3 = 40,
  113141. /** Vector3 or Vector4 */
  113142. Vector3OrVector4 = 24,
  113143. /** Vector4 or Color4 */
  113144. Vector4OrColor4 = 80,
  113145. /** Color3 or Color4 */
  113146. Color3OrColor4 = 96,
  113147. /** Vector3 or Color3 */
  113148. Vector3OrColor3OrVector4OrColor4 = 120,
  113149. /** Detect type based on connection */
  113150. AutoDetect = 1024,
  113151. /** Output type that will be defined by input type */
  113152. BasedOnInput = 2048
  113153. }
  113154. }
  113155. declare module BABYLON {
  113156. /**
  113157. * Enum used to define well known values e.g. values automatically provided by the system
  113158. */
  113159. export enum NodeMaterialWellKnownValues {
  113160. /** World */
  113161. World = 1,
  113162. /** View */
  113163. View = 2,
  113164. /** Projection */
  113165. Projection = 3,
  113166. /** ViewProjection */
  113167. ViewProjection = 4,
  113168. /** WorldView */
  113169. WorldView = 5,
  113170. /** WorldViewProjection */
  113171. WorldViewProjection = 6,
  113172. /** Will be filled by the block itself */
  113173. Automatic = 7
  113174. }
  113175. }
  113176. declare module BABYLON {
  113177. /**
  113178. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  113179. */
  113180. export enum NodeMaterialBlockConnectionPointMode {
  113181. /** Value is an uniform */
  113182. Uniform = 0,
  113183. /** Value is a mesh attribute */
  113184. Attribute = 1,
  113185. /** Value is a varying between vertex and fragment shaders */
  113186. Varying = 2,
  113187. /** Mode is undefined */
  113188. Undefined = 3
  113189. }
  113190. }
  113191. declare module BABYLON {
  113192. /**
  113193. * Class used to store shared data between 2 NodeMaterialBuildState
  113194. */
  113195. export class NodeMaterialBuildStateSharedData {
  113196. /**
  113197. * Gets the list of emitted varyings
  113198. */
  113199. varyings: string[];
  113200. /**
  113201. * Gets the varying declaration string
  113202. */
  113203. varyingDeclaration: string;
  113204. /**
  113205. * Uniform connection points
  113206. */
  113207. uniformConnectionPoints: NodeMaterialConnectionPoint[];
  113208. /**
  113209. * Bindable blocks (Blocks that need to set data to the effect)
  113210. */
  113211. bindableBlocks: NodeMaterialBlock[];
  113212. /**
  113213. * List of blocks that can provide a compilation fallback
  113214. */
  113215. blocksWithFallbacks: NodeMaterialBlock[];
  113216. /**
  113217. * List of blocks that can provide a define update
  113218. */
  113219. blocksWithDefines: NodeMaterialBlock[];
  113220. /**
  113221. * List of blocks that can provide a repeatable content
  113222. */
  113223. repeatableContentBlocks: NodeMaterialBlock[];
  113224. /**
  113225. * List of blocks that can block the isReady function for the material
  113226. */
  113227. blockingBlocks: NodeMaterialBlock[];
  113228. /**
  113229. * Build Id used to avoid multiple recompilations
  113230. */
  113231. buildId: number;
  113232. /** List of emitted variables */
  113233. variableNames: {
  113234. [key: string]: number;
  113235. };
  113236. /** List of emitted defines */
  113237. defineNames: {
  113238. [key: string]: number;
  113239. };
  113240. /** Should emit comments? */
  113241. emitComments: boolean;
  113242. /** Emit build activity */
  113243. verbose: boolean;
  113244. /**
  113245. * Gets the compilation hints emitted at compilation time
  113246. */
  113247. hints: {
  113248. needWorldViewMatrix: boolean;
  113249. needWorldViewProjectionMatrix: boolean;
  113250. needAlphaBlending: boolean;
  113251. needAlphaTesting: boolean;
  113252. };
  113253. /**
  113254. * List of compilation checks
  113255. */
  113256. checks: {
  113257. emitVertex: boolean;
  113258. emitFragment: boolean;
  113259. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  113260. };
  113261. /** Creates a new shared data */
  113262. constructor();
  113263. /**
  113264. * Emits console errors and exceptions if there is a failing check
  113265. */
  113266. emitErrors(): void;
  113267. }
  113268. }
  113269. declare module BABYLON {
  113270. /**
  113271. * Class used to store node based material build state
  113272. */
  113273. export class NodeMaterialBuildState {
  113274. /**
  113275. * Gets the list of emitted attributes
  113276. */
  113277. attributes: string[];
  113278. /**
  113279. * Gets the list of emitted uniforms
  113280. */
  113281. uniforms: string[];
  113282. /**
  113283. * Gets the list of emitted samplers
  113284. */
  113285. samplers: string[];
  113286. /**
  113287. * Gets the list of emitted functions
  113288. */
  113289. functions: {
  113290. [key: string]: string;
  113291. };
  113292. /**
  113293. * Gets the target of the compilation state
  113294. */
  113295. target: NodeMaterialBlockTargets;
  113296. /**
  113297. * Shared data between multiple NodeMaterialBuildState instances
  113298. */
  113299. sharedData: NodeMaterialBuildStateSharedData;
  113300. /** @hidden */
  113301. _vertexState: NodeMaterialBuildState;
  113302. private _attributeDeclaration;
  113303. private _uniformDeclaration;
  113304. private _samplerDeclaration;
  113305. private _varyingTransfer;
  113306. private _repeatableContentAnchorIndex;
  113307. /** @hidden */
  113308. _builtCompilationString: string;
  113309. /**
  113310. * Gets the emitted compilation strings
  113311. */
  113312. compilationString: string;
  113313. /**
  113314. * Finalize the compilation strings
  113315. * @param state defines the current compilation state
  113316. */
  113317. finalize(state: NodeMaterialBuildState): void;
  113318. /** @hidden */
  113319. readonly _repeatableContentAnchor: string;
  113320. /** @hidden */
  113321. _getFreeVariableName(prefix: string): string;
  113322. /** @hidden */
  113323. _getFreeDefineName(prefix: string): string;
  113324. /** @hidden */
  113325. _excludeVariableName(name: string): void;
  113326. /** @hidden */
  113327. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  113328. /** @hidden */
  113329. _emitFunction(name: string, code: string, comments: string): void;
  113330. /** @hidden */
  113331. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  113332. replaceStrings?: {
  113333. search: RegExp;
  113334. replace: string;
  113335. }[];
  113336. }): string;
  113337. /** @hidden */
  113338. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  113339. repeatKey?: string;
  113340. removeAttributes?: boolean;
  113341. removeUniforms?: boolean;
  113342. removeVaryings?: boolean;
  113343. removeIfDef?: boolean;
  113344. replaceStrings?: {
  113345. search: RegExp;
  113346. replace: string;
  113347. }[];
  113348. }): void;
  113349. /** @hidden */
  113350. _emitVaryings(point: NodeMaterialConnectionPoint, define?: string, force?: boolean, fromFragment?: boolean, replacementName?: string): void;
  113351. private _emitDefine;
  113352. /** @hidden */
  113353. _emitUniformOrAttributes(point: NodeMaterialConnectionPoint, define?: string): void;
  113354. }
  113355. }
  113356. declare module BABYLON {
  113357. /**
  113358. * Root class for all node material optimizers
  113359. */
  113360. export class NodeMaterialOptimizer {
  113361. /**
  113362. * Function used to optimize a NodeMaterial graph
  113363. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  113364. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  113365. */
  113366. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  113367. }
  113368. }
  113369. declare module BABYLON {
  113370. /**
  113371. * Block used to transform a vector4 with a matrix
  113372. */
  113373. export class Vector4TransformBlock extends NodeMaterialBlock {
  113374. /**
  113375. * Defines the value to use to complement Vector3 to transform it to a Vector4
  113376. */
  113377. complementW: number;
  113378. /**
  113379. * Creates a new Vector4TransformBlock
  113380. * @param name defines the block name
  113381. */
  113382. constructor(name: string);
  113383. /**
  113384. * Gets the current class name
  113385. * @returns the class name
  113386. */
  113387. getClassName(): string;
  113388. /**
  113389. * Gets the vector input
  113390. */
  113391. readonly vector: NodeMaterialConnectionPoint;
  113392. /**
  113393. * Gets the matrix transform input
  113394. */
  113395. readonly transform: NodeMaterialConnectionPoint;
  113396. protected _buildBlock(state: NodeMaterialBuildState): this;
  113397. }
  113398. }
  113399. declare module BABYLON {
  113400. /**
  113401. * Block used to output the vertex position
  113402. */
  113403. export class VertexOutputBlock extends NodeMaterialBlock {
  113404. /**
  113405. * Creates a new VertexOutputBlock
  113406. * @param name defines the block name
  113407. */
  113408. constructor(name: string);
  113409. /**
  113410. * Gets the current class name
  113411. * @returns the class name
  113412. */
  113413. getClassName(): string;
  113414. /**
  113415. * Gets the vector input component
  113416. */
  113417. readonly vector: NodeMaterialConnectionPoint;
  113418. protected _buildBlock(state: NodeMaterialBuildState): this;
  113419. }
  113420. }
  113421. declare module BABYLON {
  113422. /**
  113423. * Block used to output the final color
  113424. */
  113425. export class FragmentOutputBlock extends NodeMaterialBlock {
  113426. /**
  113427. * Gets or sets a boolean indicating if this block will output an alpha value
  113428. */
  113429. alphaBlendingEnabled: boolean;
  113430. /**
  113431. * Create a new FragmentOutputBlock
  113432. * @param name defines the block name
  113433. */
  113434. constructor(name: string);
  113435. /**
  113436. * Gets the current class name
  113437. * @returns the class name
  113438. */
  113439. getClassName(): string;
  113440. /**
  113441. * Gets the color input component
  113442. */
  113443. readonly color: NodeMaterialConnectionPoint;
  113444. protected _buildBlock(state: NodeMaterialBuildState): this;
  113445. }
  113446. }
  113447. declare module BABYLON {
  113448. /**
  113449. * Interface used to configure the node material editor
  113450. */
  113451. export interface INodeMaterialEditorOptions {
  113452. /** Define the URl to load node editor script */
  113453. editorURL?: string;
  113454. }
  113455. /** @hidden */
  113456. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  113457. /** BONES */
  113458. NUM_BONE_INFLUENCERS: number;
  113459. BonesPerMesh: number;
  113460. BONETEXTURE: boolean;
  113461. /** MORPH TARGETS */
  113462. MORPHTARGETS: boolean;
  113463. MORPHTARGETS_NORMAL: boolean;
  113464. MORPHTARGETS_TANGENT: boolean;
  113465. NUM_MORPH_INFLUENCERS: number;
  113466. /** IMAGE PROCESSING */
  113467. IMAGEPROCESSING: boolean;
  113468. VIGNETTE: boolean;
  113469. VIGNETTEBLENDMODEMULTIPLY: boolean;
  113470. VIGNETTEBLENDMODEOPAQUE: boolean;
  113471. TONEMAPPING: boolean;
  113472. TONEMAPPING_ACES: boolean;
  113473. CONTRAST: boolean;
  113474. EXPOSURE: boolean;
  113475. COLORCURVES: boolean;
  113476. COLORGRADING: boolean;
  113477. COLORGRADING3D: boolean;
  113478. SAMPLER3DGREENDEPTH: boolean;
  113479. SAMPLER3DBGRMAP: boolean;
  113480. IMAGEPROCESSINGPOSTPROCESS: boolean;
  113481. constructor();
  113482. setValue(name: string, value: boolean): void;
  113483. }
  113484. /**
  113485. * Class used to configure NodeMaterial
  113486. */
  113487. export interface INodeMaterialOptions {
  113488. /**
  113489. * Defines if blocks should emit comments
  113490. */
  113491. emitComments: boolean;
  113492. }
  113493. /**
  113494. * Class used to create a node based material built by assembling shader blocks
  113495. */
  113496. export class NodeMaterial extends PushMaterial {
  113497. private _options;
  113498. private _vertexCompilationState;
  113499. private _fragmentCompilationState;
  113500. private _sharedData;
  113501. private _buildId;
  113502. private _buildWasSuccessful;
  113503. private _cachedWorldViewMatrix;
  113504. private _cachedWorldViewProjectionMatrix;
  113505. private _textureConnectionPoints;
  113506. private _optimizers;
  113507. /** Define the URl to load node editor script */
  113508. static EditorURL: string;
  113509. private BJSNODEMATERIALEDITOR;
  113510. /** Get the inspector from bundle or global */
  113511. private _getGlobalNodeMaterialEditor;
  113512. /**
  113513. * Defines the maximum number of lights that can be used in the material
  113514. */
  113515. maxSimultaneousLights: number;
  113516. /**
  113517. * Observable raised when the material is built
  113518. */
  113519. onBuildObservable: Observable<NodeMaterial>;
  113520. /**
  113521. * Gets or sets the root nodes of the material vertex shader
  113522. */
  113523. _vertexOutputNodes: NodeMaterialBlock[];
  113524. /**
  113525. * Gets or sets the root nodes of the material fragment (pixel) shader
  113526. */
  113527. _fragmentOutputNodes: NodeMaterialBlock[];
  113528. /** Gets or sets options to control the node material overall behavior */
  113529. options: INodeMaterialOptions;
  113530. /**
  113531. * Default configuration related to image processing available in the standard Material.
  113532. */
  113533. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  113534. /**
  113535. * Gets the image processing configuration used either in this material.
  113536. */
  113537. /**
  113538. * Sets the Default image processing configuration used either in the this material.
  113539. *
  113540. * If sets to null, the scene one is in use.
  113541. */
  113542. imageProcessingConfiguration: ImageProcessingConfiguration;
  113543. /**
  113544. * Create a new node based material
  113545. * @param name defines the material name
  113546. * @param scene defines the hosting scene
  113547. * @param options defines creation option
  113548. */
  113549. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  113550. /**
  113551. * Gets the current class name of the material e.g. "NodeMaterial"
  113552. * @returns the class name
  113553. */
  113554. getClassName(): string;
  113555. /**
  113556. * Keep track of the image processing observer to allow dispose and replace.
  113557. */
  113558. private _imageProcessingObserver;
  113559. /**
  113560. * Attaches a new image processing configuration to the Standard Material.
  113561. * @param configuration
  113562. */
  113563. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  113564. /**
  113565. * Adds a new optimizer to the list of optimizers
  113566. * @param optimizer defines the optimizers to add
  113567. * @returns the current material
  113568. */
  113569. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  113570. /**
  113571. * Remove an optimizer from the list of optimizers
  113572. * @param optimizer defines the optimizers to remove
  113573. * @returns the current material
  113574. */
  113575. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  113576. /**
  113577. * Add a new block to the list of output nodes
  113578. * @param node defines the node to add
  113579. * @returns the current material
  113580. */
  113581. addOutputNode(node: NodeMaterialBlock): this;
  113582. /**
  113583. * Remove a block from the list of root nodes
  113584. * @param node defines the node to remove
  113585. * @returns the current material
  113586. */
  113587. removeOutputNode(node: NodeMaterialBlock): this;
  113588. private _addVertexOutputNode;
  113589. private _removeVertexOutputNode;
  113590. private _addFragmentOutputNode;
  113591. private _removeFragmentOutputNode;
  113592. /**
  113593. * Specifies if the material will require alpha blending
  113594. * @returns a boolean specifying if alpha blending is needed
  113595. */
  113596. needAlphaBlending(): boolean;
  113597. /**
  113598. * Specifies if this material should be rendered in alpha test mode
  113599. * @returns a boolean specifying if an alpha test is needed.
  113600. */
  113601. needAlphaTesting(): boolean;
  113602. private _initializeBlock;
  113603. private _resetDualBlocks;
  113604. /**
  113605. * Build the material and generates the inner effect
  113606. * @param verbose defines if the build should log activity
  113607. */
  113608. build(verbose?: boolean): void;
  113609. /**
  113610. * Runs an otpimization phase to try to improve the shader code
  113611. */
  113612. optimize(): void;
  113613. private _prepareDefinesForAttributes;
  113614. /**
  113615. * Get if the submesh is ready to be used and all its information available.
  113616. * Child classes can use it to update shaders
  113617. * @param mesh defines the mesh to check
  113618. * @param subMesh defines which submesh to check
  113619. * @param useInstances specifies that instances should be used
  113620. * @returns a boolean indicating that the submesh is ready or not
  113621. */
  113622. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  113623. /**
  113624. * Binds the world matrix to the material
  113625. * @param world defines the world transformation matrix
  113626. */
  113627. bindOnlyWorldMatrix(world: Matrix): void;
  113628. /**
  113629. * Binds the submesh to this material by preparing the effect and shader to draw
  113630. * @param world defines the world transformation matrix
  113631. * @param mesh defines the mesh containing the submesh
  113632. * @param subMesh defines the submesh to bind the material to
  113633. */
  113634. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  113635. /**
  113636. * Gets the active textures from the material
  113637. * @returns an array of textures
  113638. */
  113639. getActiveTextures(): BaseTexture[];
  113640. /**
  113641. * Specifies if the material uses a texture
  113642. * @param texture defines the texture to check against the material
  113643. * @returns a boolean specifying if the material uses the texture
  113644. */
  113645. hasTexture(texture: BaseTexture): boolean;
  113646. /**
  113647. * Disposes the material
  113648. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  113649. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  113650. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  113651. */
  113652. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  113653. /** Creates the node editor window. */
  113654. private _createNodeEditor;
  113655. /**
  113656. * Launch the node material editor
  113657. * @param config Define the configuration of the editor
  113658. * @return a promise fulfilled when the node editor is visible
  113659. */
  113660. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  113661. /**
  113662. * Clear the current material
  113663. */
  113664. clear(): void;
  113665. /**
  113666. * Clear the current material and set it to a default state
  113667. */
  113668. setToDefault(): void;
  113669. }
  113670. }
  113671. declare module BABYLON {
  113672. /**
  113673. * Defines a block that can be used inside a node based material
  113674. */
  113675. export class NodeMaterialBlock {
  113676. private _buildId;
  113677. private _target;
  113678. private _isFinalMerger;
  113679. /** @hidden */
  113680. _inputs: NodeMaterialConnectionPoint[];
  113681. /** @hidden */
  113682. _outputs: NodeMaterialConnectionPoint[];
  113683. /**
  113684. * Gets or sets the name of the block
  113685. */
  113686. name: string;
  113687. /**
  113688. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  113689. */
  113690. readonly isFinalMerger: boolean;
  113691. /**
  113692. * Gets or sets the build Id
  113693. */
  113694. buildId: number;
  113695. /**
  113696. * Gets or sets the target of the block
  113697. */
  113698. target: NodeMaterialBlockTargets;
  113699. /**
  113700. * Gets the list of input points
  113701. */
  113702. readonly inputs: NodeMaterialConnectionPoint[];
  113703. /** Gets the list of output points */
  113704. readonly outputs: NodeMaterialConnectionPoint[];
  113705. /**
  113706. * Find an input by its name
  113707. * @param name defines the name of the input to look for
  113708. * @returns the input or null if not found
  113709. */
  113710. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  113711. /**
  113712. * Find an output by its name
  113713. * @param name defines the name of the outputto look for
  113714. * @returns the output or null if not found
  113715. */
  113716. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  113717. /**
  113718. * Creates a new NodeMaterialBlock
  113719. * @param name defines the block name
  113720. * @param target defines the target of that block (Vertex by default)
  113721. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  113722. */
  113723. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean);
  113724. /**
  113725. * Initialize the block and prepare the context for build
  113726. * @param state defines the state that will be used for the build
  113727. */
  113728. initialize(state: NodeMaterialBuildState): void;
  113729. /**
  113730. * Bind data to effect. Will only be called for blocks with isBindable === true
  113731. * @param effect defines the effect to bind data to
  113732. * @param nodeMaterial defines the hosting NodeMaterial
  113733. * @param mesh defines the mesh that will be rendered
  113734. */
  113735. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  113736. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  113737. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  113738. protected _writeFloat(value: number): string;
  113739. /**
  113740. * Gets the current class name e.g. "NodeMaterialBlock"
  113741. * @returns the class name
  113742. */
  113743. getClassName(): string;
  113744. /**
  113745. * Register a new input. Must be called inside a block constructor
  113746. * @param name defines the connection point name
  113747. * @param type defines the connection point type
  113748. * @param isOptional defines a boolean indicating that this input can be omitted
  113749. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  113750. * @returns the current block
  113751. */
  113752. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  113753. /**
  113754. * Register a new output. Must be called inside a block constructor
  113755. * @param name defines the connection point name
  113756. * @param type defines the connection point type
  113757. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  113758. * @returns the current block
  113759. */
  113760. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  113761. /**
  113762. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  113763. * @param forOutput defines an optional connection point to check compatibility with
  113764. * @returns the first available input or null
  113765. */
  113766. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  113767. /**
  113768. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  113769. * @param forBlock defines an optional block to check compatibility with
  113770. * @returns the first available input or null
  113771. */
  113772. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  113773. /**
  113774. * Connect current block with another block
  113775. * @param other defines the block to connect with
  113776. * @param options define the various options to help pick the right connections
  113777. * @returns the current block
  113778. */
  113779. connectTo(other: NodeMaterialBlock, options?: {
  113780. input?: string;
  113781. output?: string;
  113782. outputSwizzle?: string;
  113783. }): this | undefined;
  113784. protected _buildBlock(state: NodeMaterialBuildState): void;
  113785. /**
  113786. * Add potential fallbacks if shader compilation fails
  113787. * @param mesh defines the mesh to be rendered
  113788. * @param fallbacks defines the current prioritized list of fallbacks
  113789. */
  113790. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  113791. /**
  113792. * Update defines for shader compilation
  113793. * @param mesh defines the mesh to be rendered
  113794. * @param nodeMaterial defines the node material requesting the update
  113795. * @param defines defines the material defines to update
  113796. * @param useInstances specifies that instances should be used
  113797. */
  113798. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  113799. /**
  113800. * Lets the block try to connect some inputs automatically
  113801. */
  113802. autoConfigure(): void;
  113803. /**
  113804. * Function called when a block is declared as repeatable content generator
  113805. * @param vertexShaderState defines the current compilation state for the vertex shader
  113806. * @param fragmentShaderState defines the current compilation state for the fragment shader
  113807. * @param mesh defines the mesh to be rendered
  113808. * @param defines defines the material defines to update
  113809. */
  113810. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  113811. /**
  113812. * Checks if the block is ready
  113813. * @param mesh defines the mesh to be rendered
  113814. * @param nodeMaterial defines the node material requesting the update
  113815. * @param defines defines the material defines to update
  113816. * @param useInstances specifies that instances should be used
  113817. * @returns true if the block is ready
  113818. */
  113819. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  113820. /**
  113821. * Compile the current node and generate the shader code
  113822. * @param state defines the current compilation state (uniforms, samplers, current string)
  113823. * @returns the current block
  113824. */
  113825. build(state: NodeMaterialBuildState): this | undefined;
  113826. }
  113827. }
  113828. declare module BABYLON {
  113829. /**
  113830. * Defines a connection point for a block
  113831. */
  113832. export class NodeMaterialConnectionPoint {
  113833. /** @hidden */
  113834. _ownerBlock: NodeMaterialBlock;
  113835. /** @hidden */
  113836. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  113837. private _associatedVariableName;
  113838. private _endpoints;
  113839. private _storedValue;
  113840. private _valueCallback;
  113841. private _mode;
  113842. /** @hidden */
  113843. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  113844. /** @hidden */
  113845. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  113846. /** @hidden */
  113847. _needToEmitVarying: boolean;
  113848. private _type;
  113849. /**
  113850. * Gets or sets the connection point type (default is float)
  113851. */
  113852. type: NodeMaterialBlockConnectionPointTypes;
  113853. /**
  113854. * Gets or sets the connection point name
  113855. */
  113856. name: string;
  113857. /**
  113858. * Gets or sets the swizzle to apply to this connection point when reading or writing
  113859. */
  113860. swizzle: string;
  113861. /**
  113862. * Gets or sets a boolean indicating that this connection point can be omitted
  113863. */
  113864. isOptional: boolean;
  113865. /**
  113866. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  113867. */
  113868. define: string;
  113869. /** Gets or sets the target of that connection point */
  113870. target: NodeMaterialBlockTargets;
  113871. /**
  113872. * Gets or sets the value of that point.
  113873. * Please note that this value will be ignored if valueCallback is defined
  113874. */
  113875. value: any;
  113876. /**
  113877. * Gets or sets a callback used to get the value of that point.
  113878. * Please note that setting this value will force the connection point to ignore the value property
  113879. */
  113880. valueCallback: () => any;
  113881. /**
  113882. * Gets or sets the associated variable name in the shader
  113883. */
  113884. associatedVariableName: string;
  113885. /**
  113886. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  113887. * In this case the connection point name must be the name of the uniform to use.
  113888. * Can only be set on inputs
  113889. */
  113890. isUniform: boolean;
  113891. /**
  113892. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  113893. * In this case the connection point name must be the name of the attribute to use
  113894. * Can only be set on inputs
  113895. */
  113896. isAttribute: boolean;
  113897. /**
  113898. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  113899. * Can only be set on exit points
  113900. */
  113901. isVarying: boolean;
  113902. /** Get the other side of the connection (if any) */
  113903. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  113904. /** Get the block that owns this connection point */
  113905. readonly ownerBlock: NodeMaterialBlock;
  113906. /** Get the block connected on the other side of this connection (if any) */
  113907. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  113908. /** Get the block connected on the endpoints of this connection (if any) */
  113909. readonly connectedBlocks: Array<NodeMaterialBlock>;
  113910. /**
  113911. * Creates a new connection point
  113912. * @param name defines the connection point name
  113913. * @param ownerBlock defines the block hosting this connection point
  113914. */
  113915. constructor(name: string, ownerBlock: NodeMaterialBlock);
  113916. /**
  113917. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  113918. * @returns the class name
  113919. */
  113920. getClassName(): string;
  113921. /**
  113922. * Set the source of this connection point to a vertex attribute
  113923. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  113924. * @returns the current connection point
  113925. */
  113926. setAsAttribute(attributeName?: string): NodeMaterialConnectionPoint;
  113927. /**
  113928. * Set the source of this connection point to a well known value
  113929. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  113930. * @returns the current connection point
  113931. */
  113932. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): NodeMaterialConnectionPoint;
  113933. /**
  113934. * Gets a boolean indicating that the current connection point is a well known value
  113935. */
  113936. readonly isWellKnownValue: boolean;
  113937. /**
  113938. * Gets or sets the current well known value or null if not defined as well know value
  113939. */
  113940. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  113941. private _getTypeLength;
  113942. /**
  113943. * Connect this point to another connection point
  113944. * @param connectionPoint defines the other connection point
  113945. * @returns the current connection point
  113946. */
  113947. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  113948. /**
  113949. * Disconnect this point from one of his endpoint
  113950. * @param endpoint defines the other connection point
  113951. * @returns the current connection point
  113952. */
  113953. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  113954. /**
  113955. * When connection point is an uniform, this function will send its value to the effect
  113956. * @param effect defines the effect to transmit value to
  113957. * @param world defines the world matrix
  113958. * @param worldView defines the worldxview matrix
  113959. * @param worldViewProjection defines the worldxviewxprojection matrix
  113960. */
  113961. transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  113962. /**
  113963. * When connection point is an uniform, this function will send its value to the effect
  113964. * @param effect defines the effect to transmit value to
  113965. * @param scene defines the hosting scene
  113966. */
  113967. transmit(effect: Effect, scene: Scene): void;
  113968. }
  113969. }
  113970. declare module BABYLON {
  113971. /**
  113972. * Block used to add support for vertex skinning (bones)
  113973. */
  113974. export class BonesBlock extends NodeMaterialBlock {
  113975. /**
  113976. * Creates a new BonesBlock
  113977. * @param name defines the block name
  113978. */
  113979. constructor(name: string);
  113980. /**
  113981. * Initialize the block and prepare the context for build
  113982. * @param state defines the state that will be used for the build
  113983. */
  113984. initialize(state: NodeMaterialBuildState): void;
  113985. /**
  113986. * Gets the current class name
  113987. * @returns the class name
  113988. */
  113989. getClassName(): string;
  113990. /**
  113991. * Gets the matrix indices input component
  113992. */
  113993. readonly matricesIndices: NodeMaterialConnectionPoint;
  113994. /**
  113995. * Gets the matrix weights input component
  113996. */
  113997. readonly matricesWeights: NodeMaterialConnectionPoint;
  113998. /**
  113999. * Gets the extra matrix indices input component
  114000. */
  114001. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  114002. /**
  114003. * Gets the extra matrix weights input component
  114004. */
  114005. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  114006. /**
  114007. * Gets the world input component
  114008. */
  114009. readonly world: NodeMaterialConnectionPoint;
  114010. autoConfigure(): void;
  114011. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  114012. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  114013. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  114014. protected _buildBlock(state: NodeMaterialBuildState): this;
  114015. }
  114016. }
  114017. declare module BABYLON {
  114018. /**
  114019. * Block used to add support for instances
  114020. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  114021. */
  114022. export class InstancesBlock extends NodeMaterialBlock {
  114023. /**
  114024. * Creates a new InstancesBlock
  114025. * @param name defines the block name
  114026. */
  114027. constructor(name: string);
  114028. /**
  114029. * Gets the current class name
  114030. * @returns the class name
  114031. */
  114032. getClassName(): string;
  114033. /**
  114034. * Gets the first world row input component
  114035. */
  114036. readonly world0: NodeMaterialConnectionPoint;
  114037. /**
  114038. * Gets the second world row input component
  114039. */
  114040. readonly world1: NodeMaterialConnectionPoint;
  114041. /**
  114042. * Gets the third world row input component
  114043. */
  114044. readonly world2: NodeMaterialConnectionPoint;
  114045. /**
  114046. * Gets the forth world row input component
  114047. */
  114048. readonly world3: NodeMaterialConnectionPoint;
  114049. /**
  114050. * Gets the world input component
  114051. */
  114052. readonly world: NodeMaterialConnectionPoint;
  114053. /**
  114054. * Gets the output component
  114055. */
  114056. readonly output: NodeMaterialConnectionPoint;
  114057. autoConfigure(): void;
  114058. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  114059. protected _buildBlock(state: NodeMaterialBuildState): this;
  114060. }
  114061. }
  114062. declare module BABYLON {
  114063. /**
  114064. * Block used to add morph targets support to vertex shader
  114065. */
  114066. export class MorphTargetsBlock extends NodeMaterialBlock {
  114067. private _repeatableContentAnchor;
  114068. private _repeatebleContentGenerated;
  114069. /**
  114070. * Create a new MorphTargetsBlock
  114071. * @param name defines the block name
  114072. */
  114073. constructor(name: string);
  114074. /**
  114075. * Gets the current class name
  114076. * @returns the class name
  114077. */
  114078. getClassName(): string;
  114079. /**
  114080. * Gets the position input component
  114081. */
  114082. readonly position: NodeMaterialConnectionPoint;
  114083. /**
  114084. * Gets the normal input component
  114085. */
  114086. readonly normal: NodeMaterialConnectionPoint;
  114087. /**
  114088. * Gets the tangent input component
  114089. */
  114090. readonly tangent: NodeMaterialConnectionPoint;
  114091. /**
  114092. * Gets the position output component
  114093. */
  114094. readonly positionOutput: NodeMaterialConnectionPoint;
  114095. /**
  114096. * Gets the normal output component
  114097. */
  114098. readonly normalOutput: NodeMaterialConnectionPoint;
  114099. /**
  114100. * Gets the tangent output component
  114101. */
  114102. readonly tangentOutput: NodeMaterialConnectionPoint;
  114103. initialize(state: NodeMaterialBuildState): void;
  114104. autoConfigure(): void;
  114105. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  114106. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  114107. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  114108. protected _buildBlock(state: NodeMaterialBuildState): this;
  114109. }
  114110. }
  114111. declare module BABYLON {
  114112. /**
  114113. * Block used to add an alpha test in the fragment shader
  114114. */
  114115. export class AlphaTestBlock extends NodeMaterialBlock {
  114116. /**
  114117. * Gets or sets the alpha value where alpha testing happens
  114118. */
  114119. alphaCutOff: number;
  114120. /**
  114121. * Create a new AlphaTestBlock
  114122. * @param name defines the block name
  114123. */
  114124. constructor(name: string);
  114125. /**
  114126. * Gets the current class name
  114127. * @returns the class name
  114128. */
  114129. getClassName(): string;
  114130. /**
  114131. * Gets the color input component
  114132. */
  114133. readonly color: NodeMaterialConnectionPoint;
  114134. protected _buildBlock(state: NodeMaterialBuildState): this;
  114135. }
  114136. }
  114137. declare module BABYLON {
  114138. /**
  114139. * Block used to create a Color4 out of 4 inputs (one for each component)
  114140. */
  114141. export class RGBAMergerBlock extends NodeMaterialBlock {
  114142. /**
  114143. * Create a new RGBAMergerBlock
  114144. * @param name defines the block name
  114145. */
  114146. constructor(name: string);
  114147. /**
  114148. * Gets the current class name
  114149. * @returns the class name
  114150. */
  114151. getClassName(): string;
  114152. /**
  114153. * Gets the R input component
  114154. */
  114155. readonly r: NodeMaterialConnectionPoint;
  114156. /**
  114157. * Gets the G input component
  114158. */
  114159. readonly g: NodeMaterialConnectionPoint;
  114160. /**
  114161. * Gets the B input component
  114162. */
  114163. readonly b: NodeMaterialConnectionPoint;
  114164. /**
  114165. * Gets the RGB input component
  114166. */
  114167. readonly rgb: NodeMaterialConnectionPoint;
  114168. /**
  114169. * Gets the R input component
  114170. */
  114171. readonly a: NodeMaterialConnectionPoint;
  114172. protected _buildBlock(state: NodeMaterialBuildState): this;
  114173. }
  114174. }
  114175. declare module BABYLON {
  114176. /**
  114177. * Block used to create a Color3 out of 3 inputs (one for each component)
  114178. */
  114179. export class RGBMergerBlock extends NodeMaterialBlock {
  114180. /**
  114181. * Create a new RGBMergerBlock
  114182. * @param name defines the block name
  114183. */
  114184. constructor(name: string);
  114185. /**
  114186. * Gets the current class name
  114187. * @returns the class name
  114188. */
  114189. getClassName(): string;
  114190. /**
  114191. * Gets the R component input
  114192. */
  114193. readonly r: NodeMaterialConnectionPoint;
  114194. /**
  114195. * Gets the G component input
  114196. */
  114197. readonly g: NodeMaterialConnectionPoint;
  114198. /**
  114199. * Gets the B component input
  114200. */
  114201. readonly b: NodeMaterialConnectionPoint;
  114202. protected _buildBlock(state: NodeMaterialBuildState): this;
  114203. }
  114204. }
  114205. declare module BABYLON {
  114206. /**
  114207. * Block used to expand a Color4 or a Vector4 into 4 outputs (one for each component)
  114208. */
  114209. export class RGBASplitterBlock extends NodeMaterialBlock {
  114210. /**
  114211. * Create a new RGBASplitterBlock
  114212. * @param name defines the block name
  114213. */
  114214. constructor(name: string);
  114215. /**
  114216. * Gets the current class name
  114217. * @returns the class name
  114218. */
  114219. getClassName(): string;
  114220. /**
  114221. * Gets the input component
  114222. */
  114223. readonly input: NodeMaterialConnectionPoint;
  114224. protected _buildBlock(state: NodeMaterialBuildState): this;
  114225. }
  114226. }
  114227. declare module BABYLON {
  114228. /**
  114229. * Block used to expand a Color3 or a Vector3 into 3 outputs (one for each component)
  114230. */
  114231. export class RGBSplitterBlock extends NodeMaterialBlock {
  114232. /**
  114233. * Create a new RGBSplitterBlock
  114234. * @param name defines the block name
  114235. */
  114236. constructor(name: string);
  114237. /**
  114238. * Gets the current class name
  114239. * @returns the class name
  114240. */
  114241. getClassName(): string;
  114242. /**
  114243. * Gets the input component
  114244. */
  114245. readonly input: NodeMaterialConnectionPoint;
  114246. protected _buildBlock(state: NodeMaterialBuildState): this;
  114247. }
  114248. }
  114249. declare module BABYLON {
  114250. /**
  114251. * Block used to read a texture from a sampler
  114252. */
  114253. export class TextureBlock extends NodeMaterialBlock {
  114254. private _defineName;
  114255. /**
  114256. * Gets or sets a boolean indicating that the block can automatically fetch the texture matrix
  114257. */
  114258. autoConnectTextureMatrix: boolean;
  114259. /**
  114260. * Gets or sets a boolean indicating that the block can automatically select the uv channel based on texture
  114261. */
  114262. autoSelectUV: boolean;
  114263. /**
  114264. * Create a new TextureBlock
  114265. * @param name defines the block name
  114266. */
  114267. constructor(name: string);
  114268. /**
  114269. * Gets the current class name
  114270. * @returns the class name
  114271. */
  114272. getClassName(): string;
  114273. /**
  114274. * Gets the uv input component
  114275. */
  114276. readonly uv: NodeMaterialConnectionPoint;
  114277. /**
  114278. * Gets the texture information input component
  114279. */
  114280. readonly textureInfo: NodeMaterialConnectionPoint;
  114281. /**
  114282. * Gets the transformed uv input component
  114283. */
  114284. readonly transformedUV: NodeMaterialConnectionPoint;
  114285. /**
  114286. * Gets the texture input component
  114287. */
  114288. readonly texture: NodeMaterialConnectionPoint;
  114289. /**
  114290. * Gets the texture transform input component
  114291. */
  114292. readonly textureTransform: NodeMaterialConnectionPoint;
  114293. autoConfigure(): void;
  114294. initialize(state: NodeMaterialBuildState): void;
  114295. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  114296. isReady(): boolean;
  114297. private _injectVertexCode;
  114298. protected _buildBlock(state: NodeMaterialBuildState): this;
  114299. }
  114300. }
  114301. declare module BABYLON {
  114302. /**
  114303. * Block used to add image processing support to fragment shader
  114304. */
  114305. export class ImageProcessingBlock extends NodeMaterialBlock {
  114306. /**
  114307. * Create a new ImageProcessingBlock
  114308. * @param name defines the block name
  114309. */
  114310. constructor(name: string);
  114311. /**
  114312. * Gets the current class name
  114313. * @returns the class name
  114314. */
  114315. getClassName(): string;
  114316. /**
  114317. * Gets the color input component
  114318. */
  114319. readonly color: NodeMaterialConnectionPoint;
  114320. /**
  114321. * Initialize the block and prepare the context for build
  114322. * @param state defines the state that will be used for the build
  114323. */
  114324. initialize(state: NodeMaterialBuildState): void;
  114325. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  114326. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  114327. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  114328. protected _buildBlock(state: NodeMaterialBuildState): this;
  114329. }
  114330. }
  114331. declare module BABYLON {
  114332. /**
  114333. * Block used to add support for scene fog
  114334. */
  114335. export class FogBlock extends NodeMaterialBlock {
  114336. /**
  114337. * Create a new FogBlock
  114338. * @param name defines the block name
  114339. */
  114340. constructor(name: string);
  114341. /**
  114342. * Gets the current class name
  114343. * @returns the class name
  114344. */
  114345. getClassName(): string;
  114346. /**
  114347. * Gets the world position input component
  114348. */
  114349. readonly worldPosition: NodeMaterialConnectionPoint;
  114350. /**
  114351. * Gets the view input component
  114352. */
  114353. readonly view: NodeMaterialConnectionPoint;
  114354. /**
  114355. * Gets the color input component
  114356. */
  114357. readonly color: NodeMaterialConnectionPoint;
  114358. /**
  114359. * Gets the fog color input component
  114360. */
  114361. readonly fogColor: NodeMaterialConnectionPoint;
  114362. /**
  114363. * Gets the for parameter input component
  114364. */
  114365. readonly fogParameters: NodeMaterialConnectionPoint;
  114366. autoConfigure(): void;
  114367. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  114368. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  114369. protected _buildBlock(state: NodeMaterialBuildState): this;
  114370. }
  114371. }
  114372. declare module BABYLON {
  114373. /**
  114374. * Block used to multiply 2 vector4
  114375. */
  114376. export class MultiplyBlock extends NodeMaterialBlock {
  114377. /**
  114378. * Creates a new MultiplyBlock
  114379. * @param name defines the block name
  114380. */
  114381. constructor(name: string);
  114382. /**
  114383. * Gets the current class name
  114384. * @returns the class name
  114385. */
  114386. getClassName(): string;
  114387. /**
  114388. * Gets the left operand input component
  114389. */
  114390. readonly left: NodeMaterialConnectionPoint;
  114391. /**
  114392. * Gets the right operand input component
  114393. */
  114394. readonly right: NodeMaterialConnectionPoint;
  114395. protected _buildBlock(state: NodeMaterialBuildState): this;
  114396. }
  114397. }
  114398. declare module BABYLON {
  114399. /**
  114400. * Block used to add 2 vector4
  114401. */
  114402. export class AddBlock extends NodeMaterialBlock {
  114403. /**
  114404. * Creates a new AddBlock
  114405. * @param name defines the block name
  114406. */
  114407. constructor(name: string);
  114408. /**
  114409. * Gets the current class name
  114410. * @returns the class name
  114411. */
  114412. getClassName(): string;
  114413. /**
  114414. * Gets the left operand input component
  114415. */
  114416. readonly left: NodeMaterialConnectionPoint;
  114417. /**
  114418. * Gets the right operand input component
  114419. */
  114420. readonly right: NodeMaterialConnectionPoint;
  114421. protected _buildBlock(state: NodeMaterialBuildState): this;
  114422. }
  114423. }
  114424. declare module BABYLON {
  114425. /**
  114426. * Block used to clamp a float
  114427. */
  114428. export class ClampBlock extends NodeMaterialBlock {
  114429. /** Gets or sets the minimum range */
  114430. minimum: number;
  114431. /** Gets or sets the maximum range */
  114432. maximum: number;
  114433. /**
  114434. * Creates a new ClampBlock
  114435. * @param name defines the block name
  114436. */
  114437. constructor(name: string);
  114438. /**
  114439. * Gets the current class name
  114440. * @returns the class name
  114441. */
  114442. getClassName(): string;
  114443. /**
  114444. * Gets the value input component
  114445. */
  114446. readonly value: NodeMaterialConnectionPoint;
  114447. protected _buildBlock(state: NodeMaterialBuildState): this;
  114448. }
  114449. }
  114450. declare module BABYLON {
  114451. /**
  114452. * Block used to scale a value
  114453. */
  114454. export class ScaleBlock extends NodeMaterialBlock {
  114455. /**
  114456. * Creates a new ScaleBlock
  114457. * @param name defines the block name
  114458. */
  114459. constructor(name: string);
  114460. /**
  114461. * Gets the current class name
  114462. * @returns the class name
  114463. */
  114464. getClassName(): string;
  114465. /**
  114466. * Gets the value operand input component
  114467. */
  114468. readonly value: NodeMaterialConnectionPoint;
  114469. /**
  114470. * Gets the scale operand input component
  114471. */
  114472. readonly scale: NodeMaterialConnectionPoint;
  114473. /**
  114474. * Gets the right operand input component
  114475. */
  114476. readonly right: NodeMaterialConnectionPoint;
  114477. protected _buildBlock(state: NodeMaterialBuildState): this;
  114478. }
  114479. }
  114480. declare module BABYLON {
  114481. /**
  114482. * Block used to transform a vector2 with a matrix
  114483. */
  114484. export class Vector2TransformBlock extends NodeMaterialBlock {
  114485. /**
  114486. * Defines the value to use to complement Vector2 to transform it to a Vector4
  114487. */
  114488. complementZ: number;
  114489. /**
  114490. * Defines the value to use to complement Vector2 to transform it to a Vector4
  114491. */
  114492. complementW: number;
  114493. /**
  114494. * Creates a new Vector2TransformBlock
  114495. * @param name defines the block name
  114496. */
  114497. constructor(name: string);
  114498. /**
  114499. * Gets the vector input
  114500. */
  114501. readonly vector: NodeMaterialConnectionPoint;
  114502. /**
  114503. * Gets the matrix transform input
  114504. */
  114505. readonly transform: NodeMaterialConnectionPoint;
  114506. /**
  114507. * Gets the current class name
  114508. * @returns the class name
  114509. */
  114510. getClassName(): string;
  114511. protected _buildBlock(state: NodeMaterialBuildState): this;
  114512. }
  114513. }
  114514. declare module BABYLON {
  114515. /**
  114516. * Block used to transform a vector3 with a matrix
  114517. */
  114518. export class Vector3TransformBlock extends NodeMaterialBlock {
  114519. /**
  114520. * Defines the value to use to complement Vector3 to transform it to a Vector4
  114521. */
  114522. complement: number;
  114523. /**
  114524. * Creates a new Vector3TransformBlock
  114525. * @param name defines the block name
  114526. */
  114527. constructor(name: string);
  114528. /**
  114529. * Gets the vector input
  114530. */
  114531. readonly vector: NodeMaterialConnectionPoint;
  114532. /**
  114533. * Gets the matrix transform input
  114534. */
  114535. readonly transform: NodeMaterialConnectionPoint;
  114536. /**
  114537. * Gets the current class name
  114538. * @returns the class name
  114539. */
  114540. getClassName(): string;
  114541. protected _buildBlock(state: NodeMaterialBuildState): this;
  114542. }
  114543. }
  114544. declare module BABYLON {
  114545. /**
  114546. * Block used to multiply two matrices
  114547. */
  114548. export class MatrixMultiplicationBlock extends NodeMaterialBlock {
  114549. /**
  114550. * Creates a new MatrixMultiplicationBlock
  114551. * @param name defines the block name
  114552. */
  114553. constructor(name: string);
  114554. /**
  114555. * Gets the left operand
  114556. */
  114557. readonly left: NodeMaterialConnectionPoint;
  114558. /**
  114559. * Gets the right operand
  114560. */
  114561. readonly right: NodeMaterialConnectionPoint;
  114562. /**
  114563. * Gets the current class name
  114564. * @returns the class name
  114565. */
  114566. getClassName(): string;
  114567. protected _buildBlock(state: NodeMaterialBuildState): this;
  114568. }
  114569. }
  114570. declare module BABYLON {
  114571. /**
  114572. * Helper class to push actions to a pool of workers.
  114573. */
  114574. export class WorkerPool implements IDisposable {
  114575. private _workerInfos;
  114576. private _pendingActions;
  114577. /**
  114578. * Constructor
  114579. * @param workers Array of workers to use for actions
  114580. */
  114581. constructor(workers: Array<Worker>);
  114582. /**
  114583. * Terminates all workers and clears any pending actions.
  114584. */
  114585. dispose(): void;
  114586. /**
  114587. * Pushes an action to the worker pool. If all the workers are active, the action will be
  114588. * pended until a worker has completed its action.
  114589. * @param action The action to perform. Call onComplete when the action is complete.
  114590. */
  114591. push(action: (worker: Worker, onComplete: () => void) => void): void;
  114592. private _execute;
  114593. }
  114594. }
  114595. declare module BABYLON {
  114596. /**
  114597. * Configuration for Draco compression
  114598. */
  114599. export interface IDracoCompressionConfiguration {
  114600. /**
  114601. * Configuration for the decoder.
  114602. */
  114603. decoder: {
  114604. /**
  114605. * The url to the WebAssembly module.
  114606. */
  114607. wasmUrl?: string;
  114608. /**
  114609. * The url to the WebAssembly binary.
  114610. */
  114611. wasmBinaryUrl?: string;
  114612. /**
  114613. * The url to the fallback JavaScript module.
  114614. */
  114615. fallbackUrl?: string;
  114616. };
  114617. }
  114618. /**
  114619. * Draco compression (https://google.github.io/draco/)
  114620. *
  114621. * This class wraps the Draco module.
  114622. *
  114623. * **Encoder**
  114624. *
  114625. * The encoder is not currently implemented.
  114626. *
  114627. * **Decoder**
  114628. *
  114629. * 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.
  114630. *
  114631. * To update the configuration, use the following code:
  114632. * ```javascript
  114633. * DracoCompression.Configuration = {
  114634. * decoder: {
  114635. * wasmUrl: "<url to the WebAssembly library>",
  114636. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  114637. * fallbackUrl: "<url to the fallback JavaScript library>",
  114638. * }
  114639. * };
  114640. * ```
  114641. *
  114642. * 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.
  114643. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  114644. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  114645. *
  114646. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  114647. * ```javascript
  114648. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  114649. * ```
  114650. *
  114651. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  114652. */
  114653. export class DracoCompression implements IDisposable {
  114654. private _workerPoolPromise?;
  114655. private _decoderModulePromise?;
  114656. /**
  114657. * The configuration. Defaults to the following urls:
  114658. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  114659. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  114660. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  114661. */
  114662. static Configuration: IDracoCompressionConfiguration;
  114663. /**
  114664. * Returns true if the decoder configuration is available.
  114665. */
  114666. static readonly DecoderAvailable: boolean;
  114667. /**
  114668. * Default number of workers to create when creating the draco compression object.
  114669. */
  114670. static DefaultNumWorkers: number;
  114671. private static GetDefaultNumWorkers;
  114672. private static _Default;
  114673. /**
  114674. * Default instance for the draco compression object.
  114675. */
  114676. static readonly Default: DracoCompression;
  114677. /**
  114678. * Constructor
  114679. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  114680. */
  114681. constructor(numWorkers?: number);
  114682. /**
  114683. * Stop all async operations and release resources.
  114684. */
  114685. dispose(): void;
  114686. /**
  114687. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  114688. * @returns a promise that resolves when ready
  114689. */
  114690. whenReadyAsync(): Promise<void>;
  114691. /**
  114692. * Decode Draco compressed mesh data to vertex data.
  114693. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  114694. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  114695. * @returns A promise that resolves with the decoded vertex data
  114696. */
  114697. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  114698. [kind: string]: number;
  114699. }): Promise<VertexData>;
  114700. }
  114701. }
  114702. declare module BABYLON {
  114703. /**
  114704. * Class for building Constructive Solid Geometry
  114705. */
  114706. export class CSG {
  114707. private polygons;
  114708. /**
  114709. * The world matrix
  114710. */
  114711. matrix: Matrix;
  114712. /**
  114713. * Stores the position
  114714. */
  114715. position: Vector3;
  114716. /**
  114717. * Stores the rotation
  114718. */
  114719. rotation: Vector3;
  114720. /**
  114721. * Stores the rotation quaternion
  114722. */
  114723. rotationQuaternion: Nullable<Quaternion>;
  114724. /**
  114725. * Stores the scaling vector
  114726. */
  114727. scaling: Vector3;
  114728. /**
  114729. * Convert the Mesh to CSG
  114730. * @param mesh The Mesh to convert to CSG
  114731. * @returns A new CSG from the Mesh
  114732. */
  114733. static FromMesh(mesh: Mesh): CSG;
  114734. /**
  114735. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  114736. * @param polygons Polygons used to construct a CSG solid
  114737. */
  114738. private static FromPolygons;
  114739. /**
  114740. * Clones, or makes a deep copy, of the CSG
  114741. * @returns A new CSG
  114742. */
  114743. clone(): CSG;
  114744. /**
  114745. * Unions this CSG with another CSG
  114746. * @param csg The CSG to union against this CSG
  114747. * @returns The unioned CSG
  114748. */
  114749. union(csg: CSG): CSG;
  114750. /**
  114751. * Unions this CSG with another CSG in place
  114752. * @param csg The CSG to union against this CSG
  114753. */
  114754. unionInPlace(csg: CSG): void;
  114755. /**
  114756. * Subtracts this CSG with another CSG
  114757. * @param csg The CSG to subtract against this CSG
  114758. * @returns A new CSG
  114759. */
  114760. subtract(csg: CSG): CSG;
  114761. /**
  114762. * Subtracts this CSG with another CSG in place
  114763. * @param csg The CSG to subtact against this CSG
  114764. */
  114765. subtractInPlace(csg: CSG): void;
  114766. /**
  114767. * Intersect this CSG with another CSG
  114768. * @param csg The CSG to intersect against this CSG
  114769. * @returns A new CSG
  114770. */
  114771. intersect(csg: CSG): CSG;
  114772. /**
  114773. * Intersects this CSG with another CSG in place
  114774. * @param csg The CSG to intersect against this CSG
  114775. */
  114776. intersectInPlace(csg: CSG): void;
  114777. /**
  114778. * Return a new CSG solid with solid and empty space switched. This solid is
  114779. * not modified.
  114780. * @returns A new CSG solid with solid and empty space switched
  114781. */
  114782. inverse(): CSG;
  114783. /**
  114784. * Inverses the CSG in place
  114785. */
  114786. inverseInPlace(): void;
  114787. /**
  114788. * This is used to keep meshes transformations so they can be restored
  114789. * when we build back a Babylon Mesh
  114790. * NB : All CSG operations are performed in world coordinates
  114791. * @param csg The CSG to copy the transform attributes from
  114792. * @returns This CSG
  114793. */
  114794. copyTransformAttributes(csg: CSG): CSG;
  114795. /**
  114796. * Build Raw mesh from CSG
  114797. * Coordinates here are in world space
  114798. * @param name The name of the mesh geometry
  114799. * @param scene The Scene
  114800. * @param keepSubMeshes Specifies if the submeshes should be kept
  114801. * @returns A new Mesh
  114802. */
  114803. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  114804. /**
  114805. * Build Mesh from CSG taking material and transforms into account
  114806. * @param name The name of the Mesh
  114807. * @param material The material of the Mesh
  114808. * @param scene The Scene
  114809. * @param keepSubMeshes Specifies if submeshes should be kept
  114810. * @returns The new Mesh
  114811. */
  114812. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  114813. }
  114814. }
  114815. declare module BABYLON {
  114816. /**
  114817. * Class used to create a trail following a mesh
  114818. */
  114819. export class TrailMesh extends Mesh {
  114820. private _generator;
  114821. private _autoStart;
  114822. private _running;
  114823. private _diameter;
  114824. private _length;
  114825. private _sectionPolygonPointsCount;
  114826. private _sectionVectors;
  114827. private _sectionNormalVectors;
  114828. private _beforeRenderObserver;
  114829. /**
  114830. * @constructor
  114831. * @param name The value used by scene.getMeshByName() to do a lookup.
  114832. * @param generator The mesh to generate a trail.
  114833. * @param scene The scene to add this mesh to.
  114834. * @param diameter Diameter of trailing mesh. Default is 1.
  114835. * @param length Length of trailing mesh. Default is 60.
  114836. * @param autoStart Automatically start trailing mesh. Default true.
  114837. */
  114838. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  114839. /**
  114840. * "TrailMesh"
  114841. * @returns "TrailMesh"
  114842. */
  114843. getClassName(): string;
  114844. private _createMesh;
  114845. /**
  114846. * Start trailing mesh.
  114847. */
  114848. start(): void;
  114849. /**
  114850. * Stop trailing mesh.
  114851. */
  114852. stop(): void;
  114853. /**
  114854. * Update trailing mesh geometry.
  114855. */
  114856. update(): void;
  114857. /**
  114858. * Returns a new TrailMesh object.
  114859. * @param name is a string, the name given to the new mesh
  114860. * @param newGenerator use new generator object for cloned trail mesh
  114861. * @returns a new mesh
  114862. */
  114863. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  114864. /**
  114865. * Serializes this trail mesh
  114866. * @param serializationObject object to write serialization to
  114867. */
  114868. serialize(serializationObject: any): void;
  114869. /**
  114870. * Parses a serialized trail mesh
  114871. * @param parsedMesh the serialized mesh
  114872. * @param scene the scene to create the trail mesh in
  114873. * @returns the created trail mesh
  114874. */
  114875. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  114876. }
  114877. }
  114878. declare module BABYLON {
  114879. /**
  114880. * Class containing static functions to help procedurally build meshes
  114881. */
  114882. export class TiledBoxBuilder {
  114883. /**
  114884. * Creates a box mesh
  114885. * faceTiles sets the pattern, tile size and number of tiles for a face * * 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)
  114886. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  114887. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114888. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114889. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114890. * @param name defines the name of the mesh
  114891. * @param options defines the options used to create the mesh
  114892. * @param scene defines the hosting scene
  114893. * @returns the box mesh
  114894. */
  114895. static CreateTiledBox(name: string, options: {
  114896. pattern?: number;
  114897. width?: number;
  114898. height?: number;
  114899. depth?: number;
  114900. tileSize?: number;
  114901. tileWidth?: number;
  114902. tileHeight?: number;
  114903. alignHorizontal?: number;
  114904. alignVertical?: number;
  114905. faceUV?: Vector4[];
  114906. faceColors?: Color4[];
  114907. sideOrientation?: number;
  114908. updatable?: boolean;
  114909. }, scene?: Nullable<Scene>): Mesh;
  114910. }
  114911. }
  114912. declare module BABYLON {
  114913. /**
  114914. * Class containing static functions to help procedurally build meshes
  114915. */
  114916. export class TorusKnotBuilder {
  114917. /**
  114918. * Creates a torus knot mesh
  114919. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  114920. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  114921. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  114922. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  114923. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114924. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114925. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  114926. * @param name defines the name of the mesh
  114927. * @param options defines the options used to create the mesh
  114928. * @param scene defines the hosting scene
  114929. * @returns the torus knot mesh
  114930. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  114931. */
  114932. static CreateTorusKnot(name: string, options: {
  114933. radius?: number;
  114934. tube?: number;
  114935. radialSegments?: number;
  114936. tubularSegments?: number;
  114937. p?: number;
  114938. q?: number;
  114939. updatable?: boolean;
  114940. sideOrientation?: number;
  114941. frontUVs?: Vector4;
  114942. backUVs?: Vector4;
  114943. }, scene: any): Mesh;
  114944. }
  114945. }
  114946. declare module BABYLON {
  114947. /**
  114948. * Polygon
  114949. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  114950. */
  114951. export class Polygon {
  114952. /**
  114953. * Creates a rectangle
  114954. * @param xmin bottom X coord
  114955. * @param ymin bottom Y coord
  114956. * @param xmax top X coord
  114957. * @param ymax top Y coord
  114958. * @returns points that make the resulting rectation
  114959. */
  114960. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  114961. /**
  114962. * Creates a circle
  114963. * @param radius radius of circle
  114964. * @param cx scale in x
  114965. * @param cy scale in y
  114966. * @param numberOfSides number of sides that make up the circle
  114967. * @returns points that make the resulting circle
  114968. */
  114969. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  114970. /**
  114971. * Creates a polygon from input string
  114972. * @param input Input polygon data
  114973. * @returns the parsed points
  114974. */
  114975. static Parse(input: string): Vector2[];
  114976. /**
  114977. * Starts building a polygon from x and y coordinates
  114978. * @param x x coordinate
  114979. * @param y y coordinate
  114980. * @returns the started path2
  114981. */
  114982. static StartingAt(x: number, y: number): Path2;
  114983. }
  114984. /**
  114985. * Builds a polygon
  114986. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  114987. */
  114988. export class PolygonMeshBuilder {
  114989. private _points;
  114990. private _outlinepoints;
  114991. private _holes;
  114992. private _name;
  114993. private _scene;
  114994. private _epoints;
  114995. private _eholes;
  114996. private _addToepoint;
  114997. /**
  114998. * Babylon reference to the earcut plugin.
  114999. */
  115000. bjsEarcut: any;
  115001. /**
  115002. * Creates a PolygonMeshBuilder
  115003. * @param name name of the builder
  115004. * @param contours Path of the polygon
  115005. * @param scene scene to add to when creating the mesh
  115006. * @param earcutInjection can be used to inject your own earcut reference
  115007. */
  115008. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  115009. /**
  115010. * Adds a whole within the polygon
  115011. * @param hole Array of points defining the hole
  115012. * @returns this
  115013. */
  115014. addHole(hole: Vector2[]): PolygonMeshBuilder;
  115015. /**
  115016. * Creates the polygon
  115017. * @param updatable If the mesh should be updatable
  115018. * @param depth The depth of the mesh created
  115019. * @returns the created mesh
  115020. */
  115021. build(updatable?: boolean, depth?: number): Mesh;
  115022. /**
  115023. * Creates the polygon
  115024. * @param depth The depth of the mesh created
  115025. * @returns the created VertexData
  115026. */
  115027. buildVertexData(depth?: number): VertexData;
  115028. /**
  115029. * Adds a side to the polygon
  115030. * @param positions points that make the polygon
  115031. * @param normals normals of the polygon
  115032. * @param uvs uvs of the polygon
  115033. * @param indices indices of the polygon
  115034. * @param bounds bounds of the polygon
  115035. * @param points points of the polygon
  115036. * @param depth depth of the polygon
  115037. * @param flip flip of the polygon
  115038. */
  115039. private addSide;
  115040. }
  115041. }
  115042. declare module BABYLON {
  115043. /**
  115044. * Class containing static functions to help procedurally build meshes
  115045. */
  115046. export class PolygonBuilder {
  115047. /**
  115048. * Creates a polygon mesh
  115049. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  115050. * * 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
  115051. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115052. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115053. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  115054. * * Remember you can only change the shape positions, not their number when updating a polygon
  115055. * @param name defines the name of the mesh
  115056. * @param options defines the options used to create the mesh
  115057. * @param scene defines the hosting scene
  115058. * @param earcutInjection can be used to inject your own earcut reference
  115059. * @returns the polygon mesh
  115060. */
  115061. static CreatePolygon(name: string, options: {
  115062. shape: Vector3[];
  115063. holes?: Vector3[][];
  115064. depth?: number;
  115065. faceUV?: Vector4[];
  115066. faceColors?: Color4[];
  115067. updatable?: boolean;
  115068. sideOrientation?: number;
  115069. frontUVs?: Vector4;
  115070. backUVs?: Vector4;
  115071. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  115072. /**
  115073. * Creates an extruded polygon mesh, with depth in the Y direction.
  115074. * * 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)
  115075. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  115076. * @param name defines the name of the mesh
  115077. * @param options defines the options used to create the mesh
  115078. * @param scene defines the hosting scene
  115079. * @param earcutInjection can be used to inject your own earcut reference
  115080. * @returns the polygon mesh
  115081. */
  115082. static ExtrudePolygon(name: string, options: {
  115083. shape: Vector3[];
  115084. holes?: Vector3[][];
  115085. depth?: number;
  115086. faceUV?: Vector4[];
  115087. faceColors?: Color4[];
  115088. updatable?: boolean;
  115089. sideOrientation?: number;
  115090. frontUVs?: Vector4;
  115091. backUVs?: Vector4;
  115092. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  115093. }
  115094. }
  115095. declare module BABYLON {
  115096. /**
  115097. * Class containing static functions to help procedurally build meshes
  115098. */
  115099. export class LatheBuilder {
  115100. /**
  115101. * Creates lathe mesh.
  115102. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  115103. * * 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
  115104. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  115105. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  115106. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  115107. * * 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
  115108. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  115109. * * 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
  115110. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115111. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115112. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  115113. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115114. * @param name defines the name of the mesh
  115115. * @param options defines the options used to create the mesh
  115116. * @param scene defines the hosting scene
  115117. * @returns the lathe mesh
  115118. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  115119. */
  115120. static CreateLathe(name: string, options: {
  115121. shape: Vector3[];
  115122. radius?: number;
  115123. tessellation?: number;
  115124. clip?: number;
  115125. arc?: number;
  115126. closed?: boolean;
  115127. updatable?: boolean;
  115128. sideOrientation?: number;
  115129. frontUVs?: Vector4;
  115130. backUVs?: Vector4;
  115131. cap?: number;
  115132. invertUV?: boolean;
  115133. }, scene?: Nullable<Scene>): Mesh;
  115134. }
  115135. }
  115136. declare module BABYLON {
  115137. /**
  115138. * Class containing static functions to help procedurally build meshes
  115139. */
  115140. export class TiledPlaneBuilder {
  115141. /**
  115142. * Creates a tiled plane mesh
  115143. * * The parameter `pattern` will, depending on value, do nothing or
  115144. * * * flip (reflect about central vertical) alternate tiles across and up
  115145. * * * flip every tile on alternate rows
  115146. * * * rotate (180 degs) alternate tiles across and up
  115147. * * * rotate every tile on alternate rows
  115148. * * * flip and rotate alternate tiles across and up
  115149. * * * flip and rotate every tile on alternate rows
  115150. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  115151. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  115152. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115153. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115154. * * 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)
  115155. * * 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)
  115156. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  115157. * @param name defines the name of the mesh
  115158. * @param options defines the options used to create the mesh
  115159. * @param scene defines the hosting scene
  115160. * @returns the box mesh
  115161. */
  115162. static CreateTiledPlane(name: string, options: {
  115163. pattern?: number;
  115164. tileSize?: number;
  115165. tileWidth?: number;
  115166. tileHeight?: number;
  115167. size?: number;
  115168. width?: number;
  115169. height?: number;
  115170. alignHorizontal?: number;
  115171. alignVertical?: number;
  115172. sideOrientation?: number;
  115173. frontUVs?: Vector4;
  115174. backUVs?: Vector4;
  115175. updatable?: boolean;
  115176. }, scene?: Nullable<Scene>): Mesh;
  115177. }
  115178. }
  115179. declare module BABYLON {
  115180. /**
  115181. * Class containing static functions to help procedurally build meshes
  115182. */
  115183. export class TubeBuilder {
  115184. /**
  115185. * Creates a tube mesh.
  115186. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  115187. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  115188. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  115189. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  115190. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  115191. * * 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)
  115192. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  115193. * * 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
  115194. * * 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
  115195. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115196. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115197. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  115198. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115199. * @param name defines the name of the mesh
  115200. * @param options defines the options used to create the mesh
  115201. * @param scene defines the hosting scene
  115202. * @returns the tube mesh
  115203. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  115204. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  115205. */
  115206. static CreateTube(name: string, options: {
  115207. path: Vector3[];
  115208. radius?: number;
  115209. tessellation?: number;
  115210. radiusFunction?: {
  115211. (i: number, distance: number): number;
  115212. };
  115213. cap?: number;
  115214. arc?: number;
  115215. updatable?: boolean;
  115216. sideOrientation?: number;
  115217. frontUVs?: Vector4;
  115218. backUVs?: Vector4;
  115219. instance?: Mesh;
  115220. invertUV?: boolean;
  115221. }, scene?: Nullable<Scene>): Mesh;
  115222. }
  115223. }
  115224. declare module BABYLON {
  115225. /**
  115226. * Class containing static functions to help procedurally build meshes
  115227. */
  115228. export class IcoSphereBuilder {
  115229. /**
  115230. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  115231. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  115232. * * 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`)
  115233. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  115234. * * 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
  115235. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115236. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115237. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115238. * @param name defines the name of the mesh
  115239. * @param options defines the options used to create the mesh
  115240. * @param scene defines the hosting scene
  115241. * @returns the icosahedron mesh
  115242. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  115243. */
  115244. static CreateIcoSphere(name: string, options: {
  115245. radius?: number;
  115246. radiusX?: number;
  115247. radiusY?: number;
  115248. radiusZ?: number;
  115249. flat?: boolean;
  115250. subdivisions?: number;
  115251. sideOrientation?: number;
  115252. frontUVs?: Vector4;
  115253. backUVs?: Vector4;
  115254. updatable?: boolean;
  115255. }, scene?: Nullable<Scene>): Mesh;
  115256. }
  115257. }
  115258. declare module BABYLON {
  115259. /**
  115260. * Class containing static functions to help procedurally build meshes
  115261. */
  115262. export class DecalBuilder {
  115263. /**
  115264. * Creates a decal mesh.
  115265. * 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
  115266. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  115267. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  115268. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  115269. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  115270. * @param name defines the name of the mesh
  115271. * @param sourceMesh defines the mesh where the decal must be applied
  115272. * @param options defines the options used to create the mesh
  115273. * @param scene defines the hosting scene
  115274. * @returns the decal mesh
  115275. * @see https://doc.babylonjs.com/how_to/decals
  115276. */
  115277. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  115278. position?: Vector3;
  115279. normal?: Vector3;
  115280. size?: Vector3;
  115281. angle?: number;
  115282. }): Mesh;
  115283. }
  115284. }
  115285. declare module BABYLON {
  115286. /**
  115287. * Class containing static functions to help procedurally build meshes
  115288. */
  115289. export class MeshBuilder {
  115290. /**
  115291. * Creates a box mesh
  115292. * * The parameter `size` sets the size (float) of each box side (default 1)
  115293. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  115294. * * 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)
  115295. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  115296. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115297. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115298. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115299. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  115300. * @param name defines the name of the mesh
  115301. * @param options defines the options used to create the mesh
  115302. * @param scene defines the hosting scene
  115303. * @returns the box mesh
  115304. */
  115305. static CreateBox(name: string, options: {
  115306. size?: number;
  115307. width?: number;
  115308. height?: number;
  115309. depth?: number;
  115310. faceUV?: Vector4[];
  115311. faceColors?: Color4[];
  115312. sideOrientation?: number;
  115313. frontUVs?: Vector4;
  115314. backUVs?: Vector4;
  115315. updatable?: boolean;
  115316. }, scene?: Nullable<Scene>): Mesh;
  115317. /**
  115318. * Creates a tiled box mesh
  115319. * * faceTiles sets the pattern, tile size and number of tiles for a face
  115320. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115321. * @param name defines the name of the mesh
  115322. * @param options defines the options used to create the mesh
  115323. * @param scene defines the hosting scene
  115324. * @returns the tiled box mesh
  115325. */
  115326. static CreateTiledBox(name: string, options: {
  115327. pattern?: number;
  115328. size?: number;
  115329. width?: number;
  115330. height?: number;
  115331. depth: number;
  115332. tileSize?: number;
  115333. tileWidth?: number;
  115334. tileHeight?: number;
  115335. faceUV?: Vector4[];
  115336. faceColors?: Color4[];
  115337. alignHorizontal?: number;
  115338. alignVertical?: number;
  115339. sideOrientation?: number;
  115340. updatable?: boolean;
  115341. }, scene?: Nullable<Scene>): Mesh;
  115342. /**
  115343. * Creates a sphere mesh
  115344. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  115345. * * 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`)
  115346. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  115347. * * 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
  115348. * * 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)
  115349. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115350. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115351. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115352. * @param name defines the name of the mesh
  115353. * @param options defines the options used to create the mesh
  115354. * @param scene defines the hosting scene
  115355. * @returns the sphere mesh
  115356. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  115357. */
  115358. static CreateSphere(name: string, options: {
  115359. segments?: number;
  115360. diameter?: number;
  115361. diameterX?: number;
  115362. diameterY?: number;
  115363. diameterZ?: number;
  115364. arc?: number;
  115365. slice?: number;
  115366. sideOrientation?: number;
  115367. frontUVs?: Vector4;
  115368. backUVs?: Vector4;
  115369. updatable?: boolean;
  115370. }, scene?: Nullable<Scene>): Mesh;
  115371. /**
  115372. * Creates a plane polygonal mesh. By default, this is a disc
  115373. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  115374. * * 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
  115375. * * 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
  115376. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115377. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115378. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115379. * @param name defines the name of the mesh
  115380. * @param options defines the options used to create the mesh
  115381. * @param scene defines the hosting scene
  115382. * @returns the plane polygonal mesh
  115383. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  115384. */
  115385. static CreateDisc(name: string, options: {
  115386. radius?: number;
  115387. tessellation?: number;
  115388. arc?: number;
  115389. updatable?: boolean;
  115390. sideOrientation?: number;
  115391. frontUVs?: Vector4;
  115392. backUVs?: Vector4;
  115393. }, scene?: Nullable<Scene>): Mesh;
  115394. /**
  115395. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  115396. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  115397. * * 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`)
  115398. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  115399. * * 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
  115400. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115401. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115402. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115403. * @param name defines the name of the mesh
  115404. * @param options defines the options used to create the mesh
  115405. * @param scene defines the hosting scene
  115406. * @returns the icosahedron mesh
  115407. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  115408. */
  115409. static CreateIcoSphere(name: string, options: {
  115410. radius?: number;
  115411. radiusX?: number;
  115412. radiusY?: number;
  115413. radiusZ?: number;
  115414. flat?: boolean;
  115415. subdivisions?: number;
  115416. sideOrientation?: number;
  115417. frontUVs?: Vector4;
  115418. backUVs?: Vector4;
  115419. updatable?: boolean;
  115420. }, scene?: Nullable<Scene>): Mesh;
  115421. /**
  115422. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  115423. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  115424. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  115425. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  115426. * * 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
  115427. * * 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
  115428. * * 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
  115429. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115430. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115431. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  115432. * * 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
  115433. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  115434. * * 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
  115435. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  115436. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115437. * @param name defines the name of the mesh
  115438. * @param options defines the options used to create the mesh
  115439. * @param scene defines the hosting scene
  115440. * @returns the ribbon mesh
  115441. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  115442. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  115443. */
  115444. static CreateRibbon(name: string, options: {
  115445. pathArray: Vector3[][];
  115446. closeArray?: boolean;
  115447. closePath?: boolean;
  115448. offset?: number;
  115449. updatable?: boolean;
  115450. sideOrientation?: number;
  115451. frontUVs?: Vector4;
  115452. backUVs?: Vector4;
  115453. instance?: Mesh;
  115454. invertUV?: boolean;
  115455. uvs?: Vector2[];
  115456. colors?: Color4[];
  115457. }, scene?: Nullable<Scene>): Mesh;
  115458. /**
  115459. * Creates a cylinder or a cone mesh
  115460. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  115461. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  115462. * * 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.
  115463. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  115464. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  115465. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  115466. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  115467. * * The parameter `cap` sets the way the cylinder is capped. Possible values : BABYLON.Mesh.NO_CAP, BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL (default).
  115468. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  115469. * * 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).
  115470. * * 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
  115471. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  115472. * * 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
  115473. * * 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.
  115474. * * If `enclose` is false, a ring surface is one element.
  115475. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  115476. * * 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
  115477. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115478. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115479. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115480. * @param name defines the name of the mesh
  115481. * @param options defines the options used to create the mesh
  115482. * @param scene defines the hosting scene
  115483. * @returns the cylinder mesh
  115484. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  115485. */
  115486. static CreateCylinder(name: string, options: {
  115487. height?: number;
  115488. diameterTop?: number;
  115489. diameterBottom?: number;
  115490. diameter?: number;
  115491. tessellation?: number;
  115492. subdivisions?: number;
  115493. arc?: number;
  115494. faceColors?: Color4[];
  115495. faceUV?: Vector4[];
  115496. updatable?: boolean;
  115497. hasRings?: boolean;
  115498. enclose?: boolean;
  115499. cap?: number;
  115500. sideOrientation?: number;
  115501. frontUVs?: Vector4;
  115502. backUVs?: Vector4;
  115503. }, scene?: Nullable<Scene>): Mesh;
  115504. /**
  115505. * Creates a torus mesh
  115506. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  115507. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  115508. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  115509. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115510. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115511. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115512. * @param name defines the name of the mesh
  115513. * @param options defines the options used to create the mesh
  115514. * @param scene defines the hosting scene
  115515. * @returns the torus mesh
  115516. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  115517. */
  115518. static CreateTorus(name: string, options: {
  115519. diameter?: number;
  115520. thickness?: number;
  115521. tessellation?: number;
  115522. updatable?: boolean;
  115523. sideOrientation?: number;
  115524. frontUVs?: Vector4;
  115525. backUVs?: Vector4;
  115526. }, scene?: Nullable<Scene>): Mesh;
  115527. /**
  115528. * Creates a torus knot mesh
  115529. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  115530. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  115531. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  115532. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  115533. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115534. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115535. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115536. * @param name defines the name of the mesh
  115537. * @param options defines the options used to create the mesh
  115538. * @param scene defines the hosting scene
  115539. * @returns the torus knot mesh
  115540. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  115541. */
  115542. static CreateTorusKnot(name: string, options: {
  115543. radius?: number;
  115544. tube?: number;
  115545. radialSegments?: number;
  115546. tubularSegments?: number;
  115547. p?: number;
  115548. q?: number;
  115549. updatable?: boolean;
  115550. sideOrientation?: number;
  115551. frontUVs?: Vector4;
  115552. backUVs?: Vector4;
  115553. }, scene?: Nullable<Scene>): Mesh;
  115554. /**
  115555. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  115556. * * 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
  115557. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  115558. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  115559. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  115560. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  115561. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  115562. * * 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
  115563. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  115564. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115565. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  115566. * @param name defines the name of the new line system
  115567. * @param options defines the options used to create the line system
  115568. * @param scene defines the hosting scene
  115569. * @returns a new line system mesh
  115570. */
  115571. static CreateLineSystem(name: string, options: {
  115572. lines: Vector3[][];
  115573. updatable?: boolean;
  115574. instance?: Nullable<LinesMesh>;
  115575. colors?: Nullable<Color4[][]>;
  115576. useVertexAlpha?: boolean;
  115577. }, scene: Nullable<Scene>): LinesMesh;
  115578. /**
  115579. * Creates a line mesh
  115580. * 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
  115581. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  115582. * * The parameter `points` is an array successive Vector3
  115583. * * 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
  115584. * * The optional parameter `colors` is an array of successive Color4, one per line point
  115585. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  115586. * * When updating an instance, remember that only point positions can change, not the number of points
  115587. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115588. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  115589. * @param name defines the name of the new line system
  115590. * @param options defines the options used to create the line system
  115591. * @param scene defines the hosting scene
  115592. * @returns a new line mesh
  115593. */
  115594. static CreateLines(name: string, options: {
  115595. points: Vector3[];
  115596. updatable?: boolean;
  115597. instance?: Nullable<LinesMesh>;
  115598. colors?: Color4[];
  115599. useVertexAlpha?: boolean;
  115600. }, scene?: Nullable<Scene>): LinesMesh;
  115601. /**
  115602. * Creates a dashed line mesh
  115603. * * 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
  115604. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  115605. * * The parameter `points` is an array successive Vector3
  115606. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  115607. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  115608. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  115609. * * 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
  115610. * * When updating an instance, remember that only point positions can change, not the number of points
  115611. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115612. * @param name defines the name of the mesh
  115613. * @param options defines the options used to create the mesh
  115614. * @param scene defines the hosting scene
  115615. * @returns the dashed line mesh
  115616. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  115617. */
  115618. static CreateDashedLines(name: string, options: {
  115619. points: Vector3[];
  115620. dashSize?: number;
  115621. gapSize?: number;
  115622. dashNb?: number;
  115623. updatable?: boolean;
  115624. instance?: LinesMesh;
  115625. }, scene?: Nullable<Scene>): LinesMesh;
  115626. /**
  115627. * 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.
  115628. * * 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.
  115629. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  115630. * * 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.
  115631. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  115632. * * 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
  115633. * * 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
  115634. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  115635. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115636. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115637. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  115638. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115639. * @param name defines the name of the mesh
  115640. * @param options defines the options used to create the mesh
  115641. * @param scene defines the hosting scene
  115642. * @returns the extruded shape mesh
  115643. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  115644. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  115645. */
  115646. static ExtrudeShape(name: string, options: {
  115647. shape: Vector3[];
  115648. path: Vector3[];
  115649. scale?: number;
  115650. rotation?: number;
  115651. cap?: number;
  115652. updatable?: boolean;
  115653. sideOrientation?: number;
  115654. frontUVs?: Vector4;
  115655. backUVs?: Vector4;
  115656. instance?: Mesh;
  115657. invertUV?: boolean;
  115658. }, scene?: Nullable<Scene>): Mesh;
  115659. /**
  115660. * Creates an custom extruded shape mesh.
  115661. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  115662. * * 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.
  115663. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  115664. * * 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
  115665. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  115666. * * 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
  115667. * * It must returns a float value that will be the scale value applied to the shape on each path point
  115668. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  115669. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  115670. * * 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
  115671. * * 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
  115672. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  115673. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115674. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115675. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  115676. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115677. * @param name defines the name of the mesh
  115678. * @param options defines the options used to create the mesh
  115679. * @param scene defines the hosting scene
  115680. * @returns the custom extruded shape mesh
  115681. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  115682. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  115683. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  115684. */
  115685. static ExtrudeShapeCustom(name: string, options: {
  115686. shape: Vector3[];
  115687. path: Vector3[];
  115688. scaleFunction?: any;
  115689. rotationFunction?: any;
  115690. ribbonCloseArray?: boolean;
  115691. ribbonClosePath?: boolean;
  115692. cap?: number;
  115693. updatable?: boolean;
  115694. sideOrientation?: number;
  115695. frontUVs?: Vector4;
  115696. backUVs?: Vector4;
  115697. instance?: Mesh;
  115698. invertUV?: boolean;
  115699. }, scene?: Nullable<Scene>): Mesh;
  115700. /**
  115701. * Creates lathe mesh.
  115702. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  115703. * * 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
  115704. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  115705. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  115706. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  115707. * * 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
  115708. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  115709. * * 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
  115710. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115711. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115712. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  115713. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115714. * @param name defines the name of the mesh
  115715. * @param options defines the options used to create the mesh
  115716. * @param scene defines the hosting scene
  115717. * @returns the lathe mesh
  115718. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  115719. */
  115720. static CreateLathe(name: string, options: {
  115721. shape: Vector3[];
  115722. radius?: number;
  115723. tessellation?: number;
  115724. clip?: number;
  115725. arc?: number;
  115726. closed?: boolean;
  115727. updatable?: boolean;
  115728. sideOrientation?: number;
  115729. frontUVs?: Vector4;
  115730. backUVs?: Vector4;
  115731. cap?: number;
  115732. invertUV?: boolean;
  115733. }, scene?: Nullable<Scene>): Mesh;
  115734. /**
  115735. * Creates a tiled plane mesh
  115736. * * You can set a limited pattern arrangement with the tiles
  115737. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115738. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115739. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115740. * @param name defines the name of the mesh
  115741. * @param options defines the options used to create the mesh
  115742. * @param scene defines the hosting scene
  115743. * @returns the plane mesh
  115744. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  115745. */
  115746. static CreateTiledPlane(name: string, options: {
  115747. pattern?: number;
  115748. tileSize?: number;
  115749. tileWidth?: number;
  115750. tileHeight?: number;
  115751. size?: number;
  115752. width?: number;
  115753. height?: number;
  115754. alignHorizontal?: number;
  115755. alignVertical?: number;
  115756. sideOrientation?: number;
  115757. frontUVs?: Vector4;
  115758. backUVs?: Vector4;
  115759. updatable?: boolean;
  115760. }, scene?: Nullable<Scene>): Mesh;
  115761. /**
  115762. * Creates a plane mesh
  115763. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  115764. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  115765. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  115766. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115767. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115768. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115769. * @param name defines the name of the mesh
  115770. * @param options defines the options used to create the mesh
  115771. * @param scene defines the hosting scene
  115772. * @returns the plane mesh
  115773. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  115774. */
  115775. static CreatePlane(name: string, options: {
  115776. size?: number;
  115777. width?: number;
  115778. height?: number;
  115779. sideOrientation?: number;
  115780. frontUVs?: Vector4;
  115781. backUVs?: Vector4;
  115782. updatable?: boolean;
  115783. sourcePlane?: Plane;
  115784. }, scene?: Nullable<Scene>): Mesh;
  115785. /**
  115786. * Creates a ground mesh
  115787. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  115788. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  115789. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115790. * @param name defines the name of the mesh
  115791. * @param options defines the options used to create the mesh
  115792. * @param scene defines the hosting scene
  115793. * @returns the ground mesh
  115794. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  115795. */
  115796. static CreateGround(name: string, options: {
  115797. width?: number;
  115798. height?: number;
  115799. subdivisions?: number;
  115800. subdivisionsX?: number;
  115801. subdivisionsY?: number;
  115802. updatable?: boolean;
  115803. }, scene?: Nullable<Scene>): Mesh;
  115804. /**
  115805. * Creates a tiled ground mesh
  115806. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  115807. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  115808. * * 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
  115809. * * 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
  115810. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115811. * @param name defines the name of the mesh
  115812. * @param options defines the options used to create the mesh
  115813. * @param scene defines the hosting scene
  115814. * @returns the tiled ground mesh
  115815. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  115816. */
  115817. static CreateTiledGround(name: string, options: {
  115818. xmin: number;
  115819. zmin: number;
  115820. xmax: number;
  115821. zmax: number;
  115822. subdivisions?: {
  115823. w: number;
  115824. h: number;
  115825. };
  115826. precision?: {
  115827. w: number;
  115828. h: number;
  115829. };
  115830. updatable?: boolean;
  115831. }, scene?: Nullable<Scene>): Mesh;
  115832. /**
  115833. * Creates a ground mesh from a height map
  115834. * * The parameter `url` sets the URL of the height map image resource.
  115835. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  115836. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  115837. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  115838. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  115839. * * 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.
  115840. * * 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).
  115841. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  115842. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115843. * @param name defines the name of the mesh
  115844. * @param url defines the url to the height map
  115845. * @param options defines the options used to create the mesh
  115846. * @param scene defines the hosting scene
  115847. * @returns the ground mesh
  115848. * @see https://doc.babylonjs.com/babylon101/height_map
  115849. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  115850. */
  115851. static CreateGroundFromHeightMap(name: string, url: string, options: {
  115852. width?: number;
  115853. height?: number;
  115854. subdivisions?: number;
  115855. minHeight?: number;
  115856. maxHeight?: number;
  115857. colorFilter?: Color3;
  115858. alphaFilter?: number;
  115859. updatable?: boolean;
  115860. onReady?: (mesh: GroundMesh) => void;
  115861. }, scene?: Nullable<Scene>): GroundMesh;
  115862. /**
  115863. * Creates a polygon mesh
  115864. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  115865. * * 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
  115866. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115867. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115868. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  115869. * * Remember you can only change the shape positions, not their number when updating a polygon
  115870. * @param name defines the name of the mesh
  115871. * @param options defines the options used to create the mesh
  115872. * @param scene defines the hosting scene
  115873. * @param earcutInjection can be used to inject your own earcut reference
  115874. * @returns the polygon mesh
  115875. */
  115876. static CreatePolygon(name: string, options: {
  115877. shape: Vector3[];
  115878. holes?: Vector3[][];
  115879. depth?: number;
  115880. faceUV?: Vector4[];
  115881. faceColors?: Color4[];
  115882. updatable?: boolean;
  115883. sideOrientation?: number;
  115884. frontUVs?: Vector4;
  115885. backUVs?: Vector4;
  115886. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  115887. /**
  115888. * Creates an extruded polygon mesh, with depth in the Y direction.
  115889. * * 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)
  115890. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  115891. * @param name defines the name of the mesh
  115892. * @param options defines the options used to create the mesh
  115893. * @param scene defines the hosting scene
  115894. * @param earcutInjection can be used to inject your own earcut reference
  115895. * @returns the polygon mesh
  115896. */
  115897. static ExtrudePolygon(name: string, options: {
  115898. shape: Vector3[];
  115899. holes?: Vector3[][];
  115900. depth?: number;
  115901. faceUV?: Vector4[];
  115902. faceColors?: Color4[];
  115903. updatable?: boolean;
  115904. sideOrientation?: number;
  115905. frontUVs?: Vector4;
  115906. backUVs?: Vector4;
  115907. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  115908. /**
  115909. * Creates a tube mesh.
  115910. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  115911. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  115912. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  115913. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  115914. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  115915. * * 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)
  115916. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  115917. * * 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
  115918. * * 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
  115919. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115920. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115921. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  115922. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115923. * @param name defines the name of the mesh
  115924. * @param options defines the options used to create the mesh
  115925. * @param scene defines the hosting scene
  115926. * @returns the tube mesh
  115927. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  115928. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  115929. */
  115930. static CreateTube(name: string, options: {
  115931. path: Vector3[];
  115932. radius?: number;
  115933. tessellation?: number;
  115934. radiusFunction?: {
  115935. (i: number, distance: number): number;
  115936. };
  115937. cap?: number;
  115938. arc?: number;
  115939. updatable?: boolean;
  115940. sideOrientation?: number;
  115941. frontUVs?: Vector4;
  115942. backUVs?: Vector4;
  115943. instance?: Mesh;
  115944. invertUV?: boolean;
  115945. }, scene?: Nullable<Scene>): Mesh;
  115946. /**
  115947. * Creates a polyhedron mesh
  115948. * * 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
  115949. * * The parameter `size` (positive float, default 1) sets the polygon size
  115950. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  115951. * * 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`
  115952. * * 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
  115953. * * 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)`)
  115954. * * 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
  115955. * * 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
  115956. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115957. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115958. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115959. * @param name defines the name of the mesh
  115960. * @param options defines the options used to create the mesh
  115961. * @param scene defines the hosting scene
  115962. * @returns the polyhedron mesh
  115963. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  115964. */
  115965. static CreatePolyhedron(name: string, options: {
  115966. type?: number;
  115967. size?: number;
  115968. sizeX?: number;
  115969. sizeY?: number;
  115970. sizeZ?: number;
  115971. custom?: any;
  115972. faceUV?: Vector4[];
  115973. faceColors?: Color4[];
  115974. flat?: boolean;
  115975. updatable?: boolean;
  115976. sideOrientation?: number;
  115977. frontUVs?: Vector4;
  115978. backUVs?: Vector4;
  115979. }, scene?: Nullable<Scene>): Mesh;
  115980. /**
  115981. * Creates a decal mesh.
  115982. * 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
  115983. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  115984. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  115985. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  115986. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  115987. * @param name defines the name of the mesh
  115988. * @param sourceMesh defines the mesh where the decal must be applied
  115989. * @param options defines the options used to create the mesh
  115990. * @param scene defines the hosting scene
  115991. * @returns the decal mesh
  115992. * @see https://doc.babylonjs.com/how_to/decals
  115993. */
  115994. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  115995. position?: Vector3;
  115996. normal?: Vector3;
  115997. size?: Vector3;
  115998. angle?: number;
  115999. }): Mesh;
  116000. }
  116001. }
  116002. declare module BABYLON {
  116003. /**
  116004. * A simplifier interface for future simplification implementations
  116005. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  116006. */
  116007. export interface ISimplifier {
  116008. /**
  116009. * Simplification of a given mesh according to the given settings.
  116010. * Since this requires computation, it is assumed that the function runs async.
  116011. * @param settings The settings of the simplification, including quality and distance
  116012. * @param successCallback A callback that will be called after the mesh was simplified.
  116013. * @param errorCallback in case of an error, this callback will be called. optional.
  116014. */
  116015. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  116016. }
  116017. /**
  116018. * Expected simplification settings.
  116019. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  116020. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  116021. */
  116022. export interface ISimplificationSettings {
  116023. /**
  116024. * Gets or sets the expected quality
  116025. */
  116026. quality: number;
  116027. /**
  116028. * Gets or sets the distance when this optimized version should be used
  116029. */
  116030. distance: number;
  116031. /**
  116032. * Gets an already optimized mesh
  116033. */
  116034. optimizeMesh?: boolean;
  116035. }
  116036. /**
  116037. * Class used to specify simplification options
  116038. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  116039. */
  116040. export class SimplificationSettings implements ISimplificationSettings {
  116041. /** expected quality */
  116042. quality: number;
  116043. /** distance when this optimized version should be used */
  116044. distance: number;
  116045. /** already optimized mesh */
  116046. optimizeMesh?: boolean | undefined;
  116047. /**
  116048. * Creates a SimplificationSettings
  116049. * @param quality expected quality
  116050. * @param distance distance when this optimized version should be used
  116051. * @param optimizeMesh already optimized mesh
  116052. */
  116053. constructor(
  116054. /** expected quality */
  116055. quality: number,
  116056. /** distance when this optimized version should be used */
  116057. distance: number,
  116058. /** already optimized mesh */
  116059. optimizeMesh?: boolean | undefined);
  116060. }
  116061. /**
  116062. * Interface used to define a simplification task
  116063. */
  116064. export interface ISimplificationTask {
  116065. /**
  116066. * Array of settings
  116067. */
  116068. settings: Array<ISimplificationSettings>;
  116069. /**
  116070. * Simplification type
  116071. */
  116072. simplificationType: SimplificationType;
  116073. /**
  116074. * Mesh to simplify
  116075. */
  116076. mesh: Mesh;
  116077. /**
  116078. * Callback called on success
  116079. */
  116080. successCallback?: () => void;
  116081. /**
  116082. * Defines if parallel processing can be used
  116083. */
  116084. parallelProcessing: boolean;
  116085. }
  116086. /**
  116087. * Queue used to order the simplification tasks
  116088. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  116089. */
  116090. export class SimplificationQueue {
  116091. private _simplificationArray;
  116092. /**
  116093. * Gets a boolean indicating that the process is still running
  116094. */
  116095. running: boolean;
  116096. /**
  116097. * Creates a new queue
  116098. */
  116099. constructor();
  116100. /**
  116101. * Adds a new simplification task
  116102. * @param task defines a task to add
  116103. */
  116104. addTask(task: ISimplificationTask): void;
  116105. /**
  116106. * Execute next task
  116107. */
  116108. executeNext(): void;
  116109. /**
  116110. * Execute a simplification task
  116111. * @param task defines the task to run
  116112. */
  116113. runSimplification(task: ISimplificationTask): void;
  116114. private getSimplifier;
  116115. }
  116116. /**
  116117. * The implemented types of simplification
  116118. * At the moment only Quadratic Error Decimation is implemented
  116119. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  116120. */
  116121. export enum SimplificationType {
  116122. /** Quadratic error decimation */
  116123. QUADRATIC = 0
  116124. }
  116125. }
  116126. declare module BABYLON {
  116127. interface Scene {
  116128. /** @hidden (Backing field) */
  116129. _simplificationQueue: SimplificationQueue;
  116130. /**
  116131. * Gets or sets the simplification queue attached to the scene
  116132. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  116133. */
  116134. simplificationQueue: SimplificationQueue;
  116135. }
  116136. interface Mesh {
  116137. /**
  116138. * Simplify the mesh according to the given array of settings.
  116139. * Function will return immediately and will simplify async
  116140. * @param settings a collection of simplification settings
  116141. * @param parallelProcessing should all levels calculate parallel or one after the other
  116142. * @param simplificationType the type of simplification to run
  116143. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  116144. * @returns the current mesh
  116145. */
  116146. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  116147. }
  116148. /**
  116149. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  116150. * created in a scene
  116151. */
  116152. export class SimplicationQueueSceneComponent implements ISceneComponent {
  116153. /**
  116154. * The component name helpfull to identify the component in the list of scene components.
  116155. */
  116156. readonly name: string;
  116157. /**
  116158. * The scene the component belongs to.
  116159. */
  116160. scene: Scene;
  116161. /**
  116162. * Creates a new instance of the component for the given scene
  116163. * @param scene Defines the scene to register the component in
  116164. */
  116165. constructor(scene: Scene);
  116166. /**
  116167. * Registers the component in a given scene
  116168. */
  116169. register(): void;
  116170. /**
  116171. * Rebuilds the elements related to this component in case of
  116172. * context lost for instance.
  116173. */
  116174. rebuild(): void;
  116175. /**
  116176. * Disposes the component and the associated ressources
  116177. */
  116178. dispose(): void;
  116179. private _beforeCameraUpdate;
  116180. }
  116181. }
  116182. declare module BABYLON {
  116183. /**
  116184. * Class used to enable access to IndexedDB
  116185. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  116186. */
  116187. export class Database implements IOfflineProvider {
  116188. private _callbackManifestChecked;
  116189. private _currentSceneUrl;
  116190. private _db;
  116191. private _enableSceneOffline;
  116192. private _enableTexturesOffline;
  116193. private _manifestVersionFound;
  116194. private _mustUpdateRessources;
  116195. private _hasReachedQuota;
  116196. private _isSupported;
  116197. private _idbFactory;
  116198. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  116199. private static IsUASupportingBlobStorage;
  116200. /**
  116201. * Gets a boolean indicating if Database storate is enabled (off by default)
  116202. */
  116203. static IDBStorageEnabled: boolean;
  116204. /**
  116205. * Gets a boolean indicating if scene must be saved in the database
  116206. */
  116207. readonly enableSceneOffline: boolean;
  116208. /**
  116209. * Gets a boolean indicating if textures must be saved in the database
  116210. */
  116211. readonly enableTexturesOffline: boolean;
  116212. /**
  116213. * Creates a new Database
  116214. * @param urlToScene defines the url to load the scene
  116215. * @param callbackManifestChecked defines the callback to use when manifest is checked
  116216. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  116217. */
  116218. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  116219. private static _ParseURL;
  116220. private static _ReturnFullUrlLocation;
  116221. private _checkManifestFile;
  116222. /**
  116223. * Open the database and make it available
  116224. * @param successCallback defines the callback to call on success
  116225. * @param errorCallback defines the callback to call on error
  116226. */
  116227. open(successCallback: () => void, errorCallback: () => void): void;
  116228. /**
  116229. * Loads an image from the database
  116230. * @param url defines the url to load from
  116231. * @param image defines the target DOM image
  116232. */
  116233. loadImage(url: string, image: HTMLImageElement): void;
  116234. private _loadImageFromDBAsync;
  116235. private _saveImageIntoDBAsync;
  116236. private _checkVersionFromDB;
  116237. private _loadVersionFromDBAsync;
  116238. private _saveVersionIntoDBAsync;
  116239. /**
  116240. * Loads a file from database
  116241. * @param url defines the URL to load from
  116242. * @param sceneLoaded defines a callback to call on success
  116243. * @param progressCallBack defines a callback to call when progress changed
  116244. * @param errorCallback defines a callback to call on error
  116245. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  116246. */
  116247. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  116248. private _loadFileAsync;
  116249. private _saveFileAsync;
  116250. /**
  116251. * Validates if xhr data is correct
  116252. * @param xhr defines the request to validate
  116253. * @param dataType defines the expected data type
  116254. * @returns true if data is correct
  116255. */
  116256. private static _ValidateXHRData;
  116257. }
  116258. }
  116259. declare module BABYLON {
  116260. /** @hidden */
  116261. export var gpuUpdateParticlesPixelShader: {
  116262. name: string;
  116263. shader: string;
  116264. };
  116265. }
  116266. declare module BABYLON {
  116267. /** @hidden */
  116268. export var gpuUpdateParticlesVertexShader: {
  116269. name: string;
  116270. shader: string;
  116271. };
  116272. }
  116273. declare module BABYLON {
  116274. /** @hidden */
  116275. export var clipPlaneFragmentDeclaration2: {
  116276. name: string;
  116277. shader: string;
  116278. };
  116279. }
  116280. declare module BABYLON {
  116281. /** @hidden */
  116282. export var gpuRenderParticlesPixelShader: {
  116283. name: string;
  116284. shader: string;
  116285. };
  116286. }
  116287. declare module BABYLON {
  116288. /** @hidden */
  116289. export var clipPlaneVertexDeclaration2: {
  116290. name: string;
  116291. shader: string;
  116292. };
  116293. }
  116294. declare module BABYLON {
  116295. /** @hidden */
  116296. export var gpuRenderParticlesVertexShader: {
  116297. name: string;
  116298. shader: string;
  116299. };
  116300. }
  116301. declare module BABYLON {
  116302. /**
  116303. * This represents a GPU particle system in Babylon
  116304. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  116305. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  116306. */
  116307. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  116308. /**
  116309. * The layer mask we are rendering the particles through.
  116310. */
  116311. layerMask: number;
  116312. private _capacity;
  116313. private _activeCount;
  116314. private _currentActiveCount;
  116315. private _accumulatedCount;
  116316. private _renderEffect;
  116317. private _updateEffect;
  116318. private _buffer0;
  116319. private _buffer1;
  116320. private _spriteBuffer;
  116321. private _updateVAO;
  116322. private _renderVAO;
  116323. private _targetIndex;
  116324. private _sourceBuffer;
  116325. private _targetBuffer;
  116326. private _engine;
  116327. private _currentRenderId;
  116328. private _started;
  116329. private _stopped;
  116330. private _timeDelta;
  116331. private _randomTexture;
  116332. private _randomTexture2;
  116333. private _attributesStrideSize;
  116334. private _updateEffectOptions;
  116335. private _randomTextureSize;
  116336. private _actualFrame;
  116337. private readonly _rawTextureWidth;
  116338. /**
  116339. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  116340. */
  116341. static readonly IsSupported: boolean;
  116342. /**
  116343. * An event triggered when the system is disposed.
  116344. */
  116345. onDisposeObservable: Observable<GPUParticleSystem>;
  116346. /**
  116347. * Gets the maximum number of particles active at the same time.
  116348. * @returns The max number of active particles.
  116349. */
  116350. getCapacity(): number;
  116351. /**
  116352. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  116353. * to override the particles.
  116354. */
  116355. forceDepthWrite: boolean;
  116356. /**
  116357. * Gets or set the number of active particles
  116358. */
  116359. activeParticleCount: number;
  116360. private _preWarmDone;
  116361. /**
  116362. * Is this system ready to be used/rendered
  116363. * @return true if the system is ready
  116364. */
  116365. isReady(): boolean;
  116366. /**
  116367. * Gets if the system has been started. (Note: this will still be true after stop is called)
  116368. * @returns True if it has been started, otherwise false.
  116369. */
  116370. isStarted(): boolean;
  116371. /**
  116372. * Starts the particle system and begins to emit
  116373. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  116374. */
  116375. start(delay?: number): void;
  116376. /**
  116377. * Stops the particle system.
  116378. */
  116379. stop(): void;
  116380. /**
  116381. * Remove all active particles
  116382. */
  116383. reset(): void;
  116384. /**
  116385. * Returns the string "GPUParticleSystem"
  116386. * @returns a string containing the class name
  116387. */
  116388. getClassName(): string;
  116389. private _colorGradientsTexture;
  116390. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  116391. /**
  116392. * Adds a new color gradient
  116393. * @param gradient defines the gradient to use (between 0 and 1)
  116394. * @param color1 defines the color to affect to the specified gradient
  116395. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  116396. * @returns the current particle system
  116397. */
  116398. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  116399. /**
  116400. * Remove a specific color gradient
  116401. * @param gradient defines the gradient to remove
  116402. * @returns the current particle system
  116403. */
  116404. removeColorGradient(gradient: number): GPUParticleSystem;
  116405. private _angularSpeedGradientsTexture;
  116406. private _sizeGradientsTexture;
  116407. private _velocityGradientsTexture;
  116408. private _limitVelocityGradientsTexture;
  116409. private _dragGradientsTexture;
  116410. private _addFactorGradient;
  116411. /**
  116412. * Adds a new size gradient
  116413. * @param gradient defines the gradient to use (between 0 and 1)
  116414. * @param factor defines the size factor to affect to the specified gradient
  116415. * @returns the current particle system
  116416. */
  116417. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  116418. /**
  116419. * Remove a specific size gradient
  116420. * @param gradient defines the gradient to remove
  116421. * @returns the current particle system
  116422. */
  116423. removeSizeGradient(gradient: number): GPUParticleSystem;
  116424. /**
  116425. * Adds a new angular speed gradient
  116426. * @param gradient defines the gradient to use (between 0 and 1)
  116427. * @param factor defines the angular speed to affect to the specified gradient
  116428. * @returns the current particle system
  116429. */
  116430. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  116431. /**
  116432. * Remove a specific angular speed gradient
  116433. * @param gradient defines the gradient to remove
  116434. * @returns the current particle system
  116435. */
  116436. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  116437. /**
  116438. * Adds a new velocity gradient
  116439. * @param gradient defines the gradient to use (between 0 and 1)
  116440. * @param factor defines the velocity to affect to the specified gradient
  116441. * @returns the current particle system
  116442. */
  116443. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  116444. /**
  116445. * Remove a specific velocity gradient
  116446. * @param gradient defines the gradient to remove
  116447. * @returns the current particle system
  116448. */
  116449. removeVelocityGradient(gradient: number): GPUParticleSystem;
  116450. /**
  116451. * Adds a new limit velocity gradient
  116452. * @param gradient defines the gradient to use (between 0 and 1)
  116453. * @param factor defines the limit velocity value to affect to the specified gradient
  116454. * @returns the current particle system
  116455. */
  116456. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  116457. /**
  116458. * Remove a specific limit velocity gradient
  116459. * @param gradient defines the gradient to remove
  116460. * @returns the current particle system
  116461. */
  116462. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  116463. /**
  116464. * Adds a new drag gradient
  116465. * @param gradient defines the gradient to use (between 0 and 1)
  116466. * @param factor defines the drag value to affect to the specified gradient
  116467. * @returns the current particle system
  116468. */
  116469. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  116470. /**
  116471. * Remove a specific drag gradient
  116472. * @param gradient defines the gradient to remove
  116473. * @returns the current particle system
  116474. */
  116475. removeDragGradient(gradient: number): GPUParticleSystem;
  116476. /**
  116477. * Not supported by GPUParticleSystem
  116478. * @param gradient defines the gradient to use (between 0 and 1)
  116479. * @param factor defines the emit rate value to affect to the specified gradient
  116480. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  116481. * @returns the current particle system
  116482. */
  116483. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  116484. /**
  116485. * Not supported by GPUParticleSystem
  116486. * @param gradient defines the gradient to remove
  116487. * @returns the current particle system
  116488. */
  116489. removeEmitRateGradient(gradient: number): IParticleSystem;
  116490. /**
  116491. * Not supported by GPUParticleSystem
  116492. * @param gradient defines the gradient to use (between 0 and 1)
  116493. * @param factor defines the start size value to affect to the specified gradient
  116494. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  116495. * @returns the current particle system
  116496. */
  116497. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  116498. /**
  116499. * Not supported by GPUParticleSystem
  116500. * @param gradient defines the gradient to remove
  116501. * @returns the current particle system
  116502. */
  116503. removeStartSizeGradient(gradient: number): IParticleSystem;
  116504. /**
  116505. * Not supported by GPUParticleSystem
  116506. * @param gradient defines the gradient to use (between 0 and 1)
  116507. * @param min defines the color remap minimal range
  116508. * @param max defines the color remap maximal range
  116509. * @returns the current particle system
  116510. */
  116511. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  116512. /**
  116513. * Not supported by GPUParticleSystem
  116514. * @param gradient defines the gradient to remove
  116515. * @returns the current particle system
  116516. */
  116517. removeColorRemapGradient(): IParticleSystem;
  116518. /**
  116519. * Not supported by GPUParticleSystem
  116520. * @param gradient defines the gradient to use (between 0 and 1)
  116521. * @param min defines the alpha remap minimal range
  116522. * @param max defines the alpha remap maximal range
  116523. * @returns the current particle system
  116524. */
  116525. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  116526. /**
  116527. * Not supported by GPUParticleSystem
  116528. * @param gradient defines the gradient to remove
  116529. * @returns the current particle system
  116530. */
  116531. removeAlphaRemapGradient(): IParticleSystem;
  116532. /**
  116533. * Not supported by GPUParticleSystem
  116534. * @param gradient defines the gradient to use (between 0 and 1)
  116535. * @param color defines the color to affect to the specified gradient
  116536. * @returns the current particle system
  116537. */
  116538. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  116539. /**
  116540. * Not supported by GPUParticleSystem
  116541. * @param gradient defines the gradient to remove
  116542. * @returns the current particle system
  116543. */
  116544. removeRampGradient(): IParticleSystem;
  116545. /**
  116546. * Not supported by GPUParticleSystem
  116547. * @returns the list of ramp gradients
  116548. */
  116549. getRampGradients(): Nullable<Array<Color3Gradient>>;
  116550. /**
  116551. * Not supported by GPUParticleSystem
  116552. * Gets or sets a boolean indicating that ramp gradients must be used
  116553. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  116554. */
  116555. useRampGradients: boolean;
  116556. /**
  116557. * Not supported by GPUParticleSystem
  116558. * @param gradient defines the gradient to use (between 0 and 1)
  116559. * @param factor defines the life time factor to affect to the specified gradient
  116560. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  116561. * @returns the current particle system
  116562. */
  116563. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  116564. /**
  116565. * Not supported by GPUParticleSystem
  116566. * @param gradient defines the gradient to remove
  116567. * @returns the current particle system
  116568. */
  116569. removeLifeTimeGradient(gradient: number): IParticleSystem;
  116570. /**
  116571. * Instantiates a GPU particle system.
  116572. * 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.
  116573. * @param name The name of the particle system
  116574. * @param options The options used to create the system
  116575. * @param scene The scene the particle system belongs to
  116576. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  116577. */
  116578. constructor(name: string, options: Partial<{
  116579. capacity: number;
  116580. randomTextureSize: number;
  116581. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  116582. protected _reset(): void;
  116583. private _createUpdateVAO;
  116584. private _createRenderVAO;
  116585. private _initialize;
  116586. /** @hidden */
  116587. _recreateUpdateEffect(): void;
  116588. /** @hidden */
  116589. _recreateRenderEffect(): void;
  116590. /**
  116591. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  116592. * @param preWarm defines if we are in the pre-warmimg phase
  116593. */
  116594. animate(preWarm?: boolean): void;
  116595. private _createFactorGradientTexture;
  116596. private _createSizeGradientTexture;
  116597. private _createAngularSpeedGradientTexture;
  116598. private _createVelocityGradientTexture;
  116599. private _createLimitVelocityGradientTexture;
  116600. private _createDragGradientTexture;
  116601. private _createColorGradientTexture;
  116602. /**
  116603. * Renders the particle system in its current state
  116604. * @param preWarm defines if the system should only update the particles but not render them
  116605. * @returns the current number of particles
  116606. */
  116607. render(preWarm?: boolean): number;
  116608. /**
  116609. * Rebuilds the particle system
  116610. */
  116611. rebuild(): void;
  116612. private _releaseBuffers;
  116613. private _releaseVAOs;
  116614. /**
  116615. * Disposes the particle system and free the associated resources
  116616. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  116617. */
  116618. dispose(disposeTexture?: boolean): void;
  116619. /**
  116620. * Clones the particle system.
  116621. * @param name The name of the cloned object
  116622. * @param newEmitter The new emitter to use
  116623. * @returns the cloned particle system
  116624. */
  116625. clone(name: string, newEmitter: any): GPUParticleSystem;
  116626. /**
  116627. * Serializes the particle system to a JSON object.
  116628. * @returns the JSON object
  116629. */
  116630. serialize(): any;
  116631. /**
  116632. * Parses a JSON object to create a GPU particle system.
  116633. * @param parsedParticleSystem The JSON object to parse
  116634. * @param scene The scene to create the particle system in
  116635. * @param rootUrl The root url to use to load external dependencies like texture
  116636. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  116637. * @returns the parsed GPU particle system
  116638. */
  116639. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  116640. }
  116641. }
  116642. declare module BABYLON {
  116643. /**
  116644. * Represents a set of particle systems working together to create a specific effect
  116645. */
  116646. export class ParticleSystemSet implements IDisposable {
  116647. private _emitterCreationOptions;
  116648. private _emitterNode;
  116649. /**
  116650. * Gets the particle system list
  116651. */
  116652. systems: IParticleSystem[];
  116653. /**
  116654. * Gets the emitter node used with this set
  116655. */
  116656. readonly emitterNode: Nullable<TransformNode>;
  116657. /**
  116658. * Creates a new emitter mesh as a sphere
  116659. * @param options defines the options used to create the sphere
  116660. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  116661. * @param scene defines the hosting scene
  116662. */
  116663. setEmitterAsSphere(options: {
  116664. diameter: number;
  116665. segments: number;
  116666. color: Color3;
  116667. }, renderingGroupId: number, scene: Scene): void;
  116668. /**
  116669. * Starts all particle systems of the set
  116670. * @param emitter defines an optional mesh to use as emitter for the particle systems
  116671. */
  116672. start(emitter?: AbstractMesh): void;
  116673. /**
  116674. * Release all associated resources
  116675. */
  116676. dispose(): void;
  116677. /**
  116678. * Serialize the set into a JSON compatible object
  116679. * @returns a JSON compatible representation of the set
  116680. */
  116681. serialize(): any;
  116682. /**
  116683. * Parse a new ParticleSystemSet from a serialized source
  116684. * @param data defines a JSON compatible representation of the set
  116685. * @param scene defines the hosting scene
  116686. * @param gpu defines if we want GPU particles or CPU particles
  116687. * @returns a new ParticleSystemSet
  116688. */
  116689. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  116690. }
  116691. }
  116692. declare module BABYLON {
  116693. /**
  116694. * This class is made for on one-liner static method to help creating particle system set.
  116695. */
  116696. export class ParticleHelper {
  116697. /**
  116698. * Gets or sets base Assets URL
  116699. */
  116700. static BaseAssetsUrl: string;
  116701. /**
  116702. * Create a default particle system that you can tweak
  116703. * @param emitter defines the emitter to use
  116704. * @param capacity defines the system capacity (default is 500 particles)
  116705. * @param scene defines the hosting scene
  116706. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  116707. * @returns the new Particle system
  116708. */
  116709. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  116710. /**
  116711. * This is the main static method (one-liner) of this helper to create different particle systems
  116712. * @param type This string represents the type to the particle system to create
  116713. * @param scene The scene where the particle system should live
  116714. * @param gpu If the system will use gpu
  116715. * @returns the ParticleSystemSet created
  116716. */
  116717. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  116718. /**
  116719. * Static function used to export a particle system to a ParticleSystemSet variable.
  116720. * Please note that the emitter shape is not exported
  116721. * @param systems defines the particle systems to export
  116722. * @returns the created particle system set
  116723. */
  116724. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  116725. }
  116726. }
  116727. declare module BABYLON {
  116728. interface Engine {
  116729. /**
  116730. * Create an effect to use with particle systems.
  116731. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  116732. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  116733. * @param uniformsNames defines a list of attribute names
  116734. * @param samplers defines an array of string used to represent textures
  116735. * @param defines defines the string containing the defines to use to compile the shaders
  116736. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  116737. * @param onCompiled defines a function to call when the effect creation is successful
  116738. * @param onError defines a function to call when the effect creation has failed
  116739. * @returns the new Effect
  116740. */
  116741. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  116742. }
  116743. interface Mesh {
  116744. /**
  116745. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  116746. * @returns an array of IParticleSystem
  116747. */
  116748. getEmittedParticleSystems(): IParticleSystem[];
  116749. /**
  116750. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  116751. * @returns an array of IParticleSystem
  116752. */
  116753. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  116754. }
  116755. /**
  116756. * @hidden
  116757. */
  116758. export var _IDoNeedToBeInTheBuild: number;
  116759. }
  116760. declare module BABYLON {
  116761. interface Scene {
  116762. /** @hidden (Backing field) */
  116763. _physicsEngine: Nullable<IPhysicsEngine>;
  116764. /**
  116765. * Gets the current physics engine
  116766. * @returns a IPhysicsEngine or null if none attached
  116767. */
  116768. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  116769. /**
  116770. * Enables physics to the current scene
  116771. * @param gravity defines the scene's gravity for the physics engine
  116772. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  116773. * @return a boolean indicating if the physics engine was initialized
  116774. */
  116775. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  116776. /**
  116777. * Disables and disposes the physics engine associated with the scene
  116778. */
  116779. disablePhysicsEngine(): void;
  116780. /**
  116781. * Gets a boolean indicating if there is an active physics engine
  116782. * @returns a boolean indicating if there is an active physics engine
  116783. */
  116784. isPhysicsEnabled(): boolean;
  116785. /**
  116786. * Deletes a physics compound impostor
  116787. * @param compound defines the compound to delete
  116788. */
  116789. deleteCompoundImpostor(compound: any): void;
  116790. /**
  116791. * An event triggered when physic simulation is about to be run
  116792. */
  116793. onBeforePhysicsObservable: Observable<Scene>;
  116794. /**
  116795. * An event triggered when physic simulation has been done
  116796. */
  116797. onAfterPhysicsObservable: Observable<Scene>;
  116798. }
  116799. interface AbstractMesh {
  116800. /** @hidden */
  116801. _physicsImpostor: Nullable<PhysicsImpostor>;
  116802. /**
  116803. * Gets or sets impostor used for physic simulation
  116804. * @see http://doc.babylonjs.com/features/physics_engine
  116805. */
  116806. physicsImpostor: Nullable<PhysicsImpostor>;
  116807. /**
  116808. * Gets the current physics impostor
  116809. * @see http://doc.babylonjs.com/features/physics_engine
  116810. * @returns a physics impostor or null
  116811. */
  116812. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  116813. /** Apply a physic impulse to the mesh
  116814. * @param force defines the force to apply
  116815. * @param contactPoint defines where to apply the force
  116816. * @returns the current mesh
  116817. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  116818. */
  116819. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  116820. /**
  116821. * Creates a physic joint between two meshes
  116822. * @param otherMesh defines the other mesh to use
  116823. * @param pivot1 defines the pivot to use on this mesh
  116824. * @param pivot2 defines the pivot to use on the other mesh
  116825. * @param options defines additional options (can be plugin dependent)
  116826. * @returns the current mesh
  116827. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  116828. */
  116829. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  116830. /** @hidden */
  116831. _disposePhysicsObserver: Nullable<Observer<Node>>;
  116832. }
  116833. /**
  116834. * Defines the physics engine scene component responsible to manage a physics engine
  116835. */
  116836. export class PhysicsEngineSceneComponent implements ISceneComponent {
  116837. /**
  116838. * The component name helpful to identify the component in the list of scene components.
  116839. */
  116840. readonly name: string;
  116841. /**
  116842. * The scene the component belongs to.
  116843. */
  116844. scene: Scene;
  116845. /**
  116846. * Creates a new instance of the component for the given scene
  116847. * @param scene Defines the scene to register the component in
  116848. */
  116849. constructor(scene: Scene);
  116850. /**
  116851. * Registers the component in a given scene
  116852. */
  116853. register(): void;
  116854. /**
  116855. * Rebuilds the elements related to this component in case of
  116856. * context lost for instance.
  116857. */
  116858. rebuild(): void;
  116859. /**
  116860. * Disposes the component and the associated ressources
  116861. */
  116862. dispose(): void;
  116863. }
  116864. }
  116865. declare module BABYLON {
  116866. /**
  116867. * A helper for physics simulations
  116868. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  116869. */
  116870. export class PhysicsHelper {
  116871. private _scene;
  116872. private _physicsEngine;
  116873. /**
  116874. * Initializes the Physics helper
  116875. * @param scene Babylon.js scene
  116876. */
  116877. constructor(scene: Scene);
  116878. /**
  116879. * Applies a radial explosion impulse
  116880. * @param origin the origin of the explosion
  116881. * @param radiusOrEventOptions the radius or the options of radial explosion
  116882. * @param strength the explosion strength
  116883. * @param falloff possible options: Constant & Linear. Defaults to Constant
  116884. * @returns A physics radial explosion event, or null
  116885. */
  116886. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  116887. /**
  116888. * Applies a radial explosion force
  116889. * @param origin the origin of the explosion
  116890. * @param radiusOrEventOptions the radius or the options of radial explosion
  116891. * @param strength the explosion strength
  116892. * @param falloff possible options: Constant & Linear. Defaults to Constant
  116893. * @returns A physics radial explosion event, or null
  116894. */
  116895. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  116896. /**
  116897. * Creates a gravitational field
  116898. * @param origin the origin of the explosion
  116899. * @param radiusOrEventOptions the radius or the options of radial explosion
  116900. * @param strength the explosion strength
  116901. * @param falloff possible options: Constant & Linear. Defaults to Constant
  116902. * @returns A physics gravitational field event, or null
  116903. */
  116904. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  116905. /**
  116906. * Creates a physics updraft event
  116907. * @param origin the origin of the updraft
  116908. * @param radiusOrEventOptions the radius or the options of the updraft
  116909. * @param strength the strength of the updraft
  116910. * @param height the height of the updraft
  116911. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  116912. * @returns A physics updraft event, or null
  116913. */
  116914. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  116915. /**
  116916. * Creates a physics vortex event
  116917. * @param origin the of the vortex
  116918. * @param radiusOrEventOptions the radius or the options of the vortex
  116919. * @param strength the strength of the vortex
  116920. * @param height the height of the vortex
  116921. * @returns a Physics vortex event, or null
  116922. * A physics vortex event or null
  116923. */
  116924. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  116925. }
  116926. /**
  116927. * Represents a physics radial explosion event
  116928. */
  116929. class PhysicsRadialExplosionEvent {
  116930. private _scene;
  116931. private _options;
  116932. private _sphere;
  116933. private _dataFetched;
  116934. /**
  116935. * Initializes a radial explosioin event
  116936. * @param _scene BabylonJS scene
  116937. * @param _options The options for the vortex event
  116938. */
  116939. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  116940. /**
  116941. * Returns the data related to the radial explosion event (sphere).
  116942. * @returns The radial explosion event data
  116943. */
  116944. getData(): PhysicsRadialExplosionEventData;
  116945. /**
  116946. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  116947. * @param impostor A physics imposter
  116948. * @param origin the origin of the explosion
  116949. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  116950. */
  116951. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  116952. /**
  116953. * Triggers affecterd impostors callbacks
  116954. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  116955. */
  116956. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  116957. /**
  116958. * Disposes the sphere.
  116959. * @param force Specifies if the sphere should be disposed by force
  116960. */
  116961. dispose(force?: boolean): void;
  116962. /*** Helpers ***/
  116963. private _prepareSphere;
  116964. private _intersectsWithSphere;
  116965. }
  116966. /**
  116967. * Represents a gravitational field event
  116968. */
  116969. class PhysicsGravitationalFieldEvent {
  116970. private _physicsHelper;
  116971. private _scene;
  116972. private _origin;
  116973. private _options;
  116974. private _tickCallback;
  116975. private _sphere;
  116976. private _dataFetched;
  116977. /**
  116978. * Initializes the physics gravitational field event
  116979. * @param _physicsHelper A physics helper
  116980. * @param _scene BabylonJS scene
  116981. * @param _origin The origin position of the gravitational field event
  116982. * @param _options The options for the vortex event
  116983. */
  116984. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  116985. /**
  116986. * Returns the data related to the gravitational field event (sphere).
  116987. * @returns A gravitational field event
  116988. */
  116989. getData(): PhysicsGravitationalFieldEventData;
  116990. /**
  116991. * Enables the gravitational field.
  116992. */
  116993. enable(): void;
  116994. /**
  116995. * Disables the gravitational field.
  116996. */
  116997. disable(): void;
  116998. /**
  116999. * Disposes the sphere.
  117000. * @param force The force to dispose from the gravitational field event
  117001. */
  117002. dispose(force?: boolean): void;
  117003. private _tick;
  117004. }
  117005. /**
  117006. * Represents a physics updraft event
  117007. */
  117008. class PhysicsUpdraftEvent {
  117009. private _scene;
  117010. private _origin;
  117011. private _options;
  117012. private _physicsEngine;
  117013. private _originTop;
  117014. private _originDirection;
  117015. private _tickCallback;
  117016. private _cylinder;
  117017. private _cylinderPosition;
  117018. private _dataFetched;
  117019. /**
  117020. * Initializes the physics updraft event
  117021. * @param _scene BabylonJS scene
  117022. * @param _origin The origin position of the updraft
  117023. * @param _options The options for the updraft event
  117024. */
  117025. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  117026. /**
  117027. * Returns the data related to the updraft event (cylinder).
  117028. * @returns A physics updraft event
  117029. */
  117030. getData(): PhysicsUpdraftEventData;
  117031. /**
  117032. * Enables the updraft.
  117033. */
  117034. enable(): void;
  117035. /**
  117036. * Disables the updraft.
  117037. */
  117038. disable(): void;
  117039. /**
  117040. * Disposes the cylinder.
  117041. * @param force Specifies if the updraft should be disposed by force
  117042. */
  117043. dispose(force?: boolean): void;
  117044. private getImpostorHitData;
  117045. private _tick;
  117046. /*** Helpers ***/
  117047. private _prepareCylinder;
  117048. private _intersectsWithCylinder;
  117049. }
  117050. /**
  117051. * Represents a physics vortex event
  117052. */
  117053. class PhysicsVortexEvent {
  117054. private _scene;
  117055. private _origin;
  117056. private _options;
  117057. private _physicsEngine;
  117058. private _originTop;
  117059. private _tickCallback;
  117060. private _cylinder;
  117061. private _cylinderPosition;
  117062. private _dataFetched;
  117063. /**
  117064. * Initializes the physics vortex event
  117065. * @param _scene The BabylonJS scene
  117066. * @param _origin The origin position of the vortex
  117067. * @param _options The options for the vortex event
  117068. */
  117069. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  117070. /**
  117071. * Returns the data related to the vortex event (cylinder).
  117072. * @returns The physics vortex event data
  117073. */
  117074. getData(): PhysicsVortexEventData;
  117075. /**
  117076. * Enables the vortex.
  117077. */
  117078. enable(): void;
  117079. /**
  117080. * Disables the cortex.
  117081. */
  117082. disable(): void;
  117083. /**
  117084. * Disposes the sphere.
  117085. * @param force
  117086. */
  117087. dispose(force?: boolean): void;
  117088. private getImpostorHitData;
  117089. private _tick;
  117090. /*** Helpers ***/
  117091. private _prepareCylinder;
  117092. private _intersectsWithCylinder;
  117093. }
  117094. /**
  117095. * Options fot the radial explosion event
  117096. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117097. */
  117098. export class PhysicsRadialExplosionEventOptions {
  117099. /**
  117100. * The radius of the sphere for the radial explosion.
  117101. */
  117102. radius: number;
  117103. /**
  117104. * The strenth of the explosion.
  117105. */
  117106. strength: number;
  117107. /**
  117108. * The strenght of the force in correspondence to the distance of the affected object
  117109. */
  117110. falloff: PhysicsRadialImpulseFalloff;
  117111. /**
  117112. * Sphere options for the radial explosion.
  117113. */
  117114. sphere: {
  117115. segments: number;
  117116. diameter: number;
  117117. };
  117118. /**
  117119. * Sphere options for the radial explosion.
  117120. */
  117121. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  117122. }
  117123. /**
  117124. * Options fot the updraft event
  117125. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117126. */
  117127. export class PhysicsUpdraftEventOptions {
  117128. /**
  117129. * The radius of the cylinder for the vortex
  117130. */
  117131. radius: number;
  117132. /**
  117133. * The strenth of the updraft.
  117134. */
  117135. strength: number;
  117136. /**
  117137. * The height of the cylinder for the updraft.
  117138. */
  117139. height: number;
  117140. /**
  117141. * The mode for the the updraft.
  117142. */
  117143. updraftMode: PhysicsUpdraftMode;
  117144. }
  117145. /**
  117146. * Options fot the vortex event
  117147. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117148. */
  117149. export class PhysicsVortexEventOptions {
  117150. /**
  117151. * The radius of the cylinder for the vortex
  117152. */
  117153. radius: number;
  117154. /**
  117155. * The strenth of the vortex.
  117156. */
  117157. strength: number;
  117158. /**
  117159. * The height of the cylinder for the vortex.
  117160. */
  117161. height: number;
  117162. /**
  117163. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  117164. */
  117165. centripetalForceThreshold: number;
  117166. /**
  117167. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  117168. */
  117169. centripetalForceMultiplier: number;
  117170. /**
  117171. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  117172. */
  117173. centrifugalForceMultiplier: number;
  117174. /**
  117175. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  117176. */
  117177. updraftForceMultiplier: number;
  117178. }
  117179. /**
  117180. * The strenght of the force in correspondence to the distance of the affected object
  117181. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117182. */
  117183. export enum PhysicsRadialImpulseFalloff {
  117184. /** Defines that impulse is constant in strength across it's whole radius */
  117185. Constant = 0,
  117186. /** Defines that impulse gets weaker if it's further from the origin */
  117187. Linear = 1
  117188. }
  117189. /**
  117190. * The strength of the force in correspondence to the distance of the affected object
  117191. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117192. */
  117193. export enum PhysicsUpdraftMode {
  117194. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  117195. Center = 0,
  117196. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  117197. Perpendicular = 1
  117198. }
  117199. /**
  117200. * Interface for a physics hit data
  117201. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117202. */
  117203. export interface PhysicsHitData {
  117204. /**
  117205. * The force applied at the contact point
  117206. */
  117207. force: Vector3;
  117208. /**
  117209. * The contact point
  117210. */
  117211. contactPoint: Vector3;
  117212. /**
  117213. * The distance from the origin to the contact point
  117214. */
  117215. distanceFromOrigin: number;
  117216. }
  117217. /**
  117218. * Interface for radial explosion event data
  117219. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117220. */
  117221. export interface PhysicsRadialExplosionEventData {
  117222. /**
  117223. * A sphere used for the radial explosion event
  117224. */
  117225. sphere: Mesh;
  117226. }
  117227. /**
  117228. * Interface for gravitational field event data
  117229. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117230. */
  117231. export interface PhysicsGravitationalFieldEventData {
  117232. /**
  117233. * A sphere mesh used for the gravitational field event
  117234. */
  117235. sphere: Mesh;
  117236. }
  117237. /**
  117238. * Interface for updraft event data
  117239. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117240. */
  117241. export interface PhysicsUpdraftEventData {
  117242. /**
  117243. * A cylinder used for the updraft event
  117244. */
  117245. cylinder: Mesh;
  117246. }
  117247. /**
  117248. * Interface for vortex event data
  117249. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117250. */
  117251. export interface PhysicsVortexEventData {
  117252. /**
  117253. * A cylinder used for the vortex event
  117254. */
  117255. cylinder: Mesh;
  117256. }
  117257. /**
  117258. * Interface for an affected physics impostor
  117259. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117260. */
  117261. export interface PhysicsAffectedImpostorWithData {
  117262. /**
  117263. * The impostor affected by the effect
  117264. */
  117265. impostor: PhysicsImpostor;
  117266. /**
  117267. * The data about the hit/horce from the explosion
  117268. */
  117269. hitData: PhysicsHitData;
  117270. }
  117271. }
  117272. declare module BABYLON {
  117273. /** @hidden */
  117274. export var blackAndWhitePixelShader: {
  117275. name: string;
  117276. shader: string;
  117277. };
  117278. }
  117279. declare module BABYLON {
  117280. /**
  117281. * Post process used to render in black and white
  117282. */
  117283. export class BlackAndWhitePostProcess extends PostProcess {
  117284. /**
  117285. * Linear about to convert he result to black and white (default: 1)
  117286. */
  117287. degree: number;
  117288. /**
  117289. * Creates a black and white post process
  117290. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  117291. * @param name The name of the effect.
  117292. * @param options The required width/height ratio to downsize to before computing the render pass.
  117293. * @param camera The camera to apply the render pass to.
  117294. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117295. * @param engine The engine which the post process will be applied. (default: current engine)
  117296. * @param reusable If the post process can be reused on the same frame. (default: false)
  117297. */
  117298. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  117299. }
  117300. }
  117301. declare module BABYLON {
  117302. /**
  117303. * This represents a set of one or more post processes in Babylon.
  117304. * A post process can be used to apply a shader to a texture after it is rendered.
  117305. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  117306. */
  117307. export class PostProcessRenderEffect {
  117308. private _postProcesses;
  117309. private _getPostProcesses;
  117310. private _singleInstance;
  117311. private _cameras;
  117312. private _indicesForCamera;
  117313. /**
  117314. * Name of the effect
  117315. * @hidden
  117316. */
  117317. _name: string;
  117318. /**
  117319. * Instantiates a post process render effect.
  117320. * A post process can be used to apply a shader to a texture after it is rendered.
  117321. * @param engine The engine the effect is tied to
  117322. * @param name The name of the effect
  117323. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  117324. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  117325. */
  117326. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  117327. /**
  117328. * Checks if all the post processes in the effect are supported.
  117329. */
  117330. readonly isSupported: boolean;
  117331. /**
  117332. * Updates the current state of the effect
  117333. * @hidden
  117334. */
  117335. _update(): void;
  117336. /**
  117337. * Attaches the effect on cameras
  117338. * @param cameras The camera to attach to.
  117339. * @hidden
  117340. */
  117341. _attachCameras(cameras: Camera): void;
  117342. /**
  117343. * Attaches the effect on cameras
  117344. * @param cameras The camera to attach to.
  117345. * @hidden
  117346. */
  117347. _attachCameras(cameras: Camera[]): void;
  117348. /**
  117349. * Detaches the effect on cameras
  117350. * @param cameras The camera to detatch from.
  117351. * @hidden
  117352. */
  117353. _detachCameras(cameras: Camera): void;
  117354. /**
  117355. * Detatches the effect on cameras
  117356. * @param cameras The camera to detatch from.
  117357. * @hidden
  117358. */
  117359. _detachCameras(cameras: Camera[]): void;
  117360. /**
  117361. * Enables the effect on given cameras
  117362. * @param cameras The camera to enable.
  117363. * @hidden
  117364. */
  117365. _enable(cameras: Camera): void;
  117366. /**
  117367. * Enables the effect on given cameras
  117368. * @param cameras The camera to enable.
  117369. * @hidden
  117370. */
  117371. _enable(cameras: Nullable<Camera[]>): void;
  117372. /**
  117373. * Disables the effect on the given cameras
  117374. * @param cameras The camera to disable.
  117375. * @hidden
  117376. */
  117377. _disable(cameras: Camera): void;
  117378. /**
  117379. * Disables the effect on the given cameras
  117380. * @param cameras The camera to disable.
  117381. * @hidden
  117382. */
  117383. _disable(cameras: Nullable<Camera[]>): void;
  117384. /**
  117385. * Gets a list of the post processes contained in the effect.
  117386. * @param camera The camera to get the post processes on.
  117387. * @returns The list of the post processes in the effect.
  117388. */
  117389. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  117390. }
  117391. }
  117392. declare module BABYLON {
  117393. /** @hidden */
  117394. export var extractHighlightsPixelShader: {
  117395. name: string;
  117396. shader: string;
  117397. };
  117398. }
  117399. declare module BABYLON {
  117400. /**
  117401. * 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.
  117402. */
  117403. export class ExtractHighlightsPostProcess extends PostProcess {
  117404. /**
  117405. * The luminance threshold, pixels below this value will be set to black.
  117406. */
  117407. threshold: number;
  117408. /** @hidden */
  117409. _exposure: number;
  117410. /**
  117411. * Post process which has the input texture to be used when performing highlight extraction
  117412. * @hidden
  117413. */
  117414. _inputPostProcess: Nullable<PostProcess>;
  117415. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  117416. }
  117417. }
  117418. declare module BABYLON {
  117419. /** @hidden */
  117420. export var bloomMergePixelShader: {
  117421. name: string;
  117422. shader: string;
  117423. };
  117424. }
  117425. declare module BABYLON {
  117426. /**
  117427. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  117428. */
  117429. export class BloomMergePostProcess extends PostProcess {
  117430. /** Weight of the bloom to be added to the original input. */
  117431. weight: number;
  117432. /**
  117433. * Creates a new instance of @see BloomMergePostProcess
  117434. * @param name The name of the effect.
  117435. * @param originalFromInput Post process which's input will be used for the merge.
  117436. * @param blurred Blurred highlights post process which's output will be used.
  117437. * @param weight Weight of the bloom to be added to the original input.
  117438. * @param options The required width/height ratio to downsize to before computing the render pass.
  117439. * @param camera The camera to apply the render pass to.
  117440. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117441. * @param engine The engine which the post process will be applied. (default: current engine)
  117442. * @param reusable If the post process can be reused on the same frame. (default: false)
  117443. * @param textureType Type of textures used when performing the post process. (default: 0)
  117444. * @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)
  117445. */
  117446. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  117447. /** Weight of the bloom to be added to the original input. */
  117448. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  117449. }
  117450. }
  117451. declare module BABYLON {
  117452. /**
  117453. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  117454. */
  117455. export class BloomEffect extends PostProcessRenderEffect {
  117456. private bloomScale;
  117457. /**
  117458. * @hidden Internal
  117459. */
  117460. _effects: Array<PostProcess>;
  117461. /**
  117462. * @hidden Internal
  117463. */
  117464. _downscale: ExtractHighlightsPostProcess;
  117465. private _blurX;
  117466. private _blurY;
  117467. private _merge;
  117468. /**
  117469. * The luminance threshold to find bright areas of the image to bloom.
  117470. */
  117471. threshold: number;
  117472. /**
  117473. * The strength of the bloom.
  117474. */
  117475. weight: number;
  117476. /**
  117477. * Specifies the size of the bloom blur kernel, relative to the final output size
  117478. */
  117479. kernel: number;
  117480. /**
  117481. * Creates a new instance of @see BloomEffect
  117482. * @param scene The scene the effect belongs to.
  117483. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  117484. * @param bloomKernel The size of the kernel to be used when applying the blur.
  117485. * @param bloomWeight The the strength of bloom.
  117486. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  117487. * @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)
  117488. */
  117489. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  117490. /**
  117491. * Disposes each of the internal effects for a given camera.
  117492. * @param camera The camera to dispose the effect on.
  117493. */
  117494. disposeEffects(camera: Camera): void;
  117495. /**
  117496. * @hidden Internal
  117497. */
  117498. _updateEffects(): void;
  117499. /**
  117500. * Internal
  117501. * @returns if all the contained post processes are ready.
  117502. * @hidden
  117503. */
  117504. _isReady(): boolean;
  117505. }
  117506. }
  117507. declare module BABYLON {
  117508. /** @hidden */
  117509. export var chromaticAberrationPixelShader: {
  117510. name: string;
  117511. shader: string;
  117512. };
  117513. }
  117514. declare module BABYLON {
  117515. /**
  117516. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  117517. */
  117518. export class ChromaticAberrationPostProcess extends PostProcess {
  117519. /**
  117520. * The amount of seperation of rgb channels (default: 30)
  117521. */
  117522. aberrationAmount: number;
  117523. /**
  117524. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  117525. */
  117526. radialIntensity: number;
  117527. /**
  117528. * 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))
  117529. */
  117530. direction: Vector2;
  117531. /**
  117532. * 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))
  117533. */
  117534. centerPosition: Vector2;
  117535. /**
  117536. * Creates a new instance ChromaticAberrationPostProcess
  117537. * @param name The name of the effect.
  117538. * @param screenWidth The width of the screen to apply the effect on.
  117539. * @param screenHeight The height of the screen to apply the effect on.
  117540. * @param options The required width/height ratio to downsize to before computing the render pass.
  117541. * @param camera The camera to apply the render pass to.
  117542. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117543. * @param engine The engine which the post process will be applied. (default: current engine)
  117544. * @param reusable If the post process can be reused on the same frame. (default: false)
  117545. * @param textureType Type of textures used when performing the post process. (default: 0)
  117546. * @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)
  117547. */
  117548. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  117549. }
  117550. }
  117551. declare module BABYLON {
  117552. /** @hidden */
  117553. export var circleOfConfusionPixelShader: {
  117554. name: string;
  117555. shader: string;
  117556. };
  117557. }
  117558. declare module BABYLON {
  117559. /**
  117560. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  117561. */
  117562. export class CircleOfConfusionPostProcess extends PostProcess {
  117563. /**
  117564. * 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.
  117565. */
  117566. lensSize: number;
  117567. /**
  117568. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  117569. */
  117570. fStop: number;
  117571. /**
  117572. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  117573. */
  117574. focusDistance: number;
  117575. /**
  117576. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  117577. */
  117578. focalLength: number;
  117579. private _depthTexture;
  117580. /**
  117581. * Creates a new instance CircleOfConfusionPostProcess
  117582. * @param name The name of the effect.
  117583. * @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.
  117584. * @param options The required width/height ratio to downsize to before computing the render pass.
  117585. * @param camera The camera to apply the render pass to.
  117586. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117587. * @param engine The engine which the post process will be applied. (default: current engine)
  117588. * @param reusable If the post process can be reused on the same frame. (default: false)
  117589. * @param textureType Type of textures used when performing the post process. (default: 0)
  117590. * @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)
  117591. */
  117592. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  117593. /**
  117594. * 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.
  117595. */
  117596. depthTexture: RenderTargetTexture;
  117597. }
  117598. }
  117599. declare module BABYLON {
  117600. /** @hidden */
  117601. export var colorCorrectionPixelShader: {
  117602. name: string;
  117603. shader: string;
  117604. };
  117605. }
  117606. declare module BABYLON {
  117607. /**
  117608. *
  117609. * This post-process allows the modification of rendered colors by using
  117610. * a 'look-up table' (LUT). This effect is also called Color Grading.
  117611. *
  117612. * The object needs to be provided an url to a texture containing the color
  117613. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  117614. * Use an image editing software to tweak the LUT to match your needs.
  117615. *
  117616. * For an example of a color LUT, see here:
  117617. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  117618. * For explanations on color grading, see here:
  117619. * @see http://udn.epicgames.com/Three/ColorGrading.html
  117620. *
  117621. */
  117622. export class ColorCorrectionPostProcess extends PostProcess {
  117623. private _colorTableTexture;
  117624. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  117625. }
  117626. }
  117627. declare module BABYLON {
  117628. /** @hidden */
  117629. export var convolutionPixelShader: {
  117630. name: string;
  117631. shader: string;
  117632. };
  117633. }
  117634. declare module BABYLON {
  117635. /**
  117636. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  117637. * input texture to perform effects such as edge detection or sharpening
  117638. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  117639. */
  117640. export class ConvolutionPostProcess extends PostProcess {
  117641. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  117642. kernel: number[];
  117643. /**
  117644. * Creates a new instance ConvolutionPostProcess
  117645. * @param name The name of the effect.
  117646. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  117647. * @param options The required width/height ratio to downsize to before computing the render pass.
  117648. * @param camera The camera to apply the render pass to.
  117649. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117650. * @param engine The engine which the post process will be applied. (default: current engine)
  117651. * @param reusable If the post process can be reused on the same frame. (default: false)
  117652. * @param textureType Type of textures used when performing the post process. (default: 0)
  117653. */
  117654. constructor(name: string,
  117655. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  117656. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  117657. /**
  117658. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  117659. */
  117660. static EdgeDetect0Kernel: number[];
  117661. /**
  117662. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  117663. */
  117664. static EdgeDetect1Kernel: number[];
  117665. /**
  117666. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  117667. */
  117668. static EdgeDetect2Kernel: number[];
  117669. /**
  117670. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  117671. */
  117672. static SharpenKernel: number[];
  117673. /**
  117674. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  117675. */
  117676. static EmbossKernel: number[];
  117677. /**
  117678. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  117679. */
  117680. static GaussianKernel: number[];
  117681. }
  117682. }
  117683. declare module BABYLON {
  117684. /**
  117685. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  117686. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  117687. * based on samples that have a large difference in distance than the center pixel.
  117688. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  117689. */
  117690. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  117691. direction: Vector2;
  117692. /**
  117693. * Creates a new instance CircleOfConfusionPostProcess
  117694. * @param name The name of the effect.
  117695. * @param scene The scene the effect belongs to.
  117696. * @param direction The direction the blur should be applied.
  117697. * @param kernel The size of the kernel used to blur.
  117698. * @param options The required width/height ratio to downsize to before computing the render pass.
  117699. * @param camera The camera to apply the render pass to.
  117700. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  117701. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  117702. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117703. * @param engine The engine which the post process will be applied. (default: current engine)
  117704. * @param reusable If the post process can be reused on the same frame. (default: false)
  117705. * @param textureType Type of textures used when performing the post process. (default: 0)
  117706. * @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)
  117707. */
  117708. 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);
  117709. }
  117710. }
  117711. declare module BABYLON {
  117712. /** @hidden */
  117713. export var depthOfFieldMergePixelShader: {
  117714. name: string;
  117715. shader: string;
  117716. };
  117717. }
  117718. declare module BABYLON {
  117719. /**
  117720. * Options to be set when merging outputs from the default pipeline.
  117721. */
  117722. export class DepthOfFieldMergePostProcessOptions {
  117723. /**
  117724. * The original image to merge on top of
  117725. */
  117726. originalFromInput: PostProcess;
  117727. /**
  117728. * Parameters to perform the merge of the depth of field effect
  117729. */
  117730. depthOfField?: {
  117731. circleOfConfusion: PostProcess;
  117732. blurSteps: Array<PostProcess>;
  117733. };
  117734. /**
  117735. * Parameters to perform the merge of bloom effect
  117736. */
  117737. bloom?: {
  117738. blurred: PostProcess;
  117739. weight: number;
  117740. };
  117741. }
  117742. /**
  117743. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  117744. */
  117745. export class DepthOfFieldMergePostProcess extends PostProcess {
  117746. private blurSteps;
  117747. /**
  117748. * Creates a new instance of DepthOfFieldMergePostProcess
  117749. * @param name The name of the effect.
  117750. * @param originalFromInput Post process which's input will be used for the merge.
  117751. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  117752. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  117753. * @param options The required width/height ratio to downsize to before computing the render pass.
  117754. * @param camera The camera to apply the render pass to.
  117755. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117756. * @param engine The engine which the post process will be applied. (default: current engine)
  117757. * @param reusable If the post process can be reused on the same frame. (default: false)
  117758. * @param textureType Type of textures used when performing the post process. (default: 0)
  117759. * @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)
  117760. */
  117761. 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);
  117762. /**
  117763. * Updates the effect with the current post process compile time values and recompiles the shader.
  117764. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  117765. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  117766. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  117767. * @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
  117768. * @param onCompiled Called when the shader has been compiled.
  117769. * @param onError Called if there is an error when compiling a shader.
  117770. */
  117771. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  117772. }
  117773. }
  117774. declare module BABYLON {
  117775. /**
  117776. * Specifies the level of max blur that should be applied when using the depth of field effect
  117777. */
  117778. export enum DepthOfFieldEffectBlurLevel {
  117779. /**
  117780. * Subtle blur
  117781. */
  117782. Low = 0,
  117783. /**
  117784. * Medium blur
  117785. */
  117786. Medium = 1,
  117787. /**
  117788. * Large blur
  117789. */
  117790. High = 2
  117791. }
  117792. /**
  117793. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  117794. */
  117795. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  117796. private _circleOfConfusion;
  117797. /**
  117798. * @hidden Internal, blurs from high to low
  117799. */
  117800. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  117801. private _depthOfFieldBlurY;
  117802. private _dofMerge;
  117803. /**
  117804. * @hidden Internal post processes in depth of field effect
  117805. */
  117806. _effects: Array<PostProcess>;
  117807. /**
  117808. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  117809. */
  117810. focalLength: number;
  117811. /**
  117812. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  117813. */
  117814. fStop: number;
  117815. /**
  117816. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  117817. */
  117818. focusDistance: number;
  117819. /**
  117820. * 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.
  117821. */
  117822. lensSize: number;
  117823. /**
  117824. * Creates a new instance DepthOfFieldEffect
  117825. * @param scene The scene the effect belongs to.
  117826. * @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.
  117827. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  117828. * @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)
  117829. */
  117830. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  117831. /**
  117832. * Get the current class name of the current effet
  117833. * @returns "DepthOfFieldEffect"
  117834. */
  117835. getClassName(): string;
  117836. /**
  117837. * 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.
  117838. */
  117839. depthTexture: RenderTargetTexture;
  117840. /**
  117841. * Disposes each of the internal effects for a given camera.
  117842. * @param camera The camera to dispose the effect on.
  117843. */
  117844. disposeEffects(camera: Camera): void;
  117845. /**
  117846. * @hidden Internal
  117847. */
  117848. _updateEffects(): void;
  117849. /**
  117850. * Internal
  117851. * @returns if all the contained post processes are ready.
  117852. * @hidden
  117853. */
  117854. _isReady(): boolean;
  117855. }
  117856. }
  117857. declare module BABYLON {
  117858. /** @hidden */
  117859. export var displayPassPixelShader: {
  117860. name: string;
  117861. shader: string;
  117862. };
  117863. }
  117864. declare module BABYLON {
  117865. /**
  117866. * DisplayPassPostProcess which produces an output the same as it's input
  117867. */
  117868. export class DisplayPassPostProcess extends PostProcess {
  117869. /**
  117870. * Creates the DisplayPassPostProcess
  117871. * @param name The name of the effect.
  117872. * @param options The required width/height ratio to downsize to before computing the render pass.
  117873. * @param camera The camera to apply the render pass to.
  117874. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117875. * @param engine The engine which the post process will be applied. (default: current engine)
  117876. * @param reusable If the post process can be reused on the same frame. (default: false)
  117877. */
  117878. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  117879. }
  117880. }
  117881. declare module BABYLON {
  117882. /** @hidden */
  117883. export var filterPixelShader: {
  117884. name: string;
  117885. shader: string;
  117886. };
  117887. }
  117888. declare module BABYLON {
  117889. /**
  117890. * Applies a kernel filter to the image
  117891. */
  117892. export class FilterPostProcess extends PostProcess {
  117893. /** The matrix to be applied to the image */
  117894. kernelMatrix: Matrix;
  117895. /**
  117896. *
  117897. * @param name The name of the effect.
  117898. * @param kernelMatrix The matrix to be applied to the image
  117899. * @param options The required width/height ratio to downsize to before computing the render pass.
  117900. * @param camera The camera to apply the render pass to.
  117901. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117902. * @param engine The engine which the post process will be applied. (default: current engine)
  117903. * @param reusable If the post process can be reused on the same frame. (default: false)
  117904. */
  117905. constructor(name: string,
  117906. /** The matrix to be applied to the image */
  117907. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  117908. }
  117909. }
  117910. declare module BABYLON {
  117911. /** @hidden */
  117912. export var fxaaPixelShader: {
  117913. name: string;
  117914. shader: string;
  117915. };
  117916. }
  117917. declare module BABYLON {
  117918. /** @hidden */
  117919. export var fxaaVertexShader: {
  117920. name: string;
  117921. shader: string;
  117922. };
  117923. }
  117924. declare module BABYLON {
  117925. /**
  117926. * Fxaa post process
  117927. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  117928. */
  117929. export class FxaaPostProcess extends PostProcess {
  117930. /** @hidden */
  117931. texelWidth: number;
  117932. /** @hidden */
  117933. texelHeight: number;
  117934. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  117935. private _getDefines;
  117936. }
  117937. }
  117938. declare module BABYLON {
  117939. /** @hidden */
  117940. export var grainPixelShader: {
  117941. name: string;
  117942. shader: string;
  117943. };
  117944. }
  117945. declare module BABYLON {
  117946. /**
  117947. * The GrainPostProcess adds noise to the image at mid luminance levels
  117948. */
  117949. export class GrainPostProcess extends PostProcess {
  117950. /**
  117951. * The intensity of the grain added (default: 30)
  117952. */
  117953. intensity: number;
  117954. /**
  117955. * If the grain should be randomized on every frame
  117956. */
  117957. animated: boolean;
  117958. /**
  117959. * Creates a new instance of @see GrainPostProcess
  117960. * @param name The name of the effect.
  117961. * @param options The required width/height ratio to downsize to before computing the render pass.
  117962. * @param camera The camera to apply the render pass to.
  117963. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117964. * @param engine The engine which the post process will be applied. (default: current engine)
  117965. * @param reusable If the post process can be reused on the same frame. (default: false)
  117966. * @param textureType Type of textures used when performing the post process. (default: 0)
  117967. * @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)
  117968. */
  117969. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  117970. }
  117971. }
  117972. declare module BABYLON {
  117973. /** @hidden */
  117974. export var highlightsPixelShader: {
  117975. name: string;
  117976. shader: string;
  117977. };
  117978. }
  117979. declare module BABYLON {
  117980. /**
  117981. * Extracts highlights from the image
  117982. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  117983. */
  117984. export class HighlightsPostProcess extends PostProcess {
  117985. /**
  117986. * Extracts highlights from the image
  117987. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  117988. * @param name The name of the effect.
  117989. * @param options The required width/height ratio to downsize to before computing the render pass.
  117990. * @param camera The camera to apply the render pass to.
  117991. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117992. * @param engine The engine which the post process will be applied. (default: current engine)
  117993. * @param reusable If the post process can be reused on the same frame. (default: false)
  117994. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  117995. */
  117996. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  117997. }
  117998. }
  117999. declare module BABYLON {
  118000. /** @hidden */
  118001. export var mrtFragmentDeclaration: {
  118002. name: string;
  118003. shader: string;
  118004. };
  118005. }
  118006. declare module BABYLON {
  118007. /** @hidden */
  118008. export var geometryPixelShader: {
  118009. name: string;
  118010. shader: string;
  118011. };
  118012. }
  118013. declare module BABYLON {
  118014. /** @hidden */
  118015. export var geometryVertexShader: {
  118016. name: string;
  118017. shader: string;
  118018. };
  118019. }
  118020. declare module BABYLON {
  118021. /** @hidden */
  118022. interface ISavedTransformationMatrix {
  118023. world: Matrix;
  118024. viewProjection: Matrix;
  118025. }
  118026. /**
  118027. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  118028. */
  118029. export class GeometryBufferRenderer {
  118030. /**
  118031. * Constant used to retrieve the position texture index in the G-Buffer textures array
  118032. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  118033. */
  118034. static readonly POSITION_TEXTURE_TYPE: number;
  118035. /**
  118036. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  118037. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  118038. */
  118039. static readonly VELOCITY_TEXTURE_TYPE: number;
  118040. /**
  118041. * Dictionary used to store the previous transformation matrices of each rendered mesh
  118042. * in order to compute objects velocities when enableVelocity is set to "true"
  118043. * @hidden
  118044. */
  118045. _previousTransformationMatrices: {
  118046. [index: number]: ISavedTransformationMatrix;
  118047. };
  118048. /**
  118049. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  118050. * in order to compute objects velocities when enableVelocity is set to "true"
  118051. * @hidden
  118052. */
  118053. _previousBonesTransformationMatrices: {
  118054. [index: number]: Float32Array;
  118055. };
  118056. /**
  118057. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  118058. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  118059. */
  118060. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  118061. private _scene;
  118062. private _multiRenderTarget;
  118063. private _ratio;
  118064. private _enablePosition;
  118065. private _enableVelocity;
  118066. private _positionIndex;
  118067. private _velocityIndex;
  118068. protected _effect: Effect;
  118069. protected _cachedDefines: string;
  118070. /**
  118071. * Set the render list (meshes to be rendered) used in the G buffer.
  118072. */
  118073. renderList: Mesh[];
  118074. /**
  118075. * Gets wether or not G buffer are supported by the running hardware.
  118076. * This requires draw buffer supports
  118077. */
  118078. readonly isSupported: boolean;
  118079. /**
  118080. * Returns the index of the given texture type in the G-Buffer textures array
  118081. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  118082. * @returns the index of the given texture type in the G-Buffer textures array
  118083. */
  118084. getTextureIndex(textureType: number): number;
  118085. /**
  118086. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  118087. */
  118088. /**
  118089. * Sets whether or not objects positions are enabled for the G buffer.
  118090. */
  118091. enablePosition: boolean;
  118092. /**
  118093. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  118094. */
  118095. /**
  118096. * Sets wether or not objects velocities are enabled for the G buffer.
  118097. */
  118098. enableVelocity: boolean;
  118099. /**
  118100. * Gets the scene associated with the buffer.
  118101. */
  118102. readonly scene: Scene;
  118103. /**
  118104. * Gets the ratio used by the buffer during its creation.
  118105. * How big is the buffer related to the main canvas.
  118106. */
  118107. readonly ratio: number;
  118108. /** @hidden */
  118109. static _SceneComponentInitialization: (scene: Scene) => void;
  118110. /**
  118111. * Creates a new G Buffer for the scene
  118112. * @param scene The scene the buffer belongs to
  118113. * @param ratio How big is the buffer related to the main canvas.
  118114. */
  118115. constructor(scene: Scene, ratio?: number);
  118116. /**
  118117. * Checks wether everything is ready to render a submesh to the G buffer.
  118118. * @param subMesh the submesh to check readiness for
  118119. * @param useInstances is the mesh drawn using instance or not
  118120. * @returns true if ready otherwise false
  118121. */
  118122. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  118123. /**
  118124. * Gets the current underlying G Buffer.
  118125. * @returns the buffer
  118126. */
  118127. getGBuffer(): MultiRenderTarget;
  118128. /**
  118129. * Gets the number of samples used to render the buffer (anti aliasing).
  118130. */
  118131. /**
  118132. * Sets the number of samples used to render the buffer (anti aliasing).
  118133. */
  118134. samples: number;
  118135. /**
  118136. * Disposes the renderer and frees up associated resources.
  118137. */
  118138. dispose(): void;
  118139. protected _createRenderTargets(): void;
  118140. private _copyBonesTransformationMatrices;
  118141. }
  118142. }
  118143. declare module BABYLON {
  118144. interface Scene {
  118145. /** @hidden (Backing field) */
  118146. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  118147. /**
  118148. * Gets or Sets the current geometry buffer associated to the scene.
  118149. */
  118150. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  118151. /**
  118152. * Enables a GeometryBufferRender and associates it with the scene
  118153. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  118154. * @returns the GeometryBufferRenderer
  118155. */
  118156. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  118157. /**
  118158. * Disables the GeometryBufferRender associated with the scene
  118159. */
  118160. disableGeometryBufferRenderer(): void;
  118161. }
  118162. /**
  118163. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  118164. * in several rendering techniques.
  118165. */
  118166. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  118167. /**
  118168. * The component name helpful to identify the component in the list of scene components.
  118169. */
  118170. readonly name: string;
  118171. /**
  118172. * The scene the component belongs to.
  118173. */
  118174. scene: Scene;
  118175. /**
  118176. * Creates a new instance of the component for the given scene
  118177. * @param scene Defines the scene to register the component in
  118178. */
  118179. constructor(scene: Scene);
  118180. /**
  118181. * Registers the component in a given scene
  118182. */
  118183. register(): void;
  118184. /**
  118185. * Rebuilds the elements related to this component in case of
  118186. * context lost for instance.
  118187. */
  118188. rebuild(): void;
  118189. /**
  118190. * Disposes the component and the associated ressources
  118191. */
  118192. dispose(): void;
  118193. private _gatherRenderTargets;
  118194. }
  118195. }
  118196. declare module BABYLON {
  118197. /** @hidden */
  118198. export var motionBlurPixelShader: {
  118199. name: string;
  118200. shader: string;
  118201. };
  118202. }
  118203. declare module BABYLON {
  118204. /**
  118205. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  118206. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  118207. * As an example, all you have to do is to create the post-process:
  118208. * var mb = new BABYLON.MotionBlurPostProcess(
  118209. * 'mb', // The name of the effect.
  118210. * scene, // The scene containing the objects to blur according to their velocity.
  118211. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  118212. * camera // The camera to apply the render pass to.
  118213. * );
  118214. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  118215. */
  118216. export class MotionBlurPostProcess extends PostProcess {
  118217. /**
  118218. * Defines how much the image is blurred by the movement. Default value is equal to 1
  118219. */
  118220. motionStrength: number;
  118221. /**
  118222. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  118223. */
  118224. /**
  118225. * Sets the number of iterations to be used for motion blur quality
  118226. */
  118227. motionBlurSamples: number;
  118228. private _motionBlurSamples;
  118229. private _geometryBufferRenderer;
  118230. /**
  118231. * Creates a new instance MotionBlurPostProcess
  118232. * @param name The name of the effect.
  118233. * @param scene The scene containing the objects to blur according to their velocity.
  118234. * @param options The required width/height ratio to downsize to before computing the render pass.
  118235. * @param camera The camera to apply the render pass to.
  118236. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118237. * @param engine The engine which the post process will be applied. (default: current engine)
  118238. * @param reusable If the post process can be reused on the same frame. (default: false)
  118239. * @param textureType Type of textures used when performing the post process. (default: 0)
  118240. * @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)
  118241. */
  118242. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  118243. /**
  118244. * Excludes the given skinned mesh from computing bones velocities.
  118245. * Computing bones velocities can have a cost and that cost. The cost can be saved by calling this function and by passing the skinned mesh reference to ignore.
  118246. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  118247. */
  118248. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  118249. /**
  118250. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  118251. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  118252. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  118253. */
  118254. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  118255. /**
  118256. * Disposes the post process.
  118257. * @param camera The camera to dispose the post process on.
  118258. */
  118259. dispose(camera?: Camera): void;
  118260. }
  118261. }
  118262. declare module BABYLON {
  118263. /** @hidden */
  118264. export var refractionPixelShader: {
  118265. name: string;
  118266. shader: string;
  118267. };
  118268. }
  118269. declare module BABYLON {
  118270. /**
  118271. * Post process which applies a refractin texture
  118272. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  118273. */
  118274. export class RefractionPostProcess extends PostProcess {
  118275. /** the base color of the refraction (used to taint the rendering) */
  118276. color: Color3;
  118277. /** simulated refraction depth */
  118278. depth: number;
  118279. /** the coefficient of the base color (0 to remove base color tainting) */
  118280. colorLevel: number;
  118281. private _refTexture;
  118282. private _ownRefractionTexture;
  118283. /**
  118284. * Gets or sets the refraction texture
  118285. * Please note that you are responsible for disposing the texture if you set it manually
  118286. */
  118287. refractionTexture: Texture;
  118288. /**
  118289. * Initializes the RefractionPostProcess
  118290. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  118291. * @param name The name of the effect.
  118292. * @param refractionTextureUrl Url of the refraction texture to use
  118293. * @param color the base color of the refraction (used to taint the rendering)
  118294. * @param depth simulated refraction depth
  118295. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  118296. * @param camera The camera to apply the render pass to.
  118297. * @param options The required width/height ratio to downsize to before computing the render pass.
  118298. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118299. * @param engine The engine which the post process will be applied. (default: current engine)
  118300. * @param reusable If the post process can be reused on the same frame. (default: false)
  118301. */
  118302. constructor(name: string, refractionTextureUrl: string,
  118303. /** the base color of the refraction (used to taint the rendering) */
  118304. color: Color3,
  118305. /** simulated refraction depth */
  118306. depth: number,
  118307. /** the coefficient of the base color (0 to remove base color tainting) */
  118308. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  118309. /**
  118310. * Disposes of the post process
  118311. * @param camera Camera to dispose post process on
  118312. */
  118313. dispose(camera: Camera): void;
  118314. }
  118315. }
  118316. declare module BABYLON {
  118317. /** @hidden */
  118318. export var sharpenPixelShader: {
  118319. name: string;
  118320. shader: string;
  118321. };
  118322. }
  118323. declare module BABYLON {
  118324. /**
  118325. * The SharpenPostProcess applies a sharpen kernel to every pixel
  118326. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  118327. */
  118328. export class SharpenPostProcess extends PostProcess {
  118329. /**
  118330. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  118331. */
  118332. colorAmount: number;
  118333. /**
  118334. * How much sharpness should be applied (default: 0.3)
  118335. */
  118336. edgeAmount: number;
  118337. /**
  118338. * Creates a new instance ConvolutionPostProcess
  118339. * @param name The name of the effect.
  118340. * @param options The required width/height ratio to downsize to before computing the render pass.
  118341. * @param camera The camera to apply the render pass to.
  118342. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118343. * @param engine The engine which the post process will be applied. (default: current engine)
  118344. * @param reusable If the post process can be reused on the same frame. (default: false)
  118345. * @param textureType Type of textures used when performing the post process. (default: 0)
  118346. * @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)
  118347. */
  118348. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  118349. }
  118350. }
  118351. declare module BABYLON {
  118352. /**
  118353. * PostProcessRenderPipeline
  118354. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  118355. */
  118356. export class PostProcessRenderPipeline {
  118357. private engine;
  118358. private _renderEffects;
  118359. private _renderEffectsForIsolatedPass;
  118360. /**
  118361. * List of inspectable custom properties (used by the Inspector)
  118362. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  118363. */
  118364. inspectableCustomProperties: IInspectable[];
  118365. /**
  118366. * @hidden
  118367. */
  118368. protected _cameras: Camera[];
  118369. /** @hidden */
  118370. _name: string;
  118371. /**
  118372. * Gets pipeline name
  118373. */
  118374. readonly name: string;
  118375. /**
  118376. * Initializes a PostProcessRenderPipeline
  118377. * @param engine engine to add the pipeline to
  118378. * @param name name of the pipeline
  118379. */
  118380. constructor(engine: Engine, name: string);
  118381. /**
  118382. * Gets the class name
  118383. * @returns "PostProcessRenderPipeline"
  118384. */
  118385. getClassName(): string;
  118386. /**
  118387. * If all the render effects in the pipeline are supported
  118388. */
  118389. readonly isSupported: boolean;
  118390. /**
  118391. * Adds an effect to the pipeline
  118392. * @param renderEffect the effect to add
  118393. */
  118394. addEffect(renderEffect: PostProcessRenderEffect): void;
  118395. /** @hidden */
  118396. _rebuild(): void;
  118397. /** @hidden */
  118398. _enableEffect(renderEffectName: string, cameras: Camera): void;
  118399. /** @hidden */
  118400. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  118401. /** @hidden */
  118402. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  118403. /** @hidden */
  118404. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  118405. /** @hidden */
  118406. _attachCameras(cameras: Camera, unique: boolean): void;
  118407. /** @hidden */
  118408. _attachCameras(cameras: Camera[], unique: boolean): void;
  118409. /** @hidden */
  118410. _detachCameras(cameras: Camera): void;
  118411. /** @hidden */
  118412. _detachCameras(cameras: Nullable<Camera[]>): void;
  118413. /** @hidden */
  118414. _update(): void;
  118415. /** @hidden */
  118416. _reset(): void;
  118417. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  118418. /**
  118419. * Disposes of the pipeline
  118420. */
  118421. dispose(): void;
  118422. }
  118423. }
  118424. declare module BABYLON {
  118425. /**
  118426. * PostProcessRenderPipelineManager class
  118427. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  118428. */
  118429. export class PostProcessRenderPipelineManager {
  118430. private _renderPipelines;
  118431. /**
  118432. * Initializes a PostProcessRenderPipelineManager
  118433. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  118434. */
  118435. constructor();
  118436. /**
  118437. * Gets the list of supported render pipelines
  118438. */
  118439. readonly supportedPipelines: PostProcessRenderPipeline[];
  118440. /**
  118441. * Adds a pipeline to the manager
  118442. * @param renderPipeline The pipeline to add
  118443. */
  118444. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  118445. /**
  118446. * Attaches a camera to the pipeline
  118447. * @param renderPipelineName The name of the pipeline to attach to
  118448. * @param cameras the camera to attach
  118449. * @param unique if the camera can be attached multiple times to the pipeline
  118450. */
  118451. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  118452. /**
  118453. * Detaches a camera from the pipeline
  118454. * @param renderPipelineName The name of the pipeline to detach from
  118455. * @param cameras the camera to detach
  118456. */
  118457. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  118458. /**
  118459. * Enables an effect by name on a pipeline
  118460. * @param renderPipelineName the name of the pipeline to enable the effect in
  118461. * @param renderEffectName the name of the effect to enable
  118462. * @param cameras the cameras that the effect should be enabled on
  118463. */
  118464. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  118465. /**
  118466. * Disables an effect by name on a pipeline
  118467. * @param renderPipelineName the name of the pipeline to disable the effect in
  118468. * @param renderEffectName the name of the effect to disable
  118469. * @param cameras the cameras that the effect should be disabled on
  118470. */
  118471. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  118472. /**
  118473. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  118474. */
  118475. update(): void;
  118476. /** @hidden */
  118477. _rebuild(): void;
  118478. /**
  118479. * Disposes of the manager and pipelines
  118480. */
  118481. dispose(): void;
  118482. }
  118483. }
  118484. declare module BABYLON {
  118485. interface Scene {
  118486. /** @hidden (Backing field) */
  118487. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  118488. /**
  118489. * Gets the postprocess render pipeline manager
  118490. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  118491. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  118492. */
  118493. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  118494. }
  118495. /**
  118496. * Defines the Render Pipeline scene component responsible to rendering pipelines
  118497. */
  118498. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  118499. /**
  118500. * The component name helpfull to identify the component in the list of scene components.
  118501. */
  118502. readonly name: string;
  118503. /**
  118504. * The scene the component belongs to.
  118505. */
  118506. scene: Scene;
  118507. /**
  118508. * Creates a new instance of the component for the given scene
  118509. * @param scene Defines the scene to register the component in
  118510. */
  118511. constructor(scene: Scene);
  118512. /**
  118513. * Registers the component in a given scene
  118514. */
  118515. register(): void;
  118516. /**
  118517. * Rebuilds the elements related to this component in case of
  118518. * context lost for instance.
  118519. */
  118520. rebuild(): void;
  118521. /**
  118522. * Disposes the component and the associated ressources
  118523. */
  118524. dispose(): void;
  118525. private _gatherRenderTargets;
  118526. }
  118527. }
  118528. declare module BABYLON {
  118529. /**
  118530. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  118531. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  118532. */
  118533. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  118534. private _scene;
  118535. private _camerasToBeAttached;
  118536. /**
  118537. * ID of the sharpen post process,
  118538. */
  118539. private readonly SharpenPostProcessId;
  118540. /**
  118541. * @ignore
  118542. * ID of the image processing post process;
  118543. */
  118544. readonly ImageProcessingPostProcessId: string;
  118545. /**
  118546. * @ignore
  118547. * ID of the Fast Approximate Anti-Aliasing post process;
  118548. */
  118549. readonly FxaaPostProcessId: string;
  118550. /**
  118551. * ID of the chromatic aberration post process,
  118552. */
  118553. private readonly ChromaticAberrationPostProcessId;
  118554. /**
  118555. * ID of the grain post process
  118556. */
  118557. private readonly GrainPostProcessId;
  118558. /**
  118559. * Sharpen post process which will apply a sharpen convolution to enhance edges
  118560. */
  118561. sharpen: SharpenPostProcess;
  118562. private _sharpenEffect;
  118563. private bloom;
  118564. /**
  118565. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  118566. */
  118567. depthOfField: DepthOfFieldEffect;
  118568. /**
  118569. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  118570. */
  118571. fxaa: FxaaPostProcess;
  118572. /**
  118573. * Image post processing pass used to perform operations such as tone mapping or color grading.
  118574. */
  118575. imageProcessing: ImageProcessingPostProcess;
  118576. /**
  118577. * Chromatic aberration post process which will shift rgb colors in the image
  118578. */
  118579. chromaticAberration: ChromaticAberrationPostProcess;
  118580. private _chromaticAberrationEffect;
  118581. /**
  118582. * Grain post process which add noise to the image
  118583. */
  118584. grain: GrainPostProcess;
  118585. private _grainEffect;
  118586. /**
  118587. * Glow post process which adds a glow to emissive areas of the image
  118588. */
  118589. private _glowLayer;
  118590. /**
  118591. * Animations which can be used to tweak settings over a period of time
  118592. */
  118593. animations: Animation[];
  118594. private _imageProcessingConfigurationObserver;
  118595. private _sharpenEnabled;
  118596. private _bloomEnabled;
  118597. private _depthOfFieldEnabled;
  118598. private _depthOfFieldBlurLevel;
  118599. private _fxaaEnabled;
  118600. private _imageProcessingEnabled;
  118601. private _defaultPipelineTextureType;
  118602. private _bloomScale;
  118603. private _chromaticAberrationEnabled;
  118604. private _grainEnabled;
  118605. private _buildAllowed;
  118606. /**
  118607. * Gets active scene
  118608. */
  118609. readonly scene: Scene;
  118610. /**
  118611. * Enable or disable the sharpen process from the pipeline
  118612. */
  118613. sharpenEnabled: boolean;
  118614. private _resizeObserver;
  118615. private _hardwareScaleLevel;
  118616. private _bloomKernel;
  118617. /**
  118618. * Specifies the size of the bloom blur kernel, relative to the final output size
  118619. */
  118620. bloomKernel: number;
  118621. /**
  118622. * Specifies the weight of the bloom in the final rendering
  118623. */
  118624. private _bloomWeight;
  118625. /**
  118626. * Specifies the luma threshold for the area that will be blurred by the bloom
  118627. */
  118628. private _bloomThreshold;
  118629. private _hdr;
  118630. /**
  118631. * The strength of the bloom.
  118632. */
  118633. bloomWeight: number;
  118634. /**
  118635. * The strength of the bloom.
  118636. */
  118637. bloomThreshold: number;
  118638. /**
  118639. * The scale of the bloom, lower value will provide better performance.
  118640. */
  118641. bloomScale: number;
  118642. /**
  118643. * Enable or disable the bloom from the pipeline
  118644. */
  118645. bloomEnabled: boolean;
  118646. private _rebuildBloom;
  118647. /**
  118648. * If the depth of field is enabled.
  118649. */
  118650. depthOfFieldEnabled: boolean;
  118651. /**
  118652. * Blur level of the depth of field effect. (Higher blur will effect performance)
  118653. */
  118654. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  118655. /**
  118656. * If the anti aliasing is enabled.
  118657. */
  118658. fxaaEnabled: boolean;
  118659. private _samples;
  118660. /**
  118661. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  118662. */
  118663. samples: number;
  118664. /**
  118665. * If image processing is enabled.
  118666. */
  118667. imageProcessingEnabled: boolean;
  118668. /**
  118669. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  118670. */
  118671. glowLayerEnabled: boolean;
  118672. /**
  118673. * Gets the glow layer (or null if not defined)
  118674. */
  118675. readonly glowLayer: Nullable<GlowLayer>;
  118676. /**
  118677. * Enable or disable the chromaticAberration process from the pipeline
  118678. */
  118679. chromaticAberrationEnabled: boolean;
  118680. /**
  118681. * Enable or disable the grain process from the pipeline
  118682. */
  118683. grainEnabled: boolean;
  118684. /**
  118685. * @constructor
  118686. * @param name - The rendering pipeline name (default: "")
  118687. * @param hdr - If high dynamic range textures should be used (default: true)
  118688. * @param scene - The scene linked to this pipeline (default: the last created scene)
  118689. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  118690. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  118691. */
  118692. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  118693. /**
  118694. * Get the class name
  118695. * @returns "DefaultRenderingPipeline"
  118696. */
  118697. getClassName(): string;
  118698. /**
  118699. * Force the compilation of the entire pipeline.
  118700. */
  118701. prepare(): void;
  118702. private _hasCleared;
  118703. private _prevPostProcess;
  118704. private _prevPrevPostProcess;
  118705. private _setAutoClearAndTextureSharing;
  118706. private _depthOfFieldSceneObserver;
  118707. private _buildPipeline;
  118708. private _disposePostProcesses;
  118709. /**
  118710. * Adds a camera to the pipeline
  118711. * @param camera the camera to be added
  118712. */
  118713. addCamera(camera: Camera): void;
  118714. /**
  118715. * Removes a camera from the pipeline
  118716. * @param camera the camera to remove
  118717. */
  118718. removeCamera(camera: Camera): void;
  118719. /**
  118720. * Dispose of the pipeline and stop all post processes
  118721. */
  118722. dispose(): void;
  118723. /**
  118724. * Serialize the rendering pipeline (Used when exporting)
  118725. * @returns the serialized object
  118726. */
  118727. serialize(): any;
  118728. /**
  118729. * Parse the serialized pipeline
  118730. * @param source Source pipeline.
  118731. * @param scene The scene to load the pipeline to.
  118732. * @param rootUrl The URL of the serialized pipeline.
  118733. * @returns An instantiated pipeline from the serialized object.
  118734. */
  118735. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  118736. }
  118737. }
  118738. declare module BABYLON {
  118739. /** @hidden */
  118740. export var lensHighlightsPixelShader: {
  118741. name: string;
  118742. shader: string;
  118743. };
  118744. }
  118745. declare module BABYLON {
  118746. /** @hidden */
  118747. export var depthOfFieldPixelShader: {
  118748. name: string;
  118749. shader: string;
  118750. };
  118751. }
  118752. declare module BABYLON {
  118753. /**
  118754. * BABYLON.JS Chromatic Aberration GLSL Shader
  118755. * Author: Olivier Guyot
  118756. * Separates very slightly R, G and B colors on the edges of the screen
  118757. * Inspired by Francois Tarlier & Martins Upitis
  118758. */
  118759. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  118760. /**
  118761. * @ignore
  118762. * The chromatic aberration PostProcess id in the pipeline
  118763. */
  118764. LensChromaticAberrationEffect: string;
  118765. /**
  118766. * @ignore
  118767. * The highlights enhancing PostProcess id in the pipeline
  118768. */
  118769. HighlightsEnhancingEffect: string;
  118770. /**
  118771. * @ignore
  118772. * The depth-of-field PostProcess id in the pipeline
  118773. */
  118774. LensDepthOfFieldEffect: string;
  118775. private _scene;
  118776. private _depthTexture;
  118777. private _grainTexture;
  118778. private _chromaticAberrationPostProcess;
  118779. private _highlightsPostProcess;
  118780. private _depthOfFieldPostProcess;
  118781. private _edgeBlur;
  118782. private _grainAmount;
  118783. private _chromaticAberration;
  118784. private _distortion;
  118785. private _highlightsGain;
  118786. private _highlightsThreshold;
  118787. private _dofDistance;
  118788. private _dofAperture;
  118789. private _dofDarken;
  118790. private _dofPentagon;
  118791. private _blurNoise;
  118792. /**
  118793. * @constructor
  118794. *
  118795. * Effect parameters are as follow:
  118796. * {
  118797. * chromatic_aberration: number; // from 0 to x (1 for realism)
  118798. * edge_blur: number; // from 0 to x (1 for realism)
  118799. * distortion: number; // from 0 to x (1 for realism)
  118800. * grain_amount: number; // from 0 to 1
  118801. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  118802. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  118803. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  118804. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  118805. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  118806. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  118807. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  118808. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  118809. * }
  118810. * Note: if an effect parameter is unset, effect is disabled
  118811. *
  118812. * @param name The rendering pipeline name
  118813. * @param parameters - An object containing all parameters (see above)
  118814. * @param scene The scene linked to this pipeline
  118815. * @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)
  118816. * @param cameras The array of cameras that the rendering pipeline will be attached to
  118817. */
  118818. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  118819. /**
  118820. * Get the class name
  118821. * @returns "LensRenderingPipeline"
  118822. */
  118823. getClassName(): string;
  118824. /**
  118825. * Gets associated scene
  118826. */
  118827. readonly scene: Scene;
  118828. /**
  118829. * Gets or sets the edge blur
  118830. */
  118831. edgeBlur: number;
  118832. /**
  118833. * Gets or sets the grain amount
  118834. */
  118835. grainAmount: number;
  118836. /**
  118837. * Gets or sets the chromatic aberration amount
  118838. */
  118839. chromaticAberration: number;
  118840. /**
  118841. * Gets or sets the depth of field aperture
  118842. */
  118843. dofAperture: number;
  118844. /**
  118845. * Gets or sets the edge distortion
  118846. */
  118847. edgeDistortion: number;
  118848. /**
  118849. * Gets or sets the depth of field distortion
  118850. */
  118851. dofDistortion: number;
  118852. /**
  118853. * Gets or sets the darken out of focus amount
  118854. */
  118855. darkenOutOfFocus: number;
  118856. /**
  118857. * Gets or sets a boolean indicating if blur noise is enabled
  118858. */
  118859. blurNoise: boolean;
  118860. /**
  118861. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  118862. */
  118863. pentagonBokeh: boolean;
  118864. /**
  118865. * Gets or sets the highlight grain amount
  118866. */
  118867. highlightsGain: number;
  118868. /**
  118869. * Gets or sets the highlight threshold
  118870. */
  118871. highlightsThreshold: number;
  118872. /**
  118873. * Sets the amount of blur at the edges
  118874. * @param amount blur amount
  118875. */
  118876. setEdgeBlur(amount: number): void;
  118877. /**
  118878. * Sets edge blur to 0
  118879. */
  118880. disableEdgeBlur(): void;
  118881. /**
  118882. * Sets the amout of grain
  118883. * @param amount Amount of grain
  118884. */
  118885. setGrainAmount(amount: number): void;
  118886. /**
  118887. * Set grain amount to 0
  118888. */
  118889. disableGrain(): void;
  118890. /**
  118891. * Sets the chromatic aberration amount
  118892. * @param amount amount of chromatic aberration
  118893. */
  118894. setChromaticAberration(amount: number): void;
  118895. /**
  118896. * Sets chromatic aberration amount to 0
  118897. */
  118898. disableChromaticAberration(): void;
  118899. /**
  118900. * Sets the EdgeDistortion amount
  118901. * @param amount amount of EdgeDistortion
  118902. */
  118903. setEdgeDistortion(amount: number): void;
  118904. /**
  118905. * Sets edge distortion to 0
  118906. */
  118907. disableEdgeDistortion(): void;
  118908. /**
  118909. * Sets the FocusDistance amount
  118910. * @param amount amount of FocusDistance
  118911. */
  118912. setFocusDistance(amount: number): void;
  118913. /**
  118914. * Disables depth of field
  118915. */
  118916. disableDepthOfField(): void;
  118917. /**
  118918. * Sets the Aperture amount
  118919. * @param amount amount of Aperture
  118920. */
  118921. setAperture(amount: number): void;
  118922. /**
  118923. * Sets the DarkenOutOfFocus amount
  118924. * @param amount amount of DarkenOutOfFocus
  118925. */
  118926. setDarkenOutOfFocus(amount: number): void;
  118927. private _pentagonBokehIsEnabled;
  118928. /**
  118929. * Creates a pentagon bokeh effect
  118930. */
  118931. enablePentagonBokeh(): void;
  118932. /**
  118933. * Disables the pentagon bokeh effect
  118934. */
  118935. disablePentagonBokeh(): void;
  118936. /**
  118937. * Enables noise blur
  118938. */
  118939. enableNoiseBlur(): void;
  118940. /**
  118941. * Disables noise blur
  118942. */
  118943. disableNoiseBlur(): void;
  118944. /**
  118945. * Sets the HighlightsGain amount
  118946. * @param amount amount of HighlightsGain
  118947. */
  118948. setHighlightsGain(amount: number): void;
  118949. /**
  118950. * Sets the HighlightsThreshold amount
  118951. * @param amount amount of HighlightsThreshold
  118952. */
  118953. setHighlightsThreshold(amount: number): void;
  118954. /**
  118955. * Disables highlights
  118956. */
  118957. disableHighlights(): void;
  118958. /**
  118959. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  118960. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  118961. */
  118962. dispose(disableDepthRender?: boolean): void;
  118963. private _createChromaticAberrationPostProcess;
  118964. private _createHighlightsPostProcess;
  118965. private _createDepthOfFieldPostProcess;
  118966. private _createGrainTexture;
  118967. }
  118968. }
  118969. declare module BABYLON {
  118970. /** @hidden */
  118971. export var ssao2PixelShader: {
  118972. name: string;
  118973. shader: string;
  118974. };
  118975. }
  118976. declare module BABYLON {
  118977. /** @hidden */
  118978. export var ssaoCombinePixelShader: {
  118979. name: string;
  118980. shader: string;
  118981. };
  118982. }
  118983. declare module BABYLON {
  118984. /**
  118985. * Render pipeline to produce ssao effect
  118986. */
  118987. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  118988. /**
  118989. * @ignore
  118990. * The PassPostProcess id in the pipeline that contains the original scene color
  118991. */
  118992. SSAOOriginalSceneColorEffect: string;
  118993. /**
  118994. * @ignore
  118995. * The SSAO PostProcess id in the pipeline
  118996. */
  118997. SSAORenderEffect: string;
  118998. /**
  118999. * @ignore
  119000. * The horizontal blur PostProcess id in the pipeline
  119001. */
  119002. SSAOBlurHRenderEffect: string;
  119003. /**
  119004. * @ignore
  119005. * The vertical blur PostProcess id in the pipeline
  119006. */
  119007. SSAOBlurVRenderEffect: string;
  119008. /**
  119009. * @ignore
  119010. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  119011. */
  119012. SSAOCombineRenderEffect: string;
  119013. /**
  119014. * The output strength of the SSAO post-process. Default value is 1.0.
  119015. */
  119016. totalStrength: number;
  119017. /**
  119018. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  119019. */
  119020. maxZ: number;
  119021. /**
  119022. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  119023. */
  119024. minZAspect: number;
  119025. private _samples;
  119026. /**
  119027. * Number of samples used for the SSAO calculations. Default value is 8
  119028. */
  119029. samples: number;
  119030. private _textureSamples;
  119031. /**
  119032. * Number of samples to use for antialiasing
  119033. */
  119034. textureSamples: number;
  119035. /**
  119036. * Ratio object used for SSAO ratio and blur ratio
  119037. */
  119038. private _ratio;
  119039. /**
  119040. * Dynamically generated sphere sampler.
  119041. */
  119042. private _sampleSphere;
  119043. /**
  119044. * Blur filter offsets
  119045. */
  119046. private _samplerOffsets;
  119047. private _expensiveBlur;
  119048. /**
  119049. * If bilateral blur should be used
  119050. */
  119051. expensiveBlur: boolean;
  119052. /**
  119053. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  119054. */
  119055. radius: number;
  119056. /**
  119057. * The base color of the SSAO post-process
  119058. * The final result is "base + ssao" between [0, 1]
  119059. */
  119060. base: number;
  119061. /**
  119062. * Support test.
  119063. */
  119064. static readonly IsSupported: boolean;
  119065. private _scene;
  119066. private _depthTexture;
  119067. private _normalTexture;
  119068. private _randomTexture;
  119069. private _originalColorPostProcess;
  119070. private _ssaoPostProcess;
  119071. private _blurHPostProcess;
  119072. private _blurVPostProcess;
  119073. private _ssaoCombinePostProcess;
  119074. private _firstUpdate;
  119075. /**
  119076. * Gets active scene
  119077. */
  119078. readonly scene: Scene;
  119079. /**
  119080. * @constructor
  119081. * @param name The rendering pipeline name
  119082. * @param scene The scene linked to this pipeline
  119083. * @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 }
  119084. * @param cameras The array of cameras that the rendering pipeline will be attached to
  119085. */
  119086. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  119087. /**
  119088. * Get the class name
  119089. * @returns "SSAO2RenderingPipeline"
  119090. */
  119091. getClassName(): string;
  119092. /**
  119093. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  119094. */
  119095. dispose(disableGeometryBufferRenderer?: boolean): void;
  119096. private _createBlurPostProcess;
  119097. /** @hidden */
  119098. _rebuild(): void;
  119099. private _bits;
  119100. private _radicalInverse_VdC;
  119101. private _hammersley;
  119102. private _hemisphereSample_uniform;
  119103. private _generateHemisphere;
  119104. private _createSSAOPostProcess;
  119105. private _createSSAOCombinePostProcess;
  119106. private _createRandomTexture;
  119107. /**
  119108. * Serialize the rendering pipeline (Used when exporting)
  119109. * @returns the serialized object
  119110. */
  119111. serialize(): any;
  119112. /**
  119113. * Parse the serialized pipeline
  119114. * @param source Source pipeline.
  119115. * @param scene The scene to load the pipeline to.
  119116. * @param rootUrl The URL of the serialized pipeline.
  119117. * @returns An instantiated pipeline from the serialized object.
  119118. */
  119119. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  119120. }
  119121. }
  119122. declare module BABYLON {
  119123. /** @hidden */
  119124. export var ssaoPixelShader: {
  119125. name: string;
  119126. shader: string;
  119127. };
  119128. }
  119129. declare module BABYLON {
  119130. /**
  119131. * Render pipeline to produce ssao effect
  119132. */
  119133. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  119134. /**
  119135. * @ignore
  119136. * The PassPostProcess id in the pipeline that contains the original scene color
  119137. */
  119138. SSAOOriginalSceneColorEffect: string;
  119139. /**
  119140. * @ignore
  119141. * The SSAO PostProcess id in the pipeline
  119142. */
  119143. SSAORenderEffect: string;
  119144. /**
  119145. * @ignore
  119146. * The horizontal blur PostProcess id in the pipeline
  119147. */
  119148. SSAOBlurHRenderEffect: string;
  119149. /**
  119150. * @ignore
  119151. * The vertical blur PostProcess id in the pipeline
  119152. */
  119153. SSAOBlurVRenderEffect: string;
  119154. /**
  119155. * @ignore
  119156. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  119157. */
  119158. SSAOCombineRenderEffect: string;
  119159. /**
  119160. * The output strength of the SSAO post-process. Default value is 1.0.
  119161. */
  119162. totalStrength: number;
  119163. /**
  119164. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  119165. */
  119166. radius: number;
  119167. /**
  119168. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  119169. * Must not be equal to fallOff and superior to fallOff.
  119170. * Default value is 0.0075
  119171. */
  119172. area: number;
  119173. /**
  119174. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  119175. * Must not be equal to area and inferior to area.
  119176. * Default value is 0.000001
  119177. */
  119178. fallOff: number;
  119179. /**
  119180. * The base color of the SSAO post-process
  119181. * The final result is "base + ssao" between [0, 1]
  119182. */
  119183. base: number;
  119184. private _scene;
  119185. private _depthTexture;
  119186. private _randomTexture;
  119187. private _originalColorPostProcess;
  119188. private _ssaoPostProcess;
  119189. private _blurHPostProcess;
  119190. private _blurVPostProcess;
  119191. private _ssaoCombinePostProcess;
  119192. private _firstUpdate;
  119193. /**
  119194. * Gets active scene
  119195. */
  119196. readonly scene: Scene;
  119197. /**
  119198. * @constructor
  119199. * @param name - The rendering pipeline name
  119200. * @param scene - The scene linked to this pipeline
  119201. * @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 }
  119202. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  119203. */
  119204. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  119205. /**
  119206. * Get the class name
  119207. * @returns "SSAORenderingPipeline"
  119208. */
  119209. getClassName(): string;
  119210. /**
  119211. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  119212. */
  119213. dispose(disableDepthRender?: boolean): void;
  119214. private _createBlurPostProcess;
  119215. /** @hidden */
  119216. _rebuild(): void;
  119217. private _createSSAOPostProcess;
  119218. private _createSSAOCombinePostProcess;
  119219. private _createRandomTexture;
  119220. }
  119221. }
  119222. declare module BABYLON {
  119223. /** @hidden */
  119224. export var standardPixelShader: {
  119225. name: string;
  119226. shader: string;
  119227. };
  119228. }
  119229. declare module BABYLON {
  119230. /**
  119231. * Standard rendering pipeline
  119232. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  119233. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  119234. */
  119235. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  119236. /**
  119237. * Public members
  119238. */
  119239. /**
  119240. * Post-process which contains the original scene color before the pipeline applies all the effects
  119241. */
  119242. originalPostProcess: Nullable<PostProcess>;
  119243. /**
  119244. * Post-process used to down scale an image x4
  119245. */
  119246. downSampleX4PostProcess: Nullable<PostProcess>;
  119247. /**
  119248. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  119249. */
  119250. brightPassPostProcess: Nullable<PostProcess>;
  119251. /**
  119252. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  119253. */
  119254. blurHPostProcesses: PostProcess[];
  119255. /**
  119256. * Post-process array storing all the vertical blur post-processes used by the pipeline
  119257. */
  119258. blurVPostProcesses: PostProcess[];
  119259. /**
  119260. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  119261. */
  119262. textureAdderPostProcess: Nullable<PostProcess>;
  119263. /**
  119264. * Post-process used to create volumetric lighting effect
  119265. */
  119266. volumetricLightPostProcess: Nullable<PostProcess>;
  119267. /**
  119268. * Post-process used to smooth the previous volumetric light post-process on the X axis
  119269. */
  119270. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  119271. /**
  119272. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  119273. */
  119274. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  119275. /**
  119276. * Post-process used to merge the volumetric light effect and the real scene color
  119277. */
  119278. volumetricLightMergePostProces: Nullable<PostProcess>;
  119279. /**
  119280. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  119281. */
  119282. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  119283. /**
  119284. * Base post-process used to calculate the average luminance of the final image for HDR
  119285. */
  119286. luminancePostProcess: Nullable<PostProcess>;
  119287. /**
  119288. * Post-processes used to create down sample post-processes in order to get
  119289. * the average luminance of the final image for HDR
  119290. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  119291. */
  119292. luminanceDownSamplePostProcesses: PostProcess[];
  119293. /**
  119294. * Post-process used to create a HDR effect (light adaptation)
  119295. */
  119296. hdrPostProcess: Nullable<PostProcess>;
  119297. /**
  119298. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  119299. */
  119300. textureAdderFinalPostProcess: Nullable<PostProcess>;
  119301. /**
  119302. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  119303. */
  119304. lensFlareFinalPostProcess: Nullable<PostProcess>;
  119305. /**
  119306. * Post-process used to merge the final HDR post-process and the real scene color
  119307. */
  119308. hdrFinalPostProcess: Nullable<PostProcess>;
  119309. /**
  119310. * Post-process used to create a lens flare effect
  119311. */
  119312. lensFlarePostProcess: Nullable<PostProcess>;
  119313. /**
  119314. * Post-process that merges the result of the lens flare post-process and the real scene color
  119315. */
  119316. lensFlareComposePostProcess: Nullable<PostProcess>;
  119317. /**
  119318. * Post-process used to create a motion blur effect
  119319. */
  119320. motionBlurPostProcess: Nullable<PostProcess>;
  119321. /**
  119322. * Post-process used to create a depth of field effect
  119323. */
  119324. depthOfFieldPostProcess: Nullable<PostProcess>;
  119325. /**
  119326. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  119327. */
  119328. fxaaPostProcess: Nullable<FxaaPostProcess>;
  119329. /**
  119330. * Represents the brightness threshold in order to configure the illuminated surfaces
  119331. */
  119332. brightThreshold: number;
  119333. /**
  119334. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  119335. */
  119336. blurWidth: number;
  119337. /**
  119338. * Sets if the blur for highlighted surfaces must be only horizontal
  119339. */
  119340. horizontalBlur: boolean;
  119341. /**
  119342. * Gets the overall exposure used by the pipeline
  119343. */
  119344. /**
  119345. * Sets the overall exposure used by the pipeline
  119346. */
  119347. exposure: number;
  119348. /**
  119349. * Texture used typically to simulate "dirty" on camera lens
  119350. */
  119351. lensTexture: Nullable<Texture>;
  119352. /**
  119353. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  119354. */
  119355. volumetricLightCoefficient: number;
  119356. /**
  119357. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  119358. */
  119359. volumetricLightPower: number;
  119360. /**
  119361. * Used the set the blur intensity to smooth the volumetric lights
  119362. */
  119363. volumetricLightBlurScale: number;
  119364. /**
  119365. * Light (spot or directional) used to generate the volumetric lights rays
  119366. * The source light must have a shadow generate so the pipeline can get its
  119367. * depth map
  119368. */
  119369. sourceLight: Nullable<SpotLight | DirectionalLight>;
  119370. /**
  119371. * For eye adaptation, represents the minimum luminance the eye can see
  119372. */
  119373. hdrMinimumLuminance: number;
  119374. /**
  119375. * For eye adaptation, represents the decrease luminance speed
  119376. */
  119377. hdrDecreaseRate: number;
  119378. /**
  119379. * For eye adaptation, represents the increase luminance speed
  119380. */
  119381. hdrIncreaseRate: number;
  119382. /**
  119383. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  119384. */
  119385. /**
  119386. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  119387. */
  119388. hdrAutoExposure: boolean;
  119389. /**
  119390. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  119391. */
  119392. lensColorTexture: Nullable<Texture>;
  119393. /**
  119394. * The overall strengh for the lens flare effect
  119395. */
  119396. lensFlareStrength: number;
  119397. /**
  119398. * Dispersion coefficient for lens flare ghosts
  119399. */
  119400. lensFlareGhostDispersal: number;
  119401. /**
  119402. * Main lens flare halo width
  119403. */
  119404. lensFlareHaloWidth: number;
  119405. /**
  119406. * Based on the lens distortion effect, defines how much the lens flare result
  119407. * is distorted
  119408. */
  119409. lensFlareDistortionStrength: number;
  119410. /**
  119411. * Lens star texture must be used to simulate rays on the flares and is available
  119412. * in the documentation
  119413. */
  119414. lensStarTexture: Nullable<Texture>;
  119415. /**
  119416. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  119417. * flare effect by taking account of the dirt texture
  119418. */
  119419. lensFlareDirtTexture: Nullable<Texture>;
  119420. /**
  119421. * Represents the focal length for the depth of field effect
  119422. */
  119423. depthOfFieldDistance: number;
  119424. /**
  119425. * Represents the blur intensity for the blurred part of the depth of field effect
  119426. */
  119427. depthOfFieldBlurWidth: number;
  119428. /**
  119429. * Gets how much the image is blurred by the movement while using the motion blur post-process
  119430. */
  119431. /**
  119432. * Sets how much the image is blurred by the movement while using the motion blur post-process
  119433. */
  119434. motionStrength: number;
  119435. /**
  119436. * Gets wether or not the motion blur post-process is object based or screen based.
  119437. */
  119438. /**
  119439. * Sets wether or not the motion blur post-process should be object based or screen based
  119440. */
  119441. objectBasedMotionBlur: boolean;
  119442. /**
  119443. * List of animations for the pipeline (IAnimatable implementation)
  119444. */
  119445. animations: Animation[];
  119446. /**
  119447. * Private members
  119448. */
  119449. private _scene;
  119450. private _currentDepthOfFieldSource;
  119451. private _basePostProcess;
  119452. private _fixedExposure;
  119453. private _currentExposure;
  119454. private _hdrAutoExposure;
  119455. private _hdrCurrentLuminance;
  119456. private _motionStrength;
  119457. private _isObjectBasedMotionBlur;
  119458. private _floatTextureType;
  119459. private _ratio;
  119460. private _bloomEnabled;
  119461. private _depthOfFieldEnabled;
  119462. private _vlsEnabled;
  119463. private _lensFlareEnabled;
  119464. private _hdrEnabled;
  119465. private _motionBlurEnabled;
  119466. private _fxaaEnabled;
  119467. private _motionBlurSamples;
  119468. private _volumetricLightStepsCount;
  119469. private _samples;
  119470. /**
  119471. * @ignore
  119472. * Specifies if the bloom pipeline is enabled
  119473. */
  119474. BloomEnabled: boolean;
  119475. /**
  119476. * @ignore
  119477. * Specifies if the depth of field pipeline is enabed
  119478. */
  119479. DepthOfFieldEnabled: boolean;
  119480. /**
  119481. * @ignore
  119482. * Specifies if the lens flare pipeline is enabed
  119483. */
  119484. LensFlareEnabled: boolean;
  119485. /**
  119486. * @ignore
  119487. * Specifies if the HDR pipeline is enabled
  119488. */
  119489. HDREnabled: boolean;
  119490. /**
  119491. * @ignore
  119492. * Specifies if the volumetric lights scattering effect is enabled
  119493. */
  119494. VLSEnabled: boolean;
  119495. /**
  119496. * @ignore
  119497. * Specifies if the motion blur effect is enabled
  119498. */
  119499. MotionBlurEnabled: boolean;
  119500. /**
  119501. * Specifies if anti-aliasing is enabled
  119502. */
  119503. fxaaEnabled: boolean;
  119504. /**
  119505. * Specifies the number of steps used to calculate the volumetric lights
  119506. * Typically in interval [50, 200]
  119507. */
  119508. volumetricLightStepsCount: number;
  119509. /**
  119510. * Specifies the number of samples used for the motion blur effect
  119511. * Typically in interval [16, 64]
  119512. */
  119513. motionBlurSamples: number;
  119514. /**
  119515. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  119516. */
  119517. samples: number;
  119518. /**
  119519. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  119520. * @constructor
  119521. * @param name The rendering pipeline name
  119522. * @param scene The scene linked to this pipeline
  119523. * @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)
  119524. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  119525. * @param cameras The array of cameras that the rendering pipeline will be attached to
  119526. */
  119527. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  119528. private _buildPipeline;
  119529. private _createDownSampleX4PostProcess;
  119530. private _createBrightPassPostProcess;
  119531. private _createBlurPostProcesses;
  119532. private _createTextureAdderPostProcess;
  119533. private _createVolumetricLightPostProcess;
  119534. private _createLuminancePostProcesses;
  119535. private _createHdrPostProcess;
  119536. private _createLensFlarePostProcess;
  119537. private _createDepthOfFieldPostProcess;
  119538. private _createMotionBlurPostProcess;
  119539. private _getDepthTexture;
  119540. private _disposePostProcesses;
  119541. /**
  119542. * Dispose of the pipeline and stop all post processes
  119543. */
  119544. dispose(): void;
  119545. /**
  119546. * Serialize the rendering pipeline (Used when exporting)
  119547. * @returns the serialized object
  119548. */
  119549. serialize(): any;
  119550. /**
  119551. * Parse the serialized pipeline
  119552. * @param source Source pipeline.
  119553. * @param scene The scene to load the pipeline to.
  119554. * @param rootUrl The URL of the serialized pipeline.
  119555. * @returns An instantiated pipeline from the serialized object.
  119556. */
  119557. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  119558. /**
  119559. * Luminance steps
  119560. */
  119561. static LuminanceSteps: number;
  119562. }
  119563. }
  119564. declare module BABYLON {
  119565. /** @hidden */
  119566. export var tonemapPixelShader: {
  119567. name: string;
  119568. shader: string;
  119569. };
  119570. }
  119571. declare module BABYLON {
  119572. /** Defines operator used for tonemapping */
  119573. export enum TonemappingOperator {
  119574. /** Hable */
  119575. Hable = 0,
  119576. /** Reinhard */
  119577. Reinhard = 1,
  119578. /** HejiDawson */
  119579. HejiDawson = 2,
  119580. /** Photographic */
  119581. Photographic = 3
  119582. }
  119583. /**
  119584. * Defines a post process to apply tone mapping
  119585. */
  119586. export class TonemapPostProcess extends PostProcess {
  119587. private _operator;
  119588. /** Defines the required exposure adjustement */
  119589. exposureAdjustment: number;
  119590. /**
  119591. * Creates a new TonemapPostProcess
  119592. * @param name defines the name of the postprocess
  119593. * @param _operator defines the operator to use
  119594. * @param exposureAdjustment defines the required exposure adjustement
  119595. * @param camera defines the camera to use (can be null)
  119596. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  119597. * @param engine defines the hosting engine (can be ignore if camera is set)
  119598. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  119599. */
  119600. constructor(name: string, _operator: TonemappingOperator,
  119601. /** Defines the required exposure adjustement */
  119602. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  119603. }
  119604. }
  119605. declare module BABYLON {
  119606. /** @hidden */
  119607. export var depthVertexShader: {
  119608. name: string;
  119609. shader: string;
  119610. };
  119611. }
  119612. declare module BABYLON {
  119613. /** @hidden */
  119614. export var volumetricLightScatteringPixelShader: {
  119615. name: string;
  119616. shader: string;
  119617. };
  119618. }
  119619. declare module BABYLON {
  119620. /** @hidden */
  119621. export var volumetricLightScatteringPassPixelShader: {
  119622. name: string;
  119623. shader: string;
  119624. };
  119625. }
  119626. declare module BABYLON {
  119627. /**
  119628. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  119629. */
  119630. export class VolumetricLightScatteringPostProcess extends PostProcess {
  119631. private _volumetricLightScatteringPass;
  119632. private _volumetricLightScatteringRTT;
  119633. private _viewPort;
  119634. private _screenCoordinates;
  119635. private _cachedDefines;
  119636. /**
  119637. * If not undefined, the mesh position is computed from the attached node position
  119638. */
  119639. attachedNode: {
  119640. position: Vector3;
  119641. };
  119642. /**
  119643. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  119644. */
  119645. customMeshPosition: Vector3;
  119646. /**
  119647. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  119648. */
  119649. useCustomMeshPosition: boolean;
  119650. /**
  119651. * If the post-process should inverse the light scattering direction
  119652. */
  119653. invert: boolean;
  119654. /**
  119655. * The internal mesh used by the post-process
  119656. */
  119657. mesh: Mesh;
  119658. /**
  119659. * @hidden
  119660. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  119661. */
  119662. useDiffuseColor: boolean;
  119663. /**
  119664. * Array containing the excluded meshes not rendered in the internal pass
  119665. */
  119666. excludedMeshes: AbstractMesh[];
  119667. /**
  119668. * Controls the overall intensity of the post-process
  119669. */
  119670. exposure: number;
  119671. /**
  119672. * Dissipates each sample's contribution in range [0, 1]
  119673. */
  119674. decay: number;
  119675. /**
  119676. * Controls the overall intensity of each sample
  119677. */
  119678. weight: number;
  119679. /**
  119680. * Controls the density of each sample
  119681. */
  119682. density: number;
  119683. /**
  119684. * @constructor
  119685. * @param name The post-process name
  119686. * @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)
  119687. * @param camera The camera that the post-process will be attached to
  119688. * @param mesh The mesh used to create the light scattering
  119689. * @param samples The post-process quality, default 100
  119690. * @param samplingModeThe post-process filtering mode
  119691. * @param engine The babylon engine
  119692. * @param reusable If the post-process is reusable
  119693. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  119694. */
  119695. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  119696. /**
  119697. * Returns the string "VolumetricLightScatteringPostProcess"
  119698. * @returns "VolumetricLightScatteringPostProcess"
  119699. */
  119700. getClassName(): string;
  119701. private _isReady;
  119702. /**
  119703. * Sets the new light position for light scattering effect
  119704. * @param position The new custom light position
  119705. */
  119706. setCustomMeshPosition(position: Vector3): void;
  119707. /**
  119708. * Returns the light position for light scattering effect
  119709. * @return Vector3 The custom light position
  119710. */
  119711. getCustomMeshPosition(): Vector3;
  119712. /**
  119713. * Disposes the internal assets and detaches the post-process from the camera
  119714. */
  119715. dispose(camera: Camera): void;
  119716. /**
  119717. * Returns the render target texture used by the post-process
  119718. * @return the render target texture used by the post-process
  119719. */
  119720. getPass(): RenderTargetTexture;
  119721. private _meshExcluded;
  119722. private _createPass;
  119723. private _updateMeshScreenCoordinates;
  119724. /**
  119725. * Creates a default mesh for the Volumeric Light Scattering post-process
  119726. * @param name The mesh name
  119727. * @param scene The scene where to create the mesh
  119728. * @return the default mesh
  119729. */
  119730. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  119731. }
  119732. }
  119733. declare module BABYLON {
  119734. interface Scene {
  119735. /** @hidden (Backing field) */
  119736. _boundingBoxRenderer: BoundingBoxRenderer;
  119737. /** @hidden (Backing field) */
  119738. _forceShowBoundingBoxes: boolean;
  119739. /**
  119740. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  119741. */
  119742. forceShowBoundingBoxes: boolean;
  119743. /**
  119744. * Gets the bounding box renderer associated with the scene
  119745. * @returns a BoundingBoxRenderer
  119746. */
  119747. getBoundingBoxRenderer(): BoundingBoxRenderer;
  119748. }
  119749. interface AbstractMesh {
  119750. /** @hidden (Backing field) */
  119751. _showBoundingBox: boolean;
  119752. /**
  119753. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  119754. */
  119755. showBoundingBox: boolean;
  119756. }
  119757. /**
  119758. * Component responsible of rendering the bounding box of the meshes in a scene.
  119759. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  119760. */
  119761. export class BoundingBoxRenderer implements ISceneComponent {
  119762. /**
  119763. * The component name helpfull to identify the component in the list of scene components.
  119764. */
  119765. readonly name: string;
  119766. /**
  119767. * The scene the component belongs to.
  119768. */
  119769. scene: Scene;
  119770. /**
  119771. * Color of the bounding box lines placed in front of an object
  119772. */
  119773. frontColor: Color3;
  119774. /**
  119775. * Color of the bounding box lines placed behind an object
  119776. */
  119777. backColor: Color3;
  119778. /**
  119779. * Defines if the renderer should show the back lines or not
  119780. */
  119781. showBackLines: boolean;
  119782. /**
  119783. * @hidden
  119784. */
  119785. renderList: SmartArray<BoundingBox>;
  119786. private _colorShader;
  119787. private _vertexBuffers;
  119788. private _indexBuffer;
  119789. private _fillIndexBuffer;
  119790. private _fillIndexData;
  119791. /**
  119792. * Instantiates a new bounding box renderer in a scene.
  119793. * @param scene the scene the renderer renders in
  119794. */
  119795. constructor(scene: Scene);
  119796. /**
  119797. * Registers the component in a given scene
  119798. */
  119799. register(): void;
  119800. private _evaluateSubMesh;
  119801. private _activeMesh;
  119802. private _prepareRessources;
  119803. private _createIndexBuffer;
  119804. /**
  119805. * Rebuilds the elements related to this component in case of
  119806. * context lost for instance.
  119807. */
  119808. rebuild(): void;
  119809. /**
  119810. * @hidden
  119811. */
  119812. reset(): void;
  119813. /**
  119814. * Render the bounding boxes of a specific rendering group
  119815. * @param renderingGroupId defines the rendering group to render
  119816. */
  119817. render(renderingGroupId: number): void;
  119818. /**
  119819. * In case of occlusion queries, we can render the occlusion bounding box through this method
  119820. * @param mesh Define the mesh to render the occlusion bounding box for
  119821. */
  119822. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  119823. /**
  119824. * Dispose and release the resources attached to this renderer.
  119825. */
  119826. dispose(): void;
  119827. }
  119828. }
  119829. declare module BABYLON {
  119830. /** @hidden */
  119831. export var depthPixelShader: {
  119832. name: string;
  119833. shader: string;
  119834. };
  119835. }
  119836. declare module BABYLON {
  119837. /**
  119838. * This represents a depth renderer in Babylon.
  119839. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  119840. */
  119841. export class DepthRenderer {
  119842. private _scene;
  119843. private _depthMap;
  119844. private _effect;
  119845. private _cachedDefines;
  119846. private _camera;
  119847. /**
  119848. * Specifiess that the depth renderer will only be used within
  119849. * the camera it is created for.
  119850. * This can help forcing its rendering during the camera processing.
  119851. */
  119852. useOnlyInActiveCamera: boolean;
  119853. /** @hidden */
  119854. static _SceneComponentInitialization: (scene: Scene) => void;
  119855. /**
  119856. * Instantiates a depth renderer
  119857. * @param scene The scene the renderer belongs to
  119858. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  119859. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  119860. */
  119861. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  119862. /**
  119863. * Creates the depth rendering effect and checks if the effect is ready.
  119864. * @param subMesh The submesh to be used to render the depth map of
  119865. * @param useInstances If multiple world instances should be used
  119866. * @returns if the depth renderer is ready to render the depth map
  119867. */
  119868. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  119869. /**
  119870. * Gets the texture which the depth map will be written to.
  119871. * @returns The depth map texture
  119872. */
  119873. getDepthMap(): RenderTargetTexture;
  119874. /**
  119875. * Disposes of the depth renderer.
  119876. */
  119877. dispose(): void;
  119878. }
  119879. }
  119880. declare module BABYLON {
  119881. interface Scene {
  119882. /** @hidden (Backing field) */
  119883. _depthRenderer: {
  119884. [id: string]: DepthRenderer;
  119885. };
  119886. /**
  119887. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  119888. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  119889. * @returns the created depth renderer
  119890. */
  119891. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  119892. /**
  119893. * Disables a depth renderer for a given camera
  119894. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  119895. */
  119896. disableDepthRenderer(camera?: Nullable<Camera>): void;
  119897. }
  119898. /**
  119899. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  119900. * in several rendering techniques.
  119901. */
  119902. export class DepthRendererSceneComponent implements ISceneComponent {
  119903. /**
  119904. * The component name helpfull to identify the component in the list of scene components.
  119905. */
  119906. readonly name: string;
  119907. /**
  119908. * The scene the component belongs to.
  119909. */
  119910. scene: Scene;
  119911. /**
  119912. * Creates a new instance of the component for the given scene
  119913. * @param scene Defines the scene to register the component in
  119914. */
  119915. constructor(scene: Scene);
  119916. /**
  119917. * Registers the component in a given scene
  119918. */
  119919. register(): void;
  119920. /**
  119921. * Rebuilds the elements related to this component in case of
  119922. * context lost for instance.
  119923. */
  119924. rebuild(): void;
  119925. /**
  119926. * Disposes the component and the associated ressources
  119927. */
  119928. dispose(): void;
  119929. private _gatherRenderTargets;
  119930. private _gatherActiveCameraRenderTargets;
  119931. }
  119932. }
  119933. declare module BABYLON {
  119934. /** @hidden */
  119935. export var outlinePixelShader: {
  119936. name: string;
  119937. shader: string;
  119938. };
  119939. }
  119940. declare module BABYLON {
  119941. /** @hidden */
  119942. export var outlineVertexShader: {
  119943. name: string;
  119944. shader: string;
  119945. };
  119946. }
  119947. declare module BABYLON {
  119948. interface Scene {
  119949. /** @hidden */
  119950. _outlineRenderer: OutlineRenderer;
  119951. /**
  119952. * Gets the outline renderer associated with the scene
  119953. * @returns a OutlineRenderer
  119954. */
  119955. getOutlineRenderer(): OutlineRenderer;
  119956. }
  119957. interface AbstractMesh {
  119958. /** @hidden (Backing field) */
  119959. _renderOutline: boolean;
  119960. /**
  119961. * Gets or sets a boolean indicating if the outline must be rendered as well
  119962. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  119963. */
  119964. renderOutline: boolean;
  119965. /** @hidden (Backing field) */
  119966. _renderOverlay: boolean;
  119967. /**
  119968. * Gets or sets a boolean indicating if the overlay must be rendered as well
  119969. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  119970. */
  119971. renderOverlay: boolean;
  119972. }
  119973. /**
  119974. * This class is responsible to draw bothe outline/overlay of meshes.
  119975. * It should not be used directly but through the available method on mesh.
  119976. */
  119977. export class OutlineRenderer implements ISceneComponent {
  119978. /**
  119979. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  119980. */
  119981. private static _StencilReference;
  119982. /**
  119983. * The name of the component. Each component must have a unique name.
  119984. */
  119985. name: string;
  119986. /**
  119987. * The scene the component belongs to.
  119988. */
  119989. scene: Scene;
  119990. /**
  119991. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  119992. */
  119993. zOffset: number;
  119994. private _engine;
  119995. private _effect;
  119996. private _cachedDefines;
  119997. private _savedDepthWrite;
  119998. /**
  119999. * Instantiates a new outline renderer. (There could be only one per scene).
  120000. * @param scene Defines the scene it belongs to
  120001. */
  120002. constructor(scene: Scene);
  120003. /**
  120004. * Register the component to one instance of a scene.
  120005. */
  120006. register(): void;
  120007. /**
  120008. * Rebuilds the elements related to this component in case of
  120009. * context lost for instance.
  120010. */
  120011. rebuild(): void;
  120012. /**
  120013. * Disposes the component and the associated ressources.
  120014. */
  120015. dispose(): void;
  120016. /**
  120017. * Renders the outline in the canvas.
  120018. * @param subMesh Defines the sumesh to render
  120019. * @param batch Defines the batch of meshes in case of instances
  120020. * @param useOverlay Defines if the rendering is for the overlay or the outline
  120021. */
  120022. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  120023. /**
  120024. * Returns whether or not the outline renderer is ready for a given submesh.
  120025. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  120026. * @param subMesh Defines the submesh to check readyness for
  120027. * @param useInstances Defines wheter wee are trying to render instances or not
  120028. * @returns true if ready otherwise false
  120029. */
  120030. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  120031. private _beforeRenderingMesh;
  120032. private _afterRenderingMesh;
  120033. }
  120034. }
  120035. declare module BABYLON {
  120036. /**
  120037. * Defines the list of states available for a task inside a AssetsManager
  120038. */
  120039. export enum AssetTaskState {
  120040. /**
  120041. * Initialization
  120042. */
  120043. INIT = 0,
  120044. /**
  120045. * Running
  120046. */
  120047. RUNNING = 1,
  120048. /**
  120049. * Done
  120050. */
  120051. DONE = 2,
  120052. /**
  120053. * Error
  120054. */
  120055. ERROR = 3
  120056. }
  120057. /**
  120058. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  120059. */
  120060. export abstract class AbstractAssetTask {
  120061. /**
  120062. * Task name
  120063. */ name: string;
  120064. /**
  120065. * Callback called when the task is successful
  120066. */
  120067. onSuccess: (task: any) => void;
  120068. /**
  120069. * Callback called when the task is not successful
  120070. */
  120071. onError: (task: any, message?: string, exception?: any) => void;
  120072. /**
  120073. * Creates a new AssetsManager
  120074. * @param name defines the name of the task
  120075. */
  120076. constructor(
  120077. /**
  120078. * Task name
  120079. */ name: string);
  120080. private _isCompleted;
  120081. private _taskState;
  120082. private _errorObject;
  120083. /**
  120084. * Get if the task is completed
  120085. */
  120086. readonly isCompleted: boolean;
  120087. /**
  120088. * Gets the current state of the task
  120089. */
  120090. readonly taskState: AssetTaskState;
  120091. /**
  120092. * Gets the current error object (if task is in error)
  120093. */
  120094. readonly errorObject: {
  120095. message?: string;
  120096. exception?: any;
  120097. };
  120098. /**
  120099. * Internal only
  120100. * @hidden
  120101. */
  120102. _setErrorObject(message?: string, exception?: any): void;
  120103. /**
  120104. * Execute the current task
  120105. * @param scene defines the scene where you want your assets to be loaded
  120106. * @param onSuccess is a callback called when the task is successfully executed
  120107. * @param onError is a callback called if an error occurs
  120108. */
  120109. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120110. /**
  120111. * Execute the current task
  120112. * @param scene defines the scene where you want your assets to be loaded
  120113. * @param onSuccess is a callback called when the task is successfully executed
  120114. * @param onError is a callback called if an error occurs
  120115. */
  120116. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120117. /**
  120118. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  120119. * This can be used with failed tasks that have the reason for failure fixed.
  120120. */
  120121. reset(): void;
  120122. private onErrorCallback;
  120123. private onDoneCallback;
  120124. }
  120125. /**
  120126. * Define the interface used by progress events raised during assets loading
  120127. */
  120128. export interface IAssetsProgressEvent {
  120129. /**
  120130. * Defines the number of remaining tasks to process
  120131. */
  120132. remainingCount: number;
  120133. /**
  120134. * Defines the total number of tasks
  120135. */
  120136. totalCount: number;
  120137. /**
  120138. * Defines the task that was just processed
  120139. */
  120140. task: AbstractAssetTask;
  120141. }
  120142. /**
  120143. * Class used to share progress information about assets loading
  120144. */
  120145. export class AssetsProgressEvent implements IAssetsProgressEvent {
  120146. /**
  120147. * Defines the number of remaining tasks to process
  120148. */
  120149. remainingCount: number;
  120150. /**
  120151. * Defines the total number of tasks
  120152. */
  120153. totalCount: number;
  120154. /**
  120155. * Defines the task that was just processed
  120156. */
  120157. task: AbstractAssetTask;
  120158. /**
  120159. * Creates a AssetsProgressEvent
  120160. * @param remainingCount defines the number of remaining tasks to process
  120161. * @param totalCount defines the total number of tasks
  120162. * @param task defines the task that was just processed
  120163. */
  120164. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  120165. }
  120166. /**
  120167. * Define a task used by AssetsManager to load meshes
  120168. */
  120169. export class MeshAssetTask extends AbstractAssetTask {
  120170. /**
  120171. * Defines the name of the task
  120172. */
  120173. name: string;
  120174. /**
  120175. * Defines the list of mesh's names you want to load
  120176. */
  120177. meshesNames: any;
  120178. /**
  120179. * Defines the root url to use as a base to load your meshes and associated resources
  120180. */
  120181. rootUrl: string;
  120182. /**
  120183. * Defines the filename of the scene to load from
  120184. */
  120185. sceneFilename: string;
  120186. /**
  120187. * Gets the list of loaded meshes
  120188. */
  120189. loadedMeshes: Array<AbstractMesh>;
  120190. /**
  120191. * Gets the list of loaded particle systems
  120192. */
  120193. loadedParticleSystems: Array<IParticleSystem>;
  120194. /**
  120195. * Gets the list of loaded skeletons
  120196. */
  120197. loadedSkeletons: Array<Skeleton>;
  120198. /**
  120199. * Gets the list of loaded animation groups
  120200. */
  120201. loadedAnimationGroups: Array<AnimationGroup>;
  120202. /**
  120203. * Callback called when the task is successful
  120204. */
  120205. onSuccess: (task: MeshAssetTask) => void;
  120206. /**
  120207. * Callback called when the task is successful
  120208. */
  120209. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  120210. /**
  120211. * Creates a new MeshAssetTask
  120212. * @param name defines the name of the task
  120213. * @param meshesNames defines the list of mesh's names you want to load
  120214. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  120215. * @param sceneFilename defines the filename of the scene to load from
  120216. */
  120217. constructor(
  120218. /**
  120219. * Defines the name of the task
  120220. */
  120221. name: string,
  120222. /**
  120223. * Defines the list of mesh's names you want to load
  120224. */
  120225. meshesNames: any,
  120226. /**
  120227. * Defines the root url to use as a base to load your meshes and associated resources
  120228. */
  120229. rootUrl: string,
  120230. /**
  120231. * Defines the filename of the scene to load from
  120232. */
  120233. sceneFilename: string);
  120234. /**
  120235. * Execute the current task
  120236. * @param scene defines the scene where you want your assets to be loaded
  120237. * @param onSuccess is a callback called when the task is successfully executed
  120238. * @param onError is a callback called if an error occurs
  120239. */
  120240. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120241. }
  120242. /**
  120243. * Define a task used by AssetsManager to load text content
  120244. */
  120245. export class TextFileAssetTask extends AbstractAssetTask {
  120246. /**
  120247. * Defines the name of the task
  120248. */
  120249. name: string;
  120250. /**
  120251. * Defines the location of the file to load
  120252. */
  120253. url: string;
  120254. /**
  120255. * Gets the loaded text string
  120256. */
  120257. text: string;
  120258. /**
  120259. * Callback called when the task is successful
  120260. */
  120261. onSuccess: (task: TextFileAssetTask) => void;
  120262. /**
  120263. * Callback called when the task is successful
  120264. */
  120265. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  120266. /**
  120267. * Creates a new TextFileAssetTask object
  120268. * @param name defines the name of the task
  120269. * @param url defines the location of the file to load
  120270. */
  120271. constructor(
  120272. /**
  120273. * Defines the name of the task
  120274. */
  120275. name: string,
  120276. /**
  120277. * Defines the location of the file to load
  120278. */
  120279. url: string);
  120280. /**
  120281. * Execute the current task
  120282. * @param scene defines the scene where you want your assets to be loaded
  120283. * @param onSuccess is a callback called when the task is successfully executed
  120284. * @param onError is a callback called if an error occurs
  120285. */
  120286. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120287. }
  120288. /**
  120289. * Define a task used by AssetsManager to load binary data
  120290. */
  120291. export class BinaryFileAssetTask extends AbstractAssetTask {
  120292. /**
  120293. * Defines the name of the task
  120294. */
  120295. name: string;
  120296. /**
  120297. * Defines the location of the file to load
  120298. */
  120299. url: string;
  120300. /**
  120301. * Gets the lodaded data (as an array buffer)
  120302. */
  120303. data: ArrayBuffer;
  120304. /**
  120305. * Callback called when the task is successful
  120306. */
  120307. onSuccess: (task: BinaryFileAssetTask) => void;
  120308. /**
  120309. * Callback called when the task is successful
  120310. */
  120311. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  120312. /**
  120313. * Creates a new BinaryFileAssetTask object
  120314. * @param name defines the name of the new task
  120315. * @param url defines the location of the file to load
  120316. */
  120317. constructor(
  120318. /**
  120319. * Defines the name of the task
  120320. */
  120321. name: string,
  120322. /**
  120323. * Defines the location of the file to load
  120324. */
  120325. url: string);
  120326. /**
  120327. * Execute the current task
  120328. * @param scene defines the scene where you want your assets to be loaded
  120329. * @param onSuccess is a callback called when the task is successfully executed
  120330. * @param onError is a callback called if an error occurs
  120331. */
  120332. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120333. }
  120334. /**
  120335. * Define a task used by AssetsManager to load images
  120336. */
  120337. export class ImageAssetTask extends AbstractAssetTask {
  120338. /**
  120339. * Defines the name of the task
  120340. */
  120341. name: string;
  120342. /**
  120343. * Defines the location of the image to load
  120344. */
  120345. url: string;
  120346. /**
  120347. * Gets the loaded images
  120348. */
  120349. image: HTMLImageElement;
  120350. /**
  120351. * Callback called when the task is successful
  120352. */
  120353. onSuccess: (task: ImageAssetTask) => void;
  120354. /**
  120355. * Callback called when the task is successful
  120356. */
  120357. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  120358. /**
  120359. * Creates a new ImageAssetTask
  120360. * @param name defines the name of the task
  120361. * @param url defines the location of the image to load
  120362. */
  120363. constructor(
  120364. /**
  120365. * Defines the name of the task
  120366. */
  120367. name: string,
  120368. /**
  120369. * Defines the location of the image to load
  120370. */
  120371. url: string);
  120372. /**
  120373. * Execute the current task
  120374. * @param scene defines the scene where you want your assets to be loaded
  120375. * @param onSuccess is a callback called when the task is successfully executed
  120376. * @param onError is a callback called if an error occurs
  120377. */
  120378. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120379. }
  120380. /**
  120381. * Defines the interface used by texture loading tasks
  120382. */
  120383. export interface ITextureAssetTask<TEX extends BaseTexture> {
  120384. /**
  120385. * Gets the loaded texture
  120386. */
  120387. texture: TEX;
  120388. }
  120389. /**
  120390. * Define a task used by AssetsManager to load 2D textures
  120391. */
  120392. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  120393. /**
  120394. * Defines the name of the task
  120395. */
  120396. name: string;
  120397. /**
  120398. * Defines the location of the file to load
  120399. */
  120400. url: string;
  120401. /**
  120402. * Defines if mipmap should not be generated (default is false)
  120403. */
  120404. noMipmap?: boolean | undefined;
  120405. /**
  120406. * Defines if texture must be inverted on Y axis (default is false)
  120407. */
  120408. invertY?: boolean | undefined;
  120409. /**
  120410. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  120411. */
  120412. samplingMode: number;
  120413. /**
  120414. * Gets the loaded texture
  120415. */
  120416. texture: Texture;
  120417. /**
  120418. * Callback called when the task is successful
  120419. */
  120420. onSuccess: (task: TextureAssetTask) => void;
  120421. /**
  120422. * Callback called when the task is successful
  120423. */
  120424. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  120425. /**
  120426. * Creates a new TextureAssetTask object
  120427. * @param name defines the name of the task
  120428. * @param url defines the location of the file to load
  120429. * @param noMipmap defines if mipmap should not be generated (default is false)
  120430. * @param invertY defines if texture must be inverted on Y axis (default is false)
  120431. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  120432. */
  120433. constructor(
  120434. /**
  120435. * Defines the name of the task
  120436. */
  120437. name: string,
  120438. /**
  120439. * Defines the location of the file to load
  120440. */
  120441. url: string,
  120442. /**
  120443. * Defines if mipmap should not be generated (default is false)
  120444. */
  120445. noMipmap?: boolean | undefined,
  120446. /**
  120447. * Defines if texture must be inverted on Y axis (default is false)
  120448. */
  120449. invertY?: boolean | undefined,
  120450. /**
  120451. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  120452. */
  120453. samplingMode?: number);
  120454. /**
  120455. * Execute the current task
  120456. * @param scene defines the scene where you want your assets to be loaded
  120457. * @param onSuccess is a callback called when the task is successfully executed
  120458. * @param onError is a callback called if an error occurs
  120459. */
  120460. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120461. }
  120462. /**
  120463. * Define a task used by AssetsManager to load cube textures
  120464. */
  120465. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  120466. /**
  120467. * Defines the name of the task
  120468. */
  120469. name: string;
  120470. /**
  120471. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  120472. */
  120473. url: string;
  120474. /**
  120475. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  120476. */
  120477. extensions?: string[] | undefined;
  120478. /**
  120479. * Defines if mipmaps should not be generated (default is false)
  120480. */
  120481. noMipmap?: boolean | undefined;
  120482. /**
  120483. * Defines the explicit list of files (undefined by default)
  120484. */
  120485. files?: string[] | undefined;
  120486. /**
  120487. * Gets the loaded texture
  120488. */
  120489. texture: CubeTexture;
  120490. /**
  120491. * Callback called when the task is successful
  120492. */
  120493. onSuccess: (task: CubeTextureAssetTask) => void;
  120494. /**
  120495. * Callback called when the task is successful
  120496. */
  120497. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  120498. /**
  120499. * Creates a new CubeTextureAssetTask
  120500. * @param name defines the name of the task
  120501. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  120502. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  120503. * @param noMipmap defines if mipmaps should not be generated (default is false)
  120504. * @param files defines the explicit list of files (undefined by default)
  120505. */
  120506. constructor(
  120507. /**
  120508. * Defines the name of the task
  120509. */
  120510. name: string,
  120511. /**
  120512. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  120513. */
  120514. url: string,
  120515. /**
  120516. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  120517. */
  120518. extensions?: string[] | undefined,
  120519. /**
  120520. * Defines if mipmaps should not be generated (default is false)
  120521. */
  120522. noMipmap?: boolean | undefined,
  120523. /**
  120524. * Defines the explicit list of files (undefined by default)
  120525. */
  120526. files?: string[] | undefined);
  120527. /**
  120528. * Execute the current task
  120529. * @param scene defines the scene where you want your assets to be loaded
  120530. * @param onSuccess is a callback called when the task is successfully executed
  120531. * @param onError is a callback called if an error occurs
  120532. */
  120533. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120534. }
  120535. /**
  120536. * Define a task used by AssetsManager to load HDR cube textures
  120537. */
  120538. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  120539. /**
  120540. * Defines the name of the task
  120541. */
  120542. name: string;
  120543. /**
  120544. * Defines the location of the file to load
  120545. */
  120546. url: string;
  120547. /**
  120548. * Defines the desired size (the more it increases the longer the generation will be)
  120549. */
  120550. size: number;
  120551. /**
  120552. * Defines if mipmaps should not be generated (default is false)
  120553. */
  120554. noMipmap: boolean;
  120555. /**
  120556. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  120557. */
  120558. generateHarmonics: boolean;
  120559. /**
  120560. * 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)
  120561. */
  120562. gammaSpace: boolean;
  120563. /**
  120564. * Internal Use Only
  120565. */
  120566. reserved: boolean;
  120567. /**
  120568. * Gets the loaded texture
  120569. */
  120570. texture: HDRCubeTexture;
  120571. /**
  120572. * Callback called when the task is successful
  120573. */
  120574. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  120575. /**
  120576. * Callback called when the task is successful
  120577. */
  120578. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  120579. /**
  120580. * Creates a new HDRCubeTextureAssetTask object
  120581. * @param name defines the name of the task
  120582. * @param url defines the location of the file to load
  120583. * @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.
  120584. * @param noMipmap defines if mipmaps should not be generated (default is false)
  120585. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  120586. * @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)
  120587. * @param reserved Internal use only
  120588. */
  120589. constructor(
  120590. /**
  120591. * Defines the name of the task
  120592. */
  120593. name: string,
  120594. /**
  120595. * Defines the location of the file to load
  120596. */
  120597. url: string,
  120598. /**
  120599. * Defines the desired size (the more it increases the longer the generation will be)
  120600. */
  120601. size: number,
  120602. /**
  120603. * Defines if mipmaps should not be generated (default is false)
  120604. */
  120605. noMipmap?: boolean,
  120606. /**
  120607. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  120608. */
  120609. generateHarmonics?: boolean,
  120610. /**
  120611. * 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)
  120612. */
  120613. gammaSpace?: boolean,
  120614. /**
  120615. * Internal Use Only
  120616. */
  120617. reserved?: boolean);
  120618. /**
  120619. * Execute the current task
  120620. * @param scene defines the scene where you want your assets to be loaded
  120621. * @param onSuccess is a callback called when the task is successfully executed
  120622. * @param onError is a callback called if an error occurs
  120623. */
  120624. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120625. }
  120626. /**
  120627. * Define a task used by AssetsManager to load Equirectangular cube textures
  120628. */
  120629. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  120630. /**
  120631. * Defines the name of the task
  120632. */
  120633. name: string;
  120634. /**
  120635. * Defines the location of the file to load
  120636. */
  120637. url: string;
  120638. /**
  120639. * Defines the desired size (the more it increases the longer the generation will be)
  120640. */
  120641. size: number;
  120642. /**
  120643. * Defines if mipmaps should not be generated (default is false)
  120644. */
  120645. noMipmap: boolean;
  120646. /**
  120647. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  120648. * but the standard material would require them in Gamma space) (default is true)
  120649. */
  120650. gammaSpace: boolean;
  120651. /**
  120652. * Gets the loaded texture
  120653. */
  120654. texture: EquiRectangularCubeTexture;
  120655. /**
  120656. * Callback called when the task is successful
  120657. */
  120658. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  120659. /**
  120660. * Callback called when the task is successful
  120661. */
  120662. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  120663. /**
  120664. * Creates a new EquiRectangularCubeTextureAssetTask object
  120665. * @param name defines the name of the task
  120666. * @param url defines the location of the file to load
  120667. * @param size defines the desired size (the more it increases the longer the generation will be)
  120668. * If the size is omitted this implies you are using a preprocessed cubemap.
  120669. * @param noMipmap defines if mipmaps should not be generated (default is false)
  120670. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  120671. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  120672. * (default is true)
  120673. */
  120674. constructor(
  120675. /**
  120676. * Defines the name of the task
  120677. */
  120678. name: string,
  120679. /**
  120680. * Defines the location of the file to load
  120681. */
  120682. url: string,
  120683. /**
  120684. * Defines the desired size (the more it increases the longer the generation will be)
  120685. */
  120686. size: number,
  120687. /**
  120688. * Defines if mipmaps should not be generated (default is false)
  120689. */
  120690. noMipmap?: boolean,
  120691. /**
  120692. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  120693. * but the standard material would require them in Gamma space) (default is true)
  120694. */
  120695. gammaSpace?: boolean);
  120696. /**
  120697. * Execute the current task
  120698. * @param scene defines the scene where you want your assets to be loaded
  120699. * @param onSuccess is a callback called when the task is successfully executed
  120700. * @param onError is a callback called if an error occurs
  120701. */
  120702. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120703. }
  120704. /**
  120705. * This class can be used to easily import assets into a scene
  120706. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  120707. */
  120708. export class AssetsManager {
  120709. private _scene;
  120710. private _isLoading;
  120711. protected _tasks: AbstractAssetTask[];
  120712. protected _waitingTasksCount: number;
  120713. protected _totalTasksCount: number;
  120714. /**
  120715. * Callback called when all tasks are processed
  120716. */
  120717. onFinish: (tasks: AbstractAssetTask[]) => void;
  120718. /**
  120719. * Callback called when a task is successful
  120720. */
  120721. onTaskSuccess: (task: AbstractAssetTask) => void;
  120722. /**
  120723. * Callback called when a task had an error
  120724. */
  120725. onTaskError: (task: AbstractAssetTask) => void;
  120726. /**
  120727. * Callback called when a task is done (whatever the result is)
  120728. */
  120729. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  120730. /**
  120731. * Observable called when all tasks are processed
  120732. */
  120733. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  120734. /**
  120735. * Observable called when a task had an error
  120736. */
  120737. onTaskErrorObservable: Observable<AbstractAssetTask>;
  120738. /**
  120739. * Observable called when all tasks were executed
  120740. */
  120741. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  120742. /**
  120743. * Observable called when a task is done (whatever the result is)
  120744. */
  120745. onProgressObservable: Observable<IAssetsProgressEvent>;
  120746. /**
  120747. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  120748. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  120749. */
  120750. useDefaultLoadingScreen: boolean;
  120751. /**
  120752. * Creates a new AssetsManager
  120753. * @param scene defines the scene to work on
  120754. */
  120755. constructor(scene: Scene);
  120756. /**
  120757. * Add a MeshAssetTask to the list of active tasks
  120758. * @param taskName defines the name of the new task
  120759. * @param meshesNames defines the name of meshes to load
  120760. * @param rootUrl defines the root url to use to locate files
  120761. * @param sceneFilename defines the filename of the scene file
  120762. * @returns a new MeshAssetTask object
  120763. */
  120764. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  120765. /**
  120766. * Add a TextFileAssetTask to the list of active tasks
  120767. * @param taskName defines the name of the new task
  120768. * @param url defines the url of the file to load
  120769. * @returns a new TextFileAssetTask object
  120770. */
  120771. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  120772. /**
  120773. * Add a BinaryFileAssetTask to the list of active tasks
  120774. * @param taskName defines the name of the new task
  120775. * @param url defines the url of the file to load
  120776. * @returns a new BinaryFileAssetTask object
  120777. */
  120778. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  120779. /**
  120780. * Add a ImageAssetTask to the list of active tasks
  120781. * @param taskName defines the name of the new task
  120782. * @param url defines the url of the file to load
  120783. * @returns a new ImageAssetTask object
  120784. */
  120785. addImageTask(taskName: string, url: string): ImageAssetTask;
  120786. /**
  120787. * Add a TextureAssetTask to the list of active tasks
  120788. * @param taskName defines the name of the new task
  120789. * @param url defines the url of the file to load
  120790. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  120791. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  120792. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  120793. * @returns a new TextureAssetTask object
  120794. */
  120795. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  120796. /**
  120797. * Add a CubeTextureAssetTask to the list of active tasks
  120798. * @param taskName defines the name of the new task
  120799. * @param url defines the url of the file to load
  120800. * @param extensions defines the extension to use to load the cube map (can be null)
  120801. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  120802. * @param files defines the list of files to load (can be null)
  120803. * @returns a new CubeTextureAssetTask object
  120804. */
  120805. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  120806. /**
  120807. *
  120808. * Add a HDRCubeTextureAssetTask to the list of active tasks
  120809. * @param taskName defines the name of the new task
  120810. * @param url defines the url of the file to load
  120811. * @param size defines the size you want for the cubemap (can be null)
  120812. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  120813. * @param generateHarmonics defines if you want to automatically generate (true by default)
  120814. * @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)
  120815. * @param reserved Internal use only
  120816. * @returns a new HDRCubeTextureAssetTask object
  120817. */
  120818. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  120819. /**
  120820. *
  120821. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  120822. * @param taskName defines the name of the new task
  120823. * @param url defines the url of the file to load
  120824. * @param size defines the size you want for the cubemap (can be null)
  120825. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  120826. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  120827. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  120828. * @returns a new EquiRectangularCubeTextureAssetTask object
  120829. */
  120830. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  120831. /**
  120832. * Remove a task from the assets manager.
  120833. * @param task the task to remove
  120834. */
  120835. removeTask(task: AbstractAssetTask): void;
  120836. private _decreaseWaitingTasksCount;
  120837. private _runTask;
  120838. /**
  120839. * Reset the AssetsManager and remove all tasks
  120840. * @return the current instance of the AssetsManager
  120841. */
  120842. reset(): AssetsManager;
  120843. /**
  120844. * Start the loading process
  120845. * @return the current instance of the AssetsManager
  120846. */
  120847. load(): AssetsManager;
  120848. /**
  120849. * Start the loading process as an async operation
  120850. * @return a promise returning the list of failed tasks
  120851. */
  120852. loadAsync(): Promise<void>;
  120853. }
  120854. }
  120855. declare module BABYLON {
  120856. /**
  120857. * Wrapper class for promise with external resolve and reject.
  120858. */
  120859. export class Deferred<T> {
  120860. /**
  120861. * The promise associated with this deferred object.
  120862. */
  120863. readonly promise: Promise<T>;
  120864. private _resolve;
  120865. private _reject;
  120866. /**
  120867. * The resolve method of the promise associated with this deferred object.
  120868. */
  120869. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  120870. /**
  120871. * The reject method of the promise associated with this deferred object.
  120872. */
  120873. readonly reject: (reason?: any) => void;
  120874. /**
  120875. * Constructor for this deferred object.
  120876. */
  120877. constructor();
  120878. }
  120879. }
  120880. declare module BABYLON {
  120881. /**
  120882. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  120883. */
  120884. export class MeshExploder {
  120885. private _centerMesh;
  120886. private _meshes;
  120887. private _meshesOrigins;
  120888. private _toCenterVectors;
  120889. private _scaledDirection;
  120890. private _newPosition;
  120891. private _centerPosition;
  120892. /**
  120893. * Explodes meshes from a center mesh.
  120894. * @param meshes The meshes to explode.
  120895. * @param centerMesh The mesh to be center of explosion.
  120896. */
  120897. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  120898. private _setCenterMesh;
  120899. /**
  120900. * Get class name
  120901. * @returns "MeshExploder"
  120902. */
  120903. getClassName(): string;
  120904. /**
  120905. * "Exploded meshes"
  120906. * @returns Array of meshes with the centerMesh at index 0.
  120907. */
  120908. getMeshes(): Array<Mesh>;
  120909. /**
  120910. * Explodes meshes giving a specific direction
  120911. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  120912. */
  120913. explode(direction?: number): void;
  120914. }
  120915. }
  120916. declare module BABYLON {
  120917. /**
  120918. * Class used to help managing file picking and drag'n'drop
  120919. */
  120920. export class FilesInput {
  120921. /**
  120922. * List of files ready to be loaded
  120923. */
  120924. static readonly FilesToLoad: {
  120925. [key: string]: File;
  120926. };
  120927. /**
  120928. * Callback called when a file is processed
  120929. */
  120930. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  120931. private _engine;
  120932. private _currentScene;
  120933. private _sceneLoadedCallback;
  120934. private _progressCallback;
  120935. private _additionalRenderLoopLogicCallback;
  120936. private _textureLoadingCallback;
  120937. private _startingProcessingFilesCallback;
  120938. private _onReloadCallback;
  120939. private _errorCallback;
  120940. private _elementToMonitor;
  120941. private _sceneFileToLoad;
  120942. private _filesToLoad;
  120943. /**
  120944. * Creates a new FilesInput
  120945. * @param engine defines the rendering engine
  120946. * @param scene defines the hosting scene
  120947. * @param sceneLoadedCallback callback called when scene is loaded
  120948. * @param progressCallback callback called to track progress
  120949. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  120950. * @param textureLoadingCallback callback called when a texture is loading
  120951. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  120952. * @param onReloadCallback callback called when a reload is requested
  120953. * @param errorCallback callback call if an error occurs
  120954. */
  120955. 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);
  120956. private _dragEnterHandler;
  120957. private _dragOverHandler;
  120958. private _dropHandler;
  120959. /**
  120960. * Calls this function to listen to drag'n'drop events on a specific DOM element
  120961. * @param elementToMonitor defines the DOM element to track
  120962. */
  120963. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  120964. /**
  120965. * Release all associated resources
  120966. */
  120967. dispose(): void;
  120968. private renderFunction;
  120969. private drag;
  120970. private drop;
  120971. private _traverseFolder;
  120972. private _processFiles;
  120973. /**
  120974. * Load files from a drop event
  120975. * @param event defines the drop event to use as source
  120976. */
  120977. loadFiles(event: any): void;
  120978. private _processReload;
  120979. /**
  120980. * Reload the current scene from the loaded files
  120981. */
  120982. reload(): void;
  120983. }
  120984. }
  120985. declare module BABYLON {
  120986. /**
  120987. * Defines the root class used to create scene optimization to use with SceneOptimizer
  120988. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  120989. */
  120990. export class SceneOptimization {
  120991. /**
  120992. * Defines the priority of this optimization (0 by default which means first in the list)
  120993. */
  120994. priority: number;
  120995. /**
  120996. * Gets a string describing the action executed by the current optimization
  120997. * @returns description string
  120998. */
  120999. getDescription(): string;
  121000. /**
  121001. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121002. * @param scene defines the current scene where to apply this optimization
  121003. * @param optimizer defines the current optimizer
  121004. * @returns true if everything that can be done was applied
  121005. */
  121006. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121007. /**
  121008. * Creates the SceneOptimization object
  121009. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  121010. * @param desc defines the description associated with the optimization
  121011. */
  121012. constructor(
  121013. /**
  121014. * Defines the priority of this optimization (0 by default which means first in the list)
  121015. */
  121016. priority?: number);
  121017. }
  121018. /**
  121019. * Defines an optimization used to reduce the size of render target textures
  121020. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121021. */
  121022. export class TextureOptimization extends SceneOptimization {
  121023. /**
  121024. * Defines the priority of this optimization (0 by default which means first in the list)
  121025. */
  121026. priority: number;
  121027. /**
  121028. * 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
  121029. */
  121030. maximumSize: number;
  121031. /**
  121032. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  121033. */
  121034. step: number;
  121035. /**
  121036. * Gets a string describing the action executed by the current optimization
  121037. * @returns description string
  121038. */
  121039. getDescription(): string;
  121040. /**
  121041. * Creates the TextureOptimization object
  121042. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  121043. * @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
  121044. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  121045. */
  121046. constructor(
  121047. /**
  121048. * Defines the priority of this optimization (0 by default which means first in the list)
  121049. */
  121050. priority?: number,
  121051. /**
  121052. * 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
  121053. */
  121054. maximumSize?: number,
  121055. /**
  121056. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  121057. */
  121058. step?: number);
  121059. /**
  121060. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121061. * @param scene defines the current scene where to apply this optimization
  121062. * @param optimizer defines the current optimizer
  121063. * @returns true if everything that can be done was applied
  121064. */
  121065. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121066. }
  121067. /**
  121068. * Defines an optimization used to increase or decrease the rendering resolution
  121069. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121070. */
  121071. export class HardwareScalingOptimization extends SceneOptimization {
  121072. /**
  121073. * Defines the priority of this optimization (0 by default which means first in the list)
  121074. */
  121075. priority: number;
  121076. /**
  121077. * Defines the maximum scale to use (2 by default)
  121078. */
  121079. maximumScale: number;
  121080. /**
  121081. * Defines the step to use between two passes (0.5 by default)
  121082. */
  121083. step: number;
  121084. private _currentScale;
  121085. private _directionOffset;
  121086. /**
  121087. * Gets a string describing the action executed by the current optimization
  121088. * @return description string
  121089. */
  121090. getDescription(): string;
  121091. /**
  121092. * Creates the HardwareScalingOptimization object
  121093. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  121094. * @param maximumScale defines the maximum scale to use (2 by default)
  121095. * @param step defines the step to use between two passes (0.5 by default)
  121096. */
  121097. constructor(
  121098. /**
  121099. * Defines the priority of this optimization (0 by default which means first in the list)
  121100. */
  121101. priority?: number,
  121102. /**
  121103. * Defines the maximum scale to use (2 by default)
  121104. */
  121105. maximumScale?: number,
  121106. /**
  121107. * Defines the step to use between two passes (0.5 by default)
  121108. */
  121109. step?: number);
  121110. /**
  121111. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121112. * @param scene defines the current scene where to apply this optimization
  121113. * @param optimizer defines the current optimizer
  121114. * @returns true if everything that can be done was applied
  121115. */
  121116. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121117. }
  121118. /**
  121119. * Defines an optimization used to remove shadows
  121120. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121121. */
  121122. export class ShadowsOptimization extends SceneOptimization {
  121123. /**
  121124. * Gets a string describing the action executed by the current optimization
  121125. * @return description string
  121126. */
  121127. getDescription(): string;
  121128. /**
  121129. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121130. * @param scene defines the current scene where to apply this optimization
  121131. * @param optimizer defines the current optimizer
  121132. * @returns true if everything that can be done was applied
  121133. */
  121134. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121135. }
  121136. /**
  121137. * Defines an optimization used to turn post-processes off
  121138. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121139. */
  121140. export class PostProcessesOptimization extends SceneOptimization {
  121141. /**
  121142. * Gets a string describing the action executed by the current optimization
  121143. * @return description string
  121144. */
  121145. getDescription(): string;
  121146. /**
  121147. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121148. * @param scene defines the current scene where to apply this optimization
  121149. * @param optimizer defines the current optimizer
  121150. * @returns true if everything that can be done was applied
  121151. */
  121152. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121153. }
  121154. /**
  121155. * Defines an optimization used to turn lens flares off
  121156. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121157. */
  121158. export class LensFlaresOptimization extends SceneOptimization {
  121159. /**
  121160. * Gets a string describing the action executed by the current optimization
  121161. * @return description string
  121162. */
  121163. getDescription(): string;
  121164. /**
  121165. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121166. * @param scene defines the current scene where to apply this optimization
  121167. * @param optimizer defines the current optimizer
  121168. * @returns true if everything that can be done was applied
  121169. */
  121170. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121171. }
  121172. /**
  121173. * Defines an optimization based on user defined callback.
  121174. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121175. */
  121176. export class CustomOptimization extends SceneOptimization {
  121177. /**
  121178. * Callback called to apply the custom optimization.
  121179. */
  121180. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  121181. /**
  121182. * Callback called to get custom description
  121183. */
  121184. onGetDescription: () => string;
  121185. /**
  121186. * Gets a string describing the action executed by the current optimization
  121187. * @returns description string
  121188. */
  121189. getDescription(): string;
  121190. /**
  121191. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121192. * @param scene defines the current scene where to apply this optimization
  121193. * @param optimizer defines the current optimizer
  121194. * @returns true if everything that can be done was applied
  121195. */
  121196. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121197. }
  121198. /**
  121199. * Defines an optimization used to turn particles off
  121200. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121201. */
  121202. export class ParticlesOptimization extends SceneOptimization {
  121203. /**
  121204. * Gets a string describing the action executed by the current optimization
  121205. * @return description string
  121206. */
  121207. getDescription(): string;
  121208. /**
  121209. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121210. * @param scene defines the current scene where to apply this optimization
  121211. * @param optimizer defines the current optimizer
  121212. * @returns true if everything that can be done was applied
  121213. */
  121214. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121215. }
  121216. /**
  121217. * Defines an optimization used to turn render targets off
  121218. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121219. */
  121220. export class RenderTargetsOptimization extends SceneOptimization {
  121221. /**
  121222. * Gets a string describing the action executed by the current optimization
  121223. * @return description string
  121224. */
  121225. getDescription(): string;
  121226. /**
  121227. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121228. * @param scene defines the current scene where to apply this optimization
  121229. * @param optimizer defines the current optimizer
  121230. * @returns true if everything that can be done was applied
  121231. */
  121232. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121233. }
  121234. /**
  121235. * Defines an optimization used to merge meshes with compatible materials
  121236. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121237. */
  121238. export class MergeMeshesOptimization extends SceneOptimization {
  121239. private static _UpdateSelectionTree;
  121240. /**
  121241. * Gets or sets a boolean which defines if optimization octree has to be updated
  121242. */
  121243. /**
  121244. * Gets or sets a boolean which defines if optimization octree has to be updated
  121245. */
  121246. static UpdateSelectionTree: boolean;
  121247. /**
  121248. * Gets a string describing the action executed by the current optimization
  121249. * @return description string
  121250. */
  121251. getDescription(): string;
  121252. private _canBeMerged;
  121253. /**
  121254. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121255. * @param scene defines the current scene where to apply this optimization
  121256. * @param optimizer defines the current optimizer
  121257. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  121258. * @returns true if everything that can be done was applied
  121259. */
  121260. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  121261. }
  121262. /**
  121263. * Defines a list of options used by SceneOptimizer
  121264. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121265. */
  121266. export class SceneOptimizerOptions {
  121267. /**
  121268. * Defines the target frame rate to reach (60 by default)
  121269. */
  121270. targetFrameRate: number;
  121271. /**
  121272. * Defines the interval between two checkes (2000ms by default)
  121273. */
  121274. trackerDuration: number;
  121275. /**
  121276. * Gets the list of optimizations to apply
  121277. */
  121278. optimizations: SceneOptimization[];
  121279. /**
  121280. * Creates a new list of options used by SceneOptimizer
  121281. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  121282. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  121283. */
  121284. constructor(
  121285. /**
  121286. * Defines the target frame rate to reach (60 by default)
  121287. */
  121288. targetFrameRate?: number,
  121289. /**
  121290. * Defines the interval between two checkes (2000ms by default)
  121291. */
  121292. trackerDuration?: number);
  121293. /**
  121294. * Add a new optimization
  121295. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  121296. * @returns the current SceneOptimizerOptions
  121297. */
  121298. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  121299. /**
  121300. * Add a new custom optimization
  121301. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  121302. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  121303. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  121304. * @returns the current SceneOptimizerOptions
  121305. */
  121306. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  121307. /**
  121308. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  121309. * @param targetFrameRate defines the target frame rate (60 by default)
  121310. * @returns a SceneOptimizerOptions object
  121311. */
  121312. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  121313. /**
  121314. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  121315. * @param targetFrameRate defines the target frame rate (60 by default)
  121316. * @returns a SceneOptimizerOptions object
  121317. */
  121318. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  121319. /**
  121320. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  121321. * @param targetFrameRate defines the target frame rate (60 by default)
  121322. * @returns a SceneOptimizerOptions object
  121323. */
  121324. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  121325. }
  121326. /**
  121327. * Class used to run optimizations in order to reach a target frame rate
  121328. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121329. */
  121330. export class SceneOptimizer implements IDisposable {
  121331. private _isRunning;
  121332. private _options;
  121333. private _scene;
  121334. private _currentPriorityLevel;
  121335. private _targetFrameRate;
  121336. private _trackerDuration;
  121337. private _currentFrameRate;
  121338. private _sceneDisposeObserver;
  121339. private _improvementMode;
  121340. /**
  121341. * Defines an observable called when the optimizer reaches the target frame rate
  121342. */
  121343. onSuccessObservable: Observable<SceneOptimizer>;
  121344. /**
  121345. * Defines an observable called when the optimizer enables an optimization
  121346. */
  121347. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  121348. /**
  121349. * Defines an observable called when the optimizer is not able to reach the target frame rate
  121350. */
  121351. onFailureObservable: Observable<SceneOptimizer>;
  121352. /**
  121353. * Gets a boolean indicating if the optimizer is in improvement mode
  121354. */
  121355. readonly isInImprovementMode: boolean;
  121356. /**
  121357. * Gets the current priority level (0 at start)
  121358. */
  121359. readonly currentPriorityLevel: number;
  121360. /**
  121361. * Gets the current frame rate checked by the SceneOptimizer
  121362. */
  121363. readonly currentFrameRate: number;
  121364. /**
  121365. * Gets or sets the current target frame rate (60 by default)
  121366. */
  121367. /**
  121368. * Gets or sets the current target frame rate (60 by default)
  121369. */
  121370. targetFrameRate: number;
  121371. /**
  121372. * Gets or sets the current interval between two checks (every 2000ms by default)
  121373. */
  121374. /**
  121375. * Gets or sets the current interval between two checks (every 2000ms by default)
  121376. */
  121377. trackerDuration: number;
  121378. /**
  121379. * Gets the list of active optimizations
  121380. */
  121381. readonly optimizations: SceneOptimization[];
  121382. /**
  121383. * Creates a new SceneOptimizer
  121384. * @param scene defines the scene to work on
  121385. * @param options defines the options to use with the SceneOptimizer
  121386. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  121387. * @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)
  121388. */
  121389. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  121390. /**
  121391. * Stops the current optimizer
  121392. */
  121393. stop(): void;
  121394. /**
  121395. * Reset the optimizer to initial step (current priority level = 0)
  121396. */
  121397. reset(): void;
  121398. /**
  121399. * Start the optimizer. By default it will try to reach a specific framerate
  121400. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  121401. */
  121402. start(): void;
  121403. private _checkCurrentState;
  121404. /**
  121405. * Release all resources
  121406. */
  121407. dispose(): void;
  121408. /**
  121409. * Helper function to create a SceneOptimizer with one single line of code
  121410. * @param scene defines the scene to work on
  121411. * @param options defines the options to use with the SceneOptimizer
  121412. * @param onSuccess defines a callback to call on success
  121413. * @param onFailure defines a callback to call on failure
  121414. * @returns the new SceneOptimizer object
  121415. */
  121416. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  121417. }
  121418. }
  121419. declare module BABYLON {
  121420. /**
  121421. * Class used to serialize a scene into a string
  121422. */
  121423. export class SceneSerializer {
  121424. /**
  121425. * Clear cache used by a previous serialization
  121426. */
  121427. static ClearCache(): void;
  121428. /**
  121429. * Serialize a scene into a JSON compatible object
  121430. * @param scene defines the scene to serialize
  121431. * @returns a JSON compatible object
  121432. */
  121433. static Serialize(scene: Scene): any;
  121434. /**
  121435. * Serialize a mesh into a JSON compatible object
  121436. * @param toSerialize defines the mesh to serialize
  121437. * @param withParents defines if parents must be serialized as well
  121438. * @param withChildren defines if children must be serialized as well
  121439. * @returns a JSON compatible object
  121440. */
  121441. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  121442. }
  121443. }
  121444. declare module BABYLON {
  121445. /**
  121446. * Class used to host texture specific utilities
  121447. */
  121448. export class TextureTools {
  121449. /**
  121450. * Uses the GPU to create a copy texture rescaled at a given size
  121451. * @param texture Texture to copy from
  121452. * @param width defines the desired width
  121453. * @param height defines the desired height
  121454. * @param useBilinearMode defines if bilinear mode has to be used
  121455. * @return the generated texture
  121456. */
  121457. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  121458. }
  121459. }
  121460. declare module BABYLON {
  121461. /**
  121462. * This represents the different options available for the video capture.
  121463. */
  121464. export interface VideoRecorderOptions {
  121465. /** Defines the mime type of the video. */
  121466. mimeType: string;
  121467. /** Defines the FPS the video should be recorded at. */
  121468. fps: number;
  121469. /** Defines the chunk size for the recording data. */
  121470. recordChunckSize: number;
  121471. /** The audio tracks to attach to the recording. */
  121472. audioTracks?: MediaStreamTrack[];
  121473. }
  121474. /**
  121475. * This can help with recording videos from BabylonJS.
  121476. * This is based on the available WebRTC functionalities of the browser.
  121477. *
  121478. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  121479. */
  121480. export class VideoRecorder {
  121481. private static readonly _defaultOptions;
  121482. /**
  121483. * Returns whether or not the VideoRecorder is available in your browser.
  121484. * @param engine Defines the Babylon Engine.
  121485. * @returns true if supported otherwise false.
  121486. */
  121487. static IsSupported(engine: Engine): boolean;
  121488. private readonly _options;
  121489. private _canvas;
  121490. private _mediaRecorder;
  121491. private _recordedChunks;
  121492. private _fileName;
  121493. private _resolve;
  121494. private _reject;
  121495. /**
  121496. * True when a recording is already in progress.
  121497. */
  121498. readonly isRecording: boolean;
  121499. /**
  121500. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  121501. * @param engine Defines the BabylonJS Engine you wish to record.
  121502. * @param options Defines options that can be used to customize the capture.
  121503. */
  121504. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  121505. /**
  121506. * Stops the current recording before the default capture timeout passed in the startRecording function.
  121507. */
  121508. stopRecording(): void;
  121509. /**
  121510. * Starts recording the canvas for a max duration specified in parameters.
  121511. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  121512. * If null no automatic download will start and you can rely on the promise to get the data back.
  121513. * @param maxDuration Defines the maximum recording time in seconds.
  121514. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  121515. * @return A promise callback at the end of the recording with the video data in Blob.
  121516. */
  121517. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  121518. /**
  121519. * Releases internal resources used during the recording.
  121520. */
  121521. dispose(): void;
  121522. private _handleDataAvailable;
  121523. private _handleError;
  121524. private _handleStop;
  121525. }
  121526. }
  121527. declare module BABYLON {
  121528. /**
  121529. * Class containing a set of static utilities functions for screenshots
  121530. */
  121531. export class ScreenshotTools {
  121532. /**
  121533. * Captures a screenshot of the current rendering
  121534. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  121535. * @param engine defines the rendering engine
  121536. * @param camera defines the source camera
  121537. * @param size This parameter can be set to a single number or to an object with the
  121538. * following (optional) properties: precision, width, height. If a single number is passed,
  121539. * it will be used for both width and height. If an object is passed, the screenshot size
  121540. * will be derived from the parameters. The precision property is a multiplier allowing
  121541. * rendering at a higher or lower resolution
  121542. * @param successCallback defines the callback receives a single parameter which contains the
  121543. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  121544. * src parameter of an <img> to display it
  121545. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  121546. * Check your browser for supported MIME types
  121547. */
  121548. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  121549. /**
  121550. * Generates an image screenshot from the specified camera.
  121551. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  121552. * @param engine The engine to use for rendering
  121553. * @param camera The camera to use for rendering
  121554. * @param size This parameter can be set to a single number or to an object with the
  121555. * following (optional) properties: precision, width, height. If a single number is passed,
  121556. * it will be used for both width and height. If an object is passed, the screenshot size
  121557. * will be derived from the parameters. The precision property is a multiplier allowing
  121558. * rendering at a higher or lower resolution
  121559. * @param successCallback The callback receives a single parameter which contains the
  121560. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  121561. * src parameter of an <img> to display it
  121562. * @param mimeType The MIME type of the screenshot image (default: image/png).
  121563. * Check your browser for supported MIME types
  121564. * @param samples Texture samples (default: 1)
  121565. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  121566. * @param fileName A name for for the downloaded file.
  121567. */
  121568. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  121569. }
  121570. }
  121571. declare module BABYLON {
  121572. /**
  121573. * A cursor which tracks a point on a path
  121574. */
  121575. export class PathCursor {
  121576. private path;
  121577. /**
  121578. * Stores path cursor callbacks for when an onchange event is triggered
  121579. */
  121580. private _onchange;
  121581. /**
  121582. * The value of the path cursor
  121583. */
  121584. value: number;
  121585. /**
  121586. * The animation array of the path cursor
  121587. */
  121588. animations: Animation[];
  121589. /**
  121590. * Initializes the path cursor
  121591. * @param path The path to track
  121592. */
  121593. constructor(path: Path2);
  121594. /**
  121595. * Gets the cursor point on the path
  121596. * @returns A point on the path cursor at the cursor location
  121597. */
  121598. getPoint(): Vector3;
  121599. /**
  121600. * Moves the cursor ahead by the step amount
  121601. * @param step The amount to move the cursor forward
  121602. * @returns This path cursor
  121603. */
  121604. moveAhead(step?: number): PathCursor;
  121605. /**
  121606. * Moves the cursor behind by the step amount
  121607. * @param step The amount to move the cursor back
  121608. * @returns This path cursor
  121609. */
  121610. moveBack(step?: number): PathCursor;
  121611. /**
  121612. * Moves the cursor by the step amount
  121613. * If the step amount is greater than one, an exception is thrown
  121614. * @param step The amount to move the cursor
  121615. * @returns This path cursor
  121616. */
  121617. move(step: number): PathCursor;
  121618. /**
  121619. * Ensures that the value is limited between zero and one
  121620. * @returns This path cursor
  121621. */
  121622. private ensureLimits;
  121623. /**
  121624. * Runs onchange callbacks on change (used by the animation engine)
  121625. * @returns This path cursor
  121626. */
  121627. private raiseOnChange;
  121628. /**
  121629. * Executes a function on change
  121630. * @param f A path cursor onchange callback
  121631. * @returns This path cursor
  121632. */
  121633. onchange(f: (cursor: PathCursor) => void): PathCursor;
  121634. }
  121635. }
  121636. declare module BABYLON {
  121637. /** @hidden */
  121638. export var blurPixelShader: {
  121639. name: string;
  121640. shader: string;
  121641. };
  121642. }
  121643. declare module BABYLON {
  121644. /** @hidden */
  121645. export var bones300Declaration: {
  121646. name: string;
  121647. shader: string;
  121648. };
  121649. }
  121650. declare module BABYLON {
  121651. /** @hidden */
  121652. export var instances300Declaration: {
  121653. name: string;
  121654. shader: string;
  121655. };
  121656. }
  121657. declare module BABYLON {
  121658. /** @hidden */
  121659. export var pointCloudVertexDeclaration: {
  121660. name: string;
  121661. shader: string;
  121662. };
  121663. }
  121664. // Mixins
  121665. interface Window {
  121666. mozIndexedDB: IDBFactory;
  121667. webkitIndexedDB: IDBFactory;
  121668. msIndexedDB: IDBFactory;
  121669. webkitURL: typeof URL;
  121670. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  121671. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  121672. WebGLRenderingContext: WebGLRenderingContext;
  121673. MSGesture: MSGesture;
  121674. CANNON: any;
  121675. AudioContext: AudioContext;
  121676. webkitAudioContext: AudioContext;
  121677. PointerEvent: any;
  121678. Math: Math;
  121679. Uint8Array: Uint8ArrayConstructor;
  121680. Float32Array: Float32ArrayConstructor;
  121681. mozURL: typeof URL;
  121682. msURL: typeof URL;
  121683. VRFrameData: any; // WebVR, from specs 1.1
  121684. DracoDecoderModule: any;
  121685. setImmediate(handler: (...args: any[]) => void): number;
  121686. }
  121687. interface HTMLCanvasElement {
  121688. requestPointerLock(): void;
  121689. msRequestPointerLock?(): void;
  121690. mozRequestPointerLock?(): void;
  121691. webkitRequestPointerLock?(): void;
  121692. /** Track wether a record is in progress */
  121693. isRecording: boolean;
  121694. /** Capture Stream method defined by some browsers */
  121695. captureStream(fps?: number): MediaStream;
  121696. }
  121697. interface CanvasRenderingContext2D {
  121698. msImageSmoothingEnabled: boolean;
  121699. }
  121700. interface MouseEvent {
  121701. mozMovementX: number;
  121702. mozMovementY: number;
  121703. webkitMovementX: number;
  121704. webkitMovementY: number;
  121705. msMovementX: number;
  121706. msMovementY: number;
  121707. }
  121708. interface Navigator {
  121709. mozGetVRDevices: (any: any) => any;
  121710. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  121711. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  121712. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  121713. webkitGetGamepads(): Gamepad[];
  121714. msGetGamepads(): Gamepad[];
  121715. webkitGamepads(): Gamepad[];
  121716. }
  121717. interface HTMLVideoElement {
  121718. mozSrcObject: any;
  121719. }
  121720. interface Math {
  121721. fround(x: number): number;
  121722. imul(a: number, b: number): number;
  121723. }
  121724. interface WebGLRenderingContext {
  121725. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  121726. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  121727. vertexAttribDivisor(index: number, divisor: number): void;
  121728. createVertexArray(): any;
  121729. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  121730. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  121731. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  121732. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  121733. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  121734. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  121735. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  121736. // Queries
  121737. createQuery(): WebGLQuery;
  121738. deleteQuery(query: WebGLQuery): void;
  121739. beginQuery(target: number, query: WebGLQuery): void;
  121740. endQuery(target: number): void;
  121741. getQueryParameter(query: WebGLQuery, pname: number): any;
  121742. getQuery(target: number, pname: number): any;
  121743. MAX_SAMPLES: number;
  121744. RGBA8: number;
  121745. READ_FRAMEBUFFER: number;
  121746. DRAW_FRAMEBUFFER: number;
  121747. UNIFORM_BUFFER: number;
  121748. HALF_FLOAT_OES: number;
  121749. RGBA16F: number;
  121750. RGBA32F: number;
  121751. R32F: number;
  121752. RG32F: number;
  121753. RGB32F: number;
  121754. R16F: number;
  121755. RG16F: number;
  121756. RGB16F: number;
  121757. RED: number;
  121758. RG: number;
  121759. R8: number;
  121760. RG8: number;
  121761. UNSIGNED_INT_24_8: number;
  121762. DEPTH24_STENCIL8: number;
  121763. /* Multiple Render Targets */
  121764. drawBuffers(buffers: number[]): void;
  121765. readBuffer(src: number): void;
  121766. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  121767. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  121768. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  121769. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  121770. // Occlusion Query
  121771. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  121772. ANY_SAMPLES_PASSED: number;
  121773. QUERY_RESULT_AVAILABLE: number;
  121774. QUERY_RESULT: number;
  121775. }
  121776. interface WebGLProgram {
  121777. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  121778. }
  121779. interface EXT_disjoint_timer_query {
  121780. QUERY_COUNTER_BITS_EXT: number;
  121781. TIME_ELAPSED_EXT: number;
  121782. TIMESTAMP_EXT: number;
  121783. GPU_DISJOINT_EXT: number;
  121784. QUERY_RESULT_EXT: number;
  121785. QUERY_RESULT_AVAILABLE_EXT: number;
  121786. queryCounterEXT(query: WebGLQuery, target: number): void;
  121787. createQueryEXT(): WebGLQuery;
  121788. beginQueryEXT(target: number, query: WebGLQuery): void;
  121789. endQueryEXT(target: number): void;
  121790. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  121791. deleteQueryEXT(query: WebGLQuery): void;
  121792. }
  121793. interface WebGLUniformLocation {
  121794. _currentState: any;
  121795. }
  121796. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  121797. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  121798. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  121799. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  121800. interface WebGLRenderingContext {
  121801. readonly RASTERIZER_DISCARD: number;
  121802. readonly DEPTH_COMPONENT24: number;
  121803. readonly TEXTURE_3D: number;
  121804. readonly TEXTURE_2D_ARRAY: number;
  121805. readonly TEXTURE_COMPARE_FUNC: number;
  121806. readonly TEXTURE_COMPARE_MODE: number;
  121807. readonly COMPARE_REF_TO_TEXTURE: number;
  121808. readonly TEXTURE_WRAP_R: number;
  121809. readonly HALF_FLOAT: number;
  121810. readonly RGB8: number;
  121811. readonly RED_INTEGER: number;
  121812. readonly RG_INTEGER: number;
  121813. readonly RGB_INTEGER: number;
  121814. readonly RGBA_INTEGER: number;
  121815. readonly R8_SNORM: number;
  121816. readonly RG8_SNORM: number;
  121817. readonly RGB8_SNORM: number;
  121818. readonly RGBA8_SNORM: number;
  121819. readonly R8I: number;
  121820. readonly RG8I: number;
  121821. readonly RGB8I: number;
  121822. readonly RGBA8I: number;
  121823. readonly R8UI: number;
  121824. readonly RG8UI: number;
  121825. readonly RGB8UI: number;
  121826. readonly RGBA8UI: number;
  121827. readonly R16I: number;
  121828. readonly RG16I: number;
  121829. readonly RGB16I: number;
  121830. readonly RGBA16I: number;
  121831. readonly R16UI: number;
  121832. readonly RG16UI: number;
  121833. readonly RGB16UI: number;
  121834. readonly RGBA16UI: number;
  121835. readonly R32I: number;
  121836. readonly RG32I: number;
  121837. readonly RGB32I: number;
  121838. readonly RGBA32I: number;
  121839. readonly R32UI: number;
  121840. readonly RG32UI: number;
  121841. readonly RGB32UI: number;
  121842. readonly RGBA32UI: number;
  121843. readonly RGB10_A2UI: number;
  121844. readonly R11F_G11F_B10F: number;
  121845. readonly RGB9_E5: number;
  121846. readonly RGB10_A2: number;
  121847. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  121848. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  121849. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  121850. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  121851. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  121852. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  121853. 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;
  121854. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  121855. readonly TRANSFORM_FEEDBACK: number;
  121856. readonly INTERLEAVED_ATTRIBS: number;
  121857. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  121858. createTransformFeedback(): WebGLTransformFeedback;
  121859. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  121860. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  121861. beginTransformFeedback(primitiveMode: number): void;
  121862. endTransformFeedback(): void;
  121863. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  121864. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  121865. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  121866. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  121867. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  121868. }
  121869. interface ImageBitmap {
  121870. readonly width: number;
  121871. readonly height: number;
  121872. close(): void;
  121873. }
  121874. interface WebGLQuery extends WebGLObject {
  121875. }
  121876. declare var WebGLQuery: {
  121877. prototype: WebGLQuery;
  121878. new(): WebGLQuery;
  121879. };
  121880. interface WebGLSampler extends WebGLObject {
  121881. }
  121882. declare var WebGLSampler: {
  121883. prototype: WebGLSampler;
  121884. new(): WebGLSampler;
  121885. };
  121886. interface WebGLSync extends WebGLObject {
  121887. }
  121888. declare var WebGLSync: {
  121889. prototype: WebGLSync;
  121890. new(): WebGLSync;
  121891. };
  121892. interface WebGLTransformFeedback extends WebGLObject {
  121893. }
  121894. declare var WebGLTransformFeedback: {
  121895. prototype: WebGLTransformFeedback;
  121896. new(): WebGLTransformFeedback;
  121897. };
  121898. interface WebGLVertexArrayObject extends WebGLObject {
  121899. }
  121900. declare var WebGLVertexArrayObject: {
  121901. prototype: WebGLVertexArrayObject;
  121902. new(): WebGLVertexArrayObject;
  121903. };
  121904. // Type definitions for WebVR API
  121905. // Project: https://w3c.github.io/webvr/
  121906. // Definitions by: six a <https://github.com/lostfictions>
  121907. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  121908. interface VRDisplay extends EventTarget {
  121909. /**
  121910. * Dictionary of capabilities describing the VRDisplay.
  121911. */
  121912. readonly capabilities: VRDisplayCapabilities;
  121913. /**
  121914. * z-depth defining the far plane of the eye view frustum
  121915. * enables mapping of values in the render target depth
  121916. * attachment to scene coordinates. Initially set to 10000.0.
  121917. */
  121918. depthFar: number;
  121919. /**
  121920. * z-depth defining the near plane of the eye view frustum
  121921. * enables mapping of values in the render target depth
  121922. * attachment to scene coordinates. Initially set to 0.01.
  121923. */
  121924. depthNear: number;
  121925. /**
  121926. * An identifier for this distinct VRDisplay. Used as an
  121927. * association point in the Gamepad API.
  121928. */
  121929. readonly displayId: number;
  121930. /**
  121931. * A display name, a user-readable name identifying it.
  121932. */
  121933. readonly displayName: string;
  121934. readonly isConnected: boolean;
  121935. readonly isPresenting: boolean;
  121936. /**
  121937. * If this VRDisplay supports room-scale experiences, the optional
  121938. * stage attribute contains details on the room-scale parameters.
  121939. */
  121940. readonly stageParameters: VRStageParameters | null;
  121941. /**
  121942. * Passing the value returned by `requestAnimationFrame` to
  121943. * `cancelAnimationFrame` will unregister the callback.
  121944. * @param handle Define the hanle of the request to cancel
  121945. */
  121946. cancelAnimationFrame(handle: number): void;
  121947. /**
  121948. * Stops presenting to the VRDisplay.
  121949. * @returns a promise to know when it stopped
  121950. */
  121951. exitPresent(): Promise<void>;
  121952. /**
  121953. * Return the current VREyeParameters for the given eye.
  121954. * @param whichEye Define the eye we want the parameter for
  121955. * @returns the eye parameters
  121956. */
  121957. getEyeParameters(whichEye: string): VREyeParameters;
  121958. /**
  121959. * Populates the passed VRFrameData with the information required to render
  121960. * the current frame.
  121961. * @param frameData Define the data structure to populate
  121962. * @returns true if ok otherwise false
  121963. */
  121964. getFrameData(frameData: VRFrameData): boolean;
  121965. /**
  121966. * Get the layers currently being presented.
  121967. * @returns the list of VR layers
  121968. */
  121969. getLayers(): VRLayer[];
  121970. /**
  121971. * Return a VRPose containing the future predicted pose of the VRDisplay
  121972. * when the current frame will be presented. The value returned will not
  121973. * change until JavaScript has returned control to the browser.
  121974. *
  121975. * The VRPose will contain the position, orientation, velocity,
  121976. * and acceleration of each of these properties.
  121977. * @returns the pose object
  121978. */
  121979. getPose(): VRPose;
  121980. /**
  121981. * Return the current instantaneous pose of the VRDisplay, with no
  121982. * prediction applied.
  121983. * @returns the current instantaneous pose
  121984. */
  121985. getImmediatePose(): VRPose;
  121986. /**
  121987. * The callback passed to `requestAnimationFrame` will be called
  121988. * any time a new frame should be rendered. When the VRDisplay is
  121989. * presenting the callback will be called at the native refresh
  121990. * rate of the HMD. When not presenting this function acts
  121991. * identically to how window.requestAnimationFrame acts. Content should
  121992. * make no assumptions of frame rate or vsync behavior as the HMD runs
  121993. * asynchronously from other displays and at differing refresh rates.
  121994. * @param callback Define the eaction to run next frame
  121995. * @returns the request handle it
  121996. */
  121997. requestAnimationFrame(callback: FrameRequestCallback): number;
  121998. /**
  121999. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  122000. * Repeat calls while already presenting will update the VRLayers being displayed.
  122001. * @param layers Define the list of layer to present
  122002. * @returns a promise to know when the request has been fulfilled
  122003. */
  122004. requestPresent(layers: VRLayer[]): Promise<void>;
  122005. /**
  122006. * Reset the pose for this display, treating its current position and
  122007. * orientation as the "origin/zero" values. VRPose.position,
  122008. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  122009. * updated when calling resetPose(). This should be called in only
  122010. * sitting-space experiences.
  122011. */
  122012. resetPose(): void;
  122013. /**
  122014. * The VRLayer provided to the VRDisplay will be captured and presented
  122015. * in the HMD. Calling this function has the same effect on the source
  122016. * canvas as any other operation that uses its source image, and canvases
  122017. * created without preserveDrawingBuffer set to true will be cleared.
  122018. * @param pose Define the pose to submit
  122019. */
  122020. submitFrame(pose?: VRPose): void;
  122021. }
  122022. declare var VRDisplay: {
  122023. prototype: VRDisplay;
  122024. new(): VRDisplay;
  122025. };
  122026. interface VRLayer {
  122027. leftBounds?: number[] | Float32Array | null;
  122028. rightBounds?: number[] | Float32Array | null;
  122029. source?: HTMLCanvasElement | null;
  122030. }
  122031. interface VRDisplayCapabilities {
  122032. readonly canPresent: boolean;
  122033. readonly hasExternalDisplay: boolean;
  122034. readonly hasOrientation: boolean;
  122035. readonly hasPosition: boolean;
  122036. readonly maxLayers: number;
  122037. }
  122038. interface VREyeParameters {
  122039. /** @deprecated */
  122040. readonly fieldOfView: VRFieldOfView;
  122041. readonly offset: Float32Array;
  122042. readonly renderHeight: number;
  122043. readonly renderWidth: number;
  122044. }
  122045. interface VRFieldOfView {
  122046. readonly downDegrees: number;
  122047. readonly leftDegrees: number;
  122048. readonly rightDegrees: number;
  122049. readonly upDegrees: number;
  122050. }
  122051. interface VRFrameData {
  122052. readonly leftProjectionMatrix: Float32Array;
  122053. readonly leftViewMatrix: Float32Array;
  122054. readonly pose: VRPose;
  122055. readonly rightProjectionMatrix: Float32Array;
  122056. readonly rightViewMatrix: Float32Array;
  122057. readonly timestamp: number;
  122058. }
  122059. interface VRPose {
  122060. readonly angularAcceleration: Float32Array | null;
  122061. readonly angularVelocity: Float32Array | null;
  122062. readonly linearAcceleration: Float32Array | null;
  122063. readonly linearVelocity: Float32Array | null;
  122064. readonly orientation: Float32Array | null;
  122065. readonly position: Float32Array | null;
  122066. readonly timestamp: number;
  122067. }
  122068. interface VRStageParameters {
  122069. sittingToStandingTransform?: Float32Array;
  122070. sizeX?: number;
  122071. sizeY?: number;
  122072. }
  122073. interface Navigator {
  122074. getVRDisplays(): Promise<VRDisplay[]>;
  122075. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  122076. }
  122077. interface Window {
  122078. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  122079. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  122080. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  122081. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  122082. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  122083. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  122084. }
  122085. interface Gamepad {
  122086. readonly displayId: number;
  122087. }
  122088. interface XRDevice {
  122089. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  122090. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  122091. }
  122092. interface XRSession {
  122093. getInputSources(): Array<any>;
  122094. baseLayer: XRWebGLLayer;
  122095. requestFrameOfReference(type: string): Promise<void>;
  122096. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  122097. end(): Promise<void>;
  122098. requestAnimationFrame: Function;
  122099. addEventListener: Function;
  122100. }
  122101. interface XRSessionCreationOptions {
  122102. outputContext?: WebGLRenderingContext | null;
  122103. immersive?: boolean;
  122104. environmentIntegration?: boolean;
  122105. }
  122106. interface XRLayer {
  122107. getViewport: Function;
  122108. framebufferWidth: number;
  122109. framebufferHeight: number;
  122110. }
  122111. interface XRView {
  122112. projectionMatrix: Float32Array;
  122113. }
  122114. interface XRFrame {
  122115. getDevicePose: Function;
  122116. getInputPose: Function;
  122117. views: Array<XRView>;
  122118. baseLayer: XRLayer;
  122119. }
  122120. interface XRFrameOfReference {
  122121. }
  122122. interface XRWebGLLayer extends XRLayer {
  122123. framebuffer: WebGLFramebuffer;
  122124. }
  122125. declare var XRWebGLLayer: {
  122126. prototype: XRWebGLLayer;
  122127. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  122128. };